viem 0.0.0 → 0.0.1-alpha.1

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