@smoothsend/sdk 2.3.5 → 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 (100) 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/aptos/index.cjs +2 -2
  6. package/dist/aptos/index.d.ts +3 -3
  7. package/dist/aptos/index.js +3 -3
  8. package/dist/avax/SmoothSendAvaxSubmitter.d.ts +2 -2
  9. package/dist/avax/SmoothSendAvaxSubmitter.d.ts.map +1 -1
  10. package/dist/avax/index.cjs +52 -14
  11. package/dist/avax/index.cjs.map +1 -1
  12. package/dist/avax/index.d.ts +3 -3
  13. package/dist/avax/index.d.ts.map +1 -1
  14. package/dist/avax/index.js +53 -15
  15. package/dist/avax/index.js.map +1 -1
  16. package/dist/avax/publicAaDefaults.d.ts +26 -0
  17. package/dist/avax/publicAaDefaults.d.ts.map +1 -1
  18. package/dist/avax/useSmoothSendAvax.d.ts +2 -0
  19. package/dist/avax/useSmoothSendAvax.d.ts.map +1 -1
  20. package/dist/chunks/{shared-CNF22ESH.js → shared-BQ9u3lrN.js} +2 -2
  21. package/dist/chunks/{shared-CNF22ESH.js.map → shared-BQ9u3lrN.js.map} +1 -1
  22. package/dist/chunks/{shared-Cgb7mhwI.d.ts → shared-BcSSEWv8.d.ts} +5 -2
  23. package/dist/chunks/{shared-x1-VC-Li.cjs → shared-BlhOY1v3.cjs} +2 -2
  24. package/dist/chunks/{shared-x1-VC-Li.cjs.map → shared-BlhOY1v3.cjs.map} +1 -1
  25. package/dist/chunks/{shared-CaQMAGQR.js → shared-CWbQR_je.js} +4 -4
  26. package/dist/chunks/{shared-CaQMAGQR.js.map → shared-CWbQR_je.js.map} +1 -1
  27. package/dist/chunks/{shared-Cn4duBJT.d.ts → shared-DMOh_aLU.d.ts} +1 -1
  28. package/dist/chunks/{shared-DEurKmpI.cjs → shared-EuyoZgP8.cjs} +4 -4
  29. package/dist/chunks/{shared-DEurKmpI.cjs.map → shared-EuyoZgP8.cjs.map} +1 -1
  30. package/dist/chunks/{shared-RVkwmkG7.d.ts → shared-W7k9S_GY.d.ts} +1 -1
  31. package/dist/chunks/{shared-CPpb2n9T.d.ts → shared-vFCAUg0m.d.ts} +1 -1
  32. package/dist/config/chains.d.ts +7 -0
  33. package/dist/config/chains.d.ts.map +1 -0
  34. package/dist/index.cjs +52 -14
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.ts +4 -4
  37. package/dist/index.esm.js +3 -1846
  38. package/dist/index.esm.js.map +1 -1
  39. package/dist/index.js +52 -14
  40. package/dist/index.js.map +1 -1
  41. package/dist/services/chainConfigService.d.ts +49 -0
  42. package/dist/services/chainConfigService.d.ts.map +1 -0
  43. package/dist/stellar/index.cjs +2 -2
  44. package/dist/stellar/index.d.ts +3 -3
  45. package/dist/stellar/index.js +2 -2
  46. package/dist/version.d.ts +1 -1
  47. package/package.json +120 -120
  48. package/dist/aptos-privy/index.cjs +0 -40
  49. package/dist/aptos-privy/index.cjs.map +0 -1
  50. package/dist/aptos-privy/index.js +0 -34
  51. package/dist/aptos-privy/index.js.map +0 -1
  52. package/dist/aptos-privy/normalizePrivyAptosWallet.d.ts +0 -4
  53. package/dist/aptos-privy/normalizePrivyAptosWallet.d.ts.map +0 -1
  54. package/dist/aptos-privy/privyAptosSigner.d.ts +0 -32
  55. package/dist/aptos-privy/privyAptosSigner.d.ts.map +0 -1
  56. package/dist/aptos-privy/useSmoothSendAptosPrivy.d.ts +0 -13
  57. package/dist/aptos-privy/useSmoothSendAptosPrivy.d.ts.map +0 -1
  58. package/dist/aptos-privy-entry.d.ts +0 -9
  59. package/dist/aptos-privy-entry.d.ts.map +0 -1
  60. package/dist/chunks/SmoothSendSDK-C_ofuBkk.cjs +0 -1519
  61. package/dist/chunks/SmoothSendSDK-C_ofuBkk.cjs.map +0 -1
  62. package/dist/chunks/SmoothSendSDK-CaV_PCIG.js +0 -1511
  63. package/dist/chunks/SmoothSendSDK-CaV_PCIG.js.map +0 -1
  64. package/dist/chunks/SmoothSendSDK.d-9GBgZONY.d.ts +0 -262
  65. package/dist/chunks/TrueGaslessClient-DThO4Tpb.cjs +0 -1237
  66. package/dist/chunks/TrueGaslessClient-DThO4Tpb.cjs.map +0 -1
  67. package/dist/chunks/TrueGaslessClient-l2uFvNAa.js +0 -1228
  68. package/dist/chunks/TrueGaslessClient-l2uFvNAa.js.map +0 -1
  69. package/dist/chunks/shared-2xx2VLH3.js +0 -453
  70. package/dist/chunks/shared-2xx2VLH3.js.map +0 -1
  71. package/dist/chunks/shared-B8UdyBTN.d.ts +0 -143
  72. package/dist/chunks/shared-BJv1JV1H.cjs +0 -702
  73. package/dist/chunks/shared-BJv1JV1H.cjs.map +0 -1
  74. package/dist/chunks/shared-BXvqbQ6f.d.ts +0 -262
  75. package/dist/chunks/shared-Bh4xtpHv.js +0 -740
  76. package/dist/chunks/shared-Bh4xtpHv.js.map +0 -1
  77. package/dist/chunks/shared-BlIQttCf.d.ts +0 -1279
  78. package/dist/chunks/shared-BoRfHN1w.js +0 -1511
  79. package/dist/chunks/shared-BoRfHN1w.js.map +0 -1
  80. package/dist/chunks/shared-CzR0rIwZ.cjs +0 -635
  81. package/dist/chunks/shared-CzR0rIwZ.cjs.map +0 -1
  82. package/dist/chunks/shared-DQbEIiTE.cjs +0 -746
  83. package/dist/chunks/shared-DQbEIiTE.cjs.map +0 -1
  84. package/dist/chunks/shared-DzwYUjQn.cjs +0 -457
  85. package/dist/chunks/shared-DzwYUjQn.cjs.map +0 -1
  86. package/dist/chunks/shared-KUvoQkzf.d.ts +0 -471
  87. package/dist/chunks/shared-XH1iLZjy.js +0 -629
  88. package/dist/chunks/shared-XH1iLZjy.js.map +0 -1
  89. package/dist/chunks/shared-kovW7ATj.js +0 -694
  90. package/dist/chunks/shared-kovW7ATj.js.map +0 -1
  91. package/dist/chunks/shared-viO0MYao.d.ts +0 -459
  92. package/dist/chunks/useSmoothSendAvax-BHeW_6x8.cjs +0 -1865
  93. package/dist/chunks/useSmoothSendAvax-BHeW_6x8.cjs.map +0 -1
  94. package/dist/chunks/useSmoothSendAvax-ZuHw1aYi.js +0 -1848
  95. package/dist/chunks/useSmoothSendAvax-ZuHw1aYi.js.map +0 -1
  96. package/dist/chunks/version-CNF22ESH.js +0 -557
  97. package/dist/chunks/version-CNF22ESH.js.map +0 -1
  98. package/dist/chunks/version-x1-VC-Li.cjs +0 -568
  99. package/dist/chunks/version-x1-VC-Li.cjs.map +0 -1
  100. package/dist/chunks/version.d-Cn4duBJT.d.ts +0 -1279
package/dist/index.js CHANGED
@@ -2762,14 +2762,14 @@ class SmoothSendAvaxSubmitter {
2762
2762
  async getSupportedEntryPoints() {
2763
2763
  return this.rpc('eth_supportedEntryPoints', []);
2764
2764
  }
2765
- async estimateUserOperationGas(userOp, entryPoint) {
2765
+ async estimateUserOperationGas(userOp, entryPoint, mode = 'developer-sponsored') {
2766
2766
  return this.rpc('eth_estimateUserOperationGas', [
2767
2767
  userOp,
2768
2768
  entryPoint,
2769
- ]);
2769
+ ], mode);
2770
2770
  }
2771
- async sendUserOperation(userOp, entryPoint) {
2772
- return this.rpc('eth_sendUserOperation', [userOp, entryPoint]);
2771
+ async sendUserOperation(userOp, entryPoint, mode = 'developer-sponsored') {
2772
+ return this.rpc('eth_sendUserOperation', [userOp, entryPoint], mode);
2773
2773
  }
2774
2774
  async getUserOperationReceipt(userOpHash) {
2775
2775
  return this.rpc('eth_getUserOperationReceipt', [userOpHash]);
@@ -2787,7 +2787,8 @@ class SmoothSendAvaxSubmitter {
2787
2787
  return null;
2788
2788
  }
2789
2789
  async paymasterSign(body) {
2790
- const res = await this.http.post('/api/v1/bundler/paymaster/sign', body);
2790
+ const mode = body.mode ?? 'developer-sponsored';
2791
+ const res = await this.http.post('/api/v1/bundler/paymaster/sign', body, { headers: { 'X-Sponsorship-Mode': mode } });
2791
2792
  if (!res.success || !res.data) {
2792
2793
  throw new Error('[SmoothSendAvaxSubmitter] paymasterSign failed');
2793
2794
  }
@@ -2814,7 +2815,7 @@ class SmoothSendAvaxSubmitter {
2814
2815
  ...opts.userOp,
2815
2816
  signature: opts.userOp.signature ?? '0x',
2816
2817
  };
2817
- const gas = await this.estimateUserOperationGas(userOp, entryPoint);
2818
+ const gas = await this.estimateUserOperationGas(userOp, entryPoint, 'user-pays-erc20');
2818
2819
  userOp = SmoothSendAvaxSubmitter.applyGasEstimate(userOp, gas);
2819
2820
  const signedPm = await this.paymasterSign({
2820
2821
  mode: 'user-pays-erc20',
@@ -2852,7 +2853,7 @@ class SmoothSendAvaxSubmitter {
2852
2853
  ...opts.userOp,
2853
2854
  signature: opts.userOp.signature ?? '0x',
2854
2855
  };
2855
- const gas = await this.estimateUserOperationGas(userOp, entryPoint);
2856
+ const gas = await this.estimateUserOperationGas(userOp, entryPoint, opts.mode ?? 'developer-sponsored');
2856
2857
  userOp = SmoothSendAvaxSubmitter.applyGasEstimate(userOp, gas);
2857
2858
  const signedPm = await this.paymasterSign({
2858
2859
  mode: opts.mode ?? 'developer-sponsored',
@@ -2864,21 +2865,21 @@ class SmoothSendAvaxSubmitter {
2864
2865
  ...userOp,
2865
2866
  signature: await opts.signUserOp(userOp),
2866
2867
  };
2867
- const userOpHash = await this.sendUserOperation(userOp, entryPoint);
2868
+ const userOpHash = await this.sendUserOperation(userOp, entryPoint, opts.mode ?? 'developer-sponsored');
2868
2869
  if (opts.waitForReceipt === false) {
2869
2870
  return { userOpHash, receipt: null };
2870
2871
  }
2871
2872
  const receipt = await this.waitForUserOperationReceipt(userOpHash, opts.receiptPoll);
2872
2873
  return { userOpHash, receipt };
2873
2874
  }
2874
- async rpc(method, params) {
2875
+ async rpc(method, params, mode = 'developer-sponsored') {
2875
2876
  const id = this.rpcId++;
2876
2877
  const envelope = await this.http.post('/', {
2877
2878
  jsonrpc: '2.0',
2878
2879
  id,
2879
2880
  method,
2880
2881
  params,
2881
- });
2882
+ }, { headers: { 'X-Sponsorship-Mode': mode } });
2882
2883
  if (!envelope.success || envelope.data == null) {
2883
2884
  throw new Error(`[SmoothSendAvaxSubmitter] ${method}: empty response`);
2884
2885
  }
@@ -3312,12 +3313,16 @@ function useSmoothSendAvax(params) {
3312
3313
  const smartAccountAddressProp = params.smartAccountAddress ?? ctx?.smartAccountAddress;
3313
3314
  const accountFactoryProp = params.accountFactory ?? ctx?.accountFactory;
3314
3315
  const accountSalt = params.accountSalt ?? ctx?.accountSalt ?? 0n;
3316
+ const { publicClient, walletClient } = params;
3317
+ const ownerAddressFromParams = params.ownerAddress;
3318
+ const signUserOpHash = params.signUserOpHash;
3315
3319
  if (!apiKey) {
3316
3320
  throw new Error('[SmoothSend AVAX] apiKey required — pass useSmoothSendAvax({ apiKey }) or wrap SmoothSendAvaxProvider');
3317
3321
  }
3318
3322
  const submitter = useMemo(() => new SmoothSendAvaxSubmitter({ apiKey, network }), [apiKey, network]);
3319
3323
  const [discovered, setDiscovered] = useState(null);
3320
3324
  const [isPending, setIsPending] = useState(false);
3325
+ const [computedScwAddress, setComputedScwAddress] = useState(null);
3321
3326
  useEffect(() => {
3322
3327
  submitter.getPublicAaDefaults().then(setDiscovered).catch(err => {
3323
3328
  console.warn('[SmoothSend AVAX] Auto-discovery failed:', err);
@@ -3325,9 +3330,33 @@ function useSmoothSendAvax(params) {
3325
3330
  }, [submitter]);
3326
3331
  const accountFactory = accountFactoryProp ?? (network === 'mainnet' ? discovered?.simpleAccountFactoryMainnet : discovered?.simpleAccountFactoryFuji);
3327
3332
  const paymasterAddress = (network === 'mainnet' ? discovered?.paymasterMainnet : discovered?.paymasterFuji);
3328
- const { publicClient, walletClient } = params;
3329
- const ownerAddressFromParams = params.ownerAddress;
3330
- const signUserOpHash = params.signUserOpHash;
3333
+ // Compute the SCW address for easy display in the UI (funding UX, balance checks, etc.)
3334
+ useEffect(() => {
3335
+ const owner = ownerAddressFromParams ?? walletClient?.account?.address;
3336
+ if (!publicClient || !owner || (!smartAccountAddressProp && !accountFactory)) {
3337
+ setComputedScwAddress(null);
3338
+ return;
3339
+ }
3340
+ const targetFactory = accountFactory;
3341
+ if (!targetFactory) {
3342
+ setComputedScwAddress(smartAccountAddressProp ?? null);
3343
+ return;
3344
+ }
3345
+ (async () => {
3346
+ try {
3347
+ const predicted = await predictSimpleAccountAddress({
3348
+ publicClient,
3349
+ factory: targetFactory,
3350
+ owner,
3351
+ salt: accountSalt,
3352
+ });
3353
+ setComputedScwAddress(predicted);
3354
+ }
3355
+ catch {
3356
+ setComputedScwAddress(smartAccountAddressProp ?? null);
3357
+ }
3358
+ })();
3359
+ }, [publicClient, ownerAddressFromParams, walletClient, smartAccountAddressProp, accountFactory, accountSalt]);
3331
3360
  const submitCall = useCallback(async (params) => {
3332
3361
  setIsPending(true);
3333
3362
  try {
@@ -3560,6 +3589,9 @@ function useSmoothSendAvax(params) {
3560
3589
  submitter,
3561
3590
  walletClient,
3562
3591
  ]);
3592
+ // Compute the effective SCW address for easy display in UIs
3593
+ // (this is the address users should send assets to for gasless flows)
3594
+ const effectiveSmartAccountAddress = smartAccountAddressProp ?? null;
3563
3595
  return {
3564
3596
  submitter,
3565
3597
  submitCall,
@@ -3567,6 +3599,12 @@ function useSmoothSendAvax(params) {
3567
3599
  estimateUserPaysFee,
3568
3600
  paymasterAddress,
3569
3601
  discoveredFactory: accountFactory ?? null,
3602
+ /**
3603
+ * The user's Smart Contract Wallet (SCW) address.
3604
+ * This is what you should show to users for funding ("send USDC here for gasless transactions").
3605
+ * Computed automatically when possible.
3606
+ */
3607
+ smartAccountAddress: computedScwAddress ?? effectiveSmartAccountAddress,
3570
3608
  isPending,
3571
3609
  };
3572
3610
  }
@@ -4167,7 +4205,7 @@ function createTrueGaslessClient(config) {
4167
4205
  return new TrueGaslessClient(config);
4168
4206
  }
4169
4207
 
4170
- const VERSION = '2.2.3';
4208
+ const VERSION = '2.3.6';
4171
4209
 
4172
4210
  /**
4173
4211
  * SmoothSend SDK v2.0