viem 0.0.1-alpha.24 → 0.0.1-alpha.25

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 (154) hide show
  1. package/contract/package.json +4 -0
  2. package/dist/call-ac509982.d.ts +23 -0
  3. package/dist/{chain-e33d019b.d.ts → chain-c4ccb458.d.ts} +1 -1
  4. package/dist/{chain-afa13f5a.d.ts → chain-f16512e8.d.ts} +20 -1
  5. package/dist/chains.d.ts +20 -8
  6. package/dist/chains.js +46 -46
  7. package/dist/chains.mjs +1 -1
  8. package/dist/{chunk-YQUC52RL.mjs → chunk-2Y3UZMSP.mjs} +77 -84
  9. package/dist/chunk-2Y3UZMSP.mjs.map +1 -0
  10. package/dist/{chunk-A2HXAZXC.js → chunk-CD2XJOBJ.js} +135 -142
  11. package/dist/chunk-CD2XJOBJ.js.map +1 -0
  12. package/dist/{chunk-LQVMDX5I.mjs → chunk-KSAO4Y4Q.mjs} +133 -54
  13. package/dist/chunk-KSAO4Y4Q.mjs.map +1 -0
  14. package/dist/{chunk-3ARWEJ3G.mjs → chunk-LEPQJNVO.mjs} +18 -2
  15. package/dist/chunk-LEPQJNVO.mjs.map +1 -0
  16. package/dist/{chunk-ZYSXBTBB.js → chunk-NUXMGPMK.js} +30 -14
  17. package/dist/chunk-NUXMGPMK.js.map +1 -0
  18. package/dist/{chunk-4D5XG6XB.js → chunk-THMRUG4D.js} +148 -69
  19. package/dist/chunk-THMRUG4D.js.map +1 -0
  20. package/dist/{contract-70f4ddbe.d.ts → contract-9e76e561.d.ts} +44 -31
  21. package/dist/contract.d.ts +123 -0
  22. package/dist/contract.js +53 -0
  23. package/dist/{clients/index.js.map → contract.js.map} +0 -0
  24. package/dist/contract.mjs +53 -0
  25. package/dist/{clients/index.mjs.map → contract.mjs.map} +0 -0
  26. package/dist/{createClient-60e3ab98.d.ts → createClient-68ee4bb4.d.ts} +3 -3
  27. package/dist/{createPublicClient-d3d12dc3.d.ts → createPublicClient-b732194e.d.ts} +3 -3
  28. package/dist/{createTestClient-5f4532c4.d.ts → createTestClient-dedf321e.d.ts} +3 -3
  29. package/dist/{createWalletClient-9ec3df4f.d.ts → createWalletClient-75813d83.d.ts} +3 -3
  30. package/dist/decodeErrorResult-0b934d23.d.ts +16 -0
  31. package/dist/{eip1193-9317a312.d.ts → eip1193-6f9ba163.d.ts} +1 -1
  32. package/dist/ens.d.ts +82 -1
  33. package/dist/ens.js +208 -3
  34. package/dist/ens.js.map +1 -1
  35. package/dist/ens.mjs +209 -4
  36. package/dist/ens.mjs.map +1 -1
  37. package/dist/getAbiItem-c8e6e7d4.d.ts +97 -0
  38. package/dist/index.d.ts +85 -175
  39. package/dist/index.js +237 -279
  40. package/dist/index.js.map +1 -1
  41. package/dist/index.mjs +245 -287
  42. package/dist/index.mjs.map +1 -1
  43. package/dist/public.d.ts +352 -10
  44. package/dist/public.js +3 -4
  45. package/dist/public.mjs +6 -7
  46. package/dist/readContract-4f6e2692.d.ts +10 -0
  47. package/dist/rpc-a5a7f376.d.ts +121 -0
  48. package/dist/{sendTransaction-54a0d509.d.ts → sendTransaction-e713f90c.d.ts} +3 -3
  49. package/dist/test.d.ts +160 -5
  50. package/dist/test.js +222 -18
  51. package/dist/test.js.map +1 -1
  52. package/dist/test.mjs +233 -29
  53. package/dist/test.mjs.map +1 -1
  54. package/dist/transactionReceipt-2a86c7c7.d.ts +26 -0
  55. package/dist/{transactionRequest-bdf57f7d.d.ts → transactionRequest-c7794f5e.d.ts} +1 -1
  56. package/dist/utils/index.d.ts +224 -20
  57. package/dist/utils/index.js +2 -6
  58. package/dist/utils/index.mjs +3 -7
  59. package/dist/wallet.d.ts +41 -7
  60. package/dist/wallet.js +3 -3
  61. package/dist/wallet.mjs +2 -2
  62. package/dist/watchEvent-c346c12d.d.ts +41 -0
  63. package/dist/window.d.ts +2 -2
  64. package/ens/package.json +4 -0
  65. package/package.json +13 -9
  66. package/src/_test/constants.ts +2 -0
  67. package/src/_test/utils.ts +10 -5
  68. package/src/actions/ens/getEnsAddress.bench.ts +26 -0
  69. package/src/actions/ens/getEnsAddress.test.ts +97 -0
  70. package/src/actions/ens/getEnsAddress.ts +122 -0
  71. package/src/actions/ens/getEnsName.bench.ts +30 -0
  72. package/src/actions/ens/getEnsName.test.ts +101 -0
  73. package/src/actions/ens/getEnsName.ts +106 -0
  74. package/src/actions/ens/index.test.ts +12 -0
  75. package/src/actions/ens/index.ts +3 -0
  76. package/src/actions/index.ts +3 -3
  77. package/src/actions/public/createEventFilter.test.ts +36 -4
  78. package/src/actions/public/createEventFilter.ts +27 -10
  79. package/src/actions/public/getFilterChanges.test.ts +198 -4
  80. package/src/actions/public/getFilterLogs.test.ts +195 -2
  81. package/src/actions/public/getLogs.test.ts +201 -2
  82. package/src/actions/public/index.test.ts +0 -1
  83. package/src/actions/public/index.ts +1 -7
  84. package/src/actions/public/multicall.ts +8 -3
  85. package/src/actions/public/simulateContract.ts +1 -4
  86. package/src/actions/public/watchContractEvent.test.ts +4 -4
  87. package/src/actions/{public → wallet}/deployContract.test.ts +1 -2
  88. package/src/actions/{public → wallet}/deployContract.ts +0 -0
  89. package/src/actions/wallet/index.test.ts +1 -0
  90. package/src/actions/wallet/index.ts +6 -0
  91. package/src/chains.test.ts +44 -1517
  92. package/src/clients/transports/webSocket.test.ts +1 -0
  93. package/src/clients/transports/webSocket.ts +1 -0
  94. package/src/contract.test.ts +31 -0
  95. package/src/contract.ts +68 -0
  96. package/src/ens.test.ts +15 -0
  97. package/src/ens.ts +4 -1
  98. package/src/errors/abi.ts +18 -2
  99. package/src/errors/chain.test.ts +46 -0
  100. package/src/errors/chain.ts +33 -0
  101. package/src/errors/contract.ts +2 -2
  102. package/src/errors/index.ts +3 -0
  103. package/src/index.test.ts +0 -147
  104. package/src/index.ts +0 -257
  105. package/src/public.test.ts +36 -0
  106. package/src/public.ts +2 -6
  107. package/src/test.test.ts +38 -0
  108. package/src/test.ts +1 -0
  109. package/src/types/contract.ts +144 -40
  110. package/src/types/index.ts +2 -1
  111. package/src/types/utils.ts +21 -0
  112. package/src/utils/abi/decodeErrorResult.test.ts +1 -1
  113. package/src/utils/abi/decodeEventLog.test.ts +542 -0
  114. package/src/utils/abi/decodeEventLog.ts +107 -0
  115. package/src/utils/abi/decodeFunctionData.test.ts +1 -2
  116. package/src/utils/abi/decodeFunctionData.ts +5 -2
  117. package/src/utils/abi/encodeFunctionData.ts +1 -4
  118. package/src/utils/abi/index.test.ts +1 -0
  119. package/src/utils/abi/index.ts +6 -0
  120. package/src/utils/ens/index.test.ts +1 -0
  121. package/src/utils/ens/index.ts +2 -0
  122. package/src/utils/ens/packetToBytes.test.ts +11 -0
  123. package/src/utils/ens/packetToBytes.ts +29 -0
  124. package/src/utils/index.test.ts +1 -3
  125. package/src/utils/index.ts +3 -2
  126. package/src/utils/rpc.test.ts +1 -0
  127. package/src/utils/rpc.ts +4 -2
  128. package/src/wallet.test.ts +19 -0
  129. package/wallet/package.json +4 -0
  130. package/clients/package.json +0 -4
  131. package/dist/chunk-3ARWEJ3G.mjs.map +0 -1
  132. package/dist/chunk-4D5XG6XB.js.map +0 -1
  133. package/dist/chunk-6QTEW2BE.mjs +0 -260
  134. package/dist/chunk-6QTEW2BE.mjs.map +0 -1
  135. package/dist/chunk-A2HXAZXC.js.map +0 -1
  136. package/dist/chunk-KRPS5CIB.mjs +0 -256
  137. package/dist/chunk-KRPS5CIB.mjs.map +0 -1
  138. package/dist/chunk-LQVMDX5I.mjs.map +0 -1
  139. package/dist/chunk-N3IOPT3R.js +0 -256
  140. package/dist/chunk-N3IOPT3R.js.map +0 -1
  141. package/dist/chunk-YQUC52RL.mjs.map +0 -1
  142. package/dist/chunk-ZSTVHQ6J.js +0 -260
  143. package/dist/chunk-ZSTVHQ6J.js.map +0 -1
  144. package/dist/chunk-ZYSXBTBB.js.map +0 -1
  145. package/dist/clients/index.d.ts +0 -9
  146. package/dist/clients/index.js +0 -24
  147. package/dist/clients/index.mjs +0 -24
  148. package/dist/normalize-ef9240c0.d.ts +0 -33
  149. package/dist/parseGwei-492ab7dd.d.ts +0 -355
  150. package/dist/rpc-26932bae.d.ts +0 -61
  151. package/dist/stopImpersonatingAccount-c1a4b7e5.d.ts +0 -156
  152. package/dist/watchAsset-d59d6e35.d.ts +0 -38
  153. package/dist/watchPendingTransactions-ea21b31d.d.ts +0 -373
  154. package/dist/webSocket-775b4037.d.ts +0 -83
package/dist/index.d.ts CHANGED
@@ -1,26 +1,18 @@
1
- import { F as Filter, C as CallArgs } from './watchPendingTransactions-ea21b31d.js';
2
- export { C as CallArgs, a as CallResponse, b as CreateBlockFilterResponse, c as CreatePendingTransactionFilterResponse, D as DeployContractArgs, e as DeployContractResponse, E as EstimateGasArgs, d as EstimateGasResponse, G as GetBalanceArgs, f as GetBalanceResponse, g as GetBlockArgs, h as GetBlockNumberArgs, i as GetBlockNumberResponse, j as GetBlockResponse, k as GetBlockTransactionCountArgs, l as GetBlockTransactionCountResponse, m as GetBytecodeArgs, n as GetBytecodeResponse, o as GetFeeHistoryArgs, p as GetFeeHistoryResponse, q as GetFilterChangesArgs, r as GetFilterChangesResponse, s as GetFilterLogsArgs, t as GetFilterLogsResponse, u as GetGasPriceResponse, v as GetTransactionArgs, w as GetTransactionConfirmationsArgs, x as GetTransactionConfirmationsResponse, y as GetTransactionCountArgs, z as GetTransactionCountResponse, B as GetTransactionReceiptArgs, H as GetTransactionReceiptResponse, A as GetTransactionResponse, O as OnBlock, I as OnBlockNumber, J as OnBlockNumberResponse, K as OnBlockResponse, L as OnTransactions, M as OnTransactionsResponse, S as SimulateContractArgs, N as SimulateContractResponse, U as UninstallFilterArgs, P as UninstallFilterResponse, W as WaitForTransactionReceiptArgs, Q as WaitForTransactionReceiptResponse, R as WatchBlockNumberArgs, T as WatchBlocksArgs, V as WatchPendingTransactionsArgs, X as WriteContractArgs, Y as WriteContractResponse, Z as call, _ as createBlockFilter, $ as createPendingTransactionFilter, a0 as deployContract, a1 as estimateGas, a2 as getBalance, a3 as getBlock, a4 as getBlockNumber, a5 as getBlockTransactionCount, a6 as getBytecode, a7 as getChainId, a8 as getFeeHistory, a9 as getFilterChanges, aa as getFilterLogs, ab as getGasPrice, ac as getTransaction, ad as getTransactionConfirmations, ae as getTransactionCount, af as getTransactionReceipt, ag as simulateContract, ah as uninstallFilter, ai as waitForTransactionReceipt, aj as watchBlockNumber, ak as watchBlocks, al as watchPendingTransactions, am as writeContract } from './watchPendingTransactions-ea21b31d.js';
3
- import { H as Hex, A as Address, a as Hash, B as ByteArray, b as BlockTag, c as BlockNumber, L as Log } from './chain-afa13f5a.js';
4
- export { d as AccessList, A as Address, e as Block, f as BlockIdentifier, c as BlockNumber, b as BlockTag, B as ByteArray, C as Chain, F as FeeHistory, g as FeeValues, h as FeeValuesEIP1559, i as FeeValuesLegacy, G as FormattedTransaction, a as Hash, H as Hex, L as Log, R as RpcBlock, j as RpcBlockIdentifier, k as RpcBlockNumber, l as RpcFeeHistory, m as RpcFeeValues, n as RpcLog, o as RpcTransaction, p as RpcTransactionReceipt, q as RpcTransactionRequest, r as RpcUncle, x as Transaction, y as TransactionBase, z as TransactionEIP1559, D as TransactionEIP2930, E as TransactionLegacy, T as TransactionReceipt, s as TransactionRequest, t as TransactionRequestBase, u as TransactionRequestEIP1559, v as TransactionRequestEIP2930, w as TransactionRequestLegacy, U as Uncle, I as formatTransaction, J as transactionType } from './chain-afa13f5a.js';
5
- import { C as ContractConfig, E as ExtractResultFromAbi, a as EventDefinition, b as ExtractArgsFromEventDefinition, c as ExtractEventNameFromAbi, d as ExtractEventArgsFromAbi } from './contract-70f4ddbe.js';
6
- export { A as AbiItem, C as ContractConfig, F as FormattedBlock, f as formatBlock } from './contract-70f4ddbe.js';
7
- import { P as PublicClient } from './createPublicClient-d3d12dc3.js';
8
- export { P as PublicClient, a as PublicClientConfig, c as createPublicClient } from './createPublicClient-d3d12dc3.js';
9
- import { Abi } from 'abitype';
10
- export { D as DropTransactionArgs, I as ImpersonateAccountArgs, a as IncreaseTimeArgs, M as MineArgs, R as ResetArgs, b as RevertArgs, S as SendUnsignedTransactionArgs, c as SendUnsignedTransactionResponse, d as SetBalanceArgs, e as SetBlockGasLimitArgs, j as SetBlockTimestampIntervalArgs, f as SetCodeArgs, g as SetCoinbaseArgs, h as SetIntervalMiningArgs, i as SetMinGasPriceArgs, l as SetNextBlockBaseFeePerGasArgs, k as SetNextBlockTimestampArgs, m as SetNonceArgs, n as SetStorageAtArgs, o as StopImpersonatingAccountArgs, p as dropTransaction, q as getAutomine, r as getTxpoolContent, s as getTxpoolStatus, t as impersonateAccount, u as increaseTime, v as inspectTxpool, w as mine, x as removeBlockTimestampInterval, y as reset, z as revert, A as sendUnsignedTransaction, B as setAutomine, C as setBalance, E as setBlockGasLimit, F as setBlockTimestampInterval, G as setCode, H as setCoinbase, J as setIntervalMining, K as setLoggingEnabled, L as setMinGasPrice, N as setNextBlockBaseFeePerGas, O as setNextBlockTimestamp, P as setNonce, Q as setStorageAt, T as snapshot, U as stopImpersonatingAccount } from './stopImpersonatingAccount-c1a4b7e5.js';
11
- export { C as Client, a as ClientConfig, T as Transport, b as TransportConfig, c as createClient, d as createTransport } from './createClient-60e3ab98.js';
12
- export { C as CustomTransport, a as CustomTransportConfig, F as FallbackTransport, b as FallbackTransportConfig, H as HttpTransport, c as HttpTransportConfig, W as WebSocketTransport, d as WebSocketTransportConfig, e as custom, f as fallback, h as http, w as webSocket } from './webSocket-775b4037.js';
13
- export { T as TestClient, a as TestClientConfig, c as createTestClient } from './createTestClient-5f4532c4.js';
14
- export { W as WalletClient, a as WalletClientConfig, c as createWalletClient } from './createWalletClient-9ec3df4f.js';
15
- export { G as GetPermissionsResponse, R as RequestPermissionsResponse, S as SignMessageArgs, a as SignMessageResponse, b as SwitchChainArgs, W as WatchAssetArgs, c as WatchAssetResponse, d as addChain, g as getAccounts, e as getPermissions, r as requestAccounts, f as requestPermissions, s as signMessage, h as switchChain, w as watchAsset } from './watchAsset-d59d6e35.js';
16
- export { S as SendTransactionArgs, a as SendTransactionResponse, s as sendTransaction } from './sendTransaction-54a0d509.js';
17
- import { B as BaseError } from './parseGwei-492ab7dd.js';
18
- export { B as BaseError, C as ContractFunctionExecutionError, a as ContractFunctionRevertedError, b as ContractFunctionZeroDataError, D as DecodeAbiArgs, c as DecodeErrorResultArgs, d as DecodeFunctionDataArgs, e as DecodeFunctionResultArgs, f as DecodeFunctionResultResponse, E as EncodeAbiArgs, g as EncodeDeployDataArgs, h as EncodeErrorResultArgs, i as EncodeEventTopicsArgs, j as EncodeFunctionDataArgs, k as EncodeFunctionResultArgs, o as EncodeRlpResponse, n as GetAbiItemArgs, G as GetContractAddressOptions, m as GetCreate2AddressOptions, l as GetCreateAddressOptions, r as boolToBytes, s as boolToHex, t as bytesToBigint, u as bytesToBool, p as bytesToHex, v as bytesToNumber, q as bytesToString, w as decodeAbi, x as decodeBytes, y as decodeErrorResult, z as decodeFunctionData, A as decodeFunctionResult, F as decodeHex, H as decodeRlp, I as encodeAbi, J as encodeBytes, K as encodeDeployData, L as encodeErrorResult, M as encodeEventTopics, N as encodeFunctionData, O as encodeFunctionResult, P as encodeHex, Q as encodeRlp, R as etherUnits, Z as formatEther, ae as formatGwei, af as formatUnit, S as getAddress, T as getContractAddress, V as getCreate2Address, U as getCreateAddress, W as getEventSignature, X as getFunctionSignature, Y as gweiUnits, a2 as hexToBigInt, a3 as hexToBool, a4 as hexToBytes, ag as hexToNumber, a5 as hexToString, _ as isAddress, $ as isAddressEqual, a0 as isBytes, a1 as isHex, a6 as keccak256, a7 as numberToBytes, ah as numberToHex, a8 as pad, a9 as padBytes, aa as padHex, ab as parseEther, ac as parseGwei, ad as parseUnit, ai as size, aj as slice, ak as sliceBytes, al as sliceHex, am as stringToBytes, an as stringToHex, ao as trim, ap as weiUnits } from './parseGwei-492ab7dd.js';
19
- export { F as FormattedTransactionRequest, f as formatTransactionRequest } from './transactionRequest-bdf57f7d.js';
1
+ import { T as TransportConfig, a as Transport, B as BaseRpcRequests } from './createClient-68ee4bb4.js';
2
+ export { C as Client, b as ClientConfig, a as Transport, T as TransportConfig, c as createClient, d as createTransport } from './createClient-68ee4bb4.js';
3
+ import WebSocket from 'isomorphic-ws';
4
+ import { H as Hex, A as Address, a as Hash, B as ByteArray, b as BlockTag } from './chain-f16512e8.js';
5
+ export { c as AccessList, A as Address, d as Block, e as BlockIdentifier, f as BlockNumber, b as BlockTag, B as ByteArray, C as Chain, F as FeeHistory, g as FeeValues, h as FeeValuesEIP1559, i as FeeValuesLegacy, a as Hash, H as Hex, L as Log, R as RpcBlock, j as RpcBlockIdentifier, k as RpcBlockNumber, l as RpcFeeHistory, m as RpcFeeValues, n as RpcLog, o as RpcTransaction, p as RpcTransactionReceipt, q as RpcTransactionRequest, r as RpcUncle, x as Transaction, y as TransactionBase, z as TransactionEIP1559, D as TransactionEIP2930, E as TransactionLegacy, T as TransactionReceipt, s as TransactionRequest, t as TransactionRequestBase, u as TransactionRequestEIP1559, v as TransactionRequestEIP2930, w as TransactionRequestLegacy, U as Uncle } from './chain-f16512e8.js';
6
+ import { B as BaseError, R as RpcResponse } from './rpc-a5a7f376.js';
7
+ export { B as BaseError, C as ContractFunctionExecutionError, a as ContractFunctionRevertedError, b as ContractFunctionZeroDataError } from './rpc-a5a7f376.js';
8
+ export { P as PublicClient, a as PublicClientConfig, c as createPublicClient } from './createPublicClient-b732194e.js';
9
+ export { T as TestClient, a as TestClientConfig, c as createTestClient } from './createTestClient-dedf321e.js';
10
+ export { W as WalletClient, a as WalletClientConfig, c as createWalletClient } from './createWalletClient-75813d83.js';
11
+ export { A as AbiItem, C as ContractConfig } from './contract-9e76e561.js';
12
+ import './eip1193-6f9ba163.js';
20
13
  import '@wagmi/chains';
21
- import './eip1193-9317a312.js';
22
- import './rpc-26932bae.js';
23
- import 'abitype/dist/abi-78346466';
14
+ import 'abitype';
15
+ import './decodeErrorResult-0b934d23.js';
24
16
 
25
17
  declare class AbiConstructorNotFoundError extends BaseError {
26
18
  name: string;
@@ -334,165 +326,83 @@ declare class UrlRequiredError extends BaseError {
334
326
  constructor();
335
327
  }
336
328
 
337
- type MAXIMUM_DEPTH = 20;
338
- type Contract<TAbi extends Abi | readonly unknown[] = Abi | readonly unknown[], TFunctionName extends string = string> = {
339
- abi: TAbi;
340
- functionName: TFunctionName;
329
+ type EthereumProvider = {
330
+ request: BaseRpcRequests['request'];
341
331
  };
342
- 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] ? [
343
- ...Result,
344
- ContractConfig<Head['abi'], Head['functionName']> & TProperties
345
- ] : TContracts extends [
346
- infer Head extends Contract,
347
- ...infer Tail extends Contract[]
348
- ] ? MulticallContracts<[
349
- ...Tail
350
- ], TProperties, [
351
- ...Result,
352
- ContractConfig<Head['abi'], Head['functionName']> & TProperties
353
- ], [
354
- ...Depth,
355
- 1
356
- ]> : unknown[] extends TContracts ? TContracts : TContracts extends ContractConfig<infer TAbi, infer TFunctionName>[] ? (ContractConfig<TAbi, TFunctionName> & TProperties)[] : (ContractConfig & TProperties)[];
357
- type MulticallResult<Result, TAllowFailure extends boolean = true> = TAllowFailure extends true ? ({
358
- error?: undefined;
359
- result: Result;
360
- status: 'success';
361
- } | {
362
- error: Error;
363
- result?: undefined;
364
- status: 'error';
365
- }) : Result;
366
- 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 [
367
- infer Head extends Contract,
368
- ...infer Tail extends Contract[]
369
- ] ? MulticallResults<[
370
- ...Tail
371
- ], TAllowFailure, [
372
- ...Result,
373
- MulticallResult<ExtractResultFromAbi<Head['abi'], Head['functionName']>, TAllowFailure>
374
- ], [
375
- ...Depth,
376
- 1
377
- ]> : TContracts extends ContractConfig<infer TAbi, infer TFunctionName>[] ? MulticallResult<ExtractResultFromAbi<TAbi, TFunctionName>, TAllowFailure>[] : MulticallResult<ExtractResultFromAbi, TAllowFailure>[];
378
-
379
- type EventFilterArgs<TEventDefinition extends EventDefinition> = ExtractArgsFromEventDefinition<TEventDefinition>;
380
- type CreateEventFilterArgs<TEventDefinition extends EventDefinition> = {
381
- address?: Address | Address[];
382
- fromBlock?: BlockNumber | BlockTag;
383
- toBlock?: BlockNumber | BlockTag;
384
- } & ({
385
- event: TEventDefinition;
386
- args?: EventFilterArgs<TEventDefinition>;
387
- } | {
388
- event?: never;
389
- args?: never;
390
- });
391
- type CreateEventFilterResponse = Filter<'event'>;
392
- declare function createEventFilter<TEventDefinition extends EventDefinition>(client: PublicClient, { address, event, args, fromBlock, toBlock, }?: CreateEventFilterArgs<TEventDefinition>): Promise<CreateEventFilterResponse>;
393
-
394
- type CreateContractEventFilterArgs<TAbi extends Abi | readonly unknown[] = Abi, TEventName extends string = any> = {
395
- address?: Address | Address[];
396
- abi: TAbi;
397
- eventName: ExtractEventNameFromAbi<TAbi, TEventName>;
398
- fromBlock?: BlockNumber | BlockTag;
399
- toBlock?: BlockNumber | BlockTag;
400
- } & ExtractEventArgsFromAbi<TAbi, TEventName>;
401
- type CreateContractEventFilterResponse = Filter<'event'>;
402
- declare function createContractEventFilter<TAbi extends Abi | readonly unknown[] = Abi, TEventName extends string = any>(client: PublicClient, { address, abi, args, eventName, fromBlock, toBlock, }: CreateContractEventFilterArgs<TAbi, TEventName>): Promise<CreateContractEventFilterResponse>;
403
-
404
- type GetLogsArgs<TEventDefinition extends EventDefinition> = {
405
- /** Address or list of addresses from which logs originated */
406
- address?: Address | Address[];
407
- } & ({
408
- event: TEventDefinition;
409
- args?: EventFilterArgs<TEventDefinition>;
410
- } | {
411
- event?: never;
412
- args?: never;
413
- }) & ({
414
- /** Block number or tag after which to include logs */
415
- fromBlock?: BlockNumber<bigint> | BlockTag;
416
- /** Block number or tag before which to include logs */
417
- toBlock?: BlockNumber<bigint> | BlockTag;
418
- blockHash?: never;
419
- } | {
420
- fromBlock?: never;
421
- toBlock?: never;
422
- /** Hash of block to include logs from */
423
- blockHash?: Hash;
424
- });
425
- type GetLogsResponse = Log[];
332
+ type CustomTransportConfig = {
333
+ /** The key of the transport. */
334
+ key?: TransportConfig['key'];
335
+ /** The name of the transport. */
336
+ name?: TransportConfig['name'];
337
+ };
338
+ type CustomTransport = Transport<'custom', EthereumProvider['request']>;
426
339
  /**
427
- * @description Returns a collection of event logs.
340
+ * @description Creates a custom transport given an EIP-1193 compliant `request` attribute.
428
341
  */
429
- declare function getLogs<TEventDefinition extends EventDefinition>(client: PublicClient, { address, blockHash, fromBlock, toBlock, event, args, }?: GetLogsArgs<TEventDefinition>): Promise<GetLogsResponse>;
342
+ declare function custom<TProvider extends EthereumProvider>(
343
+ /** An Ethereum provider with an EIP-1193 "request" attribute. */
344
+ provider: TProvider, { key, name }?: CustomTransportConfig): CustomTransport;
430
345
 
431
- type GetStorageAtArgs = {
432
- address: Address;
433
- slot: Hex;
434
- } & ({
435
- blockNumber?: never;
436
- blockTag?: BlockTag;
437
- } | {
438
- blockNumber?: bigint;
439
- blockTag?: never;
440
- });
441
- type GetStorageAtResponse = Hex | undefined;
442
- declare function getStorageAt(client: PublicClient, { address, blockNumber, blockTag, slot }: GetStorageAtArgs): Promise<GetStorageAtResponse>;
443
-
444
- type MulticallArgs<TContracts extends ContractConfig[], TAllowFailure extends boolean = true> = Pick<CallArgs, 'blockNumber' | 'blockTag'> & {
445
- allowFailure?: TAllowFailure;
446
- contracts: readonly [...MulticallContracts<TContracts>];
447
- multicallAddress: Address;
346
+ type FallbackTransportConfig = {
347
+ /** The key of the Fallback transport. */
348
+ key?: TransportConfig['key'];
349
+ /** The name of the Fallback transport. */
350
+ name?: TransportConfig['name'];
448
351
  };
449
- declare function multicall<TContracts extends ContractConfig[], TAllowFailure extends boolean = true>(client: PublicClient, args: MulticallArgs<TContracts, TAllowFailure>): Promise<MulticallResults<TContracts, TAllowFailure>>;
450
-
451
- type ReadContractArgs<TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string> = Pick<CallArgs, 'blockNumber' | 'blockTag'> & ContractConfig<TAbi, TFunctionName, 'view' | 'pure'>;
452
- type ReadContractResponse<TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string> = ExtractResultFromAbi<TAbi, TFunctionName>;
453
- declare function readContract<TAbi extends Abi | readonly unknown[], TFunctionName extends string>(client: PublicClient, { abi, address, args, functionName, ...callRequest }: ReadContractArgs<TAbi, TFunctionName>): Promise<ReadContractResponse<TAbi, TFunctionName>>;
352
+ type FallbackTransport = Transport<'fallback', {
353
+ transports: Transport[];
354
+ }>;
355
+ declare function fallback(transports: Transport[], { key, name }?: FallbackTransportConfig): FallbackTransport;
454
356
 
455
- type OnLogsResponse$1 = Log[];
456
- type OnLogs$1 = (logs: OnLogsResponse$1) => void;
457
- type WatchContractEventArgs<TAbi extends Abi | readonly unknown[] = Abi, TEventName extends string = any> = {
458
- /** The address of the contract. */
459
- address: Address | Address[];
460
- /** Contract ABI. */
461
- abi: TAbi;
462
- /** Whether or not the event logs should be batched on each invocation. */
463
- batch?: boolean;
464
- /** Contract event. */
465
- eventName?: ExtractEventNameFromAbi<TAbi, TEventName>;
466
- /** The callback to call when an error occurred when trying to get for a new block. */
467
- onError?: (error: Error) => void;
468
- /** The callback to call when new event logs are received. */
469
- onLogs: OnLogs$1;
470
- /** Polling frequency (in ms). Defaults to Client's pollingInterval config. */
471
- pollingInterval?: number;
472
- } & ExtractEventArgsFromAbi<TAbi, TEventName>;
473
- declare function watchContractEvent<TAbi extends Abi | readonly unknown[] = Abi, TEventName extends string = any>(client: PublicClient, { abi, address, args, batch, eventName, onError, onLogs, pollingInterval, }: WatchContractEventArgs<TAbi, TEventName>): () => void;
357
+ type HttpTransportConfig = {
358
+ /** The key of the HTTP transport. */
359
+ key?: TransportConfig['key'];
360
+ /** The name of the HTTP transport. */
361
+ name?: TransportConfig['name'];
362
+ };
363
+ type HttpTransport = Transport<'http', {
364
+ url?: string;
365
+ }>;
366
+ /**
367
+ * @description Creates a HTTP transport that connects to a JSON-RPC API.
368
+ */
369
+ declare function http(
370
+ /** URL of the JSON-RPC API. Defaults to the chain's public RPC URL. */
371
+ url?: string, { key, name }?: HttpTransportConfig): HttpTransport;
474
372
 
475
- type OnLogsResponse = Log[];
476
- type OnLogs = (logs: OnLogsResponse) => void;
477
- type WatchEventArgs<TEventDefinition extends EventDefinition> = {
478
- /** The address of the contract. */
479
- address?: Address | Address[];
480
- /** Whether or not the event logs should be batched on each invocation. */
481
- batch?: boolean;
482
- /** The callback to call when an error occurred when trying to get for a new block. */
483
- onError?: (error: Error) => void;
484
- /** The callback to call when new event logs are received. */
485
- onLogs: OnLogs;
486
- /** Polling frequency (in ms). Defaults to Client's pollingInterval config. */
487
- pollingInterval?: number;
488
- } & ({
489
- event: TEventDefinition;
490
- args?: EventFilterArgs<TEventDefinition>;
491
- } | {
492
- event?: never;
493
- args?: never;
494
- });
495
- declare function watchEvent<TEventDefinition extends EventDefinition>(client: PublicClient, { address, args, batch, event, onError, onLogs, pollingInterval, }: WatchEventArgs<TEventDefinition>): () => void;
373
+ type WebSocketTransportSubscribeArgs = {
374
+ onData: (data: RpcResponse) => void;
375
+ onError?: (error: any) => void;
376
+ };
377
+ type WebSocketTransportSubscribeResponse = {
378
+ subscriptionId: Hash;
379
+ unsubscribe: () => Promise<RpcResponse<boolean>>;
380
+ };
381
+ type WebSocketTransportSubscribe = {
382
+ subscribe(args: WebSocketTransportSubscribeArgs & {
383
+ /**
384
+ * @description Add information about compiled contracts
385
+ * @link https://hardhat.org/hardhat-network/docs/reference#hardhat_addcompilationresult
386
+ */
387
+ params: ['newHeads'];
388
+ }): Promise<WebSocketTransportSubscribeResponse>;
389
+ };
390
+ type WebSocketTransportConfig = {
391
+ /** The key of the WebSocket transport. */
392
+ key?: TransportConfig['key'];
393
+ /** The name of the WebSocket transport. */
394
+ name?: TransportConfig['name'];
395
+ };
396
+ type WebSocketTransport = Transport<'webSocket', {
397
+ getSocket(): Promise<WebSocket>;
398
+ subscribe: WebSocketTransportSubscribe['subscribe'];
399
+ }>;
400
+ /**
401
+ * @description Creates a WebSocket transport that connects to a JSON-RPC API.
402
+ */
403
+ declare function webSocket(
404
+ /** URL of the JSON-RPC API. Defaults to the chain's public RPC URL. */
405
+ url?: string, { key, name, }?: WebSocketTransportConfig): WebSocketTransport;
496
406
 
497
407
  declare const multicall3Abi: readonly [{
498
408
  readonly inputs: readonly [{
@@ -525,4 +435,4 @@ declare const multicall3Abi: readonly [{
525
435
  readonly type: "function";
526
436
  }];
527
437
 
528
- export { AbiConstructorNotFoundError, AbiConstructorParamsNotFoundError, AbiDecodingDataSizeInvalidError, AbiEncodingArrayLengthMismatchError, AbiEncodingLengthMismatchError, AbiErrorInputsNotFoundError, AbiErrorNotFoundError, AbiErrorSignatureNotFoundError, AbiEventNotFoundError, AbiFunctionNotFoundError, AbiFunctionOutputsNotFoundError, AbiFunctionSignatureNotFoundError, BlockNotFoundError, CreateContractEventFilterArgs, CreateContractEventFilterResponse, CreateEventFilterArgs, CreateEventFilterResponse, DataLengthTooLongError, DataLengthTooShortError, FilterTypeNotSupportedError, GetLogsArgs, GetLogsResponse, GetStorageAtArgs, GetStorageAtResponse, HttpRequestError, InternalRpcError, InvalidAbiDecodingTypeError, InvalidAbiEncodingTypeError, InvalidAddressError, InvalidArrayError, InvalidBytesBooleanError, InvalidDefinitionTypeError, InvalidGasArgumentsError, InvalidHexBooleanError, InvalidHexValueError, InvalidInputRpcError, InvalidParamsRpcError, InvalidRequestRpcError, JsonRpcVersionUnsupportedError, LimitExceededRpcError, MethodNotFoundRpcError, MethodNotSupportedRpcError, MulticallArgs, OffsetOutOfBoundsError, OnLogs, OnLogsResponse, ParseRpcError, ReadContractArgs, ReadContractResponse, RequestError, ResourceNotFoundRpcError, ResourceUnavailableRpcError, RpcError, RpcRequestError, SizeExceedsPaddingSizeError, TimeoutError, TransactionNotFoundError, TransactionReceiptNotFoundError, TransactionRejectedRpcError, UnknownRpcError, UrlRequiredError, WaitForTransactionReceiptTimeoutError, WatchContractEventArgs, WatchEventArgs, WebSocketRequestError, createContractEventFilter, createEventFilter, getLogs, getStorageAt, multicall, multicall3Abi, readContract, watchContractEvent, watchEvent };
438
+ export { AbiConstructorNotFoundError, AbiConstructorParamsNotFoundError, AbiDecodingDataSizeInvalidError, AbiEncodingArrayLengthMismatchError, AbiEncodingLengthMismatchError, AbiErrorInputsNotFoundError, AbiErrorNotFoundError, AbiErrorSignatureNotFoundError, AbiEventNotFoundError, AbiFunctionNotFoundError, AbiFunctionOutputsNotFoundError, AbiFunctionSignatureNotFoundError, BlockNotFoundError, CustomTransport, CustomTransportConfig, DataLengthTooLongError, DataLengthTooShortError, FallbackTransport, FallbackTransportConfig, FilterTypeNotSupportedError, HttpRequestError, HttpTransport, HttpTransportConfig, InternalRpcError, InvalidAbiDecodingTypeError, InvalidAbiEncodingTypeError, InvalidAddressError, InvalidArrayError, InvalidBytesBooleanError, InvalidDefinitionTypeError, InvalidGasArgumentsError, InvalidHexBooleanError, InvalidHexValueError, InvalidInputRpcError, InvalidParamsRpcError, InvalidRequestRpcError, JsonRpcVersionUnsupportedError, LimitExceededRpcError, MethodNotFoundRpcError, MethodNotSupportedRpcError, OffsetOutOfBoundsError, ParseRpcError, RequestError, ResourceNotFoundRpcError, ResourceUnavailableRpcError, RpcError, RpcRequestError, SizeExceedsPaddingSizeError, TimeoutError, TransactionNotFoundError, TransactionReceiptNotFoundError, TransactionRejectedRpcError, UnknownRpcError, UrlRequiredError, WaitForTransactionReceiptTimeoutError, WebSocketRequestError, WebSocketTransport, WebSocketTransportConfig, custom, fallback, http, multicall3Abi, webSocket };