@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.
- package/dist/aptos/index.cjs +162 -2
- package/dist/aptos/index.cjs.map +1 -1
- package/dist/aptos/index.d.ts +66 -750
- package/dist/aptos/index.js +163 -6
- package/dist/aptos/index.js.map +1 -1
- package/dist/aptos-entry.d.ts +1 -0
- package/dist/aptos-entry.d.ts.map +1 -1
- package/dist/aptos-privy/SmoothSendAptosProvider.d.ts +7 -0
- package/dist/aptos-privy/SmoothSendAptosProvider.d.ts.map +1 -0
- package/dist/aptos-privy/index.cjs +40 -0
- package/dist/aptos-privy/index.cjs.map +1 -0
- package/dist/aptos-privy/index.d.ts +4 -0
- package/dist/aptos-privy/index.d.ts.map +1 -0
- package/dist/aptos-privy/index.js +34 -0
- package/dist/aptos-privy/index.js.map +1 -0
- package/dist/aptos-privy/normalizePrivyAptosWallet.d.ts +4 -0
- package/dist/aptos-privy/normalizePrivyAptosWallet.d.ts.map +1 -0
- package/dist/aptos-privy/privyAptosSigner.d.ts +32 -0
- package/dist/aptos-privy/privyAptosSigner.d.ts.map +1 -0
- package/dist/aptos-privy/types.d.ts +71 -0
- package/dist/aptos-privy/types.d.ts.map +1 -0
- package/dist/aptos-privy/useSmoothSendAptosPrivy.d.ts +13 -0
- package/dist/aptos-privy/useSmoothSendAptosPrivy.d.ts.map +1 -0
- package/dist/aptos-privy/useSmoothSendPrivyWrite.d.ts +13 -0
- package/dist/aptos-privy/useSmoothSendPrivyWrite.d.ts.map +1 -0
- package/dist/aptos-privy-entry.d.ts +9 -0
- package/dist/aptos-privy-entry.d.ts.map +1 -0
- package/dist/avax/SmoothSendAvaxSubmitter.d.ts +2 -2
- package/dist/avax/SmoothSendAvaxSubmitter.d.ts.map +1 -1
- package/dist/avax/index.cjs +52 -14
- package/dist/avax/index.cjs.map +1 -1
- package/dist/avax/index.d.ts +3 -3
- package/dist/avax/index.d.ts.map +1 -1
- package/dist/avax/index.js +53 -15
- package/dist/avax/index.js.map +1 -1
- package/dist/avax/publicAaDefaults.d.ts +26 -0
- package/dist/avax/publicAaDefaults.d.ts.map +1 -1
- package/dist/avax/useSmoothSendAvax.d.ts +2 -0
- package/dist/avax/useSmoothSendAvax.d.ts.map +1 -1
- package/dist/chunks/shared-2xx2VLH3.js +453 -0
- package/dist/chunks/shared-2xx2VLH3.js.map +1 -0
- package/dist/chunks/shared-B8UdyBTN.d.ts +143 -0
- package/dist/chunks/shared-BJv1JV1H.cjs +702 -0
- package/dist/chunks/shared-BJv1JV1H.cjs.map +1 -0
- package/dist/chunks/shared-BQ9u3lrN.js +557 -0
- package/dist/chunks/shared-BQ9u3lrN.js.map +1 -0
- package/dist/chunks/shared-BXvqbQ6f.d.ts +262 -0
- package/dist/chunks/shared-BcSSEWv8.d.ts +474 -0
- package/dist/chunks/shared-Bh4xtpHv.js +740 -0
- package/dist/chunks/shared-Bh4xtpHv.js.map +1 -0
- package/dist/chunks/shared-BlIQttCf.d.ts +1279 -0
- package/dist/chunks/shared-BlhOY1v3.cjs +568 -0
- package/dist/chunks/shared-BlhOY1v3.cjs.map +1 -0
- package/dist/chunks/shared-BoRfHN1w.js +1511 -0
- package/dist/chunks/shared-BoRfHN1w.js.map +1 -0
- package/dist/chunks/shared-CPpb2n9T.d.ts +780 -0
- package/dist/chunks/shared-CWbQR_je.js +1511 -0
- package/dist/chunks/shared-CWbQR_je.js.map +1 -0
- package/dist/chunks/shared-CzR0rIwZ.cjs +635 -0
- package/dist/chunks/shared-CzR0rIwZ.cjs.map +1 -0
- package/dist/chunks/shared-DMOh_aLU.d.ts +1279 -0
- package/dist/chunks/shared-DQbEIiTE.cjs +746 -0
- package/dist/chunks/shared-DQbEIiTE.cjs.map +1 -0
- package/dist/chunks/shared-DYAVFARB.d.ts +472 -0
- package/dist/chunks/shared-DzwYUjQn.cjs +457 -0
- package/dist/chunks/shared-DzwYUjQn.cjs.map +1 -0
- package/dist/chunks/shared-EuyoZgP8.cjs +1519 -0
- package/dist/chunks/shared-EuyoZgP8.cjs.map +1 -0
- package/dist/chunks/shared-KUvoQkzf.d.ts +471 -0
- package/dist/chunks/shared-W7k9S_GY.d.ts +262 -0
- package/dist/chunks/shared-XH1iLZjy.js +629 -0
- package/dist/chunks/shared-XH1iLZjy.js.map +1 -0
- package/dist/chunks/shared-kovW7ATj.js +694 -0
- package/dist/chunks/shared-kovW7ATj.js.map +1 -0
- package/dist/chunks/shared-vFCAUg0m.d.ts +780 -0
- package/dist/index.cjs +52 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +52 -14
- package/dist/index.js.map +1 -1
- package/dist/stellar/index.cjs +2 -2
- package/dist/stellar/index.d.ts +3 -3
- package/dist/stellar/index.js +2 -2
- package/dist/version.d.ts +1 -1
- package/package.json +2 -2
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
|
|
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
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
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.
|
|
4208
|
+
const VERSION = '2.3.6';
|
|
4171
4209
|
|
|
4172
4210
|
/**
|
|
4173
4211
|
* SmoothSend SDK v2.0
|