11import { encodeAbiParameters , encodePacked , isHash , zeroAddress } from "viem"
2+ import { privateKeyToAccount } from "viem/accounts"
23import { describe , expect } from "vitest"
34import { testWithRpc } from "../../../permissionless-test/src/testWithRpc"
4- import { getCoreSmartAccounts } from "../../../permissionless-test/src/utils"
5+ import {
6+ getCoreSmartAccounts ,
7+ getPublicClient
8+ } from "../../../permissionless-test/src/utils"
59import { erc7579Actions } from "../erc7579"
610import { installModule } from "./installModule"
711
812describe . each ( getCoreSmartAccounts ( ) ) (
913 "installModule $name" ,
10- ( { getErc7579SmartAccountClient, name } ) => {
14+ ( { getErc7579SmartAccountClient, name, isEip7702Compliant } ) => {
1115 testWithRpc . skipIf ( ! getErc7579SmartAccountClient ) (
1216 "installModule" ,
1317 async ( { rpc } ) => {
1418 if ( ! getErc7579SmartAccountClient ) {
1519 throw new Error ( "getErc7579SmartAccountClient not defined" )
1620 }
1721
22+ const privateKey =
23+ "0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356"
24+
25+ const privateKeyAccount = privateKeyToAccount ( privateKey )
26+
1827 const smartClientWithoutExtend =
1928 await getErc7579SmartAccountClient ( {
2029 entryPoint : {
2130 version : "0.7"
2231 } ,
32+ privateKey,
2333 ...rpc
2434 } )
2535
36+ const publicClient = getPublicClient ( rpc . anvilRpc )
37+
2638 const smartClient = smartClientWithoutExtend . extend (
2739 erc7579Actions ( )
2840 )
@@ -47,7 +59,17 @@ describe.each(getCoreSmartAccounts())(
4759 )
4860 ]
4961 )
50- : moduleData
62+ : moduleData ,
63+ authorization : isEip7702Compliant
64+ ? await privateKeyAccount . signAuthorization ( {
65+ address : ( smartClient . account as any )
66+ . implementation ,
67+ chainId : smartClient . chain . id ,
68+ nonce : await publicClient . getTransactionCount ( {
69+ address : smartClient . account . address
70+ } )
71+ } )
72+ : undefined
5173 } )
5274
5375 expect ( isHash ( opHash ) ) . toBe ( true )
@@ -88,14 +110,22 @@ describe.each(getCoreSmartAccounts())(
88110 throw new Error ( "getErc7579SmartAccountClient not defined" )
89111 }
90112
113+ const privateKey =
114+ "0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356"
115+
116+ const privateKeyAccount = privateKeyToAccount ( privateKey )
117+
91118 const smartClientWithoutExtend =
92119 await getErc7579SmartAccountClient ( {
93120 entryPoint : {
94121 version : "0.7"
95122 } ,
123+ privateKey,
96124 ...rpc
97125 } )
98126
127+ const publicClient = getPublicClient ( rpc . anvilRpc )
128+
99129 const smartClient = smartClientWithoutExtend . extend (
100130 erc7579Actions ( )
101131 )
@@ -112,7 +142,17 @@ describe.each(getCoreSmartAccounts())(
112142 value : 0n ,
113143 data : "0x"
114144 }
115- ]
145+ ] ,
146+ authorization : isEip7702Compliant
147+ ? await privateKeyAccount . signAuthorization ( {
148+ address : ( smartClient . account as any )
149+ . implementation ,
150+ chainId : smartClient . chain . id ,
151+ nonce : await publicClient . getTransactionCount ( {
152+ address : smartClient . account . address
153+ } )
154+ } )
155+ : undefined
116156 } )
117157
118158 await smartClient . waitForUserOperationReceipt ( {
0 commit comments