@smoothsend/sdk 2.3.5 → 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 (38) hide show
  1. package/dist/aptos/index.cjs +2 -2
  2. package/dist/aptos/index.d.ts +3 -3
  3. package/dist/aptos/index.js +3 -3
  4. package/dist/avax/SmoothSendAvaxSubmitter.d.ts +2 -2
  5. package/dist/avax/SmoothSendAvaxSubmitter.d.ts.map +1 -1
  6. package/dist/avax/index.cjs +52 -14
  7. package/dist/avax/index.cjs.map +1 -1
  8. package/dist/avax/index.d.ts +3 -3
  9. package/dist/avax/index.d.ts.map +1 -1
  10. package/dist/avax/index.js +53 -15
  11. package/dist/avax/index.js.map +1 -1
  12. package/dist/avax/publicAaDefaults.d.ts +26 -0
  13. package/dist/avax/publicAaDefaults.d.ts.map +1 -1
  14. package/dist/avax/useSmoothSendAvax.d.ts +2 -0
  15. package/dist/avax/useSmoothSendAvax.d.ts.map +1 -1
  16. package/dist/chunks/shared-BQ9u3lrN.js +557 -0
  17. package/dist/chunks/shared-BQ9u3lrN.js.map +1 -0
  18. package/dist/chunks/shared-BcSSEWv8.d.ts +474 -0
  19. package/dist/chunks/shared-BlhOY1v3.cjs +568 -0
  20. package/dist/chunks/shared-BlhOY1v3.cjs.map +1 -0
  21. package/dist/chunks/shared-CWbQR_je.js +1511 -0
  22. package/dist/chunks/shared-CWbQR_je.js.map +1 -0
  23. package/dist/chunks/shared-DMOh_aLU.d.ts +1279 -0
  24. package/dist/chunks/shared-DYAVFARB.d.ts +472 -0
  25. package/dist/chunks/shared-EuyoZgP8.cjs +1519 -0
  26. package/dist/chunks/shared-EuyoZgP8.cjs.map +1 -0
  27. package/dist/chunks/shared-W7k9S_GY.d.ts +262 -0
  28. package/dist/chunks/shared-vFCAUg0m.d.ts +780 -0
  29. package/dist/index.cjs +52 -14
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.ts +4 -4
  32. package/dist/index.js +52 -14
  33. package/dist/index.js.map +1 -1
  34. package/dist/stellar/index.cjs +2 -2
  35. package/dist/stellar/index.d.ts +3 -3
  36. package/dist/stellar/index.js +2 -2
  37. package/dist/version.d.ts +1 -1
  38. package/package.json +2 -2
package/dist/index.cjs CHANGED
@@ -2766,14 +2766,14 @@ class SmoothSendAvaxSubmitter {
2766
2766
  async getSupportedEntryPoints() {
2767
2767
  return this.rpc('eth_supportedEntryPoints', []);
2768
2768
  }
2769
- async estimateUserOperationGas(userOp, entryPoint) {
2769
+ async estimateUserOperationGas(userOp, entryPoint, mode = 'developer-sponsored') {
2770
2770
  return this.rpc('eth_estimateUserOperationGas', [
2771
2771
  userOp,
2772
2772
  entryPoint,
2773
- ]);
2773
+ ], mode);
2774
2774
  }
2775
- async sendUserOperation(userOp, entryPoint) {
2776
- return this.rpc('eth_sendUserOperation', [userOp, entryPoint]);
2775
+ async sendUserOperation(userOp, entryPoint, mode = 'developer-sponsored') {
2776
+ return this.rpc('eth_sendUserOperation', [userOp, entryPoint], mode);
2777
2777
  }
2778
2778
  async getUserOperationReceipt(userOpHash) {
2779
2779
  return this.rpc('eth_getUserOperationReceipt', [userOpHash]);
@@ -2791,7 +2791,8 @@ class SmoothSendAvaxSubmitter {
2791
2791
  return null;
2792
2792
  }
2793
2793
  async paymasterSign(body) {
2794
- const res = await this.http.post('/api/v1/bundler/paymaster/sign', body);
2794
+ const mode = body.mode ?? 'developer-sponsored';
2795
+ const res = await this.http.post('/api/v1/bundler/paymaster/sign', body, { headers: { 'X-Sponsorship-Mode': mode } });
2795
2796
  if (!res.success || !res.data) {
2796
2797
  throw new Error('[SmoothSendAvaxSubmitter] paymasterSign failed');
2797
2798
  }
@@ -2818,7 +2819,7 @@ class SmoothSendAvaxSubmitter {
2818
2819
  ...opts.userOp,
2819
2820
  signature: opts.userOp.signature ?? '0x',
2820
2821
  };
2821
- const gas = await this.estimateUserOperationGas(userOp, entryPoint);
2822
+ const gas = await this.estimateUserOperationGas(userOp, entryPoint, 'user-pays-erc20');
2822
2823
  userOp = SmoothSendAvaxSubmitter.applyGasEstimate(userOp, gas);
2823
2824
  const signedPm = await this.paymasterSign({
2824
2825
  mode: 'user-pays-erc20',
@@ -2856,7 +2857,7 @@ class SmoothSendAvaxSubmitter {
2856
2857
  ...opts.userOp,
2857
2858
  signature: opts.userOp.signature ?? '0x',
2858
2859
  };
2859
- const gas = await this.estimateUserOperationGas(userOp, entryPoint);
2860
+ const gas = await this.estimateUserOperationGas(userOp, entryPoint, opts.mode ?? 'developer-sponsored');
2860
2861
  userOp = SmoothSendAvaxSubmitter.applyGasEstimate(userOp, gas);
2861
2862
  const signedPm = await this.paymasterSign({
2862
2863
  mode: opts.mode ?? 'developer-sponsored',
@@ -2868,21 +2869,21 @@ class SmoothSendAvaxSubmitter {
2868
2869
  ...userOp,
2869
2870
  signature: await opts.signUserOp(userOp),
2870
2871
  };
2871
- const userOpHash = await this.sendUserOperation(userOp, entryPoint);
2872
+ const userOpHash = await this.sendUserOperation(userOp, entryPoint, opts.mode ?? 'developer-sponsored');
2872
2873
  if (opts.waitForReceipt === false) {
2873
2874
  return { userOpHash, receipt: null };
2874
2875
  }
2875
2876
  const receipt = await this.waitForUserOperationReceipt(userOpHash, opts.receiptPoll);
2876
2877
  return { userOpHash, receipt };
2877
2878
  }
2878
- async rpc(method, params) {
2879
+ async rpc(method, params, mode = 'developer-sponsored') {
2879
2880
  const id = this.rpcId++;
2880
2881
  const envelope = await this.http.post('/', {
2881
2882
  jsonrpc: '2.0',
2882
2883
  id,
2883
2884
  method,
2884
2885
  params,
2885
- });
2886
+ }, { headers: { 'X-Sponsorship-Mode': mode } });
2886
2887
  if (!envelope.success || envelope.data == null) {
2887
2888
  throw new Error(`[SmoothSendAvaxSubmitter] ${method}: empty response`);
2888
2889
  }
@@ -3316,12 +3317,16 @@ function useSmoothSendAvax(params) {
3316
3317
  const smartAccountAddressProp = params.smartAccountAddress ?? ctx?.smartAccountAddress;
3317
3318
  const accountFactoryProp = params.accountFactory ?? ctx?.accountFactory;
3318
3319
  const accountSalt = params.accountSalt ?? ctx?.accountSalt ?? 0n;
3320
+ const { publicClient, walletClient } = params;
3321
+ const ownerAddressFromParams = params.ownerAddress;
3322
+ const signUserOpHash = params.signUserOpHash;
3319
3323
  if (!apiKey) {
3320
3324
  throw new Error('[SmoothSend AVAX] apiKey required — pass useSmoothSendAvax({ apiKey }) or wrap SmoothSendAvaxProvider');
3321
3325
  }
3322
3326
  const submitter = react.useMemo(() => new SmoothSendAvaxSubmitter({ apiKey, network }), [apiKey, network]);
3323
3327
  const [discovered, setDiscovered] = react.useState(null);
3324
3328
  const [isPending, setIsPending] = react.useState(false);
3329
+ const [computedScwAddress, setComputedScwAddress] = react.useState(null);
3325
3330
  react.useEffect(() => {
3326
3331
  submitter.getPublicAaDefaults().then(setDiscovered).catch(err => {
3327
3332
  console.warn('[SmoothSend AVAX] Auto-discovery failed:', err);
@@ -3329,9 +3334,33 @@ function useSmoothSendAvax(params) {
3329
3334
  }, [submitter]);
3330
3335
  const accountFactory = accountFactoryProp ?? (network === 'mainnet' ? discovered?.simpleAccountFactoryMainnet : discovered?.simpleAccountFactoryFuji);
3331
3336
  const paymasterAddress = (network === 'mainnet' ? discovered?.paymasterMainnet : discovered?.paymasterFuji);
3332
- const { publicClient, walletClient } = params;
3333
- const ownerAddressFromParams = params.ownerAddress;
3334
- const signUserOpHash = params.signUserOpHash;
3337
+ // Compute the SCW address for easy display in the UI (funding UX, balance checks, etc.)
3338
+ react.useEffect(() => {
3339
+ const owner = ownerAddressFromParams ?? walletClient?.account?.address;
3340
+ if (!publicClient || !owner || (!smartAccountAddressProp && !accountFactory)) {
3341
+ setComputedScwAddress(null);
3342
+ return;
3343
+ }
3344
+ const targetFactory = accountFactory;
3345
+ if (!targetFactory) {
3346
+ setComputedScwAddress(smartAccountAddressProp ?? null);
3347
+ return;
3348
+ }
3349
+ (async () => {
3350
+ try {
3351
+ const predicted = await predictSimpleAccountAddress({
3352
+ publicClient,
3353
+ factory: targetFactory,
3354
+ owner,
3355
+ salt: accountSalt,
3356
+ });
3357
+ setComputedScwAddress(predicted);
3358
+ }
3359
+ catch {
3360
+ setComputedScwAddress(smartAccountAddressProp ?? null);
3361
+ }
3362
+ })();
3363
+ }, [publicClient, ownerAddressFromParams, walletClient, smartAccountAddressProp, accountFactory, accountSalt]);
3335
3364
  const submitCall = react.useCallback(async (params) => {
3336
3365
  setIsPending(true);
3337
3366
  try {
@@ -3564,6 +3593,9 @@ function useSmoothSendAvax(params) {
3564
3593
  submitter,
3565
3594
  walletClient,
3566
3595
  ]);
3596
+ // Compute the effective SCW address for easy display in UIs
3597
+ // (this is the address users should send assets to for gasless flows)
3598
+ const effectiveSmartAccountAddress = smartAccountAddressProp ?? null;
3567
3599
  return {
3568
3600
  submitter,
3569
3601
  submitCall,
@@ -3571,6 +3603,12 @@ function useSmoothSendAvax(params) {
3571
3603
  estimateUserPaysFee,
3572
3604
  paymasterAddress,
3573
3605
  discoveredFactory: accountFactory ?? null,
3606
+ /**
3607
+ * The user's Smart Contract Wallet (SCW) address.
3608
+ * This is what you should show to users for funding ("send USDC here for gasless transactions").
3609
+ * Computed automatically when possible.
3610
+ */
3611
+ smartAccountAddress: computedScwAddress ?? effectiveSmartAccountAddress,
3574
3612
  isPending,
3575
3613
  };
3576
3614
  }
@@ -4171,7 +4209,7 @@ function createTrueGaslessClient(config) {
4171
4209
  return new TrueGaslessClient(config);
4172
4210
  }
4173
4211
 
4174
- const VERSION = '2.2.3';
4212
+ const VERSION = '2.3.6';
4175
4213
 
4176
4214
  /**
4177
4215
  * SmoothSend SDK v2.0