11import type { Account , Address , Chain , Hex , Transport , WalletClient } from "viem" ;
2- import { encodeAbiParameters , keccak256 , parseAbiParameters , toHex } from "viem" ;
2+ import { encodeAbiParameters , encodeFunctionData , keccak256 , parseAbiParameters , toHex } from "viem" ;
33import { waitForTransactionReceipt } from "viem/actions" ;
44import { base64urlToUint8Array , getPublicKeyBytesFromPasskeySignature } from "zksync-sso-4337/utils" ;
55
@@ -190,8 +190,9 @@ export const useRecoveryGuardian = () => {
190190
191191 // Install module if not already installed
192192 if ( ! isModuleInstalled ) {
193- const installTx = await client . writeContract ( {
194- address : accountAddress ,
193+ // NOTE: installModule must be called DIRECTLY on the account (not wrapped in execute)
194+ // We use sendTransaction with the encoded installModule call as the data
195+ const installModuleData = encodeFunctionData ( {
195196 abi : [ {
196197 type : "function" ,
197198 name : "installModule" ,
@@ -207,6 +208,11 @@ export const useRecoveryGuardian = () => {
207208 args : [ 1n , contracts . guardianExecutor , "0x" ] , // 1 = MODULE_TYPE_EXECUTOR, empty initData
208209 } ) ;
209210
211+ const installTx = await client . sendTransaction ( {
212+ to : accountAddress ,
213+ data : installModuleData ,
214+ } ) ;
215+
210216 const installReceipt = await client . waitForTransactionReceipt ( { hash : installTx } ) ;
211217
212218 if ( installReceipt . status === "reverted" ) {
0 commit comments