thirdweb 5.73.0 → 5.74.0
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/cjs/adapters/eip1193/from-eip1193.js +2 -0
- package/dist/cjs/adapters/eip1193/from-eip1193.js.map +1 -1
- package/dist/cjs/adapters/eip1193/to-eip1193.js +2 -0
- package/dist/cjs/adapters/eip1193/to-eip1193.js.map +1 -1
- package/dist/cjs/exports/wallets/smart.js +2 -1
- package/dist/cjs/exports/wallets/smart.js.map +1 -1
- package/dist/cjs/extensions/erc20/read/isERC20.js +8 -1
- package/dist/cjs/extensions/erc20/read/isERC20.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/SignatureScreen.js +12 -10
- package/dist/cjs/react/web/ui/ConnectWallet/screens/SignatureScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/useConnectModal.js.map +1 -1
- package/dist/cjs/react/web/wallets/shared/ConnectWalletSocialOptions.js +1 -1
- package/dist/cjs/react/web/wallets/shared/ConnectWalletSocialOptions.js.map +1 -1
- package/dist/cjs/utils/any-evm/zksync/isZkSyncChain.js +4 -1
- package/dist/cjs/utils/any-evm/zksync/isZkSyncChain.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/wallets/ecosystem/is-ecosystem-wallet.js +1 -1
- package/dist/cjs/wallets/in-app/core/users/getUser.js +6 -1
- package/dist/cjs/wallets/in-app/core/users/getUser.js.map +1 -1
- package/dist/cjs/wallets/in-app/core/wallet/in-app-core.js +8 -4
- package/dist/cjs/wallets/in-app/core/wallet/in-app-core.js.map +1 -1
- package/dist/cjs/wallets/in-app/web/ecosystem.js +1 -1
- package/dist/cjs/wallets/in-app/web/in-app.js +2 -2
- package/dist/cjs/wallets/smart/index.js +19 -12
- package/dist/cjs/wallets/smart/index.js.map +1 -1
- package/dist/cjs/wallets/smart/lib/bundler.js +2 -1
- package/dist/cjs/wallets/smart/lib/bundler.js.map +1 -1
- package/dist/cjs/wallets/smart/lib/constants.js +21 -1
- package/dist/cjs/wallets/smart/lib/constants.js.map +1 -1
- package/dist/cjs/wallets/smart/lib/userop.js +19 -4
- package/dist/cjs/wallets/smart/lib/userop.js.map +1 -1
- package/dist/cjs/wallets/smart/smart-wallet.js +1 -1
- package/dist/cjs/wallets/smart/types.js.map +1 -1
- package/dist/esm/adapters/eip1193/from-eip1193.js +2 -0
- package/dist/esm/adapters/eip1193/from-eip1193.js.map +1 -1
- package/dist/esm/adapters/eip1193/to-eip1193.js +2 -0
- package/dist/esm/adapters/eip1193/to-eip1193.js.map +1 -1
- package/dist/esm/exports/wallets/smart.js +1 -1
- package/dist/esm/exports/wallets/smart.js.map +1 -1
- package/dist/esm/extensions/erc20/read/isERC20.js +8 -1
- package/dist/esm/extensions/erc20/read/isERC20.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/SignatureScreen.js +12 -10
- package/dist/esm/react/web/ui/ConnectWallet/screens/SignatureScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/useConnectModal.js.map +1 -1
- package/dist/esm/react/web/wallets/shared/ConnectWalletSocialOptions.js +1 -1
- package/dist/esm/react/web/wallets/shared/ConnectWalletSocialOptions.js.map +1 -1
- package/dist/esm/utils/any-evm/zksync/isZkSyncChain.js +4 -1
- package/dist/esm/utils/any-evm/zksync/isZkSyncChain.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/wallets/ecosystem/is-ecosystem-wallet.js +1 -1
- package/dist/esm/wallets/in-app/core/users/getUser.js +6 -1
- package/dist/esm/wallets/in-app/core/users/getUser.js.map +1 -1
- package/dist/esm/wallets/in-app/core/wallet/in-app-core.js +9 -5
- package/dist/esm/wallets/in-app/core/wallet/in-app-core.js.map +1 -1
- package/dist/esm/wallets/in-app/web/ecosystem.js +1 -1
- package/dist/esm/wallets/in-app/web/in-app.js +2 -2
- package/dist/esm/wallets/smart/index.js +20 -13
- package/dist/esm/wallets/smart/index.js.map +1 -1
- package/dist/esm/wallets/smart/lib/bundler.js +2 -1
- package/dist/esm/wallets/smart/lib/bundler.js.map +1 -1
- package/dist/esm/wallets/smart/lib/constants.js +20 -0
- package/dist/esm/wallets/smart/lib/constants.js.map +1 -1
- package/dist/esm/wallets/smart/lib/userop.js +20 -5
- package/dist/esm/wallets/smart/lib/userop.js.map +1 -1
- package/dist/esm/wallets/smart/smart-wallet.js +1 -1
- package/dist/esm/wallets/smart/types.js.map +1 -1
- package/dist/types/adapters/eip1193/from-eip1193.d.ts +2 -0
- package/dist/types/adapters/eip1193/from-eip1193.d.ts.map +1 -1
- package/dist/types/adapters/eip1193/to-eip1193.d.ts +2 -0
- package/dist/types/adapters/eip1193/to-eip1193.d.ts.map +1 -1
- package/dist/types/exports/wallets/smart.d.ts +1 -1
- package/dist/types/exports/wallets/smart.d.ts.map +1 -1
- package/dist/types/extensions/erc20/read/isERC20.d.ts +8 -1
- package/dist/types/extensions/erc20/read/isERC20.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/SignatureScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/useConnectModal.d.ts +0 -8
- package/dist/types/react/web/ui/ConnectWallet/useConnectModal.d.ts.map +1 -1
- package/dist/types/utils/any-evm/zksync/isZkSyncChain.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/wallets/ecosystem/get-ecosystem-wallet-auth-options.d.ts +1 -1
- package/dist/types/wallets/ecosystem/get-ecosystem-wallet-auth-options.d.ts.map +1 -1
- package/dist/types/wallets/in-app/core/users/getUser.d.ts.map +1 -1
- package/dist/types/wallets/in-app/core/wallet/in-app-core.d.ts.map +1 -1
- package/dist/types/wallets/in-app/web/ecosystem.d.ts +1 -1
- package/dist/types/wallets/in-app/web/in-app.d.ts +2 -2
- package/dist/types/wallets/smart/index.d.ts.map +1 -1
- package/dist/types/wallets/smart/lib/bundler.d.ts +6 -0
- package/dist/types/wallets/smart/lib/bundler.d.ts.map +1 -1
- package/dist/types/wallets/smart/lib/constants.d.ts +4 -0
- package/dist/types/wallets/smart/lib/constants.d.ts.map +1 -1
- package/dist/types/wallets/smart/lib/userop.d.ts.map +1 -1
- package/dist/types/wallets/smart/smart-wallet.d.ts +1 -1
- package/dist/types/wallets/smart/types.d.ts +7 -4
- package/dist/types/wallets/smart/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/adapters/eip1193/from-eip1193.ts +2 -0
- package/src/adapters/eip1193/to-eip1193.ts +2 -0
- package/src/exports/wallets/smart.ts +1 -0
- package/src/extensions/erc20/read/isERC20.ts +8 -1
- package/src/react/web/ui/ConnectWallet/screens/SignatureScreen.test.tsx +287 -0
- package/src/react/web/ui/ConnectWallet/screens/SignatureScreen.tsx +13 -5
- package/src/react/web/ui/ConnectWallet/useConnectModal.tsx +0 -9
- package/src/react/web/wallets/shared/ConnectWalletSocialOptions.test.tsx +87 -0
- package/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx +1 -1
- package/src/utils/any-evm/zksync/isZkSyncChain.ts +4 -1
- package/src/version.ts +1 -1
- package/src/wallets/ecosystem/get-ecosystem-wallet-auth-options.ts +1 -1
- package/src/wallets/ecosystem/is-ecosystem-wallet.ts +1 -1
- package/src/wallets/in-app/core/users/getUser.test.ts +216 -0
- package/src/wallets/in-app/core/users/getUser.ts +6 -1
- package/src/wallets/in-app/core/wallet/in-app-core.test.ts +270 -0
- package/src/wallets/in-app/core/wallet/in-app-core.ts +16 -5
- package/src/wallets/in-app/web/ecosystem.ts +1 -1
- package/src/wallets/in-app/web/in-app.ts +2 -2
- package/src/wallets/smart/index.ts +37 -17
- package/src/wallets/smart/lib/bundler.ts +14 -4
- package/src/wallets/smart/lib/constants.ts +23 -0
- package/src/wallets/smart/lib/userop.ts +31 -8
- package/src/wallets/smart/smart-wallet-tokenpaymaster.test.ts +117 -0
- package/src/wallets/smart/smart-wallet.ts +1 -1
- package/src/wallets/smart/types.ts +8 -4
@@ -22,7 +22,6 @@ import type { PreparedTransaction } from "../../transaction/prepare-transaction.
|
|
22
22
|
import { readContract } from "../../transaction/read-contract.js";
|
23
23
|
import { getAddress } from "../../utils/address.js";
|
24
24
|
import { isZkSyncChain } from "../../utils/any-evm/zksync/isZkSyncChain.js";
|
25
|
-
import { concatHex } from "../../utils/encoding/helpers/concat-hex.js";
|
26
25
|
import type { Hex } from "../../utils/encoding/hex.js";
|
27
26
|
import { parseTypedData } from "../../utils/signatures/helpers/parseTypedData.js";
|
28
27
|
import type {
|
@@ -45,7 +44,12 @@ import {
|
|
45
44
|
prepareBatchExecute,
|
46
45
|
prepareExecute,
|
47
46
|
} from "./lib/calls.js";
|
48
|
-
import {
|
47
|
+
import {
|
48
|
+
ENTRYPOINT_ADDRESS_v0_6,
|
49
|
+
ENTRYPOINT_ADDRESS_v0_7,
|
50
|
+
getDefaultAccountFactory,
|
51
|
+
getEntryPointVersion,
|
52
|
+
} from "./lib/constants.js";
|
49
53
|
import {
|
50
54
|
clearAccountDeploying,
|
51
55
|
createUnsignedUserOp,
|
@@ -58,6 +62,7 @@ import type {
|
|
58
62
|
SmartAccountOptions,
|
59
63
|
SmartWalletConnectionOptions,
|
60
64
|
SmartWalletOptions,
|
65
|
+
TokenPaymasterConfig,
|
61
66
|
UserOperationV06,
|
62
67
|
UserOperationV07,
|
63
68
|
} from "./types.js";
|
@@ -116,6 +121,17 @@ export async function connectSmartWallet(
|
|
116
121
|
}
|
117
122
|
}
|
118
123
|
|
124
|
+
if (
|
125
|
+
options.overrides?.tokenPaymaster &&
|
126
|
+
!options.overrides?.entrypointAddress
|
127
|
+
) {
|
128
|
+
// if token paymaster is set, but no entrypoint address, set the entrypoint address to v0.7
|
129
|
+
options.overrides = {
|
130
|
+
...options.overrides,
|
131
|
+
entrypointAddress: ENTRYPOINT_ADDRESS_v0_7,
|
132
|
+
};
|
133
|
+
}
|
134
|
+
|
119
135
|
const factoryAddress =
|
120
136
|
options.factoryAddress ??
|
121
137
|
getDefaultAccountFactory(options.overrides?.entrypointAddress);
|
@@ -196,12 +212,24 @@ export async function disconnectSmartWallet(
|
|
196
212
|
async function createSmartAccount(
|
197
213
|
options: SmartAccountOptions,
|
198
214
|
): Promise<Account> {
|
215
|
+
const erc20Paymaster = options.overrides?.tokenPaymaster;
|
216
|
+
if (erc20Paymaster) {
|
217
|
+
if (
|
218
|
+
getEntryPointVersion(
|
219
|
+
options.overrides?.entrypointAddress || ENTRYPOINT_ADDRESS_v0_6,
|
220
|
+
) !== "v0.7"
|
221
|
+
) {
|
222
|
+
throw new Error(
|
223
|
+
"Token paymaster is only supported for entrypoint version v0.7",
|
224
|
+
);
|
225
|
+
}
|
226
|
+
}
|
227
|
+
|
199
228
|
const { accountContract } = options;
|
200
229
|
const account: Account = {
|
201
230
|
address: getAddress(accountContract.address),
|
202
231
|
async sendTransaction(transaction: SendTransactionOption) {
|
203
232
|
// if erc20 paymaster - check allowance and approve if needed
|
204
|
-
const erc20Paymaster = options.overrides?.erc20Paymaster;
|
205
233
|
let paymasterOverride:
|
206
234
|
| undefined
|
207
235
|
| ((
|
@@ -215,12 +243,7 @@ async function createSmartAccount(
|
|
215
243
|
});
|
216
244
|
const paymasterCallback = async (): Promise<PaymasterResult> => {
|
217
245
|
return {
|
218
|
-
|
219
|
-
erc20Paymaster.address as Hex,
|
220
|
-
erc20Paymaster?.token as Hex,
|
221
|
-
]),
|
222
|
-
// for 0.7 compatibility
|
223
|
-
paymaster: erc20Paymaster.address as Hex,
|
246
|
+
paymaster: erc20Paymaster.paymasterAddress as Hex,
|
224
247
|
paymasterData: "0x",
|
225
248
|
};
|
226
249
|
};
|
@@ -436,13 +459,10 @@ async function createSmartAccount(
|
|
436
459
|
async function approveERC20(args: {
|
437
460
|
accountContract: ThirdwebContract;
|
438
461
|
options: SmartAccountOptions;
|
439
|
-
erc20Paymaster:
|
440
|
-
address: string;
|
441
|
-
token: string;
|
442
|
-
};
|
462
|
+
erc20Paymaster: TokenPaymasterConfig;
|
443
463
|
}) {
|
444
464
|
const { accountContract, erc20Paymaster, options } = args;
|
445
|
-
const tokenAddress = erc20Paymaster.
|
465
|
+
const tokenAddress = erc20Paymaster.tokenAddress;
|
446
466
|
const tokenContract = getContract({
|
447
467
|
address: tokenAddress,
|
448
468
|
chain: accountContract.chain,
|
@@ -451,7 +471,7 @@ async function approveERC20(args: {
|
|
451
471
|
const accountAllowance = await allowance({
|
452
472
|
contract: tokenContract,
|
453
473
|
owner: accountContract.address,
|
454
|
-
spender: erc20Paymaster.
|
474
|
+
spender: erc20Paymaster.paymasterAddress,
|
455
475
|
});
|
456
476
|
|
457
477
|
if (accountAllowance > 0n) {
|
@@ -460,7 +480,7 @@ async function approveERC20(args: {
|
|
460
480
|
|
461
481
|
const approveTx = approve({
|
462
482
|
contract: tokenContract,
|
463
|
-
spender: erc20Paymaster.
|
483
|
+
spender: erc20Paymaster.paymasterAddress,
|
464
484
|
amountWei: maxUint96 - 1n,
|
465
485
|
});
|
466
486
|
const transaction = await toSerializableTransaction({
|
@@ -478,7 +498,7 @@ async function approveERC20(args: {
|
|
478
498
|
...options,
|
479
499
|
overrides: {
|
480
500
|
...options.overrides,
|
481
|
-
|
501
|
+
tokenPaymaster: undefined,
|
482
502
|
},
|
483
503
|
},
|
484
504
|
});
|
@@ -67,16 +67,26 @@ export async function bundleUserOp(args: {
|
|
67
67
|
* ```
|
68
68
|
* @walletUtils
|
69
69
|
*/
|
70
|
-
export async function estimateUserOpGas(
|
71
|
-
|
72
|
-
|
73
|
-
|
70
|
+
export async function estimateUserOpGas(
|
71
|
+
args: {
|
72
|
+
userOp: UserOperationV06 | UserOperationV07;
|
73
|
+
options: BundlerOptions;
|
74
|
+
},
|
75
|
+
stateOverrides?: {
|
76
|
+
[x: string]: {
|
77
|
+
stateDiff: {
|
78
|
+
[x: string]: `0x${string}`;
|
79
|
+
};
|
80
|
+
};
|
81
|
+
},
|
82
|
+
): Promise<EstimationResult> {
|
74
83
|
const res = await sendBundlerRequest({
|
75
84
|
...args,
|
76
85
|
operation: "eth_estimateUserOperationGas",
|
77
86
|
params: [
|
78
87
|
hexlifyUserOp(args.userOp),
|
79
88
|
args.options.entrypointAddress ?? ENTRYPOINT_ADDRESS_v0_6,
|
89
|
+
stateOverrides,
|
80
90
|
],
|
81
91
|
});
|
82
92
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import type { Chain } from "../../../chains/types.js";
|
2
2
|
import { getAddress } from "../../../utils/address.js";
|
3
3
|
import { getThirdwebDomains } from "../../../utils/domains.js";
|
4
|
+
import type { TokenPaymasterConfig } from "../types.js";
|
4
5
|
|
5
6
|
export const DUMMY_SIGNATURE =
|
6
7
|
"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c";
|
@@ -17,6 +18,28 @@ export const ENTRYPOINT_ADDRESS_v0_7 =
|
|
17
18
|
|
18
19
|
export const MANAGED_ACCOUNT_GAS_BUFFER = 50000n;
|
19
20
|
|
21
|
+
type PAYMASTERS = "BASE_USDC" | "CELO_CUSD" | "LISK_LSK";
|
22
|
+
export const TokenPaymaster: Record<PAYMASTERS, TokenPaymasterConfig> = {
|
23
|
+
BASE_USDC: {
|
24
|
+
chainId: 8453,
|
25
|
+
paymasterAddress: "0x2222f2738BE6bB7aA0Bfe4AEeAf2908172CF5539",
|
26
|
+
tokenAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
27
|
+
balanceStorageSlot: 9n,
|
28
|
+
},
|
29
|
+
CELO_CUSD: {
|
30
|
+
chainId: 42220,
|
31
|
+
paymasterAddress: "0x3feA3c5744D715ff46e91C4e5C9a94426DfF2aF9",
|
32
|
+
tokenAddress: "0x765DE816845861e75A25fCA122bb6898B8B1282a",
|
33
|
+
balanceStorageSlot: 9n,
|
34
|
+
},
|
35
|
+
LISK_LSK: {
|
36
|
+
chainId: 1135,
|
37
|
+
paymasterAddress: "0x9eb8cf7fBa5ed9EeDCC97a0d52254cc0e9B1AC25",
|
38
|
+
tokenAddress: "0xac485391EB2d7D88253a7F1eF18C37f4242D1A24",
|
39
|
+
balanceStorageSlot: 9n,
|
40
|
+
},
|
41
|
+
};
|
42
|
+
|
20
43
|
/*
|
21
44
|
* @internal
|
22
45
|
*/
|
@@ -1,4 +1,5 @@
|
|
1
|
-
import {
|
1
|
+
import { maxUint96 } from "ox/Solidity";
|
2
|
+
import { concat, keccak256, toHex } from "viem";
|
2
3
|
import type { Chain } from "../../../chains/types.js";
|
3
4
|
import type { ThirdwebClient } from "../../../client/client.js";
|
4
5
|
import {
|
@@ -13,6 +14,7 @@ import { encode } from "../../../transaction/actions/encode.js";
|
|
13
14
|
import { toSerializableTransaction } from "../../../transaction/actions/to-serializable-transaction.js";
|
14
15
|
import type { PreparedTransaction } from "../../../transaction/prepare-transaction.js";
|
15
16
|
import type { TransactionReceipt } from "../../../transaction/types.js";
|
17
|
+
import { encodeAbiParameters } from "../../../utils/abi/encodeAbiParameters.js";
|
16
18
|
import { isContractDeployed } from "../../../utils/bytecode/is-contract-deployed.js";
|
17
19
|
import type { Hex } from "../../../utils/encoding/hex.js";
|
18
20
|
import { hexToBytes } from "../../../utils/encoding/to-bytes.js";
|
@@ -361,17 +363,38 @@ async function populateUserOp_v0_7(args: {
|
|
361
363
|
paymasterResult.paymasterVerificationGasLimit;
|
362
364
|
} else {
|
363
365
|
// otherwise fallback to bundler for gas limits
|
364
|
-
const
|
365
|
-
|
366
|
-
|
367
|
-
|
366
|
+
const stateOverrides = overrides?.tokenPaymaster
|
367
|
+
? {
|
368
|
+
[overrides.tokenPaymaster.tokenAddress]: {
|
369
|
+
stateDiff: {
|
370
|
+
[keccak256(
|
371
|
+
encodeAbiParameters(
|
372
|
+
[{ type: "address" }, { type: "uint256" }],
|
373
|
+
[
|
374
|
+
accountContract.address,
|
375
|
+
overrides.tokenPaymaster.balanceStorageSlot,
|
376
|
+
],
|
377
|
+
),
|
378
|
+
)]: toHex(maxUint96, { size: 32 }),
|
379
|
+
},
|
380
|
+
},
|
381
|
+
}
|
382
|
+
: undefined;
|
383
|
+
const estimates = await estimateUserOpGas(
|
384
|
+
{
|
385
|
+
userOp: partialOp,
|
386
|
+
options: bundlerOptions,
|
387
|
+
},
|
388
|
+
stateOverrides,
|
389
|
+
);
|
368
390
|
partialOp.callGasLimit = estimates.callGasLimit;
|
369
391
|
partialOp.verificationGasLimit = estimates.verificationGasLimit;
|
370
392
|
partialOp.preVerificationGas = estimates.preVerificationGas;
|
371
|
-
partialOp.paymasterPostOpGasLimit =
|
372
|
-
|
393
|
+
partialOp.paymasterPostOpGasLimit = overrides?.tokenPaymaster
|
394
|
+
? 500000n // TODO: estimate this better, needed if there's an extra swap needed in the paymaster
|
395
|
+
: estimates.paymasterPostOpGasLimit || 0n;
|
373
396
|
partialOp.paymasterVerificationGasLimit =
|
374
|
-
|
397
|
+
estimates.paymasterVerificationGasLimit || 0n;
|
375
398
|
// need paymaster to re-sign after estimates
|
376
399
|
const paymasterResult2 = (await getPaymasterAndData({
|
377
400
|
userOp: partialOp,
|
@@ -0,0 +1,117 @@
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
2
|
+
import { TEST_CLIENT } from "../../../test/src/test-clients.js";
|
3
|
+
import { base } from "../../chains/chain-definitions/base.js";
|
4
|
+
import { celo } from "../../chains/chain-definitions/celo.js";
|
5
|
+
import { defineChain } from "../../chains/utils.js";
|
6
|
+
import { sendTransaction } from "../../transaction/actions/send-transaction.js";
|
7
|
+
import { prepareTransaction } from "../../transaction/prepare-transaction.js";
|
8
|
+
import { privateKeyToAccount } from "../private-key.js";
|
9
|
+
import { TokenPaymaster } from "./lib/constants.js";
|
10
|
+
import { smartWallet } from "./smart-wallet.js";
|
11
|
+
|
12
|
+
const client = TEST_CLIENT;
|
13
|
+
|
14
|
+
describe.runIf(process.env.TW_SECRET_KEY).skip.sequential(
|
15
|
+
"SmartWallet token paymaster tests",
|
16
|
+
{
|
17
|
+
retry: 0,
|
18
|
+
timeout: 240_000,
|
19
|
+
},
|
20
|
+
() => {
|
21
|
+
it.skip("should send a transaction with base usdc", async () => {
|
22
|
+
const chain = base;
|
23
|
+
const tokenPaymaster = TokenPaymaster.BASE_USDC;
|
24
|
+
const personalAccount = privateKeyToAccount({
|
25
|
+
client,
|
26
|
+
privateKey:
|
27
|
+
"edf401e8ddbb743f3353b055081cb220ce4c5c04e08da162d86e0dba7c6f0f01", // 0xa470E7c88611364f55B2d7912613e10AF2eA918D
|
28
|
+
});
|
29
|
+
const wallet = smartWallet({
|
30
|
+
chain,
|
31
|
+
gasless: true,
|
32
|
+
overrides: {
|
33
|
+
tokenPaymaster,
|
34
|
+
},
|
35
|
+
});
|
36
|
+
const smartAccount = await wallet.connect({
|
37
|
+
client: TEST_CLIENT,
|
38
|
+
personalAccount,
|
39
|
+
});
|
40
|
+
const tx = prepareTransaction({
|
41
|
+
client,
|
42
|
+
chain,
|
43
|
+
to: smartAccount.address,
|
44
|
+
value: 0n,
|
45
|
+
});
|
46
|
+
const receipt = await sendTransaction({
|
47
|
+
transaction: tx,
|
48
|
+
account: smartAccount,
|
49
|
+
});
|
50
|
+
expect(receipt.transactionHash).toBeDefined();
|
51
|
+
});
|
52
|
+
|
53
|
+
it.skip("should send a transaction with base celo", async () => {
|
54
|
+
const chain = celo;
|
55
|
+
const tokenPaymaster = TokenPaymaster.CELO_CUSD;
|
56
|
+
const personalAccount = privateKeyToAccount({
|
57
|
+
client,
|
58
|
+
privateKey:
|
59
|
+
"edf401e8ddbb743f3353b055081cb220ce4c5c04e08da162d86e0dba7c6f0f01", // 0xa470E7c88611364f55B2d7912613e10AF2eA918D
|
60
|
+
});
|
61
|
+
const wallet = smartWallet({
|
62
|
+
chain,
|
63
|
+
gasless: true,
|
64
|
+
overrides: {
|
65
|
+
tokenPaymaster,
|
66
|
+
},
|
67
|
+
});
|
68
|
+
const smartAccount = await wallet.connect({
|
69
|
+
client: TEST_CLIENT,
|
70
|
+
personalAccount,
|
71
|
+
});
|
72
|
+
const tx = prepareTransaction({
|
73
|
+
client,
|
74
|
+
chain,
|
75
|
+
to: smartAccount.address,
|
76
|
+
value: 0n,
|
77
|
+
});
|
78
|
+
const receipt = await sendTransaction({
|
79
|
+
transaction: tx,
|
80
|
+
account: smartAccount,
|
81
|
+
});
|
82
|
+
expect(receipt.transactionHash).toBeDefined();
|
83
|
+
});
|
84
|
+
|
85
|
+
it("should send a transaction with base lisk", async () => {
|
86
|
+
const chain = defineChain(1135);
|
87
|
+
const tokenPaymaster = TokenPaymaster.LISK_LSK;
|
88
|
+
const personalAccount = privateKeyToAccount({
|
89
|
+
client,
|
90
|
+
privateKey:
|
91
|
+
"edf401e8ddbb743f3353b055081cb220ce4c5c04e08da162d86e0dba7c6f0f01", // 0xa470E7c88611364f55B2d7912613e10AF2eA918D
|
92
|
+
});
|
93
|
+
const wallet = smartWallet({
|
94
|
+
chain,
|
95
|
+
gasless: true,
|
96
|
+
overrides: {
|
97
|
+
tokenPaymaster,
|
98
|
+
},
|
99
|
+
});
|
100
|
+
const smartAccount = await wallet.connect({
|
101
|
+
client: TEST_CLIENT,
|
102
|
+
personalAccount,
|
103
|
+
});
|
104
|
+
const tx = prepareTransaction({
|
105
|
+
client,
|
106
|
+
chain,
|
107
|
+
to: smartAccount.address,
|
108
|
+
value: 0n,
|
109
|
+
});
|
110
|
+
const receipt = await sendTransaction({
|
111
|
+
transaction: tx,
|
112
|
+
account: smartAccount,
|
113
|
+
});
|
114
|
+
expect(receipt.transactionHash).toBeDefined();
|
115
|
+
});
|
116
|
+
},
|
117
|
+
);
|
@@ -118,7 +118,7 @@ import { getDefaultAccountFactory } from "./lib/constants.js";
|
|
118
118
|
* accountAddress: "0x...", // override account address
|
119
119
|
* accountSalt: "0x...", // override account salt
|
120
120
|
* entrypointAddress: "0x...", // override entrypoint address
|
121
|
-
*
|
121
|
+
* tokenPaymaster: TokenPaymaster.BASE_USDC, // enable erc20 paymaster
|
122
122
|
* bundlerUrl: "https://...", // override bundler url
|
123
123
|
* paymaster: (userOp) => { ... }, // override paymaster
|
124
124
|
* ...
|
@@ -8,6 +8,13 @@ import type { Hex } from "../../utils/encoding/hex.js";
|
|
8
8
|
import type { Prettify } from "../../utils/type-utils.js";
|
9
9
|
import type { Account, SendTransactionOption } from "../interfaces/wallet.js";
|
10
10
|
|
11
|
+
export type TokenPaymasterConfig = {
|
12
|
+
chainId: number;
|
13
|
+
paymasterAddress: string;
|
14
|
+
tokenAddress: string;
|
15
|
+
balanceStorageSlot: bigint;
|
16
|
+
};
|
17
|
+
|
11
18
|
export type SmartWalletOptions = Prettify<
|
12
19
|
{
|
13
20
|
chain: Chain; // TODO consider making default chain optional
|
@@ -17,10 +24,7 @@ export type SmartWalletOptions = Prettify<
|
|
17
24
|
accountAddress?: string;
|
18
25
|
accountSalt?: string;
|
19
26
|
entrypointAddress?: string;
|
20
|
-
|
21
|
-
address: string;
|
22
|
-
token: string;
|
23
|
-
};
|
27
|
+
tokenPaymaster?: TokenPaymasterConfig;
|
24
28
|
paymaster?: (
|
25
29
|
userOp: UserOperationV06 | UserOperationV07,
|
26
30
|
) => Promise<PaymasterResult>;
|