@smoothsend/sdk 2.3.2 → 2.3.4
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/avax/SmoothSendAvaxClient.d.ts +4 -2
- package/dist/avax/SmoothSendAvaxClient.d.ts.map +1 -1
- package/dist/avax/index.cjs +155 -28
- package/dist/avax/index.cjs.map +1 -1
- package/dist/avax/index.d.ts +58 -437
- package/dist/avax/index.d.ts.map +1 -1
- package/dist/avax/index.js +153 -29
- package/dist/avax/index.js.map +1 -1
- package/dist/avax/privySigner.d.ts +12 -0
- package/dist/avax/privySigner.d.ts.map +1 -0
- package/dist/avax/types.d.ts +6 -0
- package/dist/avax/types.d.ts.map +1 -1
- package/dist/avax/useSmoothSendAvax.d.ts +6 -2
- package/dist/avax/useSmoothSendAvax.d.ts.map +1 -1
- package/dist/avax/useSmoothSendPrivyWrite.d.ts +35 -0
- package/dist/avax/useSmoothSendPrivyWrite.d.ts.map +1 -0
- package/dist/avax/useSmoothSendWrite.d.ts +30 -0
- package/dist/avax/useSmoothSendWrite.d.ts.map +1 -0
- package/dist/avax-entry.d.ts +1 -1
- package/dist/avax-entry.d.ts.map +1 -1
- package/dist/chunks/shared-Cgb7mhwI.d.ts +471 -0
- package/dist/chunks/shared-viO0MYao.d.ts +459 -0
- package/dist/index.cjs +43 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +43 -28
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3112,7 +3112,11 @@ class SmoothSendAvaxClient {
|
|
|
3112
3112
|
entryPointAddress: built.entryPoint,
|
|
3113
3113
|
userOperation: op
|
|
3114
3114
|
});
|
|
3115
|
-
return this.signUserOpHash(hash
|
|
3115
|
+
return this.signUserOpHash(hash, {
|
|
3116
|
+
chainId: built.chainId,
|
|
3117
|
+
entryPoint: built.entryPoint,
|
|
3118
|
+
sender: built.userOp.sender,
|
|
3119
|
+
});
|
|
3116
3120
|
}
|
|
3117
3121
|
});
|
|
3118
3122
|
return {
|
|
@@ -3143,11 +3147,10 @@ class SmoothSendAvaxClient {
|
|
|
3143
3147
|
}
|
|
3144
3148
|
async buildDraft(calls, overrides) {
|
|
3145
3149
|
const { publicClient, walletClient } = this.config;
|
|
3146
|
-
const
|
|
3147
|
-
if (!
|
|
3148
|
-
throw new Error('[SmoothSend AVAX] walletClient.account
|
|
3150
|
+
const ownerAddress = (this.config.ownerAddress ?? walletClient?.account?.address);
|
|
3151
|
+
if (!ownerAddress) {
|
|
3152
|
+
throw new Error('[SmoothSend AVAX] ownerAddress missing — provide ownerAddress or walletClient.account');
|
|
3149
3153
|
}
|
|
3150
|
-
const ownerAddress = account.address;
|
|
3151
3154
|
const defaults = await this.submitter.getPublicAaDefaults().catch(() => null);
|
|
3152
3155
|
const accountFactory = overrides?.accountFactory ??
|
|
3153
3156
|
this.config.accountFactory ??
|
|
@@ -3227,14 +3230,21 @@ class SmoothSendAvaxClient {
|
|
|
3227
3230
|
entryPoint
|
|
3228
3231
|
};
|
|
3229
3232
|
}
|
|
3230
|
-
async signUserOpHash(hash) {
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
+
async signUserOpHash(hash, context) {
|
|
3234
|
+
if (this.config.signUserOpHash) {
|
|
3235
|
+
return this.config.signUserOpHash({
|
|
3236
|
+
hash,
|
|
3237
|
+
chainId: context.chainId,
|
|
3238
|
+
entryPoint: context.entryPoint,
|
|
3239
|
+
sender: context.sender,
|
|
3240
|
+
});
|
|
3241
|
+
}
|
|
3242
|
+
const walletClient = this.config.walletClient;
|
|
3243
|
+
const account = walletClient?.account;
|
|
3244
|
+
if (!walletClient || !account) {
|
|
3233
3245
|
throw new Error('[SmoothSend AVAX] walletClient.account missing');
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
message: { raw: hash }
|
|
3237
|
-
});
|
|
3246
|
+
}
|
|
3247
|
+
return walletClient.signMessage({ account, message: { raw: hash } });
|
|
3238
3248
|
}
|
|
3239
3249
|
}
|
|
3240
3250
|
function createSmoothSendAvaxClient(config) {
|
|
@@ -3316,23 +3326,25 @@ function useSmoothSendAvax(params) {
|
|
|
3316
3326
|
const accountFactory = accountFactoryProp ?? (network === 'mainnet' ? discovered?.simpleAccountFactoryMainnet : discovered?.simpleAccountFactoryFuji);
|
|
3317
3327
|
const paymasterAddress = (network === 'mainnet' ? discovered?.paymasterMainnet : discovered?.paymasterFuji);
|
|
3318
3328
|
const { publicClient, walletClient } = params;
|
|
3329
|
+
const ownerAddressFromParams = params.ownerAddress;
|
|
3330
|
+
const signUserOpHash = params.signUserOpHash;
|
|
3319
3331
|
const submitCall = useCallback(async (params) => {
|
|
3320
3332
|
setIsPending(true);
|
|
3321
3333
|
try {
|
|
3322
3334
|
if (!publicClient) {
|
|
3323
3335
|
throw new Error('[SmoothSend AVAX] publicClient missing (wagmi usePublicClient)');
|
|
3324
3336
|
}
|
|
3325
|
-
if (!walletClient) {
|
|
3337
|
+
if (!walletClient && !signUserOpHash) {
|
|
3326
3338
|
throw new Error('[SmoothSend AVAX] walletClient missing (wagmi useWalletClient)');
|
|
3327
3339
|
}
|
|
3328
3340
|
if (!smartAccountAddressProp && !accountFactory) {
|
|
3329
3341
|
throw new Error('[SmoothSend AVAX] No smartAccountAddress or accountFactory provided. Pass them to SmoothSendAvaxProvider or useSmoothSendAvax hook.');
|
|
3330
3342
|
}
|
|
3331
|
-
const account = walletClient
|
|
3332
|
-
|
|
3333
|
-
|
|
3343
|
+
const account = walletClient?.account;
|
|
3344
|
+
const ownerAddress = (ownerAddressFromParams ?? account?.address);
|
|
3345
|
+
if (!ownerAddress) {
|
|
3346
|
+
throw new Error('[SmoothSend AVAX] ownerAddress missing — provide ownerAddress or walletClient.account');
|
|
3334
3347
|
}
|
|
3335
|
-
const ownerAddress = account.address;
|
|
3336
3348
|
const chainId = Number(publicClient.chain?.id ?? (await publicClient.getChainId()));
|
|
3337
3349
|
const entryPoint = (await submitter.getSupportedEntryPoints())[0];
|
|
3338
3350
|
let sender;
|
|
@@ -3415,10 +3427,13 @@ function useSmoothSendAvax(params) {
|
|
|
3415
3427
|
entryPointAddress: entryPoint,
|
|
3416
3428
|
userOperation: op,
|
|
3417
3429
|
});
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3430
|
+
if (signUserOpHash) {
|
|
3431
|
+
return signUserOpHash({ hash, chainId, entryPoint, sender });
|
|
3432
|
+
}
|
|
3433
|
+
if (!walletClient || !account) {
|
|
3434
|
+
throw new Error('[SmoothSend AVAX] walletClient/account missing for signature');
|
|
3435
|
+
}
|
|
3436
|
+
return walletClient.signMessage({ account, message: { raw: hash } });
|
|
3422
3437
|
},
|
|
3423
3438
|
});
|
|
3424
3439
|
}
|
|
@@ -3428,7 +3443,9 @@ function useSmoothSendAvax(params) {
|
|
|
3428
3443
|
}, [
|
|
3429
3444
|
accountFactory,
|
|
3430
3445
|
accountSalt,
|
|
3446
|
+
ownerAddressFromParams,
|
|
3431
3447
|
publicClient,
|
|
3448
|
+
signUserOpHash,
|
|
3432
3449
|
smartAccountAddressProp,
|
|
3433
3450
|
submitter,
|
|
3434
3451
|
walletClient,
|
|
@@ -3448,17 +3465,14 @@ function useSmoothSendAvax(params) {
|
|
|
3448
3465
|
if (!publicClient) {
|
|
3449
3466
|
throw new Error('[SmoothSend AVAX] publicClient missing (wagmi usePublicClient)');
|
|
3450
3467
|
}
|
|
3451
|
-
if (!walletClient) {
|
|
3452
|
-
throw new Error('[SmoothSend AVAX] walletClient missing (wagmi useWalletClient)');
|
|
3453
|
-
}
|
|
3454
3468
|
if (!smartAccountAddressProp && !accountFactory) {
|
|
3455
3469
|
throw new Error('[SmoothSend AVAX] No smartAccountAddress or accountFactory provided. Pass them to SmoothSendAvaxProvider or useSmoothSendAvax hook.');
|
|
3456
3470
|
}
|
|
3457
|
-
const account = walletClient
|
|
3458
|
-
|
|
3459
|
-
|
|
3471
|
+
const account = walletClient?.account;
|
|
3472
|
+
const ownerAddress = (ownerAddressFromParams ?? account?.address);
|
|
3473
|
+
if (!ownerAddress) {
|
|
3474
|
+
throw new Error('[SmoothSend AVAX] ownerAddress missing — provide ownerAddress or walletClient.account');
|
|
3460
3475
|
}
|
|
3461
|
-
const ownerAddress = account.address;
|
|
3462
3476
|
let sender;
|
|
3463
3477
|
if (accountFactory) {
|
|
3464
3478
|
const predicted = await predictSimpleAccountAddress({
|
|
@@ -3540,6 +3554,7 @@ function useSmoothSendAvax(params) {
|
|
|
3540
3554
|
}, [
|
|
3541
3555
|
accountFactory,
|
|
3542
3556
|
accountSalt,
|
|
3557
|
+
ownerAddressFromParams,
|
|
3543
3558
|
publicClient,
|
|
3544
3559
|
smartAccountAddressProp,
|
|
3545
3560
|
submitter,
|