mirror of
https://github.com/getwax/eth-global-lisbon-hackathon.git
synced 2026-01-09 15:57:55 -05:00
Sync FE with safe updates
This commit is contained in:
@@ -7,7 +7,7 @@ import { useEffect, useState } from 'react';
|
||||
import { wrapProvider } from './account/wrapProvider';
|
||||
import { ERC4337EthersProvider } from '@account-abstraction/sdk';
|
||||
import makeId from './utils/makeId';
|
||||
import TestToken from './ERC20/TestToken.json';
|
||||
// import TestToken from './ERC20/TestToken.json';
|
||||
import { ExtendedECDSASigner } from './account/ExtendedECDSASigner';
|
||||
|
||||
// aaProvider!.smartAccountAPI.getUserOpHash()
|
||||
@@ -121,7 +121,8 @@ export default class AppContext {
|
||||
return {
|
||||
sender: this.address,
|
||||
nonce: '0x00', // TODO: nonce
|
||||
token: TestToken.address, // TODO: token
|
||||
// token: TestToken.address, // TODO: token
|
||||
token: '0x01',
|
||||
...simplePayment,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { BigNumber, BigNumberish } from 'ethers';
|
||||
import {
|
||||
GnosisSafeProxy,
|
||||
GnosisSafeProxy__factory,
|
||||
GnosisSafeAccountFactory,
|
||||
GnosisSafeAccountFactory__factory,
|
||||
SafeProxy,
|
||||
SafeProxy__factory,
|
||||
SafeAccountFactory,
|
||||
SafeAccountFactory__factory,
|
||||
EIP4337Manager,
|
||||
EIP4337Manager__factory,
|
||||
UserOperationStruct,
|
||||
@@ -23,13 +23,13 @@ import { TransactionDetailsForUserOp } from '@account-abstraction/sdk/src/Transa
|
||||
*/
|
||||
export interface AccountApiParams extends BaseApiParams {
|
||||
eip4337ManagerAddress: string;
|
||||
gnosisSafeAccountFactoryAddress: string;
|
||||
safeAccountFactoryAddress: string;
|
||||
owner: Signer;
|
||||
index?: BigNumberish;
|
||||
}
|
||||
|
||||
/**
|
||||
* An implementation of the BaseAccountAPI using the Gnosis Safe contracts.
|
||||
* An implementation of the BaseAccountAPI using the Safe contracts.
|
||||
* - contract deployer gets "entrypoint", "owner" addresses and "index" nonce
|
||||
* - owner signs requests using normal "Ethereum Signed Message" (ether's signer.signMessage())
|
||||
* - nonce method is "nonce()"
|
||||
@@ -37,7 +37,7 @@ export interface AccountApiParams extends BaseApiParams {
|
||||
*/
|
||||
export class AccountAPI extends BaseAccountAPI {
|
||||
eip4337Manager: EIP4337Manager;
|
||||
gnosisSafeAccountFactory: GnosisSafeAccountFactory;
|
||||
safeAccountFactory: SafeAccountFactory;
|
||||
owner: Signer;
|
||||
index: BigNumberish;
|
||||
|
||||
@@ -45,7 +45,7 @@ export class AccountAPI extends BaseAccountAPI {
|
||||
* our account contract.
|
||||
* should support the "execFromEntryPoint" and "nonce" methods
|
||||
*/
|
||||
accountContract?: GnosisSafeProxy;
|
||||
accountContract?: SafeProxy;
|
||||
|
||||
constructor(params: AccountApiParams) {
|
||||
super(params);
|
||||
@@ -56,15 +56,15 @@ export class AccountAPI extends BaseAccountAPI {
|
||||
params.eip4337ManagerAddress,
|
||||
this.provider,
|
||||
);
|
||||
this.gnosisSafeAccountFactory = GnosisSafeAccountFactory__factory.connect(
|
||||
params.gnosisSafeAccountFactoryAddress,
|
||||
this.safeAccountFactory = SafeAccountFactory__factory.connect(
|
||||
params.safeAccountFactoryAddress,
|
||||
this.provider,
|
||||
);
|
||||
}
|
||||
|
||||
async _getAccountContract(): Promise<GnosisSafeProxy> {
|
||||
async _getAccountContract(): Promise<SafeProxy> {
|
||||
if (this.accountContract == null) {
|
||||
this.accountContract = GnosisSafeProxy__factory.connect(
|
||||
this.accountContract = SafeProxy__factory.connect(
|
||||
await this.getAccountAddress(),
|
||||
this.provider,
|
||||
);
|
||||
@@ -78,11 +78,11 @@ export class AccountAPI extends BaseAccountAPI {
|
||||
*/
|
||||
async getAccountInitCode(): Promise<string> {
|
||||
return hexConcat([
|
||||
this.gnosisSafeAccountFactory.address,
|
||||
this.gnosisSafeAccountFactory.interface.encodeFunctionData(
|
||||
'createAccount',
|
||||
[await this.owner.getAddress(), this.index],
|
||||
),
|
||||
this.safeAccountFactory.address,
|
||||
this.safeAccountFactory.interface.encodeFunctionData('createAccount', [
|
||||
await this.owner.getAddress(),
|
||||
this.index,
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@ import { JsonRpcProvider } from '@ethersproject/providers';
|
||||
import {
|
||||
EntryPoint__factory,
|
||||
EIP4337Manager__factory,
|
||||
GnosisSafe__factory,
|
||||
GnosisSafeProxyFactory__factory,
|
||||
GnosisSafeAccountFactory__factory,
|
||||
Safe__factory,
|
||||
SafeProxyFactory__factory,
|
||||
SafeAccountFactory__factory,
|
||||
} from 'account-abstraction';
|
||||
import {
|
||||
ClientConfig,
|
||||
@@ -41,17 +41,17 @@ export async function wrapProvider(
|
||||
[entryPoint.address],
|
||||
);
|
||||
const safeSingletonAddress = await detDeployer.deterministicDeploy(
|
||||
new GnosisSafe__factory(),
|
||||
new Safe__factory(),
|
||||
0,
|
||||
[],
|
||||
);
|
||||
const proxyFactoryAddress = await detDeployer.deterministicDeploy(
|
||||
new GnosisSafeProxyFactory__factory(),
|
||||
new SafeProxyFactory__factory(),
|
||||
0,
|
||||
[],
|
||||
);
|
||||
const gnosisSafeAccountFactoryAddress = await detDeployer.deterministicDeploy(
|
||||
new GnosisSafeAccountFactory__factory(),
|
||||
const safeAccountFactoryAddress = await detDeployer.deterministicDeploy(
|
||||
new SafeAccountFactory__factory(),
|
||||
0,
|
||||
[proxyFactoryAddress, safeSingletonAddress, eip4337ManagerAddress],
|
||||
);
|
||||
@@ -61,7 +61,7 @@ export async function wrapProvider(
|
||||
entryPointAddress: entryPoint.address,
|
||||
owner: originalSigner,
|
||||
eip4337ManagerAddress,
|
||||
gnosisSafeAccountFactoryAddress,
|
||||
safeAccountFactoryAddress,
|
||||
paymasterAPI: config.paymasterAPI,
|
||||
});
|
||||
debug('config=', config);
|
||||
|
||||
Reference in New Issue
Block a user