Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Nobuhito Kurose committed Apr 15, 2023
1 parent d644b2d commit d2687b7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
3 changes: 2 additions & 1 deletion packages/site/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ const Index = () => {
};

const handleCheckAAStateClick = async () => {
console.log('handleCheckAAStateClick');
const {
address,
balance,
Expand Down Expand Up @@ -282,7 +283,7 @@ const Index = () => {
/>
),
}}
disabled={!state.isFlask}
disabled={!state.isFlask || true}
/>
)}
{shouldDisplayReconnectButton(state.installedSnap) && (
Expand Down
29 changes: 25 additions & 4 deletions packages/site/src/snapMock/aaWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const getBalance = async (address: string): Promise<string> => {
};

export const getAAState = async () => {
await changeNetwork(ChainId.mumbai);
const aaProvider = new ethers.providers.JsonRpcProvider(config.rpcUrl);

const ethProvider = new ethers.providers.Web3Provider(
Expand All @@ -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;
Expand Down Expand Up @@ -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]),
Expand Down Expand Up @@ -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;
};

Expand Down Expand Up @@ -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', [
Expand Down
6 changes: 3 additions & 3 deletions packages/site/src/utils/lit.ts
Original file line number Diff line number Diff line change
@@ -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) => {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit d2687b7

Please sign in to comment.