From d2687b7d50d29068d789d527b4babbfc44dc5c53 Mon Sep 17 00:00:00 2001 From: Nobuhito Kurose Date: Sat, 15 Apr 2023 21:00:14 +0900 Subject: [PATCH] fix --- packages/site/src/pages/index.tsx | 3 ++- packages/site/src/snapMock/aaWallet.ts | 29 ++++++++++++++++++++++---- packages/site/src/utils/lit.ts | 6 +++--- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/packages/site/src/pages/index.tsx b/packages/site/src/pages/index.tsx index caeca6a..46fe266 100644 --- a/packages/site/src/pages/index.tsx +++ b/packages/site/src/pages/index.tsx @@ -107,6 +107,7 @@ const Index = () => { }; const handleCheckAAStateClick = async () => { + console.log('handleCheckAAStateClick'); const { address, balance, @@ -282,7 +283,7 @@ const Index = () => { /> ), }} - disabled={!state.isFlask} + disabled={!state.isFlask || true} /> )} {shouldDisplayReconnectButton(state.installedSnap) && ( diff --git a/packages/site/src/snapMock/aaWallet.ts b/packages/site/src/snapMock/aaWallet.ts index 006cd6d..0403112 100644 --- a/packages/site/src/snapMock/aaWallet.ts +++ b/packages/site/src/snapMock/aaWallet.ts @@ -47,6 +47,7 @@ export const getBalance = async (address: string): Promise => { }; export const getAAState = async () => { + await changeNetwork(ChainId.mumbai); const aaProvider = new ethers.providers.JsonRpcProvider(config.rpcUrl); const ethProvider = new ethers.providers.Web3Provider( @@ -65,7 +66,7 @@ export const getAAState = async () => { const code = await ethProvider.getCode(address); if (code === '0x') { - return { address, balance, secondOwner: null, deployed: false }; + return { address, balance, deployed: false }; } const myContract = new Contract(address, WalletAccount.abi, aaProvider); const secondOwner = (await myContract.secondOwner()) as string; @@ -107,11 +108,19 @@ export const set2Fa = async (address: string) => { const singedUserOp = await accountAPI.createSignedUserOp({ target: myAddress, - data: myContract.interface.encodeFunctionData('setSecondOwner', [address]), + value: 0, + data: '0x', maxPriorityFeePerGas: 0x2540be400, // 15gwei maxFeePerGas: 0x6fc23ac00, // 30gewi }); + // const singedUserOp = await accountAPI.createSignedUserOp({ + // target: myAddress, + // data: myContract.interface.encodeFunctionData('setSecondOwner', [address]), + // maxPriorityFeePerGas: 0x2540be400, // 15gwei + // maxFeePerGas: 0x6fc23ac00, // 30gewi + // }); + // const op = await accountAPI.createUnsignedUserOp({ // target: myAddress, // data: myContract.interface.encodeFunctionData('setSecondOwner', [address]), @@ -142,9 +151,21 @@ export const set2Fa = async (address: string) => { console.log(`UserOpHash: ${uoHash}`); console.log('Waiting for transaction...'); - const txHash = await accountAPI.getUserOpReceipt(uoHash); + const txHash = await accountAPI.getUserOpReceipt(uoHash, 10000); console.log(`Transaction hash: ${txHash}`); + const singedUserOp2 = await accountAPI.createSignedUserOp({ + target: myAddress, + data: myContract.interface.encodeFunctionData('setSecondOwner', [address]), + maxPriorityFeePerGas: 0x2540be400, // 15gwei + maxFeePerGas: 0x6fc23ac00, // 30gewi + }); + const uoHash2 = await client.sendUserOpToBundler(singedUserOp2); + console.log(`UserOpHash: ${uoHash}`); + + console.log('Waiting for transaction...'); + const txHash2 = await accountAPI.getUserOpReceipt(uoHash2); + console.log(`Transaction hash: ${txHash2}`); return txHash; }; @@ -264,7 +285,7 @@ export const setupSocialRecovery = async ({ const myAddress = await accountAPI.getAccountAddress(); const myContract = new Contract(myAddress, WalletAccount.abi, aaProvider); - // TODO: + // TODO: 2FA const op = await accountAPI.createSignedUserOp({ target: myAddress, data: myContract.interface.encodeFunctionData('setupSocialRecovery', [ diff --git a/packages/site/src/utils/lit.ts b/packages/site/src/utils/lit.ts index 2e03c8e..7b32865 100644 --- a/packages/site/src/utils/lit.ts +++ b/packages/site/src/utils/lit.ts @@ -1,9 +1,9 @@ -import * as LitJsSdk from '@lit-protocol/lit-node-client'; -// const LitJsSdk = {} as any; import { BaseProvider } from '@metamask/providers'; import { serialize, UnsignedTransaction } from '@ethersproject/transactions'; import { ethers } from 'ethers'; +import * as LitJsSdk from '@lit-protocol/lit-node-client'; import { ChainId, changeNetwork } from './metamask'; +// const LitJsSdk = {} as any; // TODO: enable multiple accounts export const set2FaPkpPublicKey = async (pkpPublicKey: string) => { @@ -154,7 +154,7 @@ export const executeSocialRecovery = async ({ try { const tx = await provider.sendTransaction(serializedTx); const receipt = await tx.wait(); - console.log('receipt', receipt); + // console.log('receipt', receipt); return receipt; } catch (e) { console.log('error', e);