Skip to content
This repository was archived by the owner on Oct 20, 2024. It is now read-only.

Commit 1ae8888

Browse files
committed
improve compile time by at leat 81%
1 parent fdccf65 commit 1ae8888

18 files changed

+359
-125
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"typescript-eslint": "^7.3.1"
3333
},
3434
"dependencies": {
35+
"@arktype/attest": "^0.7.0",
3536
"abitype": "^1.0.0",
3637
"ethers": "^6.11.1",
3738
"viem": "^2.9.12"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const FACTORY_ADDRESS = "0x9406Cc6185a346906296840746125a0E44976454";

src/v06/account/common/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
export * as SimpleAccount from "./simpleAccount";
1+
export * as SimpleAccountWithEthers from "./simpleAccountWithEthers";
2+
export * as SimpleAccountWithoutHoistedViemAccount from "./simpleAccountWithoutViemAccount";
3+
export * as SimpleAccountWithHoistedViemAccount from "./simpleAccountWithViemAccount";
4+
export * as SimpleAccountWithSigner from "./simpleAccountWithSigner";

src/v06/account/common/simpleAccount.ts

Lines changed: 0 additions & 59 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { Address } from "abitype";
2+
import { JsonRpcProvider, Signer } from "ethers";
3+
import { PublicClient, WalletClient, Transport, Chain, Account } from "viem";
4+
import { RequestSignature } from "../hooks";
5+
import { RequiredAccountOpts } from "../types";
6+
import { AccountAbi, FactoryAbi } from "./abi/simpleAccount";
7+
import { FACTORY_ADDRESS } from "./factoryAddress";
8+
9+
export function baseWithEthers(
10+
ethClient: PublicClient | JsonRpcProvider,
11+
eoa: WalletClient<Transport, Chain | undefined, Account> | Signer,
12+
): RequiredAccountOpts<typeof AccountAbi, typeof FactoryAbi> {
13+
return {
14+
accountAbi: AccountAbi,
15+
factoryAbi: FactoryAbi,
16+
factoryAddress: FACTORY_ADDRESS,
17+
ethClient,
18+
async setFactoryData(salt, encoder) {
19+
if ("getAddresses" in eoa) {
20+
return encoder("createAccount", [(await eoa.getAddresses())[0], salt]);
21+
} else {
22+
return encoder("createAccount", [
23+
(await eoa.getAddress()) as Address,
24+
salt,
25+
]);
26+
}
27+
},
28+
requestSignature:
29+
"getAddresses" in eoa
30+
? RequestSignature.withViemWalletClient(
31+
eoa as WalletClient<Transport, Chain | undefined, Account>,
32+
)
33+
: RequestSignature.withEthersSigner(eoa),
34+
};
35+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { Address } from "abitype";
2+
import { JsonRpcProvider, Signer } from "ethers";
3+
import { PublicClient, Account } from "viem";
4+
import { RequestSignature } from "../hooks";
5+
import { RequiredAccountOpts } from "../types";
6+
import { AccountAbi, FactoryAbi } from "./abi/simpleAccount";
7+
import { FACTORY_ADDRESS } from "./factoryAddress";
8+
9+
export function base(
10+
ethClient: PublicClient | JsonRpcProvider,
11+
eoa: Signer,
12+
account?: Account,
13+
): RequiredAccountOpts<typeof AccountAbi, typeof FactoryAbi> {
14+
return {
15+
accountAbi: AccountAbi,
16+
factoryAbi: FactoryAbi,
17+
factoryAddress: FACTORY_ADDRESS,
18+
ethClient,
19+
async setFactoryData(salt, encoder) {
20+
if (account !== undefined) {
21+
return encoder("createAccount", [account.address, salt]);
22+
} else {
23+
return encoder("createAccount", [
24+
(await eoa.getAddress()) as Address,
25+
salt,
26+
]);
27+
}
28+
},
29+
requestSignature: RequestSignature.withEthersSigner(eoa),
30+
};
31+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { JsonRpcProvider } from "ethers";
2+
import { PublicClient, WalletClient, Transport, Chain, Account } from "viem";
3+
import { RequestSignature } from "../hooks";
4+
import { RequiredAccountOpts } from "../types";
5+
import { AccountAbi, FactoryAbi } from "./abi/simpleAccount";
6+
import { FACTORY_ADDRESS } from "./factoryAddress";
7+
8+
export function baseWithViemHoistedAccount(
9+
ethClient: PublicClient | JsonRpcProvider,
10+
eoa: WalletClient<Transport, Chain | undefined, Account>,
11+
account: Account,
12+
): RequiredAccountOpts<typeof AccountAbi, typeof FactoryAbi> {
13+
return {
14+
accountAbi: AccountAbi,
15+
factoryAbi: FactoryAbi,
16+
factoryAddress: FACTORY_ADDRESS,
17+
ethClient,
18+
async setFactoryData(salt, encoder) {
19+
if (account !== undefined) {
20+
return encoder("createAccount", [account.address, salt]);
21+
} else {
22+
return encoder("createAccount", [(await eoa.getAddresses())[0], salt]);
23+
}
24+
},
25+
requestSignature:
26+
"getAddresses" in eoa
27+
? RequestSignature.withViemWalletClient(
28+
eoa as WalletClient<Transport, Chain | undefined, Account>,
29+
)
30+
: RequestSignature.withEthersSigner(eoa),
31+
};
32+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { JsonRpcProvider } from "ethers";
2+
import { PublicClient, WalletClient, Transport, Chain, Account } from "viem";
3+
import { RequestSignature } from "../hooks";
4+
import { RequiredAccountOpts } from "../types";
5+
import { AccountAbi, FactoryAbi } from "./abi/simpleAccount";
6+
import { FACTORY_ADDRESS } from "./factoryAddress";
7+
8+
export function baseWithoutHoistedViemAccount(
9+
ethClient: PublicClient | JsonRpcProvider,
10+
eoa: WalletClient<Transport, Chain | undefined, undefined>,
11+
account: Account,
12+
): RequiredAccountOpts<typeof AccountAbi, typeof FactoryAbi> {
13+
return {
14+
accountAbi: AccountAbi,
15+
factoryAbi: FactoryAbi,
16+
factoryAddress: FACTORY_ADDRESS,
17+
ethClient,
18+
async setFactoryData(salt, encoder) {
19+
if (account !== undefined) {
20+
return encoder("createAccount", [account.address, salt]);
21+
} else {
22+
return encoder("createAccount", [(await eoa.getAddresses())[0], salt]);
23+
}
24+
},
25+
requestSignature:
26+
"getAddresses" in eoa
27+
? RequestSignature.withoutViemWalletClient(
28+
eoa as WalletClient<Transport, Chain | undefined, undefined>,
29+
account,
30+
)
31+
: RequestSignature.withEthersSigner(eoa),
32+
};
33+
}

src/v06/account/hooks/requestGasPrice/common.ts

Lines changed: 0 additions & 42 deletions
This file was deleted.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
export * from "./common";
1+
export * from "./jsonProvider";
2+
export * from "./publicClient";

0 commit comments

Comments
 (0)