-
Notifications
You must be signed in to change notification settings - Fork 237
/
types.ts
173 lines (155 loc) · 4.19 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
import { ChainOrRpcUrl, SmartContract, Transaction } from "@thirdweb-dev/sdk";
import type {
BigNumber,
BigNumberish,
BytesLike,
ContractInterface,
Signer,
providers,
} from "ethers";
import type { WalletConnectReceiverConfig } from "../../../core/types/walletConnect";
import { EVMWallet } from "../../interfaces";
import { WalletOptions } from "../../wallets/base";
import { UserOperationStruct } from "@account-abstraction/contracts";
export type SmartWalletConfig = {
chain: ChainOrRpcUrl;
factoryAddress: string;
clientId?: string;
secretKey?: string;
gasless: boolean;
bundlerUrl?: string;
paymasterUrl?: string;
paymasterAPI?: PaymasterAPI;
entryPointAddress?: string;
erc20PaymasterAddress?: string;
erc20TokenAddress?: string;
} & ContractInfoInput &
WalletConnectReceiverConfig;
export type SmartWalletConnectionArgs = {
personalWallet: EVMWallet;
accountAddress?: string;
};
export type SmartWalletOptions = WalletOptions;
export interface ProviderConfig extends ContractInfo {
chain: ChainOrRpcUrl;
localSigner: Signer;
entryPointAddress: string;
clientId?: string;
secretKey?: string;
bundlerUrl: string;
factoryAddress: string;
accountAddress?: string;
paymasterAPI: PaymasterAPI;
gasless: boolean;
erc20PaymasterAddress?: string;
erc20TokenAddress?: string;
}
export type ContractInfoInput = {
factoryInfo?: FactoryContractInfo;
accountInfo?: AccountContractInfo;
};
export type ContractInfo = {
factoryInfo: FactoryContractInfoInternal;
accountInfo: AccountContractInfoInternal;
};
/**
* @internal
*/
export type AccountContractInfoInternal = {
abi?: ContractInterface;
getNonce: (account: SmartContract) => Promise<BigNumber>;
execute: (
account: SmartContract,
target: string,
value: BigNumberish,
data: string,
) => Promise<Transaction>;
};
/**
* @internal
*/
export type FactoryContractInfoInternal = {
abi?: ContractInterface;
createAccount: (
factory: SmartContract,
owner: string,
) => Promise<Transaction>;
getAccountAddress: (factory: SmartContract, owner: string) => Promise<string>;
};
export type AccountContractInfo = {
abi?: ContractInterface;
getNonce?: (account: SmartContract) => Promise<BigNumber>;
execute?: (
account: SmartContract,
target: string,
value: BigNumberish,
data: string,
) => Promise<Transaction>;
};
export type FactoryContractInfo = {
abi?: ContractInterface;
createAccount?: (
factory: SmartContract,
owner: string,
) => Promise<Transaction>;
getAccountAddress?: (
factory: SmartContract,
owner: string,
) => Promise<string>;
};
export type PaymasterResult = {
paymasterAndData: string;
preVerificationGas?: BigNumber;
verificationGasLimit?: BigNumber;
callGasLimit?: BigNumber;
};
/**
* an API to external a UserOperation with paymaster info
*/
export abstract class PaymasterAPI {
/**
* @param userOp - a partially-filled UserOperation (without signature and paymasterAndData
* note that the "preVerificationGas" is incomplete: it can't account for the
* paymasterAndData value, which will only be returned by this method..
* @returns the value to put into the PaymasterAndData, undefined to leave it empty
*/
abstract getPaymasterAndData(
userOp: Partial<UserOperationStruct>,
): Promise<PaymasterResult>;
}
export interface TransactionOptions {
gasless?: boolean;
}
export interface UserOpOptions extends TransactionOptions {
batchData?: BatchData;
}
export type BatchData = {
targets: (string | undefined)[];
data: BytesLike[];
values: BigNumberish[];
};
export interface BaseApiParams {
provider: providers.Provider;
entryPointAddress: string;
paymasterAPI: PaymasterAPI;
accountAddress?: string;
gasless: boolean;
erc20PaymasterAddress?: string;
erc20TokenAddress?: string;
}
export interface UserOpResult {
transactionHash: string;
success: boolean;
}
export type EstimateUserOpGasRawResult = {
preVerificationGas: string;
verificationGas: string;
verificationGasLimit: string;
callGasLimit: string;
};
export type EstimateUserOpGasResult = {
preVerificationGas: BigNumber;
verificationGas: BigNumber;
verificationGasLimit: BigNumber;
callGasLimit: BigNumber;
};