viem 0.0.0 → 0.0.1-alpha.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.
- package/LICENSE +21 -0
- package/actions/package.json +4 -0
- package/chains/package.json +4 -0
- package/clients/package.json +4 -0
- package/dist/BaseError-7688f84e.d.ts +18 -0
- package/dist/actions/index.d.ts +12 -0
- package/dist/actions/index.js +121 -0
- package/dist/chains.d.ts +113 -0
- package/dist/chains.js +133 -0
- package/dist/chunk-GI67STNV.js +1469 -0
- package/dist/chunk-JSYJDK4W.js +1032 -0
- package/dist/chunk-OPR6LKYX.js +251 -0
- package/dist/clients/index.d.ts +8 -0
- package/dist/clients/index.js +23 -0
- package/dist/createWalletClient-c40fef16.d.ts +130 -0
- package/dist/eip1193-8f7c22ce.d.ts +987 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +278 -0
- package/dist/parseGwei-a7d0bcb2.d.ts +275 -0
- package/dist/rpc-3c0e3985.d.ts +98 -0
- package/dist/rpc-655c0ba4.d.ts +292 -0
- package/dist/transactionRequest-ade896ac.d.ts +44 -0
- package/dist/utils/index.d.ts +17 -0
- package/dist/utils/index.js +150 -0
- package/dist/watchAsset-bb30848d.d.ts +535 -0
- package/dist/webSocket-14584a7e.d.ts +77 -0
- package/dist/window.d.ts +9 -0
- package/dist/window.js +0 -0
- package/package.json +60 -7
- package/utils/package.json +4 -0
- package/window/package.json +4 -0
@@ -0,0 +1,535 @@
|
|
1
|
+
import { Chain, Formatter } from './chains.js';
|
2
|
+
import { H as Hex, d as BlockTag, M as MergeIntersectionProperties, v as TransactionRequest, K as EstimateGasParameters, A as Address, k as Hash, F as FeeHistory, L as Log, r as RpcTransactionReceipt, T as TransactionReceipt, N as TransactionType, D as Transaction, q as RpcTransaction, Q as Quantity, f as ByteArray } from './rpc-655c0ba4.js';
|
3
|
+
import { T as TransactionRequestFormatter, e as Formatted, F as FormattedBlock, B as BlockFormatter, a as FormattedTransaction, g as TransactionFormatter, h as FormattedTransactionReceipt, i as TransactionReceiptFormatter, E as ExtractFormatter } from './transactionRequest-ade896ac.js';
|
4
|
+
import { P as PublicClient, T as TestClient, W as WalletClient } from './createWalletClient-c40fef16.js';
|
5
|
+
import { B as BaseError } from './BaseError-7688f84e.js';
|
6
|
+
import { W as WalletPermission, a as WatchAssetParams } from './eip1193-8f7c22ce.js';
|
7
|
+
|
8
|
+
type FilterType = 'transaction' | 'block' | 'event';
|
9
|
+
type Filter<TFilterType extends FilterType = 'event'> = {
|
10
|
+
id: Hex;
|
11
|
+
type: TFilterType;
|
12
|
+
};
|
13
|
+
|
14
|
+
type FormattedCall<TFormatter extends Formatter | undefined = Formatter> = MergeIntersectionProperties<Formatted<TFormatter, TransactionRequest, true>, TransactionRequest>;
|
15
|
+
type CallArgs<TChain extends Chain = Chain> = {
|
16
|
+
chain?: TChain;
|
17
|
+
request: FormattedCall<TransactionRequestFormatter<TChain>>;
|
18
|
+
} & ({
|
19
|
+
/** The balance of the account at a block number. */
|
20
|
+
blockNumber?: bigint;
|
21
|
+
blockTag?: never;
|
22
|
+
} | {
|
23
|
+
blockNumber?: never;
|
24
|
+
/** The balance of the account at a block tag. */
|
25
|
+
blockTag?: BlockTag;
|
26
|
+
});
|
27
|
+
type CallResponse = {
|
28
|
+
data: Hex | undefined;
|
29
|
+
};
|
30
|
+
declare function call<TChain extends Chain>(client: PublicClient, { blockNumber, blockTag, chain, request }: CallArgs<TChain>): Promise<CallResponse>;
|
31
|
+
|
32
|
+
type CreatePendingTransactionFilterResponse = Filter<'transaction'>;
|
33
|
+
declare function createPendingTransactionFilter(client: PublicClient): Promise<CreatePendingTransactionFilterResponse>;
|
34
|
+
|
35
|
+
type CreateBlockFilterResponse = Filter<'block'>;
|
36
|
+
declare function createBlockFilter(client: PublicClient): Promise<CreateBlockFilterResponse>;
|
37
|
+
|
38
|
+
type EstimateGasArgs = {
|
39
|
+
request: EstimateGasParameters;
|
40
|
+
} & ({
|
41
|
+
/** The balance of the account at a block number. */
|
42
|
+
blockNumber?: bigint;
|
43
|
+
blockTag?: never;
|
44
|
+
} | {
|
45
|
+
blockNumber?: never;
|
46
|
+
/** The balance of the account at a block tag. */
|
47
|
+
blockTag?: BlockTag;
|
48
|
+
});
|
49
|
+
type EstimateGasResponse = bigint;
|
50
|
+
/**
|
51
|
+
* @description Estimates the gas necessary to complete a transaction without submitting it to the network.
|
52
|
+
*/
|
53
|
+
declare function estimateGas(client: PublicClient, { blockNumber, blockTag, request: { data, from, gas, gasPrice, maxFeePerGas, maxPriorityFeePerGas, to, value, }, }: EstimateGasArgs): Promise<EstimateGasResponse>;
|
54
|
+
|
55
|
+
type GetBalanceArgs = {
|
56
|
+
/** The address of the account. */
|
57
|
+
address: Address;
|
58
|
+
} & ({
|
59
|
+
/** The balance of the account at a block number. */
|
60
|
+
blockNumber?: bigint;
|
61
|
+
blockTag?: never;
|
62
|
+
} | {
|
63
|
+
blockNumber?: never;
|
64
|
+
/** The balance of the account at a block tag. */
|
65
|
+
blockTag?: BlockTag;
|
66
|
+
});
|
67
|
+
type GetBalanceResponse = bigint;
|
68
|
+
/**
|
69
|
+
* @description Returns the balance of an address in wei.
|
70
|
+
*/
|
71
|
+
declare function getBalance(client: PublicClient, { address, blockNumber, blockTag }: GetBalanceArgs): Promise<GetBalanceResponse>;
|
72
|
+
|
73
|
+
type GetBlockArgs = {
|
74
|
+
/** Whether or not to include transaction data in the response. */
|
75
|
+
includeTransactions?: boolean;
|
76
|
+
} & ({
|
77
|
+
/** Hash of the block. */
|
78
|
+
blockHash?: Hash;
|
79
|
+
blockNumber?: never;
|
80
|
+
blockTag?: never;
|
81
|
+
} | {
|
82
|
+
blockHash?: never;
|
83
|
+
/** The block number. */
|
84
|
+
blockNumber?: bigint;
|
85
|
+
blockTag?: never;
|
86
|
+
} | {
|
87
|
+
blockHash?: never;
|
88
|
+
blockNumber?: never;
|
89
|
+
/** The block tag. Defaults to 'latest'. */
|
90
|
+
blockTag?: BlockTag;
|
91
|
+
});
|
92
|
+
type GetBlockResponse<TChain extends Chain = Chain> = FormattedBlock<BlockFormatter<TChain>>;
|
93
|
+
declare function getBlock<TChain extends Chain>(client: PublicClient<any, TChain>, { blockHash, blockNumber, blockTag, includeTransactions, }?: GetBlockArgs): Promise<GetBlockResponse<TChain>>;
|
94
|
+
|
95
|
+
type GetBlockNumberArgs = {
|
96
|
+
/** The maximum age (in ms) of the cached value. */
|
97
|
+
maxAge?: number;
|
98
|
+
};
|
99
|
+
type GetBlockNumberResponse = bigint;
|
100
|
+
declare function getBlockNumberCache(id: string): {
|
101
|
+
clear: () => void;
|
102
|
+
promise: {
|
103
|
+
clear: () => boolean;
|
104
|
+
get: () => Promise<unknown> | undefined;
|
105
|
+
set: (data: Promise<unknown>) => Map<string, Promise<unknown>>;
|
106
|
+
};
|
107
|
+
response: {
|
108
|
+
clear: () => boolean;
|
109
|
+
get: () => {
|
110
|
+
created: Date;
|
111
|
+
data: unknown;
|
112
|
+
} | undefined;
|
113
|
+
set: (data: {
|
114
|
+
created: Date;
|
115
|
+
data: unknown;
|
116
|
+
}) => Map<string, {
|
117
|
+
created: Date;
|
118
|
+
data: unknown;
|
119
|
+
}>;
|
120
|
+
};
|
121
|
+
};
|
122
|
+
/**
|
123
|
+
* @description Returns the number of the most recent block seen.
|
124
|
+
*/
|
125
|
+
declare function getBlockNumber(client: PublicClient, { maxAge }?: GetBlockNumberArgs): Promise<GetBlockNumberResponse>;
|
126
|
+
|
127
|
+
type GetBlockTransactionCountArgs = {
|
128
|
+
/** Hash of the block. */
|
129
|
+
blockHash?: Hash;
|
130
|
+
blockNumber?: never;
|
131
|
+
blockTag?: never;
|
132
|
+
} | {
|
133
|
+
blockHash?: never;
|
134
|
+
/** The block number. */
|
135
|
+
blockNumber?: bigint;
|
136
|
+
blockTag?: never;
|
137
|
+
} | {
|
138
|
+
blockHash?: never;
|
139
|
+
blockNumber?: never;
|
140
|
+
/** The block tag. Defaults to 'latest'. */
|
141
|
+
blockTag?: BlockTag;
|
142
|
+
};
|
143
|
+
type GetBlockTransactionCountResponse = number;
|
144
|
+
declare function getBlockTransactionCount<TChain extends Chain>(client: PublicClient<any, TChain>, { blockHash, blockNumber, blockTag, }?: GetBlockTransactionCountArgs): Promise<GetBlockTransactionCountResponse>;
|
145
|
+
|
146
|
+
declare function getChainId(client: PublicClient): Promise<number>;
|
147
|
+
|
148
|
+
type GetFeeHistoryArgs = {
|
149
|
+
blockCount: number;
|
150
|
+
rewardPercentiles: number[];
|
151
|
+
} & ({
|
152
|
+
blockNumber?: never;
|
153
|
+
blockTag?: BlockTag;
|
154
|
+
} | {
|
155
|
+
blockNumber?: bigint;
|
156
|
+
blockTag?: never;
|
157
|
+
});
|
158
|
+
type GetFeeHistoryResponse = FeeHistory;
|
159
|
+
/**
|
160
|
+
* @description Returns a collection of historical gas information.
|
161
|
+
*/
|
162
|
+
declare function getFeeHistory(client: PublicClient, { blockCount, blockNumber, blockTag, rewardPercentiles, }: GetFeeHistoryArgs): Promise<GetFeeHistoryResponse>;
|
163
|
+
|
164
|
+
type GetFilterChangesArgs<TFilterType extends FilterType> = {
|
165
|
+
filter: Filter<TFilterType>;
|
166
|
+
};
|
167
|
+
type GetFilterChangesResponse<TFilterType extends FilterType> = TFilterType extends 'event' ? Log[] : Hash[];
|
168
|
+
declare function getFilterChanges<TFilterType extends FilterType>(client: PublicClient, { filter }: GetFilterChangesArgs<TFilterType>): Promise<GetFilterChangesResponse<TFilterType>>;
|
169
|
+
|
170
|
+
type GetGasPriceResponse = bigint;
|
171
|
+
/**
|
172
|
+
* @description Returns the current price of gas (in wei).
|
173
|
+
*/
|
174
|
+
declare function getGasPrice(client: PublicClient): Promise<GetGasPriceResponse>;
|
175
|
+
|
176
|
+
type GetTransactionArgs = {
|
177
|
+
/** The block hash */
|
178
|
+
blockHash: Hash;
|
179
|
+
blockNumber?: never;
|
180
|
+
blockTag?: never;
|
181
|
+
hash?: never;
|
182
|
+
/** The index of the transaction on the block. */
|
183
|
+
index: number;
|
184
|
+
} | {
|
185
|
+
blockHash?: never;
|
186
|
+
/** The block number */
|
187
|
+
blockNumber: bigint;
|
188
|
+
blockTag?: never;
|
189
|
+
hash?: never;
|
190
|
+
/** The index of the transaction on the block. */
|
191
|
+
index: number;
|
192
|
+
} | {
|
193
|
+
blockHash?: never;
|
194
|
+
blockNumber?: never;
|
195
|
+
/** The block tag. */
|
196
|
+
blockTag: BlockTag;
|
197
|
+
hash?: never;
|
198
|
+
/** The index of the transaction on the block. */
|
199
|
+
index: number;
|
200
|
+
} | {
|
201
|
+
blockHash?: never;
|
202
|
+
blockNumber?: never;
|
203
|
+
blockTag?: never;
|
204
|
+
/** The hash of the transaction. */
|
205
|
+
hash: Hash;
|
206
|
+
index?: number;
|
207
|
+
};
|
208
|
+
type GetTransactionResponse<TChain extends Chain = Chain> = FormattedTransaction<TransactionFormatter<TChain>>;
|
209
|
+
/** @description Returns information about a transaction given a hash or block identifier. */
|
210
|
+
declare function getTransaction<TChain extends Chain>(client: PublicClient<any, TChain>, { blockHash, blockNumber, blockTag, hash, index, }: GetTransactionArgs): Promise<GetTransactionResponse<TChain>>;
|
211
|
+
|
212
|
+
type GetTransactionConfirmationsArgs<TChain extends Chain> = {
|
213
|
+
/** The transaction hash. */
|
214
|
+
hash: Hash;
|
215
|
+
transactionReceipt?: never;
|
216
|
+
} | {
|
217
|
+
hash?: never;
|
218
|
+
/** The transaction receipt. */
|
219
|
+
transactionReceipt: FormattedTransactionReceipt<TransactionReceiptFormatter<TChain>>;
|
220
|
+
};
|
221
|
+
type GetTransactionConfirmationsResponse = bigint;
|
222
|
+
declare function getTransactionConfirmations<TChain extends Chain>(client: PublicClient<any, TChain>, { hash, transactionReceipt }: GetTransactionConfirmationsArgs<TChain>): Promise<GetTransactionConfirmationsResponse>;
|
223
|
+
|
224
|
+
type GetTransactionCountArgs = {
|
225
|
+
/** The account address. */
|
226
|
+
address: Address;
|
227
|
+
} & ({
|
228
|
+
/** The block number. */
|
229
|
+
blockNumber?: bigint;
|
230
|
+
blockTag?: never;
|
231
|
+
} | {
|
232
|
+
blockNumber?: never;
|
233
|
+
/** The block tag. Defaults to 'latest'. */
|
234
|
+
blockTag?: BlockTag;
|
235
|
+
});
|
236
|
+
type GetTransactionCountResponse = number;
|
237
|
+
/**
|
238
|
+
* @description Returns the number of transactions an account has broadcast / sent.
|
239
|
+
*/
|
240
|
+
declare function getTransactionCount(client: PublicClient, { address, blockTag, blockNumber }: GetTransactionCountArgs): Promise<GetTransactionCountResponse>;
|
241
|
+
|
242
|
+
type GetTransactionReceiptArgs = {
|
243
|
+
/** The hash of the transaction. */
|
244
|
+
hash: Hash;
|
245
|
+
};
|
246
|
+
type GetTransactionReceiptResponse<TChain extends Chain = Chain> = FormattedTransactionReceipt<TransactionReceiptFormatter<TChain>>;
|
247
|
+
declare function getTransactionReceipt<TChain extends Chain>(client: PublicClient<any, TChain>, { hash }: GetTransactionReceiptArgs): Promise<Formatted<ExtractFormatter<TChain, "transactionReceipt", Formatter<RpcTransactionReceipt, TransactionReceipt<bigint, number, "success" | "reverted", TransactionType>>>, TransactionReceipt<bigint, number, "success" | "reverted", TransactionType>, false>>;
|
248
|
+
|
249
|
+
type UninstallFilterArgs = {
|
250
|
+
filter: Filter<any>;
|
251
|
+
};
|
252
|
+
type UninstallFilterResponse = boolean;
|
253
|
+
declare function uninstallFilter(client: PublicClient, { filter }: UninstallFilterArgs): Promise<UninstallFilterResponse>;
|
254
|
+
|
255
|
+
type ReplacementReason = 'cancelled' | 'replaced' | 'repriced';
|
256
|
+
type ReplacementResponse<TChain extends Chain = Chain> = {
|
257
|
+
reason: ReplacementReason;
|
258
|
+
replacedTransaction: Transaction;
|
259
|
+
transaction: Transaction;
|
260
|
+
transactionReceipt: GetTransactionReceiptResponse<TChain>;
|
261
|
+
};
|
262
|
+
type WaitForTransactionReceiptResponse<TChain extends Chain = Chain> = GetTransactionReceiptResponse<TChain>;
|
263
|
+
type WaitForTransactionReceiptArgs<TChain extends Chain = Chain> = {
|
264
|
+
/** The number of confirmations (blocks that have passed) to wait before resolving. */
|
265
|
+
confirmations?: number;
|
266
|
+
/** The hash of the transaction. */
|
267
|
+
hash: Hash;
|
268
|
+
onReplaced?: (response: ReplacementResponse<TChain>) => void;
|
269
|
+
/** Polling frequency (in ms). Defaults to the client's pollingInterval config. */
|
270
|
+
pollingInterval?: number;
|
271
|
+
/** Optional timeout (in milliseconds) to wait before stopping polling. */
|
272
|
+
timeout?: number;
|
273
|
+
};
|
274
|
+
declare function waitForTransactionReceipt<TChain extends Chain>(client: PublicClient<any, TChain>, { confirmations, hash, onReplaced, pollingInterval, timeout, }: WaitForTransactionReceiptArgs<TChain>): Promise<WaitForTransactionReceiptResponse<TChain>>;
|
275
|
+
declare class WaitForTransactionReceiptTimeoutError extends BaseError {
|
276
|
+
name: string;
|
277
|
+
constructor({ hash }: {
|
278
|
+
hash: Hash;
|
279
|
+
});
|
280
|
+
}
|
281
|
+
|
282
|
+
type OnBlockNumberResponse = GetBlockNumberResponse;
|
283
|
+
type OnBlockNumber = (blockNumber: OnBlockNumberResponse, prevBlockNumber: OnBlockNumberResponse | undefined) => void;
|
284
|
+
type WatchBlockNumberArgs = {
|
285
|
+
/** Whether or not to emit the missed block numbers to the callback. */
|
286
|
+
emitMissed?: boolean;
|
287
|
+
/** Whether or not to emit the latest block number to the callback when the subscription opens. */
|
288
|
+
emitOnBegin?: boolean;
|
289
|
+
/** The callback to call when a new block number is received. */
|
290
|
+
onBlockNumber: OnBlockNumber;
|
291
|
+
/** The callback to call when an error occurred when trying to get for a new block. */
|
292
|
+
onError?: (error: Error) => void;
|
293
|
+
/** Polling frequency (in ms). Defaults to Client's pollingInterval config. */
|
294
|
+
pollingInterval?: number;
|
295
|
+
};
|
296
|
+
/** @description Watches and returns incoming block numbers. */
|
297
|
+
declare function watchBlockNumber(client: PublicClient, { emitOnBegin, emitMissed, onBlockNumber, onError, pollingInterval, }: WatchBlockNumberArgs): () => void;
|
298
|
+
|
299
|
+
type OnBlockResponse<TChain extends Chain = Chain> = GetBlockResponse<TChain>;
|
300
|
+
type OnBlock<TChain extends Chain = Chain> = (block: OnBlockResponse<TChain>, prevBlock: OnBlockResponse<TChain> | undefined) => void;
|
301
|
+
type WatchBlocksArgs<TChain extends Chain = Chain> = {
|
302
|
+
/** The block tag. Defaults to "latest". */
|
303
|
+
blockTag?: BlockTag;
|
304
|
+
/** Whether or not to emit the missed blocks to the callback. */
|
305
|
+
emitMissed?: boolean;
|
306
|
+
/** Whether or not to emit the block to the callback when the subscription opens. */
|
307
|
+
emitOnBegin?: boolean;
|
308
|
+
/** The callback to call when a new block is received. */
|
309
|
+
onBlock: OnBlock<TChain>;
|
310
|
+
/** The callback to call when an error occurred when trying to get for a new block. */
|
311
|
+
onError?: (error: Error) => void;
|
312
|
+
/** Whether or not to include transaction data in the response. */
|
313
|
+
includeTransactions?: boolean;
|
314
|
+
/** Polling frequency (in ms). Defaults to the client's pollingInterval config. */
|
315
|
+
pollingInterval?: number;
|
316
|
+
};
|
317
|
+
/** @description Watches and returns information for incoming blocks. */
|
318
|
+
declare function watchBlocks<TChain extends Chain>(client: PublicClient<any, TChain>, { blockTag, emitMissed, emitOnBegin, onBlock, onError, includeTransactions, pollingInterval, }: WatchBlocksArgs<TChain>): () => void;
|
319
|
+
|
320
|
+
type OnTransactionsResponse = Hash[];
|
321
|
+
type OnTransactions = (transactions: OnTransactionsResponse) => void;
|
322
|
+
type WatchPendingTransactionsArgs = {
|
323
|
+
/** Whether or not the transaction hashes should be batched on each invocation. */
|
324
|
+
batch?: boolean;
|
325
|
+
/** The callback to call when an error occurred when trying to get for a new block. */
|
326
|
+
onError?: (error: Error) => void;
|
327
|
+
/** The callback to call when new transactions are received. */
|
328
|
+
onTransactions: OnTransactions;
|
329
|
+
/** Polling frequency (in ms). Defaults to Client's pollingInterval config. */
|
330
|
+
pollingInterval?: number;
|
331
|
+
};
|
332
|
+
declare function watchPendingTransactions(client: PublicClient, { batch, onError, onTransactions, pollingInterval, }: WatchPendingTransactionsArgs): () => void;
|
333
|
+
|
334
|
+
type DropTransactionArgs = {
|
335
|
+
/** The hash of the transaction to drop. */
|
336
|
+
hash: Hash;
|
337
|
+
};
|
338
|
+
declare function dropTransaction(client: TestClient, { hash }: DropTransactionArgs): Promise<void>;
|
339
|
+
|
340
|
+
type GetAutomineResponse = boolean;
|
341
|
+
declare function getAutomine(client: TestClient): Promise<GetAutomineResponse>;
|
342
|
+
|
343
|
+
declare function getTxpoolContent(client: TestClient): Promise<{
|
344
|
+
pending: Record<`0x${string}`, Record<string, RpcTransaction>>;
|
345
|
+
queued: Record<`0x${string}`, Record<string, RpcTransaction>>;
|
346
|
+
}>;
|
347
|
+
|
348
|
+
declare function getTxpoolStatus(client: TestClient): Promise<{
|
349
|
+
pending: number;
|
350
|
+
queued: number;
|
351
|
+
}>;
|
352
|
+
|
353
|
+
type ImpersonateAccountArgs = {
|
354
|
+
/** The account to impersonate. */
|
355
|
+
address: Address;
|
356
|
+
};
|
357
|
+
declare function impersonateAccount(client: TestClient, { address }: ImpersonateAccountArgs): Promise<void>;
|
358
|
+
|
359
|
+
type IncreaseTimeArgs = {
|
360
|
+
/** The amount of seconds to jump forward in time. */
|
361
|
+
seconds: number;
|
362
|
+
};
|
363
|
+
declare function increaseTime(client: TestClient, { seconds }: IncreaseTimeArgs): Promise<`0x${string}`>;
|
364
|
+
|
365
|
+
declare function inspectTxpool(client: TestClient): Promise<{
|
366
|
+
pending: Record<`0x${string}`, Record<string, string>>;
|
367
|
+
queued: Record<`0x${string}`, Record<string, string>>;
|
368
|
+
}>;
|
369
|
+
|
370
|
+
type MineArgs = {
|
371
|
+
/** Number of blocks to mine. */
|
372
|
+
blocks: number;
|
373
|
+
/** Interval between each block in seconds. */
|
374
|
+
interval?: number;
|
375
|
+
};
|
376
|
+
declare function mine(client: TestClient, { blocks, interval }: MineArgs): Promise<void>;
|
377
|
+
|
378
|
+
declare function removeBlockTimestampInterval(client: TestClient): Promise<void>;
|
379
|
+
|
380
|
+
type ResetArgs = {
|
381
|
+
/** The block number to reset from. */
|
382
|
+
blockNumber?: bigint;
|
383
|
+
/** The JSON RPC URL. */
|
384
|
+
jsonRpcUrl?: string;
|
385
|
+
};
|
386
|
+
declare function reset(client: TestClient, { blockNumber, jsonRpcUrl }?: ResetArgs): Promise<void>;
|
387
|
+
|
388
|
+
type RevertArgs = {
|
389
|
+
/** The snapshot ID to revert to. */
|
390
|
+
id: Quantity;
|
391
|
+
};
|
392
|
+
declare function revert(client: TestClient, { id }: RevertArgs): Promise<void>;
|
393
|
+
|
394
|
+
type SendUnsignedTransactionArgs = {
|
395
|
+
request: TransactionRequest;
|
396
|
+
};
|
397
|
+
type SendUnsignedTransactionResponse = {
|
398
|
+
hash: `0x${string}`;
|
399
|
+
};
|
400
|
+
declare function sendUnsignedTransaction(client: TestClient, { request }: SendUnsignedTransactionArgs): Promise<SendUnsignedTransactionResponse>;
|
401
|
+
|
402
|
+
declare function setAutomine(client: TestClient, enabled: boolean): Promise<void>;
|
403
|
+
|
404
|
+
type SetBalanceArgs = {
|
405
|
+
/** The account address. */
|
406
|
+
address: Address;
|
407
|
+
/** Amount (in wei) to set */
|
408
|
+
value: bigint;
|
409
|
+
};
|
410
|
+
declare function setBalance(client: TestClient, { address, value }: SetBalanceArgs): Promise<void>;
|
411
|
+
|
412
|
+
type SetBlockGasLimitArgs = {
|
413
|
+
/** Gas limit (in wei). */
|
414
|
+
gasLimit: bigint;
|
415
|
+
};
|
416
|
+
declare function setBlockGasLimit(client: TestClient, { gasLimit }: SetBlockGasLimitArgs): Promise<void>;
|
417
|
+
|
418
|
+
type SetBlockTimestampIntervalArgs = {
|
419
|
+
/** The interval (in seconds). */
|
420
|
+
interval: number;
|
421
|
+
};
|
422
|
+
declare function setBlockTimestampInterval(client: TestClient, { interval }: SetBlockTimestampIntervalArgs): Promise<void>;
|
423
|
+
|
424
|
+
type SetCodeArgs = {
|
425
|
+
/** The account address. */
|
426
|
+
address: Address;
|
427
|
+
/** The bytecode to set */
|
428
|
+
bytecode: Hex;
|
429
|
+
};
|
430
|
+
declare function setCode(client: TestClient, { address, bytecode }: SetCodeArgs): Promise<void>;
|
431
|
+
|
432
|
+
type SetCoinbaseArgs = {
|
433
|
+
/** The coinbase address. */
|
434
|
+
address: Address;
|
435
|
+
};
|
436
|
+
declare function setCoinbase(client: TestClient, { address }: SetCoinbaseArgs): Promise<void>;
|
437
|
+
|
438
|
+
type SetIntervalMiningArgs = {
|
439
|
+
/** The mining interval. */
|
440
|
+
interval: number;
|
441
|
+
};
|
442
|
+
declare function setIntervalMining(client: TestClient, { interval }: SetIntervalMiningArgs): Promise<void>;
|
443
|
+
|
444
|
+
declare function setLoggingEnabled(client: TestClient, enabled: boolean): Promise<void>;
|
445
|
+
|
446
|
+
type SetMinGasPriceArgs = {
|
447
|
+
/** The gas price. */
|
448
|
+
gasPrice: bigint;
|
449
|
+
};
|
450
|
+
declare function setMinGasPrice(client: TestClient, { gasPrice }: SetMinGasPriceArgs): Promise<void>;
|
451
|
+
|
452
|
+
type SetNextBlockBaseFeePerGasArgs = {
|
453
|
+
/** Base fee per gas (in wei). */
|
454
|
+
baseFeePerGas: bigint;
|
455
|
+
};
|
456
|
+
declare function setNextBlockBaseFeePerGas(client: TestClient, { baseFeePerGas }: SetNextBlockBaseFeePerGasArgs): Promise<void>;
|
457
|
+
|
458
|
+
type SetNextBlockTimestampArgs = {
|
459
|
+
/** The timestamp (in seconds). */
|
460
|
+
timestamp: bigint;
|
461
|
+
};
|
462
|
+
declare function setNextBlockTimestamp(client: TestClient, { timestamp }: SetNextBlockTimestampArgs): Promise<void>;
|
463
|
+
|
464
|
+
type SetNonceArgs = {
|
465
|
+
/** The account address. */
|
466
|
+
address: Address;
|
467
|
+
/** The nonce to set. */
|
468
|
+
nonce: number;
|
469
|
+
};
|
470
|
+
declare function setNonce(client: TestClient, { address, nonce }: SetNonceArgs): Promise<void>;
|
471
|
+
|
472
|
+
type SetStorageAtArgs = {
|
473
|
+
/** The account address. */
|
474
|
+
address: Address;
|
475
|
+
/** The storage slot (index). Can either be a number or hash value. */
|
476
|
+
index: number | Hash;
|
477
|
+
/** The value to store as a 32 byte hex string. */
|
478
|
+
value: Hex;
|
479
|
+
};
|
480
|
+
declare function setStorageAt(client: TestClient, { address, index, value }: SetStorageAtArgs): Promise<void>;
|
481
|
+
|
482
|
+
declare function snapshot(client: TestClient): Promise<`0x${string}`>;
|
483
|
+
|
484
|
+
type StopImpersonatingAccountArgs = {
|
485
|
+
/** The account to impersonate. */
|
486
|
+
address: Address;
|
487
|
+
};
|
488
|
+
declare function stopImpersonatingAccount(client: TestClient, { address }: StopImpersonatingAccountArgs): Promise<void>;
|
489
|
+
|
490
|
+
declare function addChain(client: WalletClient, chain: Chain): Promise<void>;
|
491
|
+
|
492
|
+
type GetPermissionsResponse = WalletPermission[];
|
493
|
+
declare function getPermissions(client: WalletClient): Promise<WalletPermission[]>;
|
494
|
+
|
495
|
+
declare function requestAccounts(client: WalletClient): Promise<`0x${string}`[]>;
|
496
|
+
|
497
|
+
type RequestPermissionsArgs = {
|
498
|
+
eth_accounts: Record<string, any>;
|
499
|
+
} & {
|
500
|
+
[key: string]: Record<string, any>;
|
501
|
+
};
|
502
|
+
type RequestPermissionsResponse = WalletPermission[];
|
503
|
+
declare function requestPermissions(client: WalletClient, permissions: RequestPermissionsArgs): Promise<WalletPermission[]>;
|
504
|
+
|
505
|
+
type FormattedTransactionRequest<TFormatter extends Formatter | undefined = Formatter> = MergeIntersectionProperties<Formatted<TFormatter, TransactionRequest, true>, TransactionRequest>;
|
506
|
+
type SendTransactionArgs<TChain extends Chain = Chain> = {
|
507
|
+
chain?: TChain;
|
508
|
+
request: FormattedTransactionRequest<TransactionRequestFormatter<TChain>>;
|
509
|
+
};
|
510
|
+
type SendTransactionResponse = {
|
511
|
+
hash: `0x${string}`;
|
512
|
+
};
|
513
|
+
declare function sendTransaction<TChain extends Chain>(client: WalletClient, { chain, request }: SendTransactionArgs<TChain>): Promise<SendTransactionResponse>;
|
514
|
+
declare class InvalidGasArgumentsError extends BaseError {
|
515
|
+
name: string;
|
516
|
+
constructor();
|
517
|
+
}
|
518
|
+
|
519
|
+
type SignMessageArgs = {
|
520
|
+
from: Address;
|
521
|
+
data: Hex | ByteArray;
|
522
|
+
};
|
523
|
+
type SignMessageResponse = Hex;
|
524
|
+
declare function signMessage(client: WalletClient, { from, data: data_ }: SignMessageArgs): Promise<SignMessageResponse>;
|
525
|
+
|
526
|
+
type SwitchChainArgs = {
|
527
|
+
id: Chain['id'];
|
528
|
+
};
|
529
|
+
declare function switchChain(client: WalletClient, { id }: SwitchChainArgs): Promise<void>;
|
530
|
+
|
531
|
+
type WatchAssetArgs = WatchAssetParams;
|
532
|
+
type WatchAssetResponse = boolean;
|
533
|
+
declare function watchAsset(client: WalletClient, params: WatchAssetParams): Promise<WatchAssetResponse>;
|
534
|
+
|
535
|
+
export { SetNextBlockBaseFeePerGasArgs as $, OnBlockNumber as A, OnBlockNumberResponse as B, CallArgs as C, DropTransactionArgs as D, EstimateGasArgs as E, OnBlockResponse as F, GetBalanceArgs as G, OnTransactions as H, ImpersonateAccountArgs as I, OnTransactionsResponse as J, RequestPermissionsResponse as K, RevertArgs as L, MineArgs as M, SendTransactionResponse as N, OnBlock as O, SendUnsignedTransactionArgs as P, SendUnsignedTransactionResponse as Q, ResetArgs as R, SendTransactionArgs as S, SetBalanceArgs as T, SetBlockGasLimitArgs as U, SetCodeArgs as V, SetCoinbaseArgs as W, SetIntervalMiningArgs as X, SetMinGasPriceArgs as Y, SetBlockTimestampIntervalArgs as Z, SetNextBlockTimestampArgs as _, CallResponse as a, switchChain as a$, SetNonceArgs as a0, SetStorageAtArgs as a1, SignMessageArgs as a2, SignMessageResponse as a3, StopImpersonatingAccountArgs as a4, SwitchChainArgs as a5, UninstallFilterArgs as a6, UninstallFilterResponse as a7, WaitForTransactionReceiptArgs as a8, WaitForTransactionReceiptResponse as a9, impersonateAccount as aA, increaseTime as aB, inspectTxpool as aC, mine as aD, removeBlockTimestampInterval as aE, reset as aF, requestAccounts as aG, requestPermissions as aH, revert as aI, sendTransaction as aJ, sendUnsignedTransaction as aK, setAutomine as aL, setBalance as aM, setBlockGasLimit as aN, setBlockTimestampInterval as aO, setCode as aP, setCoinbase as aQ, setIntervalMining as aR, setLoggingEnabled as aS, setMinGasPrice as aT, setNextBlockBaseFeePerGas as aU, setNextBlockTimestamp as aV, setNonce as aW, setStorageAt as aX, signMessage as aY, snapshot as aZ, stopImpersonatingAccount as a_, WatchAssetArgs as aa, WatchAssetResponse as ab, WatchBlockNumberArgs as ac, WatchBlocksArgs as ad, WatchPendingTransactionsArgs as ae, addChain as af, call as ag, createBlockFilter as ah, createPendingTransactionFilter as ai, estimateGas as aj, dropTransaction as ak, getAutomine as al, getBalance as am, getBlock as an, getBlockNumber as ao, getBlockTransactionCount as ap, getChainId as aq, getFeeHistory as ar, getGasPrice as as, getPermissions as at, getTransaction as au, getTransactionConfirmations as av, getTransactionCount as aw, getTransactionReceipt as ax, getTxpoolContent as ay, getTxpoolStatus as az, CreateBlockFilterResponse as b, uninstallFilter as b0, waitForTransactionReceipt as b1, watchAsset as b2, watchBlockNumber as b3, watchBlocks as b4, watchPendingTransactions as b5, getBlockNumberCache as b6, getFilterChanges as b7, ReplacementReason as b8, ReplacementResponse as b9, WaitForTransactionReceiptTimeoutError as ba, FormattedTransactionRequest as bb, InvalidGasArgumentsError as bc, CreatePendingTransactionFilterResponse as c, EstimateGasResponse as d, GetBalanceResponse as e, GetBlockArgs as f, GetBlockNumberArgs as g, GetBlockNumberResponse as h, GetBlockResponse as i, GetBlockTransactionCountArgs as j, GetBlockTransactionCountResponse as k, GetFeeHistoryArgs as l, GetFeeHistoryResponse as m, GetFilterChangesArgs as n, GetFilterChangesResponse as o, GetGasPriceResponse as p, GetPermissionsResponse as q, GetTransactionArgs as r, GetTransactionConfirmationsArgs as s, GetTransactionConfirmationsResponse as t, GetTransactionCountArgs as u, GetTransactionCountResponse as v, GetTransactionResponse as w, GetTransactionReceiptArgs as x, GetTransactionReceiptResponse as y, IncreaseTimeArgs as z };
|
@@ -0,0 +1,77 @@
|
|
1
|
+
import { B as BaseError } from './BaseError-7688f84e.js';
|
2
|
+
import { e as TransportConfig, d as Transport, B as BaseRpcRequests } from './createWalletClient-c40fef16.js';
|
3
|
+
import { k as Hash } from './rpc-655c0ba4.js';
|
4
|
+
import { a as RpcResponse } from './rpc-3c0e3985.js';
|
5
|
+
|
6
|
+
declare class UrlRequiredError extends BaseError {
|
7
|
+
constructor();
|
8
|
+
}
|
9
|
+
|
10
|
+
type EthereumProvider = {
|
11
|
+
request: BaseRpcRequests['request'];
|
12
|
+
};
|
13
|
+
type EthereumProviderTransportConfig<TProvider> = {
|
14
|
+
/** The key of the transport. */
|
15
|
+
key?: TransportConfig['key'];
|
16
|
+
/** The name of the transport. */
|
17
|
+
name?: TransportConfig['name'];
|
18
|
+
/** An EIP-1193 or equivalent provider with a "request" function. */
|
19
|
+
provider: TProvider;
|
20
|
+
};
|
21
|
+
type EthereumProviderTransport = Transport<'ethereumProvider', EthereumProvider['request']>;
|
22
|
+
/**
|
23
|
+
* @description Creates a transport based on an EIP-1193 provider (eg. `window.ethereum`).
|
24
|
+
*/
|
25
|
+
declare function ethereumProvider<TProvider extends EthereumProvider>({ key, name, provider, }: EthereumProviderTransportConfig<TProvider>): EthereumProviderTransport;
|
26
|
+
|
27
|
+
type HttpTransportConfig = {
|
28
|
+
/** The key of the HTTP transport. */
|
29
|
+
key?: TransportConfig['key'];
|
30
|
+
/** The name of the HTTP transport. */
|
31
|
+
name?: TransportConfig['name'];
|
32
|
+
/** URL of the JSON-RPC API. Defaults to the chain's public RPC URL. */
|
33
|
+
url?: string;
|
34
|
+
};
|
35
|
+
type HttpTransport = Transport<'http', {
|
36
|
+
url?: string;
|
37
|
+
}>;
|
38
|
+
/**
|
39
|
+
* @description Creates a HTTP transport that connects to a JSON-RPC API.
|
40
|
+
*/
|
41
|
+
declare function http({ key, name, url, }?: HttpTransportConfig): HttpTransport;
|
42
|
+
|
43
|
+
type WebSocketTransportSubscribeArgs = {
|
44
|
+
onData: (data: RpcResponse) => void;
|
45
|
+
onError?: (error: any) => void;
|
46
|
+
};
|
47
|
+
type WebSocketTransportSubscribeResponse = {
|
48
|
+
subscriptionId: Hash;
|
49
|
+
unsubscribe: () => Promise<RpcResponse<boolean>>;
|
50
|
+
};
|
51
|
+
type WebSocketTransportSubscribe = {
|
52
|
+
subscribe(args: WebSocketTransportSubscribeArgs & {
|
53
|
+
/**
|
54
|
+
* @description Add information about compiled contracts
|
55
|
+
* @link https://hardhat.org/hardhat-network/docs/reference#hardhat_addcompilationresult
|
56
|
+
*/
|
57
|
+
params: ['newHeads'];
|
58
|
+
}): Promise<WebSocketTransportSubscribeResponse>;
|
59
|
+
};
|
60
|
+
type WebSocketTransportConfig = {
|
61
|
+
/** The key of the WebSocket transport. */
|
62
|
+
key?: TransportConfig['key'];
|
63
|
+
/** The name of the WebSocket transport. */
|
64
|
+
name?: TransportConfig['name'];
|
65
|
+
/** URL of the JSON-RPC API. Defaults to the chain's public RPC URL. */
|
66
|
+
url?: string;
|
67
|
+
};
|
68
|
+
type WebSocketTransport = Transport<'webSocket', {
|
69
|
+
getSocket(): Promise<WebSocket>;
|
70
|
+
subscribe: WebSocketTransportSubscribe['subscribe'];
|
71
|
+
}>;
|
72
|
+
/**
|
73
|
+
* @description Creates a WebSocket transport that connects to a JSON-RPC API.
|
74
|
+
*/
|
75
|
+
declare function webSocket({ key, name, url, }?: WebSocketTransportConfig): WebSocketTransport;
|
76
|
+
|
77
|
+
export { EthereumProviderTransport as E, HttpTransport as H, UrlRequiredError as U, WebSocketTransport as W, EthereumProviderTransportConfig as a, HttpTransportConfig as b, WebSocketTransportConfig as c, ethereumProvider as e, http as h, webSocket as w };
|
package/dist/window.d.ts
ADDED
package/dist/window.js
ADDED
File without changes
|