From 0adba6bde9010cbd3eb56bf43dd0db444f11ca8d Mon Sep 17 00:00:00 2001 From: Sarah Schwartz <58856580+sarahschwartz@users.noreply.github.com> Date: Thu, 19 Sep 2024 14:25:39 -0600 Subject: [PATCH] chore: use SmartAccount for registration --- code/webauthn/frontend/utils/tx.ts | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/code/webauthn/frontend/utils/tx.ts b/code/webauthn/frontend/utils/tx.ts index 7bfde22f..806c529b 100644 --- a/code/webauthn/frontend/utils/tx.ts +++ b/code/webauthn/frontend/utils/tx.ts @@ -1,5 +1,5 @@ import { DEFAULT_GAS_PER_PUBDATA_LIMIT, getPaymasterParams } from 'zksync-ethers/build/utils'; -import { EIP712Signer, type Wallet, type Provider, utils, type types } from 'zksync-ethers'; +import { type Wallet, type Provider, type types, SmartAccount } from 'zksync-ethers'; import { ethers } from 'ethers'; import accountAbiJSON from '../../contracts/artifacts-zk/contracts/Account.sol/Account.json'; @@ -43,20 +43,8 @@ export async function registerKeyInAccount(pubKey: string, account: string, prov const data = contract.interface.encodeFunctionData('updateR1Owner', [pubKey]); const transferAmount = '0'; const registerTx = await getTransaction(account, account, transferAmount, data, provider); - const signedTxHash = EIP712Signer.getSignedDigest(registerTx); - const signingKey: ethers.utils.SigningKey = new ethers.utils.SigningKey(wallet.privateKey); - const walletSignature = signingKey.signDigest(signedTxHash); - const sig = ethers.utils.joinSignature(walletSignature); - const signature = ethers.utils.concat([sig]); - - registerTx.customData = { - ...registerTx.customData, - customSignature: signature, - }; - - const finalTx = utils.serialize(registerTx); - const sentTx = await provider.sendTransaction(finalTx); - await sentTx.wait(); + const smartAccount = new SmartAccount({ address: account, secret: wallet.privateKey }, provider); + await smartAccount.sendTransaction(registerTx); } catch (error) { console.error('Error:', error); }