@smoothsend/sdk 2.3.4 → 2.3.6

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 (85) hide show
  1. package/dist/aptos/index.cjs +162 -2
  2. package/dist/aptos/index.cjs.map +1 -1
  3. package/dist/aptos/index.d.ts +66 -750
  4. package/dist/aptos/index.js +163 -6
  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/avax/SmoothSendAvaxSubmitter.d.ts +2 -2
  29. package/dist/avax/SmoothSendAvaxSubmitter.d.ts.map +1 -1
  30. package/dist/avax/index.cjs +52 -14
  31. package/dist/avax/index.cjs.map +1 -1
  32. package/dist/avax/index.d.ts +3 -3
  33. package/dist/avax/index.d.ts.map +1 -1
  34. package/dist/avax/index.js +53 -15
  35. package/dist/avax/index.js.map +1 -1
  36. package/dist/avax/publicAaDefaults.d.ts +26 -0
  37. package/dist/avax/publicAaDefaults.d.ts.map +1 -1
  38. package/dist/avax/useSmoothSendAvax.d.ts +2 -0
  39. package/dist/avax/useSmoothSendAvax.d.ts.map +1 -1
  40. package/dist/chunks/shared-2xx2VLH3.js +453 -0
  41. package/dist/chunks/shared-2xx2VLH3.js.map +1 -0
  42. package/dist/chunks/shared-B8UdyBTN.d.ts +143 -0
  43. package/dist/chunks/shared-BJv1JV1H.cjs +702 -0
  44. package/dist/chunks/shared-BJv1JV1H.cjs.map +1 -0
  45. package/dist/chunks/shared-BQ9u3lrN.js +557 -0
  46. package/dist/chunks/shared-BQ9u3lrN.js.map +1 -0
  47. package/dist/chunks/shared-BXvqbQ6f.d.ts +262 -0
  48. package/dist/chunks/shared-BcSSEWv8.d.ts +474 -0
  49. package/dist/chunks/shared-Bh4xtpHv.js +740 -0
  50. package/dist/chunks/shared-Bh4xtpHv.js.map +1 -0
  51. package/dist/chunks/shared-BlIQttCf.d.ts +1279 -0
  52. package/dist/chunks/shared-BlhOY1v3.cjs +568 -0
  53. package/dist/chunks/shared-BlhOY1v3.cjs.map +1 -0
  54. package/dist/chunks/shared-BoRfHN1w.js +1511 -0
  55. package/dist/chunks/shared-BoRfHN1w.js.map +1 -0
  56. package/dist/chunks/shared-CPpb2n9T.d.ts +780 -0
  57. package/dist/chunks/shared-CWbQR_je.js +1511 -0
  58. package/dist/chunks/shared-CWbQR_je.js.map +1 -0
  59. package/dist/chunks/shared-CzR0rIwZ.cjs +635 -0
  60. package/dist/chunks/shared-CzR0rIwZ.cjs.map +1 -0
  61. package/dist/chunks/shared-DMOh_aLU.d.ts +1279 -0
  62. package/dist/chunks/shared-DQbEIiTE.cjs +746 -0
  63. package/dist/chunks/shared-DQbEIiTE.cjs.map +1 -0
  64. package/dist/chunks/shared-DYAVFARB.d.ts +472 -0
  65. package/dist/chunks/shared-DzwYUjQn.cjs +457 -0
  66. package/dist/chunks/shared-DzwYUjQn.cjs.map +1 -0
  67. package/dist/chunks/shared-EuyoZgP8.cjs +1519 -0
  68. package/dist/chunks/shared-EuyoZgP8.cjs.map +1 -0
  69. package/dist/chunks/shared-KUvoQkzf.d.ts +471 -0
  70. package/dist/chunks/shared-W7k9S_GY.d.ts +262 -0
  71. package/dist/chunks/shared-XH1iLZjy.js +629 -0
  72. package/dist/chunks/shared-XH1iLZjy.js.map +1 -0
  73. package/dist/chunks/shared-kovW7ATj.js +694 -0
  74. package/dist/chunks/shared-kovW7ATj.js.map +1 -0
  75. package/dist/chunks/shared-vFCAUg0m.d.ts +780 -0
  76. package/dist/index.cjs +52 -14
  77. package/dist/index.cjs.map +1 -1
  78. package/dist/index.d.ts +4 -4
  79. package/dist/index.js +52 -14
  80. package/dist/index.js.map +1 -1
  81. package/dist/stellar/index.cjs +2 -2
  82. package/dist/stellar/index.d.ts +3 -3
  83. package/dist/stellar/index.js +2 -2
  84. package/dist/version.d.ts +1 -1
  85. package/package.json +2 -2
@@ -0,0 +1,457 @@
1
+ 'use strict';
2
+
3
+ var tsSdk = require('@aptos-labs/ts-sdk');
4
+
5
+ /**
6
+ * Pre-compiled Move script bytecode for add_permissioned_handle
7
+ *
8
+ * This bytecode is used to register session keys on-chain via the
9
+ * `0x1::permissioned_delegation::add_permissioned_handle` function.
10
+ *
11
+ * The function cannot be called as an entry function directly — only via a Move script.
12
+ * This bytecode handles:
13
+ * - Takes the session public key bytes (vector<u8>) as input
14
+ * - Constructs DelegationKey from the bytes
15
+ * - Passes option::none() for rate limiter
16
+ * - Hardcodes u64::MAX for expiration (on-chain handle never expires)
17
+ *
18
+ * Source: aptos-labs/aptos-ts-sdk tests/e2e/transaction/helper.ts
19
+ */
20
+ const ADD_PERMISSIONED_HANDLE_BYTECODE = 'a11ceb0b0700000a0801001002101603262c04520405563d079301d70208ea034010aa041f0103010401060109010d010e011201140002080002080700030b0700040c0f0005100701000001050301010001020704050001030a05060001050f01080100010311090a000106130b01000107150b0100010002030702060c0a020001080001060c010a02010801010802010803010b0401090004060c08020b0401080303010c03060c060c03050802030b04010803060c0c083c53454c463e5f30046d61696e094170746f73436f696e0a6170746f735f636f696e04636f696e196d6967726174655f746f5f66756e6769626c655f73746f72650765643235353139256e65775f756e76616c6964617465645f7075626c69635f6b65795f66726f6d5f627974657314556e76616c6964617465645075626c69634b657917' +
21
+ '7065726d697373696f6e65645f64656c65676174696f6e0f67656e5f656432353531395f6b65790d44656c65676174696f6e4b65790b526174654c696d697465720c726174655f6c696d69746572066f7074696f6e046e6f6e65064f7074696f6e176164645f7065726d697373696f6e65645f68616e646c65167072696d6172795f66756e6769626c655f73746f7265146772616e745f6170745f7065726d697373696f6e167472616e73616374696f6e5f76616c69646174696f6e146772616e745f6761735f7065726d697373696f6effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000114636f6d70696c6174696f6e5f6d65746164617461090003322e3003322e3100000c170a0038000b01110111020c020a0038010c040b020b040600a0724e1809000011040c060a000e060600e1f5050000000011050b000e060600e1f50500000000110602';
22
+
23
+ /**
24
+ * SmoothSend Transaction Submitter
25
+ *
26
+ * A TransactionSubmitter implementation that integrates with the Aptos Wallet Adapter
27
+ * to enable gasless transactions via SmoothSend's relayer network.
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * import { SmoothSendTransactionSubmitter } from '@smoothsend/sdk';
32
+ * import { AptosWalletAdapterProvider } from '@aptos-labs/wallet-adapter-react';
33
+ *
34
+ * // Create the transaction submitter
35
+ * const transactionSubmitter = new SmoothSendTransactionSubmitter({
36
+ * apiKey: 'pk_nogas_your_api_key_here',
37
+ * network: 'testnet'
38
+ * });
39
+ *
40
+ * // Use in your wallet provider - that's it!
41
+ * <AptosWalletAdapterProvider
42
+ * dappConfig={{
43
+ * network: Network.TESTNET,
44
+ * transactionSubmitter: transactionSubmitter
45
+ * }}
46
+ * >
47
+ * <App />
48
+ * </AptosWalletAdapterProvider>
49
+ * ```
50
+ */
51
+ /**
52
+ * SmoothSend Transaction Submitter
53
+ *
54
+ * Implements the TransactionSubmitter interface to enable gasless transactions
55
+ * through the Aptos Wallet Adapter. Simply pass this to your AptosWalletAdapterProvider
56
+ * and all transactions will automatically be submitted as gasless through SmoothSend.
57
+ */
58
+ class SmoothSendTransactionSubmitter {
59
+ constructor(config) {
60
+ this._session = null;
61
+ this.sponsoredFunctionsCache = null;
62
+ this.sponsoredFunctionsCacheAt = 0;
63
+ this.SPONSORED_CACHE_TTL = 5 * 60 * 1000; // 5 minutes
64
+ if (!config.apiKey) {
65
+ throw new Error('SmoothSend API key is required. Get your key at dashboard.smoothsend.xyz');
66
+ }
67
+ // Validate API key format
68
+ if (!config.apiKey.startsWith('pk_nogas_') &&
69
+ !config.apiKey.startsWith('sk_nogas_') &&
70
+ !config.apiKey.startsWith('no_gas_')) {
71
+ throw new Error('Invalid API key format. Key must start with pk_nogas_, sk_nogas_, or no_gas_');
72
+ }
73
+ // Warn if using secret key in browser
74
+ if (config.apiKey.startsWith('sk_nogas_') && typeof window !== 'undefined') {
75
+ console.warn('⚠️ WARNING: Secret key detected in browser environment.\n' +
76
+ 'Secret keys (sk_nogas_*) should only be used in server-side code.\n' +
77
+ 'Use public keys (pk_nogas_*) for frontend applications.');
78
+ }
79
+ this.apiKey = config.apiKey;
80
+ this.network = config.network || 'testnet';
81
+ this.gatewayUrl = config.gatewayUrl || 'https://proxy.smoothsend.xyz';
82
+ this.timeout = config.timeout || 30000;
83
+ this.getCaptchaToken = config.getCaptchaToken;
84
+ this.debug = config.debug || false;
85
+ this.sessionEnabled = config.session || false;
86
+ this.sessionDuration = config.sessionDuration || '24h';
87
+ }
88
+ // ─── Session key methods ────────────────────────────────────────────────────
89
+ /**
90
+ * Whether a valid session is currently active.
91
+ */
92
+ hasSession() {
93
+ return this._session !== null && Date.now() < this._session.expiresAtMs;
94
+ }
95
+ /**
96
+ * Create a session key for the given master account.
97
+ * Called once by useSmoothSend when session: true and no session exists.
98
+ * SmoothSend pays gas for the setup transaction.
99
+ *
100
+ * @param masterAccount - The user's wallet account (from wallet adapter)
101
+ */
102
+ async createSession(masterAccount) {
103
+ const network = this.network === 'mainnet' ? tsSdk.Network.MAINNET : tsSdk.Network.TESTNET;
104
+ const aptosClient = new tsSdk.Aptos(new tsSdk.AptosConfig({ network }));
105
+ // Generate fresh in-memory session keypair
106
+ const sessionAccount = tsSdk.Account.generate();
107
+ const expiresAtMs = Date.now() + this._parseDuration(this.sessionDuration);
108
+ // Step 1: Register session key on-chain via pre-compiled Move script
109
+ const setupTx = await aptosClient.transaction.build.simple({
110
+ sender: masterAccount.accountAddress,
111
+ withFeePayer: true,
112
+ data: {
113
+ bytecode: ADD_PERMISSIONED_HANDLE_BYTECODE,
114
+ functionArguments: [tsSdk.MoveVector.U8(sessionAccount.publicKey.toUint8Array())],
115
+ },
116
+ options: {
117
+ replayProtectionNonce: BigInt(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER)),
118
+ },
119
+ });
120
+ const senderAuth = await this.signSenderAuthenticator(masterAccount, setupTx, aptosClient);
121
+ const setupResult = await this.submitTransaction({
122
+ aptosConfig: aptosClient.config,
123
+ transaction: setupTx,
124
+ senderAuthenticator: senderAuth,
125
+ });
126
+ await aptosClient.waitForTransaction({ transactionHash: setupResult.hash });
127
+ if (this.debug) {
128
+ console.log('[SmoothSend] Session key registered on-chain:', setupResult.hash);
129
+ }
130
+ // Step 2: Enable account abstraction (idempotent — skip if already on)
131
+ const aaEnabled = await aptosClient.abstraction.isAccountAbstractionEnabled({
132
+ accountAddress: masterAccount.accountAddress,
133
+ authenticationFunction: '0x1::permissioned_delegation::authenticate',
134
+ });
135
+ if (!aaEnabled) {
136
+ const aaTx = await aptosClient.transaction.build.simple({
137
+ sender: masterAccount.accountAddress,
138
+ withFeePayer: true,
139
+ data: {
140
+ function: '0x1::account_abstraction::add_authentication_function',
141
+ functionArguments: [
142
+ tsSdk.AccountAddress.fromString('0x1'),
143
+ 'permissioned_delegation',
144
+ 'authenticate',
145
+ ],
146
+ },
147
+ options: {
148
+ replayProtectionNonce: BigInt(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER)),
149
+ },
150
+ });
151
+ const aaAuth = await this.signSenderAuthenticator(masterAccount, aaTx, aptosClient);
152
+ const aaResult = await this.submitTransaction({
153
+ aptosConfig: aptosClient.config,
154
+ transaction: aaTx,
155
+ senderAuthenticator: aaAuth,
156
+ });
157
+ await aptosClient.waitForTransaction({ transactionHash: aaResult.hash });
158
+ if (this.debug) {
159
+ console.log('[SmoothSend] Account abstraction enabled:', aaResult.hash);
160
+ }
161
+ }
162
+ // Build AbstractedAccount — signs future txs with session key,
163
+ // sender on-chain = master address, chain validates via permissioned_delegation
164
+ const abstractedAccount = tsSdk.AbstractedAccount.fromPermissionedSigner({
165
+ signer: sessionAccount,
166
+ accountAddress: masterAccount.accountAddress,
167
+ });
168
+ this._session = {
169
+ sessionAccount,
170
+ abstractedAccount,
171
+ masterAddress: masterAccount.accountAddress,
172
+ expiresAtMs,
173
+ aptosClient,
174
+ };
175
+ }
176
+ async isPermissionedSignerEnabled(aptosClient) {
177
+ try {
178
+ const result = await aptosClient.view({
179
+ payload: {
180
+ function: '0x1::features::is_permissioned_signer_enabled',
181
+ functionArguments: [],
182
+ },
183
+ });
184
+ return Array.isArray(result) && result[0] === true;
185
+ }
186
+ catch (error) {
187
+ if (this.debug) {
188
+ console.warn('[SmoothSend] Failed to probe permissioned signer feature:', error);
189
+ }
190
+ return false;
191
+ }
192
+ }
193
+ async signSenderAuthenticator(signer, transaction, aptosClient) {
194
+ const walletLikeSigner = signer;
195
+ // Wallet-adapter compatible path (returns { authenticator, rawTransaction } in v8)
196
+ if (typeof walletLikeSigner?.signTransactionWithAuthenticator === 'function') {
197
+ const result = await walletLikeSigner.signTransactionWithAuthenticator(transaction);
198
+ return (result?.authenticator ?? result);
199
+ }
200
+ // Native ts-sdk account path
201
+ return aptosClient.transaction.sign({
202
+ signer,
203
+ transaction,
204
+ });
205
+ }
206
+ /**
207
+ * Submit a transaction using the active session key — no wallet popup.
208
+ * Called by useSmoothSend after session is established.
209
+ */
210
+ async submitWithSession(functionName, functionArguments = [], typeArguments = []) {
211
+ if (!this._session || !this.hasSession()) {
212
+ throw new Error('[SmoothSend] No active session. Call createSession() first.');
213
+ }
214
+ const { abstractedAccount, masterAddress, aptosClient } = this._session;
215
+ const tx = await aptosClient.transaction.build.simple({
216
+ sender: masterAddress,
217
+ withFeePayer: true,
218
+ data: {
219
+ function: functionName,
220
+ functionArguments,
221
+ ...(typeArguments.length > 0 ? { typeArguments } : {}),
222
+ },
223
+ options: {
224
+ replayProtectionNonce: BigInt(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER)),
225
+ },
226
+ });
227
+ const senderAuth = aptosClient.transaction.sign({
228
+ signer: abstractedAccount,
229
+ transaction: tx,
230
+ });
231
+ return this.submitTransaction({
232
+ aptosConfig: aptosClient.config,
233
+ transaction: tx,
234
+ senderAuthenticator: senderAuth,
235
+ });
236
+ }
237
+ _parseDuration(duration) {
238
+ if (duration === 'never') {
239
+ // Client-side "never expires" mode; on-chain handle already uses u64::MAX.
240
+ return Number.MAX_SAFE_INTEGER;
241
+ }
242
+ const n = parseInt(duration, 10);
243
+ if (isNaN(n))
244
+ throw new Error(`Invalid sessionDuration "${duration}". Use e.g. "2h", "24h", "7d", or "never".`);
245
+ if (duration.endsWith('s'))
246
+ return n * 1000;
247
+ if (duration.endsWith('m'))
248
+ return n * 60 * 1000;
249
+ if (duration.endsWith('h'))
250
+ return n * 3600 * 1000;
251
+ if (duration.endsWith('d'))
252
+ return n * 86400 * 1000;
253
+ throw new Error(`Unknown unit in "${duration}". Supported: s, m, h, d, or "never".`);
254
+ }
255
+ // ─── Transaction submission ──────────────────────────────────────────────────
256
+ /**
257
+ * Submit a transaction through SmoothSend's gasless relayer
258
+ *
259
+ * This method is called automatically by the Aptos Wallet Adapter when
260
+ * you use signAndSubmitTransaction. The transaction is submitted to
261
+ * SmoothSend's relayer which sponsors the gas fees.
262
+ */
263
+ async submitTransaction(args) {
264
+ const { aptosConfig, transaction, senderAuthenticator, pluginParams } = args;
265
+ // Auto-detect network from aptosConfig (source of truth from wallet adapter)
266
+ // Falls back to constructor value if aptosConfig doesn't have a recognized network
267
+ const detectedNetwork = this.resolveNetwork(aptosConfig);
268
+ if (this.debug) {
269
+ console.log('[SmoothSend] Submitting gasless transaction:', {
270
+ sender: transaction.rawTransaction?.sender?.toString(),
271
+ configNetwork: this.network,
272
+ detectedNetwork,
273
+ });
274
+ }
275
+ if (detectedNetwork !== this.network && this.debug) {
276
+ console.warn(`[SmoothSend] Network mismatch: constructor=${this.network}, aptosConfig=${detectedNetwork}. ` +
277
+ `Using aptosConfig network (${detectedNetwork}).`);
278
+ }
279
+ try {
280
+ // Serialize transaction and authenticator to bytes
281
+ const transactionBytes = Array.from(transaction.bcsToBytes());
282
+ const authenticatorBytes = Array.from(senderAuthenticator.bcsToBytes());
283
+ // Prepare request payload — always use the detected network
284
+ const payload = {
285
+ transactionBytes,
286
+ authenticatorBytes,
287
+ network: detectedNetwork,
288
+ functionName: pluginParams?.functionName || 'unknown',
289
+ };
290
+ // Make request to SmoothSend gateway
291
+ const response = await this.makeRequest('/api/v1/relayer/gasless-transaction', payload, detectedNetwork);
292
+ if (!response.success || !response.txnHash) {
293
+ throw new Error(response.error || response.details || 'Transaction submission failed');
294
+ }
295
+ if (this.debug) {
296
+ console.log('[SmoothSend] Transaction successful:', {
297
+ hash: response.txnHash,
298
+ gasUsed: response.gasUsed,
299
+ });
300
+ }
301
+ // Return in the format expected by Aptos SDK
302
+ return {
303
+ hash: response.txnHash,
304
+ sender: response.sender || transaction.rawTransaction?.sender?.toString() || '',
305
+ sequence_number: transaction.rawTransaction?.sequence_number?.toString() || '0',
306
+ max_gas_amount: transaction.rawTransaction?.max_gas_amount?.toString() || '0',
307
+ gas_unit_price: transaction.rawTransaction?.gas_unit_price?.toString() || '0',
308
+ expiration_timestamp_secs: transaction.rawTransaction?.expiration_timestamp_secs?.toString() || '0',
309
+ payload: {},
310
+ signature: undefined,
311
+ };
312
+ }
313
+ catch (error) {
314
+ if (this.debug) {
315
+ console.error('[SmoothSend] Transaction failed:', error);
316
+ }
317
+ throw new Error(`SmoothSend gasless transaction failed: ${error.message}`);
318
+ }
319
+ }
320
+ /**
321
+ * Resolve the effective network from aptosConfig.
322
+ * aptosConfig.network is the source of truth set by AptosWalletAdapterProvider.
323
+ */
324
+ resolveNetwork(aptosConfig) {
325
+ try {
326
+ const configNetwork = aptosConfig?.network;
327
+ if (configNetwork === 'testnet' || configNetwork === 'mainnet') {
328
+ return configNetwork;
329
+ }
330
+ if (typeof configNetwork === 'string') {
331
+ const normalized = configNetwork.toLowerCase();
332
+ if (normalized === 'testnet' || normalized === 'mainnet') {
333
+ return normalized;
334
+ }
335
+ }
336
+ }
337
+ catch {
338
+ // fall through
339
+ }
340
+ return this.network;
341
+ }
342
+ /**
343
+ * Make an HTTP request to the SmoothSend gateway
344
+ */
345
+ async makeRequest(endpoint, payload, network, method = 'POST') {
346
+ const effectiveNetwork = network || this.network;
347
+ const url = `${this.gatewayUrl}${endpoint}`;
348
+ const headers = {
349
+ 'Content-Type': 'application/json',
350
+ 'X-API-Key': this.apiKey,
351
+ 'X-Chain': `aptos-${effectiveNetwork}`,
352
+ };
353
+ // Add Origin header for public keys in browser
354
+ if (this.apiKey.startsWith('pk_nogas_') && typeof window !== 'undefined') {
355
+ headers['Origin'] = window.location.origin;
356
+ }
357
+ // Add captcha token if the project requires it
358
+ if (this.getCaptchaToken) {
359
+ try {
360
+ const token = await this.getCaptchaToken();
361
+ if (token) {
362
+ headers['X-Captcha-Token'] = token;
363
+ }
364
+ }
365
+ catch (e) {
366
+ if (this.debug) {
367
+ console.warn('[SmoothSend] Failed to get captcha token:', e);
368
+ }
369
+ }
370
+ }
371
+ const controller = new AbortController();
372
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
373
+ try {
374
+ const response = await fetch(url, {
375
+ method,
376
+ headers,
377
+ body: method === 'GET' ? undefined : JSON.stringify(payload),
378
+ signal: controller.signal,
379
+ });
380
+ clearTimeout(timeoutId);
381
+ if (!response.ok) {
382
+ const errorData = await response.json().catch(() => ({}));
383
+ throw new Error(errorData.error || errorData.message || `HTTP ${response.status}`);
384
+ }
385
+ return await response.json();
386
+ }
387
+ catch (error) {
388
+ clearTimeout(timeoutId);
389
+ if (error.name === 'AbortError') {
390
+ throw new Error('Request timed out');
391
+ }
392
+ throw error;
393
+ }
394
+ }
395
+ /**
396
+ * Fetch the list of sponsored functions for this API key's project.
397
+ * Results are cached for 5 minutes. Returns ['*'] if all functions are sponsored.
398
+ */
399
+ async getSponsoredFunctions() {
400
+ const now = Date.now();
401
+ if (this.sponsoredFunctionsCache !== null && now - this.sponsoredFunctionsCacheAt < this.SPONSORED_CACHE_TTL) {
402
+ return this.sponsoredFunctionsCache;
403
+ }
404
+ try {
405
+ const response = await this.makeRequest('/api/v1/sponsorship', {}, undefined, 'GET');
406
+ const fns = response.sponsoredFunctions;
407
+ this.sponsoredFunctionsCache = Array.isArray(fns) ? fns : ['*'];
408
+ }
409
+ catch {
410
+ this.sponsoredFunctionsCache = ['*']; // fail-open: assume all sponsored
411
+ }
412
+ this.sponsoredFunctionsCacheAt = now;
413
+ return this.sponsoredFunctionsCache;
414
+ }
415
+ /**
416
+ * Check if a specific function is sponsored for gasless execution.
417
+ * @param functionName - Full function identifier, e.g. "0x123::module::function"
418
+ */
419
+ async isSponsored(functionName) {
420
+ const fns = await this.getSponsoredFunctions();
421
+ if (fns.includes('*'))
422
+ return true;
423
+ const normalize = (id) => id.replace(/^(0x)0+([1-9a-f][0-9a-f]*)(::.+)$/i, '$1$2$3').toLowerCase();
424
+ const normalized = normalize(functionName);
425
+ return fns.some(f => normalize(f) === normalized);
426
+ }
427
+ /**
428
+ */
429
+ getConfig() {
430
+ return {
431
+ apiKey: this.apiKey.substring(0, 15) + '...', // Don't expose full key
432
+ network: this.network,
433
+ gatewayUrl: this.gatewayUrl,
434
+ timeout: this.timeout,
435
+ debug: this.debug,
436
+ };
437
+ }
438
+ }
439
+ /**
440
+ * Create a SmoothSend transaction submitter with minimal configuration
441
+ *
442
+ * @example
443
+ * ```typescript
444
+ * const submitter = createSmoothSendSubmitter('pk_nogas_your_key');
445
+ * ```
446
+ */
447
+ function createSmoothSendSubmitter(apiKey, options) {
448
+ return new SmoothSendTransactionSubmitter({
449
+ apiKey,
450
+ ...options,
451
+ });
452
+ }
453
+
454
+ exports.ADD_PERMISSIONED_HANDLE_BYTECODE = ADD_PERMISSIONED_HANDLE_BYTECODE;
455
+ exports.SmoothSendTransactionSubmitter = SmoothSendTransactionSubmitter;
456
+ exports.createSmoothSendSubmitter = createSmoothSendSubmitter;
457
+ //# sourceMappingURL=shared-DzwYUjQn.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-DzwYUjQn.cjs","sources":["../../src/session/constants.ts","../../src/wallet-adapter/SmoothSendTransactionSubmitter.ts"],"sourcesContent":[null,null],"names":["Network","Aptos","AptosConfigClass","Account","MoveVector","AccountAddress","AbstractedAccount"],"mappings":";;;;AAAA;;;;;;;;;;;;;;AAcG;AACI,MAAM,gCAAgC,GAC3C,8nBAA8nB;AAC9nB,IAAA;;ACjBF;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BG;AAqIH;;;;;;AAMG;MACU,8BAA8B,CAAA;AAWzC,IAAA,WAAA,CAAY,MAA4C,EAAA;QAFhD,IAAA,CAAA,QAAQ,GAAwB,IAAI;QA8YpC,IAAA,CAAA,uBAAuB,GAAoB,IAAI;QAC/C,IAAA,CAAA,yBAAyB,GAAG,CAAC;QACpB,IAAA,CAAA,mBAAmB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AA7YnD,QAAA,IAAI,C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