viem 0.0.1-alpha.23 → 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 (155) hide show
  1. package/contract/package.json +4 -0
  2. package/dist/call-ac509982.d.ts +23 -0
  3. package/dist/{chain-aa4898d0.d.ts → chain-c4ccb458.d.ts} +1 -1
  4. package/dist/{chain-4b39613a.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-RJLUZTJS.mjs → chunk-2Y3UZMSP.mjs} +203 -84
  9. package/dist/chunk-2Y3UZMSP.mjs.map +1 -0
  10. package/dist/{chunk-ZKYGWITF.js → chunk-CD2XJOBJ.js} +261 -142
  11. package/dist/chunk-CD2XJOBJ.js.map +1 -0
  12. package/dist/{chunk-XBUH66KN.mjs → chunk-KSAO4Y4Q.mjs} +133 -54
  13. package/dist/chunk-KSAO4Y4Q.mjs.map +1 -0
  14. package/dist/{chunk-TXHOG6KU.mjs → chunk-LEPQJNVO.mjs} +18 -2
  15. package/dist/chunk-LEPQJNVO.mjs.map +1 -0
  16. package/dist/{chunk-7Y5QVLX7.js → chunk-NUXMGPMK.js} +30 -14
  17. package/dist/chunk-NUXMGPMK.js.map +1 -0
  18. package/dist/{chunk-SSPRUPGN.js → chunk-THMRUG4D.js} +148 -69
  19. package/dist/chunk-THMRUG4D.js.map +1 -0
  20. package/dist/{contract-4c3a37b3.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-55a04188.d.ts → createClient-68ee4bb4.d.ts} +3 -3
  27. package/dist/{createPublicClient-3b27b282.d.ts → createPublicClient-b732194e.d.ts} +3 -3
  28. package/dist/{createTestClient-93f9eac6.d.ts → createTestClient-dedf321e.d.ts} +3 -3
  29. package/dist/{createWalletClient-c10df94d.d.ts → createWalletClient-75813d83.d.ts} +3 -3
  30. package/dist/decodeErrorResult-0b934d23.d.ts +16 -0
  31. package/dist/{eip1193-4c24765a.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 -133
  39. package/dist/index.js +237 -275
  40. package/dist/index.js.map +1 -1
  41. package/dist/index.mjs +245 -283
  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-f17a2389.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-93e9f001.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.test.ts +2 -0
  77. package/src/actions/index.ts +9 -3
  78. package/src/actions/public/createEventFilter.test.ts +36 -4
  79. package/src/actions/public/createEventFilter.ts +27 -10
  80. package/src/actions/public/getFilterChanges.test.ts +198 -4
  81. package/src/actions/public/getFilterLogs.test.ts +195 -2
  82. package/src/actions/public/getLogs.test.ts +201 -2
  83. package/src/actions/public/index.test.ts +0 -1
  84. package/src/actions/public/index.ts +1 -7
  85. package/src/actions/public/multicall.ts +8 -3
  86. package/src/actions/public/simulateContract.ts +1 -4
  87. package/src/actions/public/watchContractEvent.test.ts +4 -4
  88. package/src/actions/{public → wallet}/deployContract.test.ts +1 -2
  89. package/src/actions/{public → wallet}/deployContract.ts +0 -0
  90. package/src/actions/wallet/index.test.ts +1 -0
  91. package/src/actions/wallet/index.ts +6 -0
  92. package/src/chains.test.ts +44 -1517
  93. package/src/clients/transports/webSocket.test.ts +1 -0
  94. package/src/clients/transports/webSocket.ts +1 -0
  95. package/src/contract.test.ts +31 -0
  96. package/src/contract.ts +68 -0
  97. package/src/ens.test.ts +15 -0
  98. package/src/ens.ts +4 -1
  99. package/src/errors/abi.ts +18 -2
  100. package/src/errors/chain.test.ts +46 -0
  101. package/src/errors/chain.ts +33 -0
  102. package/src/errors/contract.ts +2 -2
  103. package/src/errors/index.ts +3 -0
  104. package/src/index.test.ts +0 -145
  105. package/src/index.ts +0 -251
  106. package/src/public.test.ts +36 -0
  107. package/src/public.ts +2 -6
  108. package/src/test.test.ts +38 -0
  109. package/src/test.ts +1 -0
  110. package/src/types/contract.ts +144 -40
  111. package/src/types/index.ts +2 -1
  112. package/src/types/utils.ts +21 -0
  113. package/src/utils/abi/decodeErrorResult.test.ts +1 -1
  114. package/src/utils/abi/decodeEventLog.test.ts +542 -0
  115. package/src/utils/abi/decodeEventLog.ts +107 -0
  116. package/src/utils/abi/decodeFunctionData.test.ts +1 -2
  117. package/src/utils/abi/decodeFunctionData.ts +5 -2
  118. package/src/utils/abi/encodeFunctionData.ts +1 -4
  119. package/src/utils/abi/index.test.ts +1 -0
  120. package/src/utils/abi/index.ts +6 -0
  121. package/src/utils/ens/index.test.ts +1 -0
  122. package/src/utils/ens/index.ts +2 -0
  123. package/src/utils/ens/packetToBytes.test.ts +11 -0
  124. package/src/utils/ens/packetToBytes.ts +29 -0
  125. package/src/utils/index.test.ts +1 -3
  126. package/src/utils/index.ts +3 -2
  127. package/src/utils/rpc.test.ts +1 -0
  128. package/src/utils/rpc.ts +4 -2
  129. package/src/wallet.test.ts +19 -0
  130. package/wallet/package.json +4 -0
  131. package/clients/package.json +0 -4
  132. package/dist/chunk-7Y5QVLX7.js.map +0 -1
  133. package/dist/chunk-BV5NTHUX.js +0 -260
  134. package/dist/chunk-BV5NTHUX.js.map +0 -1
  135. package/dist/chunk-EGVXCZNJ.mjs +0 -260
  136. package/dist/chunk-EGVXCZNJ.mjs.map +0 -1
  137. package/dist/chunk-GX2KDAM3.mjs +0 -256
  138. package/dist/chunk-GX2KDAM3.mjs.map +0 -1
  139. package/dist/chunk-NW6724MI.js +0 -256
  140. package/dist/chunk-NW6724MI.js.map +0 -1
  141. package/dist/chunk-RJLUZTJS.mjs.map +0 -1
  142. package/dist/chunk-SSPRUPGN.js.map +0 -1
  143. package/dist/chunk-TXHOG6KU.mjs.map +0 -1
  144. package/dist/chunk-XBUH66KN.mjs.map +0 -1
  145. package/dist/chunk-ZKYGWITF.js.map +0 -1
  146. package/dist/clients/index.d.ts +0 -9
  147. package/dist/clients/index.js +0 -24
  148. package/dist/clients/index.mjs +0 -24
  149. package/dist/normalize-ef9240c0.d.ts +0 -33
  150. package/dist/parseGwei-3411cf2d.d.ts +0 -355
  151. package/dist/rpc-26932bae.d.ts +0 -61
  152. package/dist/stopImpersonatingAccount-afb26486.d.ts +0 -156
  153. package/dist/watchAsset-efd3dd05.d.ts +0 -38
  154. package/dist/watchPendingTransactions-57df1a13.d.ts +0 -373
  155. package/dist/webSocket-d2e7bd0e.d.ts +0 -83
@@ -1,61 +0,0 @@
1
- type SuccessResult<T> = {
2
- method?: never;
3
- result: T;
4
- error?: never;
5
- };
6
- type ErrorResult<T> = {
7
- method?: never;
8
- result?: never;
9
- error: T;
10
- };
11
- type Subscription<TResult, TError> = {
12
- method: 'eth_subscription';
13
- error?: never;
14
- result?: never;
15
- params: {
16
- subscription: string;
17
- } & ({
18
- result: TResult;
19
- error?: never;
20
- } | {
21
- result?: never;
22
- error: TError;
23
- });
24
- };
25
- type RpcRequest = {
26
- method: string;
27
- params?: any[];
28
- };
29
- type RpcResponse<TResult = any, TError = any> = {
30
- jsonrpc: `${number}`;
31
- id: number;
32
- } & (SuccessResult<TResult> | ErrorResult<TError> | Subscription<TResult, TError>);
33
- declare function http(url: string, { body, retryDelay, retryCount, timeout, }: {
34
- body: RpcRequest;
35
- retryDelay?: number;
36
- retryCount?: number;
37
- timeout?: number;
38
- }): Promise<RpcResponse<any, any>>;
39
- type Id = string | number;
40
- type CallbackFn = (message: any) => void;
41
- type CallbackMap = Map<Id, CallbackFn>;
42
- type Socket = WebSocket & {
43
- requests: CallbackMap;
44
- subscriptions: CallbackMap;
45
- };
46
- declare function webSocket(socket: Socket, { body, onData, onError, }: {
47
- body: RpcRequest;
48
- onData?: (message: RpcResponse) => void;
49
- onError?: (message: RpcResponse['error']) => void;
50
- }): Socket;
51
- declare function webSocketAsync(socket: Socket, { body, timeout, }: {
52
- body: RpcRequest;
53
- timeout?: number;
54
- }): Promise<RpcResponse<any, any>>;
55
- declare const rpc: {
56
- http: typeof http;
57
- webSocket: typeof webSocket;
58
- webSocketAsync: typeof webSocketAsync;
59
- };
60
-
61
- export { RpcResponse as R, rpc as r };
@@ -1,156 +0,0 @@
1
- import { a as Hash, o as RpcTransaction, A as Address, X as Quantity, s as TransactionRequest, H as Hex } from './chain-4b39613a.js';
2
- import { T as TestClient } from './createTestClient-93f9eac6.js';
3
-
4
- type DropTransactionArgs = {
5
- /** The hash of the transaction to drop. */
6
- hash: Hash;
7
- };
8
- declare function dropTransaction(client: TestClient, { hash }: DropTransactionArgs): Promise<void>;
9
-
10
- type GetAutomineResponse = boolean;
11
- declare function getAutomine(client: TestClient): Promise<GetAutomineResponse>;
12
-
13
- declare function getTxpoolContent(client: TestClient): Promise<{
14
- pending: Record<`0x${string}`, Record<string, RpcTransaction>>;
15
- queued: Record<`0x${string}`, Record<string, RpcTransaction>>;
16
- }>;
17
-
18
- declare function getTxpoolStatus(client: TestClient): Promise<{
19
- pending: number;
20
- queued: number;
21
- }>;
22
-
23
- type ImpersonateAccountArgs = {
24
- /** The account to impersonate. */
25
- address: Address;
26
- };
27
- declare function impersonateAccount(client: TestClient, { address }: ImpersonateAccountArgs): Promise<void>;
28
-
29
- type IncreaseTimeArgs = {
30
- /** The amount of seconds to jump forward in time. */
31
- seconds: number;
32
- };
33
- declare function increaseTime(client: TestClient, { seconds }: IncreaseTimeArgs): Promise<`0x${string}`>;
34
-
35
- declare function inspectTxpool(client: TestClient): Promise<{
36
- pending: Record<`0x${string}`, Record<string, string>>;
37
- queued: Record<`0x${string}`, Record<string, string>>;
38
- }>;
39
-
40
- type MineArgs = {
41
- /** Number of blocks to mine. */
42
- blocks: number;
43
- /** Interval between each block in seconds. */
44
- interval?: number;
45
- };
46
- declare function mine(client: TestClient, { blocks, interval }: MineArgs): Promise<void>;
47
-
48
- declare function removeBlockTimestampInterval(client: TestClient): Promise<void>;
49
-
50
- type ResetArgs = {
51
- /** The block number to reset from. */
52
- blockNumber?: bigint;
53
- /** The JSON RPC URL. */
54
- jsonRpcUrl?: string;
55
- };
56
- declare function reset(client: TestClient, { blockNumber, jsonRpcUrl }?: ResetArgs): Promise<void>;
57
-
58
- type RevertArgs = {
59
- /** The snapshot ID to revert to. */
60
- id: Quantity;
61
- };
62
- declare function revert(client: TestClient, { id }: RevertArgs): Promise<void>;
63
-
64
- type SendUnsignedTransactionArgs = TransactionRequest;
65
- type SendUnsignedTransactionResponse = Hash;
66
- declare function sendUnsignedTransaction(client: TestClient, request: SendUnsignedTransactionArgs): Promise<SendUnsignedTransactionResponse>;
67
-
68
- declare function setAutomine(client: TestClient, enabled: boolean): Promise<void>;
69
-
70
- type SetBalanceArgs = {
71
- /** The account address. */
72
- address: Address;
73
- /** Amount (in wei) to set */
74
- value: bigint;
75
- };
76
- declare function setBalance(client: TestClient, { address, value }: SetBalanceArgs): Promise<void>;
77
-
78
- type SetBlockGasLimitArgs = {
79
- /** Gas limit (in wei). */
80
- gasLimit: bigint;
81
- };
82
- declare function setBlockGasLimit(client: TestClient, { gasLimit }: SetBlockGasLimitArgs): Promise<void>;
83
-
84
- type SetBlockTimestampIntervalArgs = {
85
- /** The interval (in seconds). */
86
- interval: number;
87
- };
88
- declare function setBlockTimestampInterval(client: TestClient, { interval }: SetBlockTimestampIntervalArgs): Promise<void>;
89
-
90
- type SetCodeArgs = {
91
- /** The account address. */
92
- address: Address;
93
- /** The bytecode to set */
94
- bytecode: Hex;
95
- };
96
- declare function setCode(client: TestClient, { address, bytecode }: SetCodeArgs): Promise<void>;
97
-
98
- type SetCoinbaseArgs = {
99
- /** The coinbase address. */
100
- address: Address;
101
- };
102
- declare function setCoinbase(client: TestClient, { address }: SetCoinbaseArgs): Promise<void>;
103
-
104
- type SetIntervalMiningArgs = {
105
- /** The mining interval. */
106
- interval: number;
107
- };
108
- declare function setIntervalMining(client: TestClient, { interval }: SetIntervalMiningArgs): Promise<void>;
109
-
110
- declare function setLoggingEnabled(client: TestClient, enabled: boolean): Promise<void>;
111
-
112
- type SetMinGasPriceArgs = {
113
- /** The gas price. */
114
- gasPrice: bigint;
115
- };
116
- declare function setMinGasPrice(client: TestClient, { gasPrice }: SetMinGasPriceArgs): Promise<void>;
117
-
118
- type SetNextBlockBaseFeePerGasArgs = {
119
- /** Base fee per gas (in wei). */
120
- baseFeePerGas: bigint;
121
- };
122
- declare function setNextBlockBaseFeePerGas(client: TestClient, { baseFeePerGas }: SetNextBlockBaseFeePerGasArgs): Promise<void>;
123
-
124
- type SetNextBlockTimestampArgs = {
125
- /** The timestamp (in seconds). */
126
- timestamp: bigint;
127
- };
128
- declare function setNextBlockTimestamp(client: TestClient, { timestamp }: SetNextBlockTimestampArgs): Promise<void>;
129
-
130
- type SetNonceArgs = {
131
- /** The account address. */
132
- address: Address;
133
- /** The nonce to set. */
134
- nonce: number;
135
- };
136
- declare function setNonce(client: TestClient, { address, nonce }: SetNonceArgs): Promise<void>;
137
-
138
- type SetStorageAtArgs = {
139
- /** The account address. */
140
- address: Address;
141
- /** The storage slot (index). Can either be a number or hash value. */
142
- index: number | Hash;
143
- /** The value to store as a 32 byte hex string. */
144
- value: Hex;
145
- };
146
- declare function setStorageAt(client: TestClient, { address, index, value }: SetStorageAtArgs): Promise<void>;
147
-
148
- declare function snapshot(client: TestClient): Promise<`0x${string}`>;
149
-
150
- type StopImpersonatingAccountArgs = {
151
- /** The account to impersonate. */
152
- address: Address;
153
- };
154
- declare function stopImpersonatingAccount(client: TestClient, { address }: StopImpersonatingAccountArgs): Promise<void>;
155
-
156
- export { sendUnsignedTransaction as A, setAutomine as B, setBalance as C, DropTransactionArgs as D, setBlockGasLimit as E, setBlockTimestampInterval as F, setCode as G, setCoinbase as H, ImpersonateAccountArgs as I, setIntervalMining as J, setLoggingEnabled as K, setMinGasPrice as L, MineArgs as M, setNextBlockBaseFeePerGas as N, setNextBlockTimestamp as O, setNonce as P, setStorageAt as Q, ResetArgs as R, SendUnsignedTransactionArgs as S, snapshot as T, stopImpersonatingAccount as U, IncreaseTimeArgs as a, RevertArgs as b, SendUnsignedTransactionResponse as c, SetBalanceArgs as d, SetBlockGasLimitArgs as e, SetCodeArgs as f, SetCoinbaseArgs as g, SetIntervalMiningArgs as h, SetMinGasPriceArgs as i, SetBlockTimestampIntervalArgs as j, SetNextBlockTimestampArgs as k, SetNextBlockBaseFeePerGasArgs as l, SetNonceArgs as m, SetStorageAtArgs as n, StopImpersonatingAccountArgs as o, dropTransaction as p, getAutomine as q, getTxpoolContent as r, getTxpoolStatus as s, impersonateAccount as t, increaseTime as u, inspectTxpool as v, mine as w, removeBlockTimestampInterval as x, reset as y, revert as z };
@@ -1,38 +0,0 @@
1
- import { C as Chain, A as Address, H as Hex, B as ByteArray } from './chain-4b39613a.js';
2
- import { W as WalletClient } from './createWalletClient-c10df94d.js';
3
- import { a as WalletPermission, b as WatchAssetParams } from './eip1193-4c24765a.js';
4
-
5
- declare function addChain(client: WalletClient, chain: Chain): Promise<void>;
6
-
7
- declare function getAccounts(client: WalletClient): Promise<`0x${string}`[]>;
8
-
9
- type GetPermissionsResponse = WalletPermission[];
10
- declare function getPermissions(client: WalletClient): Promise<WalletPermission[]>;
11
-
12
- declare function requestAccounts(client: WalletClient): Promise<`0x${string}`[]>;
13
-
14
- type RequestPermissionsArgs = {
15
- eth_accounts: Record<string, any>;
16
- } & {
17
- [key: string]: Record<string, any>;
18
- };
19
- type RequestPermissionsResponse = WalletPermission[];
20
- declare function requestPermissions(client: WalletClient, permissions: RequestPermissionsArgs): Promise<WalletPermission[]>;
21
-
22
- type SignMessageArgs = {
23
- from: Address;
24
- data: Hex | ByteArray;
25
- };
26
- type SignMessageResponse = Hex;
27
- declare function signMessage(client: WalletClient, { from, data: data_ }: SignMessageArgs): Promise<SignMessageResponse>;
28
-
29
- type SwitchChainArgs = {
30
- id: Chain['id'];
31
- };
32
- declare function switchChain(client: WalletClient, { id }: SwitchChainArgs): Promise<void>;
33
-
34
- type WatchAssetArgs = WatchAssetParams;
35
- type WatchAssetResponse = boolean;
36
- declare function watchAsset(client: WalletClient, params: WatchAssetParams): Promise<WatchAssetResponse>;
37
-
38
- export { GetPermissionsResponse as G, RequestPermissionsResponse as R, SignMessageArgs as S, WatchAssetArgs as W, SignMessageResponse as a, SwitchChainArgs as b, WatchAssetResponse as c, addChain as d, getPermissions as e, requestPermissions as f, getAccounts as g, switchChain as h, requestAccounts as r, signMessage as s, watchAsset as w };
@@ -1,373 +0,0 @@
1
- import { Abi, Narrow } from 'abitype';
2
- import { H as Hex, C as Chain, A as Address, b as BlockTag, K as Formatter, M as MergeIntersectionProperties, N as Formatted, s as TransactionRequest, O as EstimateGasParameters, a as Hash, F as FeeHistory, L as Log, G as FormattedTransaction, P as TransactionFormatter, Q as ExtractFormatter, p as RpcTransactionReceipt, T as TransactionReceipt, S as TransactionType, x as Transaction } from './chain-4b39613a.js';
3
- import { G as GetValue, C as ContractConfig, E as ExtractResultFromAbi, e as ExtractConstructorArgsFromAbi, F as FormattedBlock, B as BlockFormatter, g as FormattedTransactionReceipt, T as TransactionReceiptFormatter } from './contract-4c3a37b3.js';
4
- import { P as PublicClient } from './createPublicClient-3b27b282.js';
5
- import { W as WalletClient } from './createWalletClient-c10df94d.js';
6
- import { S as SendTransactionArgs, a as SendTransactionResponse } from './sendTransaction-f17a2389.js';
7
- import { T as TransactionRequestFormatter } from './transactionRequest-93e9f001.js';
8
-
9
- type FilterType = 'transaction' | 'block' | 'event';
10
- type Filter<TFilterType extends FilterType = 'event'> = {
11
- id: Hex;
12
- type: TFilterType;
13
- };
14
-
15
- type FormattedCall<TFormatter extends Formatter | undefined = Formatter> = MergeIntersectionProperties<Formatted<TFormatter, TransactionRequest, true>, TransactionRequest>;
16
- type CallArgs<TChain extends Chain = Chain> = FormattedCall<TransactionRequestFormatter<TChain>> & {
17
- chain?: TChain;
18
- from?: Address;
19
- } & ({
20
- /** The balance of the account at a block number. */
21
- blockNumber?: bigint;
22
- blockTag?: never;
23
- } | {
24
- blockNumber?: never;
25
- /** The balance of the account at a block tag. */
26
- blockTag?: BlockTag;
27
- });
28
- type CallResponse = {
29
- data: Hex | undefined;
30
- };
31
- 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>;
32
-
33
- type WriteContractArgs<TChain extends Chain = Chain, TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string> = Omit<SendTransactionArgs<TChain>, 'to' | 'data' | 'value'> & {
34
- value?: GetValue<TAbi, TFunctionName, SendTransactionArgs<TChain>['value']>;
35
- } & ContractConfig<TAbi, TFunctionName, 'payable' | 'nonpayable'>;
36
- type WriteContractResponse = SendTransactionResponse;
37
- declare function writeContract<TChain extends Chain, TAbi extends Abi | readonly unknown[], TFunctionName extends string>(client: WalletClient, { abi, address, args, functionName, ...request }: WriteContractArgs<TChain, TAbi, TFunctionName>): Promise<WriteContractResponse>;
38
-
39
- type SimulateContractArgs<TChain extends Chain = Chain, TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = any> = Omit<CallArgs<TChain>, 'to' | 'data' | 'value'> & ContractConfig<TAbi, TFunctionName, 'payable' | 'nonpayable'> & {
40
- value?: GetValue<TAbi, TFunctionName, CallArgs<TChain>['value']>;
41
- };
42
- type SimulateContractResponse<TChain extends Chain = Chain, TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string> = {
43
- result: ExtractResultFromAbi<TAbi, TFunctionName>;
44
- request: WriteContractArgs<TChain, TAbi, TFunctionName> & ContractConfig<TAbi, TFunctionName, 'payable' | 'nonpayable'>;
45
- };
46
- declare function simulateContract<TChain extends Chain, TAbi extends Abi | readonly unknown[], TFunctionName extends string>(client: PublicClient, { abi, address, args, functionName, ...callRequest }: SimulateContractArgs<TChain, TAbi, TFunctionName>): Promise<SimulateContractResponse<TChain, TAbi, TFunctionName>>;
47
-
48
- type CreatePendingTransactionFilterResponse = Filter<'transaction'>;
49
- declare function createPendingTransactionFilter(client: PublicClient): Promise<CreatePendingTransactionFilterResponse>;
50
-
51
- type CreateBlockFilterResponse = Filter<'block'>;
52
- declare function createBlockFilter(client: PublicClient): Promise<CreateBlockFilterResponse>;
53
-
54
- type DeployContractArgs<TChain extends Chain = Chain, TAbi extends Abi | readonly unknown[] = Abi> = Omit<SendTransactionArgs<TChain>, 'accessList' | 'to' | 'data' | 'value'> & {
55
- abi: Narrow<TAbi>;
56
- bytecode: Hex;
57
- } & ExtractConstructorArgsFromAbi<TAbi>;
58
- type DeployContractResponse = SendTransactionResponse;
59
- declare function deployContract<TChain extends Chain, TAbi extends Abi>(walletClient: WalletClient, { abi, args, bytecode, ...request }: DeployContractArgs<TChain, TAbi>): Promise<DeployContractResponse>;
60
-
61
- type EstimateGasArgs = EstimateGasParameters & ({
62
- /** The balance of the account at a block number. */
63
- blockNumber?: bigint;
64
- blockTag?: never;
65
- } | {
66
- blockNumber?: never;
67
- /** The balance of the account at a block tag. */
68
- blockTag?: BlockTag;
69
- });
70
- type EstimateGasResponse = bigint;
71
- /**
72
- * @description Estimates the gas necessary to complete a transaction without submitting it to the network.
73
- */
74
- declare function estimateGas(client: PublicClient, { blockNumber, blockTag, data, from, gas, gasPrice, maxFeePerGas, maxPriorityFeePerGas, to, value, }: EstimateGasArgs): Promise<EstimateGasResponse>;
75
-
76
- type GetBalanceArgs = {
77
- /** The address of the account. */
78
- address: Address;
79
- } & ({
80
- /** The balance of the account at a block number. */
81
- blockNumber?: bigint;
82
- blockTag?: never;
83
- } | {
84
- blockNumber?: never;
85
- /** The balance of the account at a block tag. */
86
- blockTag?: BlockTag;
87
- });
88
- type GetBalanceResponse = bigint;
89
- /**
90
- * @description Returns the balance of an address in wei.
91
- */
92
- declare function getBalance(client: PublicClient, { address, blockNumber, blockTag }: GetBalanceArgs): Promise<GetBalanceResponse>;
93
-
94
- type GetBlockArgs = {
95
- /** Whether or not to include transaction data in the response. */
96
- includeTransactions?: boolean;
97
- } & ({
98
- /** Hash of the block. */
99
- blockHash?: Hash;
100
- blockNumber?: never;
101
- blockTag?: never;
102
- } | {
103
- blockHash?: never;
104
- /** The block number. */
105
- blockNumber?: bigint;
106
- blockTag?: never;
107
- } | {
108
- blockHash?: never;
109
- blockNumber?: never;
110
- /** The block tag. Defaults to 'latest'. */
111
- blockTag?: BlockTag;
112
- });
113
- type GetBlockResponse<TChain extends Chain = Chain> = FormattedBlock<BlockFormatter<TChain>>;
114
- declare function getBlock<TChain extends Chain>(client: PublicClient<any, TChain>, { blockHash, blockNumber, blockTag, includeTransactions, }?: GetBlockArgs): Promise<GetBlockResponse<TChain>>;
115
-
116
- type GetBlockNumberArgs = {
117
- /** The maximum age (in ms) of the cached value. */
118
- maxAge?: number;
119
- };
120
- type GetBlockNumberResponse = bigint;
121
- declare function getBlockNumberCache(id: string): {
122
- clear: () => void;
123
- promise: {
124
- clear: () => boolean;
125
- get: () => Promise<unknown> | undefined;
126
- set: (data: Promise<unknown>) => Map<string, Promise<unknown>>;
127
- };
128
- response: {
129
- clear: () => boolean;
130
- get: () => {
131
- created: Date;
132
- data: unknown;
133
- } | undefined;
134
- set: (data: {
135
- created: Date;
136
- data: unknown;
137
- }) => Map<string, {
138
- created: Date;
139
- data: unknown;
140
- }>;
141
- };
142
- };
143
- /**
144
- * @description Returns the number of the most recent block seen.
145
- */
146
- declare function getBlockNumber(client: PublicClient, { maxAge }?: GetBlockNumberArgs): Promise<GetBlockNumberResponse>;
147
-
148
- type GetBlockTransactionCountArgs = {
149
- /** Hash of the block. */
150
- blockHash?: Hash;
151
- blockNumber?: never;
152
- blockTag?: never;
153
- } | {
154
- blockHash?: never;
155
- /** The block number. */
156
- blockNumber?: bigint;
157
- blockTag?: never;
158
- } | {
159
- blockHash?: never;
160
- blockNumber?: never;
161
- /** The block tag. Defaults to 'latest'. */
162
- blockTag?: BlockTag;
163
- };
164
- type GetBlockTransactionCountResponse = number;
165
- declare function getBlockTransactionCount<TChain extends Chain>(client: PublicClient<any, TChain>, { blockHash, blockNumber, blockTag, }?: GetBlockTransactionCountArgs): Promise<GetBlockTransactionCountResponse>;
166
-
167
- type GetBytecodeArgs = {
168
- address: Address;
169
- } & ({
170
- blockNumber?: never;
171
- blockTag?: BlockTag;
172
- } | {
173
- blockNumber?: bigint;
174
- blockTag?: never;
175
- });
176
- type GetBytecodeResponse = Hex | undefined;
177
- declare function getBytecode(client: PublicClient, { address, blockNumber, blockTag }: GetBytecodeArgs): Promise<GetBytecodeResponse>;
178
-
179
- declare function getChainId(client: PublicClient): Promise<number>;
180
-
181
- type GetFeeHistoryArgs = {
182
- blockCount: number;
183
- rewardPercentiles: number[];
184
- } & ({
185
- blockNumber?: never;
186
- blockTag?: BlockTag;
187
- } | {
188
- blockNumber?: bigint;
189
- blockTag?: never;
190
- });
191
- type GetFeeHistoryResponse = FeeHistory;
192
- /**
193
- * @description Returns a collection of historical gas information.
194
- */
195
- declare function getFeeHistory(client: PublicClient, { blockCount, blockNumber, blockTag, rewardPercentiles, }: GetFeeHistoryArgs): Promise<GetFeeHistoryResponse>;
196
-
197
- type GetFilterChangesArgs<TFilterType extends FilterType> = {
198
- filter: Filter<TFilterType>;
199
- };
200
- type GetFilterChangesResponse<TFilterType extends FilterType> = TFilterType extends 'event' ? Log[] : Hash[];
201
- declare function getFilterChanges<TFilterType extends FilterType>(client: PublicClient, { filter }: GetFilterChangesArgs<TFilterType>): Promise<GetFilterChangesResponse<TFilterType>>;
202
-
203
- type GetFilterLogsArgs = {
204
- filter: Filter<'event'>;
205
- };
206
- type GetFilterLogsResponse = Log[];
207
- declare function getFilterLogs<TFilterType extends FilterType>(client: PublicClient, { filter }: GetFilterLogsArgs): Promise<GetFilterLogsResponse>;
208
-
209
- type GetGasPriceResponse = bigint;
210
- /**
211
- * @description Returns the current price of gas (in wei).
212
- */
213
- declare function getGasPrice(client: PublicClient): Promise<GetGasPriceResponse>;
214
-
215
- type GetTransactionArgs = {
216
- /** The block hash */
217
- blockHash: Hash;
218
- blockNumber?: never;
219
- blockTag?: never;
220
- hash?: never;
221
- /** The index of the transaction on the block. */
222
- index: number;
223
- } | {
224
- blockHash?: never;
225
- /** The block number */
226
- blockNumber: bigint;
227
- blockTag?: never;
228
- hash?: never;
229
- /** The index of the transaction on the block. */
230
- index: number;
231
- } | {
232
- blockHash?: never;
233
- blockNumber?: never;
234
- /** The block tag. */
235
- blockTag: BlockTag;
236
- hash?: never;
237
- /** The index of the transaction on the block. */
238
- index: number;
239
- } | {
240
- blockHash?: never;
241
- blockNumber?: never;
242
- blockTag?: never;
243
- /** The hash of the transaction. */
244
- hash: Hash;
245
- index?: number;
246
- };
247
- type GetTransactionResponse<TChain extends Chain = Chain> = FormattedTransaction<TransactionFormatter<TChain>>;
248
- /** @description Returns information about a transaction given a hash or block identifier. */
249
- declare function getTransaction<TChain extends Chain>(client: PublicClient<any, TChain>, { blockHash, blockNumber, blockTag, hash, index, }: GetTransactionArgs): Promise<GetTransactionResponse<TChain>>;
250
-
251
- type GetTransactionConfirmationsArgs<TChain extends Chain> = {
252
- /** The transaction hash. */
253
- hash: Hash;
254
- transactionReceipt?: never;
255
- } | {
256
- hash?: never;
257
- /** The transaction receipt. */
258
- transactionReceipt: FormattedTransactionReceipt<TransactionReceiptFormatter<TChain>>;
259
- };
260
- type GetTransactionConfirmationsResponse = bigint;
261
- declare function getTransactionConfirmations<TChain extends Chain>(client: PublicClient<any, TChain>, { hash, transactionReceipt }: GetTransactionConfirmationsArgs<TChain>): Promise<GetTransactionConfirmationsResponse>;
262
-
263
- type GetTransactionCountArgs = {
264
- /** The account address. */
265
- address: Address;
266
- } & ({
267
- /** The block number. */
268
- blockNumber?: bigint;
269
- blockTag?: never;
270
- } | {
271
- blockNumber?: never;
272
- /** The block tag. Defaults to 'latest'. */
273
- blockTag?: BlockTag;
274
- });
275
- type GetTransactionCountResponse = number;
276
- /**
277
- * @description Returns the number of transactions an account has broadcast / sent.
278
- */
279
- declare function getTransactionCount(client: PublicClient, { address, blockTag, blockNumber }: GetTransactionCountArgs): Promise<GetTransactionCountResponse>;
280
-
281
- type GetTransactionReceiptArgs = {
282
- /** The hash of the transaction. */
283
- hash: Hash;
284
- };
285
- type GetTransactionReceiptResponse<TChain extends Chain = Chain> = FormattedTransactionReceipt<TransactionReceiptFormatter<TChain>>;
286
- 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>>;
287
-
288
- type UninstallFilterArgs = {
289
- filter: Filter<any>;
290
- };
291
- type UninstallFilterResponse = boolean;
292
- declare function uninstallFilter(client: PublicClient, { filter }: UninstallFilterArgs): Promise<UninstallFilterResponse>;
293
-
294
- type ReplacementReason = 'cancelled' | 'replaced' | 'repriced';
295
- type ReplacementResponse<TChain extends Chain = Chain> = {
296
- reason: ReplacementReason;
297
- replacedTransaction: Transaction;
298
- transaction: Transaction;
299
- transactionReceipt: GetTransactionReceiptResponse<TChain>;
300
- };
301
- type WaitForTransactionReceiptResponse<TChain extends Chain = Chain> = GetTransactionReceiptResponse<TChain>;
302
- type WaitForTransactionReceiptArgs<TChain extends Chain = Chain> = {
303
- /** The number of confirmations (blocks that have passed) to wait before resolving. */
304
- confirmations?: number;
305
- /** The hash of the transaction. */
306
- hash: Hash;
307
- onReplaced?: (response: ReplacementResponse<TChain>) => void;
308
- /** Polling frequency (in ms). Defaults to the client's pollingInterval config. */
309
- pollingInterval?: number;
310
- /** Optional timeout (in milliseconds) to wait before stopping polling. */
311
- timeout?: number;
312
- };
313
- declare function waitForTransactionReceipt<TChain extends Chain>(client: PublicClient<any, TChain>, { confirmations, hash, onReplaced, pollingInterval, timeout, }: WaitForTransactionReceiptArgs<TChain>): Promise<WaitForTransactionReceiptResponse<TChain>>;
314
-
315
- type OnBlockNumberResponse = GetBlockNumberResponse;
316
- type OnBlockNumber = (blockNumber: OnBlockNumberResponse, prevBlockNumber: OnBlockNumberResponse | undefined) => void;
317
- type WatchBlockNumberArgs = {
318
- /** Whether or not to emit the missed block numbers to the callback. */
319
- emitMissed?: boolean;
320
- /** Whether or not to emit the latest block number to the callback when the subscription opens. */
321
- emitOnBegin?: boolean;
322
- /** The callback to call when a new block number is received. */
323
- onBlockNumber: OnBlockNumber;
324
- /** The callback to call when an error occurred when trying to get for a new block. */
325
- onError?: (error: Error) => void;
326
- /** Polling frequency (in ms). Defaults to Client's pollingInterval config. */
327
- pollingInterval?: number;
328
- };
329
- /** @description Watches and returns incoming block numbers. */
330
- declare function watchBlockNumber(client: PublicClient, { emitOnBegin, emitMissed, onBlockNumber, onError, pollingInterval, }: WatchBlockNumberArgs): () => void;
331
-
332
- type OnBlockResponse<TChain extends Chain = Chain, TIncludeTransactions = false> = Omit<GetBlockResponse<TChain>, TIncludeTransactions extends false ? 'transactions' : ''>;
333
- type OnBlock<TChain extends Chain = Chain, TIncludeTransactions = false> = (block: OnBlockResponse<TChain, TIncludeTransactions>, prevBlock: OnBlockResponse<TChain, TIncludeTransactions> | undefined) => void;
334
- type WatchBlocksArgs<TChain extends Chain = Chain> = {
335
- /** The block tag. Defaults to "latest". */
336
- blockTag?: BlockTag;
337
- /** Whether or not to emit the missed blocks to the callback. */
338
- emitMissed?: boolean;
339
- /** Whether or not to emit the block to the callback when the subscription opens. */
340
- emitOnBegin?: boolean;
341
- /** The callback to call when an error occurred when trying to get for a new block. */
342
- onError?: (error: Error) => void;
343
- /** Polling frequency (in ms). Defaults to the client's pollingInterval config. */
344
- pollingInterval?: number;
345
- } & ({
346
- /** Whether or not to include transaction data in the response. */
347
- includeTransactions: true;
348
- /** The callback to call when a new block is received. */
349
- onBlock: OnBlock<TChain, true>;
350
- } | {
351
- /** Whether or not to include transaction data in the response. */
352
- includeTransactions?: false;
353
- /** The callback to call when a new block is received. */
354
- onBlock: OnBlock<TChain>;
355
- });
356
- /** @description Watches and returns information for incoming blocks. */
357
- declare function watchBlocks<TChain extends Chain, TWatchBlocksArgs extends WatchBlocksArgs<TChain>>(client: PublicClient<any, TChain>, { blockTag, emitMissed, emitOnBegin, onBlock, onError, includeTransactions, pollingInterval, }: TWatchBlocksArgs): () => void;
358
-
359
- type OnTransactionsResponse = Hash[];
360
- type OnTransactions = (transactions: OnTransactionsResponse) => void;
361
- type WatchPendingTransactionsArgs = {
362
- /** Whether or not the transaction hashes should be batched on each invocation. */
363
- batch?: boolean;
364
- /** The callback to call when an error occurred when trying to get for a new block. */
365
- onError?: (error: Error) => void;
366
- /** The callback to call when new transactions are received. */
367
- onTransactions: OnTransactions;
368
- /** Polling frequency (in ms). Defaults to Client's pollingInterval config. */
369
- pollingInterval?: number;
370
- };
371
- declare function watchPendingTransactions(client: PublicClient, { batch, onError, onTransactions, pollingInterval, }: WatchPendingTransactionsArgs): () => void;
372
-
373
- export { createPendingTransactionFilter as $, GetTransactionResponse as A, GetTransactionReceiptArgs as B, CallArgs as C, DeployContractArgs as D, EstimateGasArgs as E, Filter as F, GetBalanceArgs as G, GetTransactionReceiptResponse as H, OnBlockNumber as I, OnBlockNumberResponse as J, OnBlockResponse as K, OnTransactions as L, OnTransactionsResponse as M, SimulateContractResponse as N, OnBlock as O, UninstallFilterResponse as P, WaitForTransactionReceiptResponse as Q, WatchBlockNumberArgs as R, SimulateContractArgs as S, WatchBlocksArgs as T, UninstallFilterArgs as U, WatchPendingTransactionsArgs as V, WaitForTransactionReceiptArgs as W, WriteContractArgs as X, WriteContractResponse as Y, call as Z, createBlockFilter as _, CallResponse as a, deployContract as a0, estimateGas as a1, getBalance as a2, getBlock as a3, getBlockNumber as a4, getBlockTransactionCount as a5, getBytecode as a6, getChainId as a7, getFeeHistory as a8, getFilterChanges as a9, getFilterLogs as aa, getGasPrice as ab, getTransaction as ac, getTransactionConfirmations as ad, getTransactionCount as ae, getTransactionReceipt as af, simulateContract as ag, uninstallFilter as ah, waitForTransactionReceipt as ai, watchBlockNumber as aj, watchBlocks as ak, watchPendingTransactions as al, writeContract as am, getBlockNumberCache as an, ReplacementReason as ao, ReplacementResponse as ap, CreateBlockFilterResponse as b, CreatePendingTransactionFilterResponse as c, EstimateGasResponse as d, DeployContractResponse as e, GetBalanceResponse as f, GetBlockArgs as g, GetBlockNumberArgs as h, GetBlockNumberResponse as i, GetBlockResponse as j, GetBlockTransactionCountArgs as k, GetBlockTransactionCountResponse as l, GetBytecodeArgs as m, GetBytecodeResponse as n, GetFeeHistoryArgs as o, GetFeeHistoryResponse as p, GetFilterChangesArgs as q, GetFilterChangesResponse as r, GetFilterLogsArgs as s, GetFilterLogsResponse as t, GetGasPriceResponse as u, GetTransactionArgs as v, GetTransactionConfirmationsArgs as w, GetTransactionConfirmationsResponse as x, GetTransactionCountArgs as y, GetTransactionCountResponse as z };