1- import { base } from "src/chains/chain-definitions/base.js" ;
2- import { sendTransaction } from "src/transaction/actions/send-transaction.js" ;
3- import { prepareTransaction } from "src/transaction/prepare-transaction.js" ;
4- import { beforeAll , describe , expect , it } from "vitest" ;
1+ import { describe , expect , it } from "vitest" ;
52import { TEST_CLIENT } from "../../../test/src/test-clients.js" ;
6- import { setThirdwebDomains } from "../../utils/domains.js" ;
7- import type { Account } from "../interfaces/wallet.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 type { Address } from "../../utils/address.js" ;
89import { privateKeyToAccount } from "../private-key.js" ;
10+ import { getWalletBalance } from "../utils/getWalletBalance.js" ;
11+ import { TokenPaymaster } from "./lib/constants.js" ;
912import { smartWallet } from "./smart-wallet.js" ;
1013
11- let personalAccount : Account ;
12-
1314const client = TEST_CLIENT ;
1415
1516describe . runIf ( process . env . TW_SECRET_KEY ) . skip . sequential (
16- "SmartWallet policy tests" ,
17+ "SmartWallet token paymaster tests" ,
1718 {
1819 retry : 0 ,
1920 timeout : 240_000 ,
2021 } ,
2122 ( ) => {
22- beforeAll ( async ( ) => {
23- setThirdwebDomains ( {
24- rpc : "rpc.thirdweb-dev.com" ,
25- storage : "storage.thirdweb-dev.com" ,
26- bundler : "bundler.thirdweb-dev.com" ,
27- } ) ;
28- personalAccount = await privateKeyToAccount ( {
23+ it . skip ( "should send a transaction with base usdc" , async ( ) => {
24+ const chain = base ;
25+ const tokenPaymaster = TokenPaymaster . BASE_USDC ;
26+ const personalAccount = privateKeyToAccount ( {
2927 client,
3028 privateKey :
3129 "edf401e8ddbb743f3353b055081cb220ce4c5c04e08da162d86e0dba7c6f0f01" , // 0xa470E7c88611364f55B2d7912613e10AF2eA918D
3230 } ) ;
31+ const wallet = smartWallet ( {
32+ chain,
33+ gasless : true ,
34+ overrides : {
35+ tokenPaymaster,
36+ } ,
37+ } ) ;
38+ const smartAccount = await wallet . connect ( {
39+ client : TEST_CLIENT ,
40+ personalAccount,
41+ } ) ;
42+ const smartWalletAddress = smartAccount . address as Address ;
43+ console . log ( "smartWalletAddress" , smartWalletAddress ) ;
44+ console . log (
45+ "balance before" ,
46+ await getWalletBalance ( {
47+ address : smartAccount . address ,
48+ chain : chain ,
49+ client,
50+ tokenAddress : tokenPaymaster . tokenAddress ,
51+ } ) ,
52+ ) ;
53+ const tx = prepareTransaction ( {
54+ client,
55+ chain,
56+ to : smartAccount . address ,
57+ value : 0n ,
58+ } ) ;
59+ const receipt = await sendTransaction ( {
60+ transaction : tx ,
61+ account : smartAccount ,
62+ } ) ;
63+ expect ( receipt . transactionHash ) . toBeDefined ( ) ;
64+ console . log (
65+ "balance after" ,
66+ await getWalletBalance ( {
67+ address : smartAccount . address ,
68+ chain : chain ,
69+ client,
70+ tokenAddress : tokenPaymaster . tokenAddress ,
71+ } ) ,
72+ ) ;
3373 } ) ;
3474
35- it ( "can self transfer with BASE_USDC" , async ( ) => {
75+ it . skip ( "should send a transaction with base celo" , async ( ) => {
76+ const chain = celo ;
77+ const tokenPaymaster = TokenPaymaster . CELO_CUSD ;
78+ const personalAccount = privateKeyToAccount ( {
79+ client,
80+ privateKey :
81+ "edf401e8ddbb743f3353b055081cb220ce4c5c04e08da162d86e0dba7c6f0f01" , // 0xa470E7c88611364f55B2d7912613e10AF2eA918D
82+ } ) ;
3683 const wallet = smartWallet ( {
37- chain : base ,
84+ chain,
3885 gasless : true ,
3986 overrides : {
40- tokenPaymaster : "BASE_USDC" ,
87+ tokenPaymaster,
4188 } ,
4289 } ) ;
4390 const smartAccount = await wallet . connect ( {
4491 client : TEST_CLIENT ,
4592 personalAccount,
4693 } ) ;
94+ const smartWalletAddress = smartAccount . address as Address ;
95+ console . log ( "smartWalletAddress" , smartWalletAddress ) ;
96+ console . log (
97+ "balance before" ,
98+ await getWalletBalance ( {
99+ address : smartAccount . address ,
100+ chain : chain ,
101+ client,
102+ tokenAddress : tokenPaymaster . tokenAddress ,
103+ } ) ,
104+ ) ;
105+ const tx = prepareTransaction ( {
106+ client,
107+ chain,
108+ to : smartAccount . address ,
109+ value : 0n ,
110+ } ) ;
111+ const receipt = await sendTransaction ( {
112+ transaction : tx ,
113+ account : smartAccount ,
114+ } ) ;
115+ expect ( receipt . transactionHash ) . toBeDefined ( ) ;
116+ console . log (
117+ "balance after" ,
118+ await getWalletBalance ( {
119+ address : smartAccount . address ,
120+ chain : chain ,
121+ client,
122+ tokenAddress : tokenPaymaster . tokenAddress ,
123+ } ) ,
124+ ) ;
125+ } ) ;
47126
48- console . log ( "smartAccount" , smartAccount . address ) ;
49-
127+ it ( "should send a transaction with base lisk" , async ( ) => {
128+ const chain = defineChain ( 1135 ) ;
129+ const tokenPaymaster = TokenPaymaster . LISK_LSK ;
130+ const personalAccount = privateKeyToAccount ( {
131+ client,
132+ privateKey :
133+ "edf401e8ddbb743f3353b055081cb220ce4c5c04e08da162d86e0dba7c6f0f01" , // 0xa470E7c88611364f55B2d7912613e10AF2eA918D
134+ } ) ;
135+ const wallet = smartWallet ( {
136+ chain,
137+ gasless : true ,
138+ overrides : {
139+ tokenPaymaster,
140+ } ,
141+ } ) ;
142+ const smartAccount = await wallet . connect ( {
143+ client : TEST_CLIENT ,
144+ personalAccount,
145+ } ) ;
146+ const smartWalletAddress = smartAccount . address as Address ;
147+ console . log ( "smartWalletAddress" , smartWalletAddress ) ;
148+ console . log (
149+ "balance before" ,
150+ await getWalletBalance ( {
151+ address : smartAccount . address ,
152+ chain : chain ,
153+ client,
154+ tokenAddress : tokenPaymaster . tokenAddress ,
155+ } ) ,
156+ ) ;
50157 const tx = prepareTransaction ( {
51158 client,
52- chain : base ,
159+ chain,
53160 to : smartAccount . address ,
54161 value : 0n ,
55162 } ) ;
@@ -58,6 +165,15 @@ describe.runIf(process.env.TW_SECRET_KEY).skip.sequential(
58165 account : smartAccount ,
59166 } ) ;
60167 expect ( receipt . transactionHash ) . toBeDefined ( ) ;
168+ console . log (
169+ "balance after" ,
170+ await getWalletBalance ( {
171+ address : smartAccount . address ,
172+ chain : chain ,
173+ client,
174+ tokenAddress : tokenPaymaster . tokenAddress ,
175+ } ) ,
176+ ) ;
61177 } ) ;
62178 } ,
63179) ;
0 commit comments