viem 0.2.0-main.20230401T004104 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/accounts/package.json +4 -0
  2. package/dist/abi.d.ts +3 -3
  3. package/dist/abi.js +2 -2
  4. package/dist/abi.mjs +1 -1
  5. package/dist/accounts/index.d.ts +81 -0
  6. package/dist/accounts/index.js +142 -0
  7. package/dist/accounts/index.js.map +1 -0
  8. package/dist/accounts/index.mjs +142 -0
  9. package/dist/accounts/index.mjs.map +1 -0
  10. package/dist/{chain-1b53ef88.d.ts → chain-5507c6f0.d.ts} +212 -148
  11. package/dist/{chain-ec8c485d.d.ts → chain-fe47467d.d.ts} +1 -1
  12. package/dist/chains.d.ts +867 -99
  13. package/dist/chains.js +115 -63
  14. package/dist/chains.js.map +1 -1
  15. package/dist/chains.mjs +58 -6
  16. package/dist/chains.mjs.map +1 -1
  17. package/dist/chunk-63WKWOMO.js +31 -0
  18. package/dist/chunk-63WKWOMO.js.map +1 -0
  19. package/dist/{chunk-U5Z7JOWV.mjs → chunk-FSIBCQFR.mjs} +1886 -261
  20. package/dist/chunk-FSIBCQFR.mjs.map +1 -0
  21. package/dist/chunk-KON3DHPC.mjs +31 -0
  22. package/dist/chunk-KON3DHPC.mjs.map +1 -0
  23. package/dist/{chunk-HBDMIBEO.js → chunk-YDNKDSST.js} +1942 -317
  24. package/dist/chunk-YDNKDSST.js.map +1 -0
  25. package/dist/contract.d.ts +9 -7
  26. package/dist/contract.js +2 -2
  27. package/dist/contract.mjs +1 -1
  28. package/dist/{createTransport-e3eba9f7.d.ts → createTransport-21a0d2b3.d.ts} +24 -10
  29. package/dist/{eip1193-4f4e240c.d.ts → eip1193-2f3a9cd2.d.ts} +1 -1
  30. package/dist/{encodeFunctionResult-1f324375.d.ts → encodeFunctionResult-c5185b98.d.ts} +15 -15
  31. package/dist/{encodePacked-d5d5264a.d.ts → encodePacked-98f67d09.d.ts} +1 -1
  32. package/dist/ens.d.ts +6 -4
  33. package/dist/ens.js +8 -3
  34. package/dist/ens.js.map +1 -1
  35. package/dist/ens.mjs +7 -2
  36. package/dist/ens.mjs.map +1 -1
  37. package/dist/ethers.d.ts +5 -6
  38. package/dist/ethers.js +7 -5
  39. package/dist/ethers.js.map +1 -1
  40. package/dist/ethers.mjs +7 -5
  41. package/dist/ethers.mjs.map +1 -1
  42. package/dist/{formatAbiItem-15e8817d.d.ts → formatAbiItem-56dff508.d.ts} +1 -1
  43. package/dist/{getAbiItem-3e809ff9.d.ts → getAbiItem-bfba73d1.d.ts} +3 -3
  44. package/dist/getEnsResolver-9e26c596.d.ts +876 -0
  45. package/dist/index.d.ts +132 -15
  46. package/dist/index.js +150 -103
  47. package/dist/index.js.map +1 -1
  48. package/dist/index.mjs +96 -49
  49. package/dist/index.mjs.map +1 -1
  50. package/dist/{parseGwei-361e8a12.d.ts → parseGwei-d2147f8b.d.ts} +95 -15
  51. package/dist/public.d.ts +6 -4
  52. package/dist/public.js +2 -2
  53. package/dist/public.mjs +1 -1
  54. package/dist/publicKeyToAddress-623eb398.d.ts +16 -0
  55. package/dist/test-b67569fe.d.ts +198 -0
  56. package/dist/test.d.ts +11 -11
  57. package/dist/test.js +2 -2
  58. package/dist/test.mjs +1 -1
  59. package/dist/typedData-46b4d81f.d.ts +93 -0
  60. package/dist/utils/index.d.ts +22 -30
  61. package/dist/utils/index.js +28 -2
  62. package/dist/utils/index.mjs +31 -5
  63. package/dist/wallet.d.ts +6 -4
  64. package/dist/wallet.js +2 -2
  65. package/dist/wallet.mjs +1 -1
  66. package/dist/window.d.ts +2 -2
  67. package/package.json +13 -4
  68. package/dist/chunk-HBDMIBEO.js.map +0 -1
  69. package/dist/chunk-I5QGTPHV.mjs +0 -186
  70. package/dist/chunk-I5QGTPHV.mjs.map +0 -1
  71. package/dist/chunk-LWNOZI6J.js +0 -186
  72. package/dist/chunk-LWNOZI6J.js.map +0 -1
  73. package/dist/chunk-U5Z7JOWV.mjs.map +0 -1
  74. package/dist/createPublicClient-31d44569.d.ts +0 -841
  75. package/dist/test-67630299.d.ts +0 -205
@@ -1,841 +0,0 @@
1
- import { W as WalletPermission, a as WatchAssetParams, P as PublicRequests } from './eip1193-4f4e240c.js';
2
- import { a as Transport, b as ClientConfig, C as Client } from './createTransport-e3eba9f7.js';
3
- import { Abi, Narrow, Address, AbiEvent, ExtractAbiEvent, TypedData, TypedDataDomain, TypedDataToPrimitiveTypes } from 'abitype';
4
- import { C as Chain, H as Hex, h as ExtractConstructorArgsFromAbi, W as ExtractFormatter, a1 as Formatters, a2 as Formatter, X as Formatted, c as Block, R as RpcBlock, O as Transaction, T as TransactionReceipt, z as RpcTransactionReceipt, a3 as TransactionType, D as RpcTransactionRequest, I as TransactionRequest, f as BlockTag, a4 as MergeIntersectionProperties, g as ContractConfig, a5 as GetValue, p as ExtractResultFromAbi, a6 as MaybeAbiEventName, a7 as MaybeExtractEventArgsFromAbi, e as BlockNumber, m as ExtractEventNameFromAbi, a as Hash, F as FeeHistory, L as Log, Y as FormattedTransaction, Z as TransactionFormatter, k as ExtractEventArgsFromAbi, a8 as Prettify } from './chain-1b53ef88.js';
5
-
6
- type AddChainParameters = {
7
- chain: Chain;
8
- };
9
- declare function addChain(client: WalletClient, { chain }: AddChainParameters): Promise<void>;
10
-
11
- type DeployContractParameters<TChain extends Chain = Chain, TAbi extends Abi | readonly unknown[] = Abi> = Omit<SendTransactionParameters<TChain>, 'accessList' | 'to' | 'data' | 'value'> & {
12
- abi: Narrow<TAbi>;
13
- bytecode: Hex;
14
- } & ExtractConstructorArgsFromAbi<TAbi>;
15
- type DeployContractReturnType = SendTransactionReturnType;
16
- declare function deployContract<TChain extends Chain, TAbi extends Abi | readonly unknown[]>(walletClient: WalletClient, { abi, args, bytecode, ...request }: DeployContractParameters<TChain, TAbi>): Promise<DeployContractReturnType>;
17
-
18
- type GetAddressesReturnType = Address[];
19
- declare function getAddresses(client: WalletClient): Promise<GetAddressesReturnType>;
20
-
21
- type GetChainIdReturnType = number;
22
- declare function getChainId(client: PublicClient | WalletClient): Promise<GetChainIdReturnType>;
23
-
24
- type BlockFormatter<TChain extends Chain = Chain> = ExtractFormatter<TChain, 'block', NonNullable<Formatters['block']>>;
25
- type FormattedBlock<TFormatter extends Formatter | undefined = Formatter> = Formatted<TFormatter, Block>;
26
- declare function formatBlock(block: Partial<RpcBlock>): Block<bigint, Transaction<bigint, number>>;
27
- declare const defineBlock: <TFormat extends Formatter<Partial<RpcBlock>, Partial<Block<bigint, Transaction<bigint, number>>> & {
28
- [key: string]: unknown;
29
- }>, TExclude extends (keyof RpcBlock)[] = []>({ exclude, format: formatOverride, }: {
30
- exclude?: TExclude | undefined;
31
- format?: TFormat | undefined;
32
- }) => (data: Partial<RpcBlock> & {
33
- [key: string]: unknown;
34
- }) => Block<bigint, Transaction<bigint, number>> & ReturnType<TFormat> & { [K in TExclude[number]]: never; };
35
-
36
- type TransactionReceiptFormatter<TChain extends Chain = Chain> = ExtractFormatter<TChain, 'transactionReceipt', NonNullable<Formatters['transactionReceipt']>>;
37
- type FormattedTransactionReceipt<TFormatter extends Formatter | undefined = Formatter> = Formatted<TFormatter, TransactionReceipt>;
38
- declare const defineTransactionReceipt: <TFormat extends Formatter<Partial<RpcTransactionReceipt>, Partial<TransactionReceipt<bigint, number, "success" | "reverted", TransactionType>> & {
39
- [key: string]: unknown;
40
- }>, TExclude extends (keyof RpcTransactionReceipt)[] = []>({ exclude, format: formatOverride, }: {
41
- exclude?: TExclude | undefined;
42
- format?: TFormat | undefined;
43
- }) => (data: Partial<RpcTransactionReceipt> & {
44
- [key: string]: unknown;
45
- }) => TransactionReceipt<bigint, number, "success" | "reverted", TransactionType> & ReturnType<TFormat> & { [K in TExclude[number]]: never; };
46
-
47
- type TransactionRequestFormatter<TChain extends Chain = Chain> = ExtractFormatter<TChain, 'transactionRequest', NonNullable<Formatters['transactionRequest']>>;
48
- type FormattedTransactionRequest$1<TFormatter extends Formatter | undefined = Formatter> = Formatted<TFormatter, RpcTransactionRequest>;
49
- declare function formatTransactionRequest(transactionRequest: Partial<TransactionRequest>): RpcTransactionRequest;
50
- declare const defineTransactionRequest: <TFormat extends Formatter<Partial<TransactionRequest<bigint, number>>, Partial<RpcTransactionRequest> & {
51
- [key: string]: unknown;
52
- }>, TExclude extends ("value" | "from" | "gasPrice" | "maxFeePerGas" | "maxPriorityFeePerGas" | "data" | "gas" | "nonce" | "to" | "accessList")[] = []>({ exclude, format: formatOverride, }: {
53
- exclude?: TExclude | undefined;
54
- format?: TFormat | undefined;
55
- }) => (data: Partial<TransactionRequest<bigint, number>> & {
56
- [key: string]: unknown;
57
- }) => RpcTransactionRequest & ReturnType<TFormat> & { [K in TExclude[number]]: never; };
58
-
59
- type FormattedCall<TFormatter extends Formatter | undefined = Formatter> = MergeIntersectionProperties<Omit<Formatted<TFormatter, TransactionRequest, true>, 'from'>, TransactionRequest>;
60
- type CallParameters<TChain extends Chain = Chain> = FormattedCall<TransactionRequestFormatter<TChain>> & {
61
- account?: Account;
62
- } & ({
63
- /** The balance of the account at a block number. */
64
- blockNumber?: bigint;
65
- blockTag?: never;
66
- } | {
67
- blockNumber?: never;
68
- /** The balance of the account at a block tag. */
69
- blockTag?: BlockTag;
70
- });
71
- type CallReturnType = {
72
- data: Hex | undefined;
73
- };
74
- declare function call<TChain extends Chain>(client: PublicClient<any, TChain>, args: CallParameters<TChain>): Promise<CallReturnType>;
75
-
76
- type SimulateContractParameters<TChain extends Chain = Chain, TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = any, TChainOverride extends Chain | undefined = undefined> = Omit<CallParameters<TChainOverride extends Chain ? TChainOverride : TChain>, 'to' | 'data' | 'value'> & {
77
- chain?: TChainOverride;
78
- } & ContractConfig<TAbi, TFunctionName, 'payable' | 'nonpayable'> & {
79
- value?: GetValue<TAbi, TFunctionName, CallParameters<TChain>['value']>;
80
- };
81
- type SimulateContractReturnType<TChain extends Chain = Chain, TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string> = {
82
- result: ExtractResultFromAbi<TAbi, TFunctionName>;
83
- request: WriteContractParameters<TChain, TAbi, TFunctionName> & ContractConfig<TAbi, TFunctionName, 'payable' | 'nonpayable'>;
84
- };
85
- declare function simulateContract<TChain extends Chain, TAbi extends Abi | readonly unknown[], TFunctionName extends string, TChainOverride extends Chain | undefined>(client: PublicClient<any, TChain>, { abi, address, args, functionName, ...callRequest }: SimulateContractParameters<TChain, TAbi, TFunctionName, TChainOverride>): Promise<SimulateContractReturnType<TChainOverride extends Chain ? TChainOverride : TChain, TAbi, TFunctionName>>;
86
-
87
- type CreatePendingTransactionFilterReturnType = Filter<'transaction'>;
88
- declare function createPendingTransactionFilter(client: PublicClient): Promise<CreatePendingTransactionFilterReturnType>;
89
-
90
- type CreateBlockFilterReturnType = Filter<'block'>;
91
- declare function createBlockFilter(client: PublicClient): Promise<CreateBlockFilterReturnType>;
92
-
93
- type CreateEventFilterParameters<TAbiEvent extends AbiEvent | undefined = undefined, TAbi extends Abi | readonly unknown[] = [TAbiEvent], TEventName extends string | undefined = MaybeAbiEventName<TAbiEvent>, TArgs extends MaybeExtractEventArgsFromAbi<TAbi, TEventName> | undefined = undefined> = {
94
- address?: Address | Address[];
95
- fromBlock?: BlockNumber | BlockTag;
96
- toBlock?: BlockNumber | BlockTag;
97
- } & (MaybeExtractEventArgsFromAbi<TAbi, TEventName> extends infer TEventFilterArgs ? {
98
- args: TEventFilterArgs | (TArgs extends TEventFilterArgs ? TArgs : never);
99
- event: TAbiEvent;
100
- } | {
101
- args?: never;
102
- event?: TAbiEvent;
103
- } | {
104
- args?: never;
105
- event?: never;
106
- } : {
107
- args?: never;
108
- event?: never;
109
- });
110
- type CreateEventFilterReturnType<TAbiEvent extends AbiEvent | undefined = undefined, TAbi extends Abi | readonly unknown[] = [TAbiEvent], TEventName extends string | undefined = MaybeAbiEventName<TAbiEvent>, TArgs extends MaybeExtractEventArgsFromAbi<TAbi, TEventName> | undefined = undefined> = Filter<'event', TAbi, TEventName, TArgs>;
111
- declare function createEventFilter<TAbiEvent extends AbiEvent | undefined, TAbi extends Abi | readonly unknown[] = [TAbiEvent], TEventName extends string | undefined = MaybeAbiEventName<TAbiEvent>, TArgs extends MaybeExtractEventArgsFromAbi<TAbi, TEventName> | undefined = undefined>(client: PublicClient, { address, args, event, fromBlock, toBlock, }?: CreateEventFilterParameters<TAbiEvent, TAbi, TEventName, TArgs>): Promise<CreateEventFilterReturnType<TAbiEvent, TAbi, TEventName, TArgs>>;
112
-
113
- type CreateContractEventFilterParameters<TAbi extends Abi | readonly unknown[] = Abi, TEventName extends string | undefined = undefined, TArgs extends MaybeExtractEventArgsFromAbi<TAbi, TEventName> | undefined = undefined> = {
114
- address?: Address | Address[];
115
- abi: Narrow<TAbi>;
116
- eventName?: ExtractEventNameFromAbi<TAbi, TEventName>;
117
- fromBlock?: BlockNumber | BlockTag;
118
- toBlock?: BlockNumber | BlockTag;
119
- } & (undefined extends TEventName ? {
120
- args?: never;
121
- } : MaybeExtractEventArgsFromAbi<TAbi, TEventName> extends infer TEventFilterArgs ? {
122
- args?: TEventFilterArgs | (TArgs extends TEventFilterArgs ? TArgs : never);
123
- } : {
124
- args?: never;
125
- });
126
- type CreateContractEventFilterReturnType<TAbi extends Abi | readonly unknown[] = Abi, TEventName extends string | undefined = undefined, TArgs extends MaybeExtractEventArgsFromAbi<TAbi, TEventName> | undefined = undefined> = Filter<'event', TAbi, TEventName, TArgs>;
127
- declare function createContractEventFilter<TAbi extends Abi | readonly unknown[], TEventName extends string | undefined, TArgs extends MaybeExtractEventArgsFromAbi<TAbi, TEventName> | undefined>(client: PublicClient, { address, abi, args, eventName, fromBlock, toBlock, }: CreateContractEventFilterParameters<TAbi, TEventName, TArgs>): Promise<CreateContractEventFilterReturnType<TAbi, TEventName, TArgs>>;
128
-
129
- type FormattedEstimateGas<TFormatter extends Formatter | undefined = Formatter> = MergeIntersectionProperties<Omit<Formatted<TFormatter, TransactionRequest, true>, 'from'>, TransactionRequest>;
130
- type EstimateGasParameters<TChain extends Chain = Chain> = FormattedEstimateGas<TransactionRequestFormatter<TChain>> & {
131
- account: Account;
132
- } & ({
133
- /** The balance of the account at a block number. */
134
- blockNumber?: bigint;
135
- blockTag?: never;
136
- } | {
137
- blockNumber?: never;
138
- /** The balance of the account at a block tag. */
139
- blockTag?: BlockTag;
140
- });
141
- type EstimateGasReturnType = bigint;
142
- /**
143
- * @description Estimates the gas necessary to complete a transaction without submitting it to the network.
144
- */
145
- declare function estimateGas<TChain extends Chain>(client: PublicClient<any, TChain> | WalletClient, args: EstimateGasParameters<TChain>): Promise<EstimateGasReturnType>;
146
-
147
- type EstimateContractGasParameters<TChain extends Chain = Chain, TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = any> = Omit<EstimateGasParameters<TChain>, 'data' | 'to' | 'value'> & ContractConfig<TAbi, TFunctionName, 'payable' | 'nonpayable'> & {
148
- value?: GetValue<TAbi, TFunctionName, EstimateGasParameters<TChain>['value']>;
149
- };
150
- type EstimateContractGasReturnType = bigint;
151
- declare function estimateContractGas<TChain extends Chain, TAbi extends Abi | readonly unknown[], TFunctionName extends string>(client: PublicClient<any, TChain>, { abi, address, args, functionName, ...request }: EstimateContractGasParameters<TChain, TAbi, TFunctionName>): Promise<EstimateContractGasReturnType>;
152
-
153
- type GetBalanceParameters = {
154
- /** The address of the account. */
155
- address: Address;
156
- } & ({
157
- /** The balance of the account at a block number. */
158
- blockNumber?: bigint;
159
- blockTag?: never;
160
- } | {
161
- blockNumber?: never;
162
- /** The balance of the account at a block tag. */
163
- blockTag?: BlockTag;
164
- });
165
- type GetBalanceReturnType = bigint;
166
- /**
167
- * @description Returns the balance of an address in wei.
168
- */
169
- declare function getBalance(client: PublicClient, { address, blockNumber, blockTag }: GetBalanceParameters): Promise<GetBalanceReturnType>;
170
-
171
- type GetBlockParameters = {
172
- /** Whether or not to include transaction data in the response. */
173
- includeTransactions?: boolean;
174
- } & ({
175
- /** Hash of the block. */
176
- blockHash?: Hash;
177
- blockNumber?: never;
178
- blockTag?: never;
179
- } | {
180
- blockHash?: never;
181
- /** The block number. */
182
- blockNumber?: bigint;
183
- blockTag?: never;
184
- } | {
185
- blockHash?: never;
186
- blockNumber?: never;
187
- /** The block tag. Defaults to 'latest'. */
188
- blockTag?: BlockTag;
189
- });
190
- type GetBlockReturnType<TChain extends Chain = Chain> = FormattedBlock<BlockFormatter<TChain>>;
191
- declare function getBlock<TChain extends Chain>(client: PublicClient<any, TChain> | WalletClient, { blockHash, blockNumber, blockTag, includeTransactions, }?: GetBlockParameters): Promise<GetBlockReturnType<TChain>>;
192
-
193
- type GetBlockNumberParameters = {
194
- /** The maximum age (in ms) of the cached value. */
195
- maxAge?: number;
196
- };
197
- type GetBlockNumberReturnType = bigint;
198
- declare function getBlockNumberCache(id: string): {
199
- clear: () => void;
200
- promise: {
201
- clear: () => boolean;
202
- get: () => Promise<unknown> | undefined;
203
- set: (data: Promise<unknown>) => Map<string, Promise<unknown>>;
204
- };
205
- response: {
206
- clear: () => boolean;
207
- get: () => {
208
- created: Date;
209
- data: unknown;
210
- } | undefined;
211
- set: (data: {
212
- created: Date;
213
- data: unknown;
214
- }) => Map<string, {
215
- created: Date;
216
- data: unknown;
217
- }>;
218
- };
219
- };
220
- /**
221
- * @description Returns the number of the most recent block seen.
222
- */
223
- declare function getBlockNumber(client: PublicClient<any, any, any>, { maxAge }?: GetBlockNumberParameters): Promise<GetBlockNumberReturnType>;
224
-
225
- type GetBlockTransactionCountParameters = {
226
- /** Hash of the block. */
227
- blockHash?: Hash;
228
- blockNumber?: never;
229
- blockTag?: never;
230
- } | {
231
- blockHash?: never;
232
- /** The block number. */
233
- blockNumber?: bigint;
234
- blockTag?: never;
235
- } | {
236
- blockHash?: never;
237
- blockNumber?: never;
238
- /** The block tag. Defaults to 'latest'. */
239
- blockTag?: BlockTag;
240
- };
241
- type GetBlockTransactionCountReturnType = number;
242
- declare function getBlockTransactionCount<TChain extends Chain>(client: PublicClient<any, TChain>, { blockHash, blockNumber, blockTag, }?: GetBlockTransactionCountParameters): Promise<GetBlockTransactionCountReturnType>;
243
-
244
- type GetBytecodeParameters = {
245
- address: Address;
246
- } & ({
247
- blockNumber?: never;
248
- blockTag?: BlockTag;
249
- } | {
250
- blockNumber?: bigint;
251
- blockTag?: never;
252
- });
253
- type GetBytecodeReturnType = Hex | undefined;
254
- declare function getBytecode(client: PublicClient, { address, blockNumber, blockTag }: GetBytecodeParameters): Promise<GetBytecodeReturnType>;
255
-
256
- type GetFeeHistoryParameters = {
257
- blockCount: number;
258
- rewardPercentiles: number[];
259
- } & ({
260
- blockNumber?: never;
261
- blockTag?: BlockTag;
262
- } | {
263
- blockNumber?: bigint;
264
- blockTag?: never;
265
- });
266
- type GetFeeHistoryReturnType = FeeHistory;
267
- /**
268
- * @description Returns a collection of historical gas information.
269
- */
270
- declare function getFeeHistory(client: PublicClient, { blockCount, blockNumber, blockTag, rewardPercentiles, }: GetFeeHistoryParameters): Promise<GetFeeHistoryReturnType>;
271
-
272
- type GetFilterChangesParameters<TFilterType extends FilterType = FilterType, TAbiEvent extends AbiEvent | undefined = undefined, TAbi extends Abi | readonly unknown[] = [TAbiEvent], TEventName extends string | undefined = MaybeAbiEventName<TAbiEvent>> = {
273
- filter: Filter<TFilterType, TAbi, TEventName, any>;
274
- };
275
- type GetFilterChangesReturnType<TFilterType extends FilterType = FilterType, TAbiEvent extends AbiEvent | undefined = undefined, TAbi extends Abi | readonly unknown[] = [TAbiEvent], TEventName extends string | undefined = MaybeAbiEventName<TAbiEvent>> = TFilterType extends 'event' ? Log<bigint, number, TAbiEvent, TAbi, TEventName>[] : Hash[];
276
- declare function getFilterChanges<TFilterType extends FilterType, TAbiEvent extends AbiEvent | undefined, TAbi extends Abi | readonly unknown[], TEventName extends string | undefined>(client: PublicClient, { filter, }: GetFilterChangesParameters<TFilterType, TAbiEvent, TAbi, TEventName>): Promise<GetFilterChangesReturnType<TFilterType, TAbiEvent, TAbi, TEventName>>;
277
-
278
- type GetFilterLogsParameters<TAbiEvent extends AbiEvent | undefined = undefined, TAbi extends Abi | readonly unknown[] = [TAbiEvent], TEventName extends string | undefined = MaybeAbiEventName<TAbiEvent>> = {
279
- filter: Filter<'event', TAbi, TEventName, any>;
280
- };
281
- type GetFilterLogsReturnType<TAbiEvent extends AbiEvent | undefined = undefined, TAbi extends Abi | readonly unknown[] = [TAbiEvent], TEventName extends string | undefined = MaybeAbiEventName<TAbiEvent>> = Log<bigint, number, TAbiEvent, TAbi, TEventName>[];
282
- declare function getFilterLogs<TAbiEvent extends AbiEvent | undefined, TAbi extends Abi | readonly unknown[], TEventName extends string | undefined>(client: PublicClient, { filter }: GetFilterLogsParameters<TAbiEvent, TAbi, TEventName>): Promise<GetFilterLogsReturnType<TAbiEvent, TAbi, TEventName>>;
283
-
284
- type GetGasPriceReturnType = bigint;
285
- /**
286
- * @description Returns the current price of gas (in wei).
287
- */
288
- declare function getGasPrice(client: PublicClient | WalletClient): Promise<GetGasPriceReturnType>;
289
-
290
- type GetLogsParameters<TAbiEvent extends AbiEvent | undefined = undefined, TEventName extends string | undefined = MaybeAbiEventName<TAbiEvent>> = {
291
- /** Address or list of addresses from which logs originated */
292
- address?: Address | Address[];
293
- } & ({
294
- event: TAbiEvent;
295
- args?: MaybeExtractEventArgsFromAbi<[TAbiEvent], TEventName>;
296
- } | {
297
- event?: never;
298
- args?: never;
299
- }) & ({
300
- /** Block number or tag after which to include logs */
301
- fromBlock?: BlockNumber<bigint> | BlockTag;
302
- /** Block number or tag before which to include logs */
303
- toBlock?: BlockNumber<bigint> | BlockTag;
304
- blockHash?: never;
305
- } | {
306
- fromBlock?: never;
307
- toBlock?: never;
308
- /** Hash of block to include logs from */
309
- blockHash?: Hash;
310
- });
311
- type GetLogsReturnType<TAbiEvent extends AbiEvent | undefined = undefined, TEventName extends string | undefined = MaybeAbiEventName<TAbiEvent>> = Log<bigint, number, TAbiEvent, [TAbiEvent], TEventName>[];
312
- /**
313
- * @description Returns a collection of event logs.
314
- */
315
- declare function getLogs<TAbiEvent extends AbiEvent | undefined>(client: PublicClient, { address, blockHash, fromBlock, toBlock, event, args, }?: GetLogsParameters<TAbiEvent>): Promise<GetLogsReturnType<TAbiEvent>>;
316
-
317
- type GetStorageAtParameters = {
318
- address: Address;
319
- slot: Hex;
320
- } & ({
321
- blockNumber?: never;
322
- blockTag?: BlockTag;
323
- } | {
324
- blockNumber?: bigint;
325
- blockTag?: never;
326
- });
327
- type GetStorageAtReturnType = Hex | undefined;
328
- declare function getStorageAt(client: PublicClient, { address, blockNumber, blockTag, slot }: GetStorageAtParameters): Promise<GetStorageAtReturnType>;
329
-
330
- type GetTransactionParameters = {
331
- /** The block hash */
332
- blockHash: Hash;
333
- blockNumber?: never;
334
- blockTag?: never;
335
- hash?: never;
336
- /** The index of the transaction on the block. */
337
- index: number;
338
- } | {
339
- blockHash?: never;
340
- /** The block number */
341
- blockNumber: bigint;
342
- blockTag?: never;
343
- hash?: never;
344
- /** The index of the transaction on the block. */
345
- index: number;
346
- } | {
347
- blockHash?: never;
348
- blockNumber?: never;
349
- /** The block tag. */
350
- blockTag: BlockTag;
351
- hash?: never;
352
- /** The index of the transaction on the block. */
353
- index: number;
354
- } | {
355
- blockHash?: never;
356
- blockNumber?: never;
357
- blockTag?: never;
358
- /** The hash of the transaction. */
359
- hash: Hash;
360
- index?: number;
361
- };
362
- type GetTransactionReturnType<TChain extends Chain = Chain> = FormattedTransaction<TransactionFormatter<TChain>>;
363
- /** @description Returns information about a transaction given a hash or block identifier. */
364
- declare function getTransaction<TChain extends Chain>(client: PublicClient<any, TChain>, { blockHash, blockNumber, blockTag, hash, index, }: GetTransactionParameters): Promise<GetTransactionReturnType<TChain>>;
365
-
366
- type GetTransactionConfirmationsParameters<TChain extends Chain = Chain> = {
367
- /** The transaction hash. */
368
- hash: Hash;
369
- transactionReceipt?: never;
370
- } | {
371
- hash?: never;
372
- /** The transaction receipt. */
373
- transactionReceipt: FormattedTransactionReceipt<TransactionReceiptFormatter<TChain>>;
374
- };
375
- type GetTransactionConfirmationsReturnType = bigint;
376
- declare function getTransactionConfirmations<TChain extends Chain>(client: PublicClient<any, TChain>, { hash, transactionReceipt }: GetTransactionConfirmationsParameters<TChain>): Promise<GetTransactionConfirmationsReturnType>;
377
-
378
- type GetTransactionCountParameters = {
379
- /** The account address. */
380
- address: Address;
381
- } & ({
382
- /** The block number. */
383
- blockNumber?: bigint;
384
- blockTag?: never;
385
- } | {
386
- blockNumber?: never;
387
- /** The block tag. Defaults to 'latest'. */
388
- blockTag?: BlockTag;
389
- });
390
- type GetTransactionCountReturnType = number;
391
- /**
392
- * @description Returns the number of transactions an account has broadcast / sent.
393
- */
394
- declare function getTransactionCount(client: PublicClient | WalletClient, { address, blockTag, blockNumber }: GetTransactionCountParameters): Promise<GetTransactionCountReturnType>;
395
-
396
- type GetTransactionReceiptParameters = {
397
- /** The hash of the transaction. */
398
- hash: Hash;
399
- };
400
- type GetTransactionReceiptReturnType<TChain extends Chain = Chain> = FormattedTransactionReceipt<TransactionReceiptFormatter<TChain>>;
401
- declare function getTransactionReceipt<TChain extends Chain>(client: PublicClient<any, TChain>, { hash }: GetTransactionReceiptParameters): Promise<Formatted<ExtractFormatter<TChain, "transactionReceipt", Formatter<RpcTransactionReceipt, TransactionReceipt<bigint, number, "success" | "reverted", TransactionType>>>, TransactionReceipt<bigint, number, "success" | "reverted", TransactionType>, false, false>>;
402
-
403
- type MAXIMUM_DEPTH = 20;
404
- type Contract<TAbi extends Abi | readonly unknown[] = Abi | readonly unknown[], TFunctionName extends string = string> = {
405
- abi: TAbi;
406
- functionName: TFunctionName;
407
- };
408
- type MulticallContracts<TContracts extends Contract[], TProperties extends Record<string, any> = object, Result extends any[] = [], Depth extends ReadonlyArray<number> = []> = Depth['length'] extends MAXIMUM_DEPTH ? (ContractConfig & TProperties)[] : TContracts extends [] ? [] : TContracts extends [infer Head extends Contract] ? [
409
- ...Result,
410
- ContractConfig<Head['abi'], Head['functionName']> & TProperties
411
- ] : TContracts extends [
412
- infer Head extends Contract,
413
- ...infer Tail extends Contract[]
414
- ] ? MulticallContracts<[
415
- ...Tail
416
- ], TProperties, [
417
- ...Result,
418
- ContractConfig<Head['abi'], Head['functionName']> & TProperties
419
- ], [
420
- ...Depth,
421
- 1
422
- ]> : unknown[] extends TContracts ? TContracts : TContracts extends ContractConfig<infer TAbi, infer TFunctionName>[] ? (ContractConfig<TAbi, TFunctionName> & TProperties)[] : (ContractConfig & TProperties)[];
423
- type MulticallResult<Result, TAllowFailure extends boolean = true> = TAllowFailure extends true ? ({
424
- error?: undefined;
425
- result: Result;
426
- status: 'success';
427
- } | {
428
- error: Error;
429
- result?: undefined;
430
- status: 'error';
431
- }) : Result;
432
- type MulticallResults<TContracts extends Contract[], TAllowFailure extends boolean = true, Result extends any[] = [], Depth extends ReadonlyArray<number> = []> = Depth['length'] extends MAXIMUM_DEPTH ? MulticallResult<ExtractResultFromAbi, TAllowFailure>[] : TContracts extends [] ? [] : TContracts extends [infer Head extends Contract] ? [...Result, MulticallResult<ExtractResultFromAbi<Head['abi'], Head['functionName']>, TAllowFailure>] : TContracts extends [
433
- infer Head extends Contract,
434
- ...infer Tail extends Contract[]
435
- ] ? MulticallResults<[
436
- ...Tail
437
- ], TAllowFailure, [
438
- ...Result,
439
- MulticallResult<ExtractResultFromAbi<Head['abi'], Head['functionName']>, TAllowFailure>
440
- ], [
441
- ...Depth,
442
- 1
443
- ]> : TContracts extends ContractConfig<infer TAbi, infer TFunctionName>[] ? MulticallResult<ExtractResultFromAbi<TAbi, TFunctionName>, TAllowFailure>[] : MulticallResult<ExtractResultFromAbi, TAllowFailure>[];
444
-
445
- type MulticallParameters<TContracts extends ContractConfig[] = ContractConfig[], TAllowFailure extends boolean = true> = Pick<CallParameters, 'blockNumber' | 'blockTag'> & {
446
- allowFailure?: TAllowFailure;
447
- contracts: Narrow<readonly [...MulticallContracts<TContracts>]>;
448
- multicallAddress?: Address;
449
- };
450
- type MulticallReturnType<TContracts extends ContractConfig[] = ContractConfig[], TAllowFailure extends boolean = true> = MulticallResults<TContracts, TAllowFailure>;
451
- declare function multicall<TContracts extends ContractConfig[], TAllowFailure extends boolean = true>(client: PublicClient, args: MulticallParameters<TContracts, TAllowFailure>): Promise<MulticallReturnType<TContracts, TAllowFailure>>;
452
-
453
- type ReadContractParameters<TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string> = Pick<CallParameters, 'blockNumber' | 'blockTag'> & ContractConfig<TAbi, TFunctionName, 'view' | 'pure'>;
454
- type ReadContractReturnType<TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string> = ExtractResultFromAbi<TAbi, TFunctionName>;
455
- declare function readContract<TAbi extends Abi | readonly unknown[], TFunctionName extends string>(client: PublicClient, { abi, address, args, functionName, ...callRequest }: ReadContractParameters<TAbi, TFunctionName>): Promise<ReadContractReturnType<TAbi, TFunctionName>>;
456
-
457
- type UninstallFilterParameters = {
458
- filter: Filter<any>;
459
- };
460
- type UninstallFilterReturnType = boolean;
461
- declare function uninstallFilter(client: PublicClient, { filter }: UninstallFilterParameters): Promise<UninstallFilterReturnType>;
462
-
463
- type ReplacementReason = 'cancelled' | 'replaced' | 'repriced';
464
- type ReplacementReturnType<TChain extends Chain = Chain> = {
465
- reason: ReplacementReason;
466
- replacedTransaction: Transaction;
467
- transaction: Transaction;
468
- transactionReceipt: GetTransactionReceiptReturnType<TChain>;
469
- };
470
- type WaitForTransactionReceiptReturnType<TChain extends Chain = Chain> = GetTransactionReceiptReturnType<TChain>;
471
- type WaitForTransactionReceiptParameters<TChain extends Chain = Chain> = {
472
- /** The number of confirmations (blocks that have passed) to wait before resolving. */
473
- confirmations?: number;
474
- /** The hash of the transaction. */
475
- hash: Hash;
476
- onReplaced?: (response: ReplacementReturnType<TChain>) => void;
477
- /** Polling frequency (in ms). Defaults to the client's pollingInterval config. */
478
- pollingInterval?: number;
479
- /** Optional timeout (in milliseconds) to wait before stopping polling. */
480
- timeout?: number;
481
- };
482
- declare function waitForTransactionReceipt<TChain extends Chain>(client: PublicClient<any, TChain>, { confirmations, hash, onReplaced, pollingInterval, timeout, }: WaitForTransactionReceiptParameters<TChain>): Promise<WaitForTransactionReceiptReturnType<TChain>>;
483
-
484
- type OnBlockNumberParameter = GetBlockNumberReturnType;
485
- type OnBlockNumberFn = (blockNumber: OnBlockNumberParameter, prevBlockNumber: OnBlockNumberParameter | undefined) => void;
486
- type WatchBlockNumberParameters = {
487
- /** Whether or not to emit the missed block numbers to the callback. */
488
- emitMissed?: boolean;
489
- /** Whether or not to emit the latest block number to the callback when the subscription opens. */
490
- emitOnBegin?: boolean;
491
- /** The callback to call when a new block number is received. */
492
- onBlockNumber: OnBlockNumberFn;
493
- /** The callback to call when an error occurred when trying to get for a new block. */
494
- onError?: (error: Error) => void;
495
- /** Polling frequency (in ms). Defaults to Client's pollingInterval config. */
496
- pollingInterval?: number;
497
- };
498
- /** @description Watches and returns incoming block numbers. */
499
- declare function watchBlockNumber(client: PublicClient<any, any, any>, { emitOnBegin, emitMissed, onBlockNumber, onError, pollingInterval, }: WatchBlockNumberParameters): () => void;
500
-
501
- type OnBlockParameter<TChain extends Chain = Chain, TIncludeTransactions = false> = Omit<GetBlockReturnType<TChain>, TIncludeTransactions extends false ? 'transactions' : ''>;
502
- type OnBlock<TChain extends Chain = Chain, TIncludeTransactions = false> = (block: OnBlockParameter<TChain, TIncludeTransactions>, prevBlock: OnBlockParameter<TChain, TIncludeTransactions> | undefined) => void;
503
- type WatchBlocksParameters<TChain extends Chain = Chain> = {
504
- /** The block tag. Defaults to "latest". */
505
- blockTag?: BlockTag;
506
- /** Whether or not to emit the missed blocks to the callback. */
507
- emitMissed?: boolean;
508
- /** Whether or not to emit the block to the callback when the subscription opens. */
509
- emitOnBegin?: boolean;
510
- /** The callback to call when an error occurred when trying to get for a new block. */
511
- onError?: (error: Error) => void;
512
- /** Polling frequency (in ms). Defaults to the client's pollingInterval config. */
513
- pollingInterval?: number;
514
- } & ({
515
- /** Whether or not to include transaction data in the response. */
516
- includeTransactions: true;
517
- /** The callback to call when a new block is received. */
518
- onBlock: OnBlock<TChain, true>;
519
- } | {
520
- /** Whether or not to include transaction data in the response. */
521
- includeTransactions?: false;
522
- /** The callback to call when a new block is received. */
523
- onBlock: OnBlock<TChain>;
524
- });
525
- /** @description Watches and returns information for incoming blocks. */
526
- declare function watchBlocks<TChain extends Chain, TWatchBlocksParameters extends WatchBlocksParameters<TChain>>(client: PublicClient<any, TChain>, { blockTag, emitMissed, emitOnBegin, onBlock, onError, includeTransactions, pollingInterval, }: TWatchBlocksParameters): () => void;
527
-
528
- type OnLogsParameter$1<TAbi extends Abi | readonly unknown[] = readonly unknown[], TEventName extends string = string> = TAbi extends Abi ? Log<bigint, number, ExtractAbiEvent<TAbi, TEventName>>[] : Log[];
529
- type OnLogsFn$1<TAbi extends Abi | readonly unknown[] = readonly unknown[], TEventName extends string = string> = (logs: OnLogsParameter$1<TAbi, TEventName>) => void;
530
- type WatchContractEventParameters<TAbi extends Abi | readonly unknown[] = readonly unknown[], TEventName extends string = string> = {
531
- /** The address of the contract. */
532
- address?: Address | Address[];
533
- /** Contract ABI. */
534
- abi: Narrow<TAbi>;
535
- args?: ExtractEventArgsFromAbi<TAbi, TEventName>;
536
- /** Whether or not the event logs should be batched on each invocation. */
537
- batch?: boolean;
538
- /** Contract event. */
539
- eventName?: ExtractEventNameFromAbi<TAbi, TEventName>;
540
- /** The callback to call when an error occurred when trying to get for a new block. */
541
- onError?: (error: Error) => void;
542
- /** The callback to call when new event logs are received. */
543
- onLogs: OnLogsFn$1<TAbi, TEventName>;
544
- /** Polling frequency (in ms). Defaults to Client's pollingInterval config. */
545
- pollingInterval?: number;
546
- };
547
- declare function watchContractEvent<TAbi extends Abi | readonly unknown[], TEventName extends string>(client: PublicClient, { abi, address, args, batch, eventName, onError, onLogs, pollingInterval, }: WatchContractEventParameters<TAbi, TEventName>): () => void;
548
-
549
- type OnLogsParameter<TAbiEvent extends AbiEvent | undefined = undefined, TEventName extends string | undefined = MaybeAbiEventName<TAbiEvent>> = Log<bigint, number, TAbiEvent, [TAbiEvent], TEventName>[];
550
- type OnLogsFn<TAbiEvent extends AbiEvent | undefined = undefined, TEventName extends string | undefined = MaybeAbiEventName<TAbiEvent>> = (logs: OnLogsParameter<TAbiEvent, TEventName>) => void;
551
- type WatchEventParameters<TAbiEvent extends AbiEvent | undefined = undefined, TEventName extends string | undefined = MaybeAbiEventName<TAbiEvent>> = {
552
- /** The address of the contract. */
553
- address?: Address | Address[];
554
- /** Whether or not the event logs should be batched on each invocation. */
555
- batch?: boolean;
556
- /** The callback to call when an error occurred when trying to get for a new block. */
557
- onError?: (error: Error) => void;
558
- /** The callback to call when new event logs are received. */
559
- onLogs: OnLogsFn<TAbiEvent, TEventName>;
560
- /** Polling frequency (in ms). Defaults to Client's pollingInterval config. */
561
- pollingInterval?: number;
562
- } & ({
563
- event: TAbiEvent;
564
- args?: MaybeExtractEventArgsFromAbi<[TAbiEvent], TEventName>;
565
- } | {
566
- event?: never;
567
- args?: never;
568
- });
569
- declare function watchEvent<TAbiEvent extends AbiEvent | undefined, TEventName extends string | undefined>(client: PublicClient, { address, args, batch, event, onError, onLogs, pollingInterval, }: WatchEventParameters<TAbiEvent>): () => void;
570
-
571
- type OnTransactionsParameter = Hash[];
572
- type OnTransactionsFn = (transactions: OnTransactionsParameter) => void;
573
- type WatchPendingTransactionsParameters = {
574
- /** Whether or not the transaction hashes should be batched on each invocation. */
575
- batch?: boolean;
576
- /** The callback to call when an error occurred when trying to get for a new block. */
577
- onError?: (error: Error) => void;
578
- /** The callback to call when new transactions are received. */
579
- onTransactions: OnTransactionsFn;
580
- /** Polling frequency (in ms). Defaults to Client's pollingInterval config. */
581
- pollingInterval?: number;
582
- };
583
- declare function watchPendingTransactions(client: PublicClient, { batch, onError, onTransactions, pollingInterval, }: WatchPendingTransactionsParameters): () => void;
584
-
585
- type GetPermissionsReturnType = WalletPermission[];
586
- declare function getPermissions(client: WalletClient): Promise<WalletPermission[]>;
587
-
588
- type RequestAddressesReturnType = Address[];
589
- declare function requestAddresses(client: WalletClient): Promise<RequestAddressesReturnType>;
590
-
591
- type RequestPermissionsParameters = {
592
- eth_accounts: Record<string, any>;
593
- } & {
594
- [key: string]: Record<string, any>;
595
- };
596
- type RequestPermissionsReturnType = WalletPermission[];
597
- declare function requestPermissions(client: WalletClient, permissions: RequestPermissionsParameters): Promise<WalletPermission[]>;
598
-
599
- type FormattedTransactionRequest<TFormatter extends Formatter | undefined = Formatter> = MergeIntersectionProperties<Omit<Formatted<TFormatter, TransactionRequest, true>, 'from'>, TransactionRequest>;
600
- type SendTransactionParameters<TChain extends Chain = Chain> = FormattedTransactionRequest<TransactionRequestFormatter<TChain>> & {
601
- account: Account;
602
- } & ({
603
- assertChain?: false;
604
- chain?: TChain;
605
- } | {
606
- assertChain: true;
607
- chain: TChain;
608
- });
609
- type SendTransactionReturnType = Hash;
610
- declare function sendTransaction<TChain extends Chain>(client: WalletClient<any, any>, args: SendTransactionParameters<TChain>): Promise<SendTransactionReturnType>;
611
-
612
- type SignMessageParameters = {
613
- account: Account;
614
- } & ({
615
- /** @deprecated – `data` will be removed in 0.2.0; use `message` instead. */
616
- data: string;
617
- message?: never;
618
- } | {
619
- data?: never;
620
- message: string;
621
- });
622
- type SignMessageReturnType = Hex;
623
- declare function signMessage(client: WalletClient, { account, data, message }: SignMessageParameters): Promise<SignMessageReturnType>;
624
-
625
- type SignTypedDataParameters<TTypedData extends TypedData | {
626
- [key: string]: unknown;
627
- } = TypedData, TPrimaryType extends string = string> = {
628
- account: Account;
629
- } & TypedDataDefinition<TTypedData, TPrimaryType>;
630
- type TypedDataDefinition<TTypedData extends TypedData | {
631
- [key: string]: unknown;
632
- } = TypedData, TPrimaryType extends string = string> = {
633
- domain?: TypedDataDomain;
634
- types: Narrow<TTypedData>;
635
- primaryType: GetPrimaryType<TTypedData, TPrimaryType>;
636
- } & GetMessage<TTypedData, TPrimaryType>;
637
- type GetPrimaryType<TTypedData extends TypedData | {
638
- [key: string]: unknown;
639
- } = TypedData, TPrimaryType extends string = string> = TTypedData extends TypedData ? keyof TTypedData extends infer AbiFunctionNames ? AbiFunctionNames | (TPrimaryType extends AbiFunctionNames ? TPrimaryType : never) | (TypedData extends TTypedData ? string : never) : never : TPrimaryType;
640
- type GetMessage<TTypedData extends TypedData | {
641
- [key: string]: unknown;
642
- } = TypedData, TPrimaryType extends string = string, TSchema = TTypedData extends TypedData ? TypedDataToPrimitiveTypes<TTypedData> : {
643
- [key: string]: any;
644
- }, TMessage = TSchema[TPrimaryType extends keyof TSchema ? TPrimaryType : keyof TSchema]> = {
645
- [key: string]: any;
646
- } extends TMessage ? {
647
- /**
648
- * Data to sign
649
- *
650
- * Use a [const assertion](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#const-assertions) on {@link types} for type inference.
651
- */
652
- message: {
653
- [key: string]: unknown;
654
- };
655
- } : {
656
- /** Data to sign */
657
- message: TMessage;
658
- };
659
- type SignTypedDataReturnType = Hex;
660
- declare function signTypedData<TTypedData extends TypedData | {
661
- [key: string]: unknown;
662
- }, TPrimaryType extends string>(client: WalletClient, { account, domain, message, primaryType, types: types_, }: SignTypedDataParameters<TTypedData, TPrimaryType>): Promise<SignTypedDataReturnType>;
663
-
664
- type SwitchChainParameters = {
665
- id: Chain['id'];
666
- };
667
- declare function switchChain(client: WalletClient, { id }: SwitchChainParameters): Promise<void>;
668
-
669
- type WatchAssetParameters = WatchAssetParams;
670
- type WatchAssetReturnType = boolean;
671
- declare function watchAsset(client: WalletClient, params: WatchAssetParameters): Promise<WatchAssetReturnType>;
672
-
673
- type WriteContractParameters<TChain extends Chain = Chain, TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string> = Omit<SendTransactionParameters<TChain>, 'to' | 'data' | 'value'> & {
674
- value?: GetValue<TAbi, TFunctionName, SendTransactionParameters<TChain>['value']>;
675
- } & ContractConfig<TAbi, TFunctionName, 'payable' | 'nonpayable'>;
676
- type WriteContractReturnType = SendTransactionReturnType;
677
- declare function writeContract<TChain extends Chain, TAbi extends Abi | readonly unknown[], TFunctionName extends string>(client: WalletClient, { abi, address, args, functionName, ...request }: WriteContractParameters<TChain, TAbi, TFunctionName>): Promise<WriteContractReturnType>;
678
-
679
- type Account = JsonRpcAccount | LocalAccount;
680
- type JsonRpcAccount = {
681
- address: Address;
682
- type: 'json-rpc';
683
- };
684
- type LocalAccount = {
685
- address: Address;
686
- signMessage: (message: string) => Promise<Hash>;
687
- signTransaction: (transaction: Omit<TransactionRequest, 'from'> & {
688
- chainId: number;
689
- from: Address;
690
- }) => Promise<Hash>;
691
- signTypedData: <TTypedData extends TypedData | {
692
- [key: string]: unknown;
693
- }, TPrimaryType extends string = string>(typedData: TypedDataDefinition<TTypedData, TPrimaryType>) => Promise<Hash>;
694
- type: 'local';
695
- };
696
-
697
- type FilterType = 'transaction' | 'block' | 'event';
698
- type Filter<TFilterType extends FilterType = 'event', TAbi extends Abi | readonly unknown[] = Abi, TEventName extends string | undefined = undefined, TArgs extends MaybeExtractEventArgsFromAbi<TAbi, TEventName> | undefined = MaybeExtractEventArgsFromAbi<TAbi, TEventName>> = {
699
- id: Hex;
700
- type: TFilterType;
701
- } & (TFilterType extends 'event' ? TAbi extends Abi ? undefined extends TEventName ? {
702
- abi: TAbi;
703
- args?: never;
704
- eventName?: never;
705
- } : TArgs extends MaybeExtractEventArgsFromAbi<TAbi, TEventName> ? {
706
- abi: TAbi;
707
- args: TArgs;
708
- eventName: TEventName;
709
- } : {
710
- abi: TAbi;
711
- args?: never;
712
- eventName: TEventName;
713
- } : {
714
- abi?: never;
715
- args?: never;
716
- eventName?: never;
717
- } : {});
718
-
719
- type GetEnsAddressParameters = Prettify<Pick<ReadContractParameters, 'blockNumber' | 'blockTag'> & {
720
- /** ENS name to get address. */
721
- name: string;
722
- /** Address of ENS Universal Resolver Contract */
723
- universalResolverAddress?: Address;
724
- }>;
725
- type GetEnsAddressReturnType = Address;
726
- /**
727
- * @description Gets address for ENS name.
728
- *
729
- * - Calls `resolve(bytes, bytes)` on ENS Universal Resolver Contract.
730
- * - Since ENS names prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to [normalize ENS names](https://docs.ens.domains/contract-api-reference/name-processing#normalising-names) with [UTS-46 normalization](https://unicode.org/reports/tr46) before passing them to `getEnsAddress`. You can use the built-in [`normalize`](https://viem.sh/docs/ens/utilities/normalize.html) function for this.
731
- *
732
- * @example
733
- * import { normalize } from 'viem/ens'
734
- *
735
- * const ensAddress = await getEnsAddress(publicClient, {
736
- * name: normalize('wagmi-dev.eth'),
737
- * })
738
- * // '0xd2135CfB216b74109775236E36d4b433F1DF507B'
739
- */
740
- declare function getEnsAddress(client: PublicClient, { blockNumber, blockTag, name, universalResolverAddress: universalResolverAddress_, }: GetEnsAddressParameters): Promise<GetEnsAddressReturnType>;
741
-
742
- type GetEnsNameParameters = Prettify<Pick<ReadContractParameters, 'blockNumber' | 'blockTag'> & {
743
- /** Address to get ENS name for. */
744
- address: Address;
745
- /** Address of ENS Universal Resolver Contract. */
746
- universalResolverAddress?: Address;
747
- }>;
748
- type GetEnsNameReturnType = string | null;
749
- /**
750
- * @description Gets primary name for specified address.
751
- *
752
- * - Calls `reverse(bytes)` on ENS Universal Resolver Contract.
753
- *
754
- * @example
755
- * const ensName = await getEnsName(publicClient, {
756
- * address: '0xd2135CfB216b74109775236E36d4b433F1DF507B',
757
- * })
758
- * // 'wagmi-dev.eth'
759
- */
760
- declare function getEnsName(client: PublicClient, { address, blockNumber, blockTag, universalResolverAddress: universalResolverAddress_, }: GetEnsNameParameters): Promise<GetEnsNameReturnType>;
761
-
762
- type PublicActions<TChain extends Chain = Chain> = {
763
- call: (args: CallParameters<TChain>) => Promise<CallReturnType>;
764
- createBlockFilter: () => Promise<CreateBlockFilterReturnType>;
765
- createContractEventFilter: <TAbi extends Abi | readonly unknown[], TEventName extends string | undefined, TArgs extends MaybeExtractEventArgsFromAbi<TAbi, TEventName> | undefined>(args: CreateContractEventFilterParameters<TAbi, TEventName, TArgs>) => Promise<CreateContractEventFilterReturnType<TAbi, TEventName, TArgs>>;
766
- createEventFilter: <TAbiEvent extends AbiEvent | undefined, TAbi extends Abi | readonly unknown[], TEventName extends string | undefined, TArgs extends MaybeExtractEventArgsFromAbi<TAbi, TEventName> | undefined>(args?: CreateEventFilterParameters<TAbiEvent, TAbi, TEventName, TArgs>) => Promise<CreateEventFilterReturnType<TAbiEvent, TAbi, TEventName, TArgs>>;
767
- createPendingTransactionFilter: () => Promise<CreatePendingTransactionFilterReturnType>;
768
- estimateContractGas: <TChain extends Chain, TAbi extends Abi | readonly unknown[], TFunctionName extends string>(args: EstimateContractGasParameters<TChain, TAbi, TFunctionName>) => Promise<EstimateContractGasReturnType>;
769
- estimateGas: (args: EstimateGasParameters<TChain>) => Promise<EstimateGasReturnType>;
770
- getBalance: (args: GetBalanceParameters) => Promise<GetBalanceReturnType>;
771
- getBlock: (args?: GetBlockParameters) => Promise<GetBlockReturnType<TChain>>;
772
- getBlockNumber: (args?: GetBlockNumberParameters) => Promise<GetBlockNumberReturnType>;
773
- getBlockTransactionCount: (args?: GetBlockTransactionCountParameters) => Promise<GetBlockTransactionCountReturnType>;
774
- getBytecode: (args: GetBytecodeParameters) => Promise<GetBytecodeReturnType>;
775
- getChainId: () => Promise<GetChainIdReturnType>;
776
- getEnsAddress: (args: GetEnsAddressParameters) => Promise<GetEnsAddressReturnType>;
777
- getEnsName: (args: GetEnsNameParameters) => Promise<GetEnsNameReturnType>;
778
- getFeeHistory: (args: GetFeeHistoryParameters) => Promise<GetFeeHistoryReturnType>;
779
- getFilterChanges: <TFilterType extends FilterType, TAbiEvent extends AbiEvent | undefined, TAbi extends Abi | readonly unknown[], TEventName extends string | undefined>(args: GetFilterChangesParameters<TFilterType, TAbiEvent, TAbi, TEventName>) => Promise<GetFilterChangesReturnType<TFilterType, TAbiEvent, TAbi, TEventName>>;
780
- getFilterLogs: <TAbiEvent extends AbiEvent | undefined, TAbi extends Abi | readonly unknown[], TEventName extends string | undefined>(args: GetFilterLogsParameters<TAbiEvent, TAbi, TEventName>) => Promise<GetFilterLogsReturnType<TAbiEvent, TAbi, TEventName>>;
781
- getGasPrice: () => Promise<GetGasPriceReturnType>;
782
- getLogs: <TAbiEvent extends AbiEvent | undefined>(args?: GetLogsParameters<TAbiEvent>) => Promise<GetLogsReturnType<TAbiEvent>>;
783
- getStorageAt: (args: GetStorageAtParameters) => Promise<GetStorageAtReturnType>;
784
- getTransaction: (args: GetTransactionParameters) => Promise<GetTransactionReturnType<TChain>>;
785
- getTransactionConfirmations: (args: GetTransactionConfirmationsParameters<TChain>) => Promise<GetTransactionConfirmationsReturnType>;
786
- getTransactionCount: (args: GetTransactionCountParameters) => Promise<GetTransactionCountReturnType>;
787
- getTransactionReceipt: (args: GetTransactionReceiptParameters) => Promise<GetTransactionReceiptReturnType<TChain>>;
788
- multicall: <TContracts extends ContractConfig[], TAllowFailure extends boolean = true>(args: MulticallParameters<TContracts, TAllowFailure>) => Promise<MulticallReturnType<TContracts, TAllowFailure>>;
789
- readContract: <TAbi extends Abi | readonly unknown[], TFunctionName extends string>(args: ReadContractParameters<TAbi, TFunctionName>) => Promise<ReadContractReturnType<TAbi, TFunctionName>>;
790
- simulateContract: <TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = any, TChainOverride extends Chain | undefined = undefined>(args: SimulateContractParameters<TChain, TAbi, TFunctionName, TChainOverride>) => Promise<SimulateContractReturnType<TChainOverride extends Chain ? TChainOverride : TChain, TAbi, TFunctionName>>;
791
- uninstallFilter: (args: UninstallFilterParameters) => Promise<UninstallFilterReturnType>;
792
- waitForTransactionReceipt: (args: WaitForTransactionReceiptParameters<TChain>) => Promise<WaitForTransactionReceiptReturnType<TChain>>;
793
- watchBlockNumber: (args: WatchBlockNumberParameters) => ReturnType<typeof watchBlockNumber>;
794
- watchBlocks: (args: WatchBlocksParameters<TChain>) => ReturnType<typeof watchBlocks>;
795
- watchContractEvent: <TAbi extends Abi | readonly unknown[], TEventName extends string>(args: WatchContractEventParameters<TAbi, TEventName>) => ReturnType<typeof watchContractEvent>;
796
- watchEvent: <TAbiEvent extends AbiEvent | undefined, TEventName extends string | undefined>(args: WatchEventParameters<TAbiEvent>) => ReturnType<typeof watchEvent>;
797
- watchPendingTransactions: (args: WatchPendingTransactionsParameters) => ReturnType<typeof watchPendingTransactions>;
798
- };
799
-
800
- type WalletClientConfig<TTransport extends Transport = Transport, TChain extends Chain = Chain> = {
801
- chain?: ClientConfig<TTransport, TChain>['chain'];
802
- /** The key of the Wallet Client. */
803
- key?: ClientConfig['key'];
804
- /** The name of the Wallet Client. */
805
- name?: ClientConfig['name'];
806
- /** Frequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds. */
807
- pollingInterval?: ClientConfig['pollingInterval'];
808
- transport: ClientConfig<TTransport, TChain>['transport'];
809
- };
810
- type WalletClient<TTransport extends Transport = Transport, TChain extends Chain = Chain, TIncludeActions extends boolean = true> = Client<TTransport, TChain> & (TIncludeActions extends true ? WalletActions<TChain> : {});
811
- /**
812
- * @description Creates a wallet client with a given transport.
813
- */
814
- declare function createWalletClient<TTransport extends Transport, TChain extends Chain>({ chain, transport, key, name, pollingInterval, }: WalletClientConfig<TTransport, TChain>): WalletClient<TTransport, TChain, true>;
815
-
816
- type WalletActions<TChain extends Chain = Chain> = {
817
- addChain: (args: AddChainParameters) => Promise<void>;
818
- deployContract: <TAbi extends Abi | readonly unknown[]>(args: DeployContractParameters<TChain, TAbi>) => Promise<DeployContractReturnType>;
819
- getAddresses: () => Promise<GetAddressesReturnType>;
820
- getChainId: () => Promise<GetChainIdReturnType>;
821
- getPermissions: () => Promise<GetPermissionsReturnType>;
822
- requestAddresses: () => Promise<RequestAddressesReturnType>;
823
- requestPermissions: (args: RequestPermissionsParameters) => Promise<RequestPermissionsReturnType>;
824
- sendTransaction: <TChainOverride extends Chain>(args: SendTransactionParameters<TChainOverride>) => Promise<SendTransactionReturnType>;
825
- signMessage: (args: SignMessageParameters) => Promise<SignMessageReturnType>;
826
- signTypedData: <TTypedData extends TypedData | {
827
- [key: string]: unknown;
828
- }, TPrimaryType extends string>(args: SignTypedDataParameters<TTypedData, TPrimaryType>) => Promise<SignTypedDataReturnType>;
829
- switchChain: (args: SwitchChainParameters) => Promise<void>;
830
- watchAsset: (args: WatchAssetParameters) => Promise<WatchAssetReturnType>;
831
- writeContract: <TAbi extends Abi | readonly unknown[], TFunctionName extends string, TChainOverride extends Chain>(args: WriteContractParameters<TChainOverride, TAbi, TFunctionName>) => Promise<WriteContractReturnType>;
832
- };
833
-
834
- type PublicClientConfig<TTransport extends Transport = Transport, TChain extends Chain = Chain> = Pick<ClientConfig<TTransport, TChain>, 'chain' | 'key' | 'name' | 'pollingInterval' | 'transport'>;
835
- type PublicClient<TTransport extends Transport = Transport, TChain extends Chain = Chain, TIncludeActions extends boolean = true> = Client<TTransport, TChain, PublicRequests> & (TIncludeActions extends true ? PublicActions<TChain> : {});
836
- /**
837
- * @description Creates a public client with a given transport.
838
- */
839
- declare function createPublicClient<TTransport extends Transport, TChain extends Chain>({ chain, key, name, transport, pollingInterval, }: PublicClientConfig<TTransport, TChain>): PublicClient<TTransport, TChain, true>;
840
-
841
- export { writeContract as $, Account as A, BlockFormatter as B, CallParameters as C, estimateContractGas as D, EstimateGasParameters as E, FormattedBlock as F, GetBytecodeParameters as G, getBytecode as H, getStorageAt as I, JsonRpcAccount as J, multicall as K, LocalAccount as L, MulticallParameters as M, readContract as N, OnLogsFn as O, PublicClient as P, simulateContract as Q, ReadContractParameters as R, SendTransactionParameters as S, TransactionReceiptFormatter as T, watchContractEvent as U, DeployContractParameters as V, WalletClient as W, DeployContractReturnType as X, WriteContractParameters as Y, WriteContractReturnType as Z, deployContract as _, PublicClientConfig as a, OnTransactionsFn as a$, GetEnsAddressParameters as a0, GetEnsNameParameters as a1, getEnsAddress as a2, getEnsName as a3, call as a4, createBlockFilter as a5, createEventFilter as a6, createPendingTransactionFilter as a7, estimateGas as a8, getBalance as a9, GetBalanceParameters as aA, GetBalanceReturnType as aB, GetBlockParameters as aC, GetBlockNumberParameters as aD, GetBlockNumberReturnType as aE, GetBlockReturnType as aF, GetBlockTransactionCountParameters as aG, GetBlockTransactionCountReturnType as aH, GetFeeHistoryParameters as aI, GetFeeHistoryReturnType as aJ, GetFilterChangesParameters as aK, GetFilterChangesReturnType as aL, GetFilterLogsParameters as aM, GetFilterLogsReturnType as aN, GetGasPriceReturnType as aO, GetTransactionParameters as aP, GetTransactionConfirmationsParameters as aQ, GetTransactionConfirmationsReturnType as aR, GetTransactionCountParameters as aS, GetTransactionCountReturnType as aT, GetTransactionReceiptParameters as aU, GetTransactionReceiptReturnType as aV, GetTransactionReturnType as aW, OnBlock as aX, OnBlockNumberFn as aY, OnBlockNumberParameter as aZ, OnBlockParameter as a_, getBlock as aa, getBlockNumber as ab, getBlockNumberCache as ac, getBlockTransactionCount as ad, getChainId as ae, getFeeHistory as af, getFilterChanges as ag, getFilterLogs as ah, getLogs as ai, getGasPrice as aj, getTransaction as ak, getTransactionConfirmations as al, getTransactionCount as am, getTransactionReceipt as an, uninstallFilter as ao, waitForTransactionReceipt as ap, watchBlockNumber as aq, watchBlocks as ar, watchEvent as as, watchPendingTransactions as at, CallReturnType as au, CreateBlockFilterReturnType as av, CreateEventFilterParameters as aw, CreateEventFilterReturnType as ax, CreatePendingTransactionFilterReturnType as ay, EstimateGasReturnType as az, WalletClientConfig as b, OnTransactionsParameter as b0, ReplacementReason as b1, ReplacementReturnType as b2, UninstallFilterParameters as b3, UninstallFilterReturnType as b4, WaitForTransactionReceiptParameters as b5, WaitForTransactionReceiptReturnType as b6, WatchBlockNumberParameters as b7, WatchBlocksParameters as b8, WatchPendingTransactionsParameters as b9, addChain as ba, getAddresses as bb, getPermissions as bc, requestAddresses as bd, requestPermissions as be, sendTransaction as bf, signMessage as bg, signTypedData as bh, switchChain as bi, watchAsset as bj, AddChainParameters as bk, FormattedTransactionRequest as bl, GetPermissionsReturnType as bm, GetAddressesReturnType as bn, RequestAddressesReturnType as bo, RequestPermissionsReturnType as bp, SendTransactionReturnType as bq, SignMessageParameters as br, SignMessageReturnType as bs, SignTypedDataParameters as bt, SignTypedDataReturnType as bu, SwitchChainParameters as bv, WatchAssetParameters as bw, WatchAssetReturnType as bx, createPublicClient as c, createWalletClient as d, FormattedTransactionReceipt as e, FormattedTransactionRequest$1 as f, TransactionRequestFormatter as g, defineBlock as h, defineTransactionReceipt as i, defineTransactionRequest as j, formatBlock as k, formatTransactionRequest as l, CreateContractEventFilterParameters as m, CreateContractEventFilterReturnType as n, EstimateContractGasParameters as o, EstimateContractGasReturnType as p, GetBytecodeReturnType as q, GetStorageAtParameters as r, GetStorageAtReturnType as s, MulticallReturnType as t, OnLogsParameter as u, ReadContractReturnType as v, SimulateContractParameters as w, SimulateContractReturnType as x, WatchContractEventParameters as y, createContractEventFilter as z };