viem 0.0.0 → 0.0.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,11 @@
1
+ export { C as CallArgs, a as CallResponse, b as CreateBlockFilterResponse, c as CreatePendingTransactionFilterResponse, D as DropTransactionArgs, E as EstimateGasArgs, d as EstimateGasResponse, G as GetBalanceArgs, e as GetBalanceResponse, f as GetBlockArgs, g as GetBlockNumberArgs, h as GetBlockNumberResponse, i as GetBlockResponse, j as GetBlockTransactionCountArgs, k as GetBlockTransactionCountResponse, l as GetFeeHistoryArgs, m as GetFeeHistoryResponse, n as GetFilterChangesArgs, o as GetFilterChangesResponse, p as GetGasPriceResponse, q as GetPermissionsResponse, r as GetTransactionArgs, s as GetTransactionConfirmationsArgs, t as GetTransactionConfirmationsResponse, u as GetTransactionCountArgs, v as GetTransactionCountResponse, x as GetTransactionReceiptArgs, y as GetTransactionReceiptResponse, w as GetTransactionResponse, I as ImpersonateAccountArgs, z as IncreaseTimeArgs, M as MineArgs, O as OnBlock, A as OnBlockNumber, B as OnBlockNumberResponse, F as OnBlockResponse, H as OnTransactions, J as OnTransactionsResponse, K as RequestPermissionsResponse, R as ResetArgs, L as RevertArgs, S as SendTransactionArgs, N as SendTransactionResponse, P as SendUnsignedTransactionArgs, Q as SendUnsignedTransactionResponse, T as SetBalanceArgs, U as SetBlockGasLimitArgs, Z as SetBlockTimestampIntervalArgs, V as SetCodeArgs, W as SetCoinbaseArgs, X as SetIntervalMiningArgs, Y as SetMinGasPriceArgs, $ as SetNextBlockBaseFeePerGasArgs, _ as SetNextBlockTimestampArgs, a0 as SetNonceArgs, a1 as SetStorageAtArgs, a2 as SignMessageArgs, a3 as SignMessageResponse, a4 as StopImpersonatingAccountArgs, a5 as SwitchChainArgs, a6 as UninstallFilterArgs, a7 as UninstallFilterResponse, a8 as WaitForTransactionReceiptArgs, a9 as WaitForTransactionReceiptResponse, aa as WatchAssetArgs, ab as WatchAssetResponse, ac as WatchBlockNumberArgs, ad as WatchBlocksArgs, ae as WatchPendingTransactionsArgs, af as addChain, ag as call, ah as createBlockFilter, ai as createPendingTransactionFilter, ak as dropTransaction, aj as estimateGas, al as getAutomine, am as getBalance, an as getBlock, ao as getBlockNumber, ap as getBlockTransactionCount, aq as getChainId, ar as getFeeHistory, as as getGasPrice, at as getPermissions, au as getTransaction, av as getTransactionConfirmations, aw as getTransactionCount, ax as getTransactionReceipt, ay as getTxpoolContent, az as getTxpoolStatus, aA as impersonateAccount, aB as increaseTime, aC as inspectTxpool, aD as mine, aE as removeBlockTimestampInterval, aG as requestAccounts, aH as requestPermissions, aF as reset, aI as revert, aJ as sendTransaction, aK as sendUnsignedTransaction, aL as setAutomine, aM as setBalance, aN as setBlockGasLimit, aO as setBlockTimestampInterval, aP as setCode, aQ as setCoinbase, aR as setIntervalMining, aS as setLoggingEnabled, aT as setMinGasPrice, aU as setNextBlockBaseFeePerGas, aV as setNextBlockTimestamp, aW as setNonce, aX as setStorageAt, aY as signMessage, aZ as snapshot, a_ as stopImpersonatingAccount, a$ as switchChain, b0 as uninstallFilter, b1 as waitForTransactionReceipt, b2 as watchAsset, b3 as watchBlockNumber, b4 as watchBlocks, b5 as watchPendingTransactions } from './watchAsset-bb30848d.js';
2
+ export { C as Client, a as ClientConfig, P as PublicClient, b as PublicClientConfig, T as TestClient, c as TestClientConfig, d as Transport, e as TransportConfig, W as WalletClient, f as WalletClientConfig, g as createClient, h as createPublicClient, i as createTestClient, j as createTransport, k as createWalletClient } from './createWalletClient-c40fef16.js';
3
+ export { E as EthereumProviderTransport, a as EthereumProviderTransportConfig, H as HttpTransport, b as HttpTransportConfig, U as UrlRequiredError, W as WebSocketTransport, c as WebSocketTransportConfig, e as ethereumProvider, h as http, w as webSocket } from './webSocket-14584a7e.js';
4
+ export { a as AccessList, A as Address, B as Block, b as BlockIdentifier, c as BlockNumber, d as BlockTag, f as ByteArray, F as FeeHistory, h as FeeValues, i as FeeValuesEIP1559, j as FeeValuesLegacy, k as Hash, H as Hex, L as Log, R as RpcBlock, l as RpcBlockIdentifier, m as RpcBlockNumber, n as RpcFeeHistory, o as RpcFeeValues, p as RpcLog, q as RpcTransaction, r as RpcTransactionReceipt, s as RpcTransactionRequest, u as RpcUncle, D as Transaction, E as TransactionBase, G as TransactionEIP1559, I as TransactionEIP2930, J as TransactionLegacy, T as TransactionReceipt, v as TransactionRequest, x as TransactionRequestBase, y as TransactionRequestEIP1559, z as TransactionRequestEIP2930, C as TransactionRequestLegacy, U as Uncle, e as etherUnits, g as gweiUnits, t as transactionType, w as weiUnits } from './rpc-655c0ba4.js';
5
+ export { E as EncodeRlpResponse, G as GetContractAddressOptions, b as GetCreate2AddressOptions, a as GetCreateAddressOptions, I as InternalRpcError, c as InvalidInputRpcError, d as InvalidParamsRpcError, e as InvalidRequestRpcError, J as JsonRpcVersionUnsupportedError, L as LimitExceededRpcError, M as MethodNotFoundRpcError, f as MethodNotSupportedRpcError, P as ParseRpcError, R as ResourceNotFoundRpcError, g as ResourceUnavailableRpcError, h as RpcRequestError, T as TransactionRejectedRpcError, k as boolToBytes, l as boolToHex, m as bytesToBigint, n as bytesToBool, i as bytesToHex, o as bytesToNumber, j as bytesToString, p as decodeBytes, q as decodeHex, r as decodeRlp, s as encodeBytes, t as encodeHex, u as encodeRlp, B as formatEther, $ as formatGwei, a0 as formatUnit, v as getAddress, w as getContractAddress, y as getCreate2Address, x as getCreateAddress, z as getEventSignature, A as getFunctionSignature, K as hexToBigInt, N as hexToBool, O as hexToBytes, a1 as hexToNumber, Q as hexToString, C as isAddress, D as isAddressEqual, F as isBytes, H as isHex, S as keccak256, U as numberToBytes, a2 as numberToHex, V as pad, W as padBytes, X as padHex, Y as parseEther, Z as parseGwei, _ as parseUnit, a3 as size, a4 as slice, a5 as sliceBytes, a6 as sliceHex, a7 as stringToBytes, a8 as stringToHex, a9 as trim } from './parseGwei-a7d0bcb2.js';
6
+ export { B as BaseError } from './BaseError-7688f84e.js';
7
+ export { F as FormattedBlock, a as FormattedTransaction, b as FormattedTransactionRequest, f as formatBlock, c as formatTransaction, d as formatTransactionRequest } from './transactionRequest-ade896ac.js';
8
+ export { H as HttpRequestError, R as RpcError, T as TimeoutError } from './rpc-3c0e3985.js';
9
+ import './chains.js';
10
+ import '@wagmi/chains';
11
+ import './eip1193-8f7c22ce.js';
package/dist/index.js ADDED
@@ -0,0 +1,278 @@
1
+ import {
2
+ addChain,
3
+ call,
4
+ createBlockFilter,
5
+ createPendingTransactionFilter,
6
+ dropTransaction,
7
+ estimateGas,
8
+ getAutomine,
9
+ getBalance,
10
+ getBlock,
11
+ getBlockNumber,
12
+ getBlockTransactionCount,
13
+ getChainId,
14
+ getFeeHistory,
15
+ getGasPrice,
16
+ getPermissions,
17
+ getTransaction,
18
+ getTransactionConfirmations,
19
+ getTransactionCount,
20
+ getTransactionReceipt,
21
+ getTxpoolContent,
22
+ getTxpoolStatus,
23
+ impersonateAccount,
24
+ increaseTime,
25
+ inspectTxpool,
26
+ mine,
27
+ removeBlockTimestampInterval,
28
+ requestAccounts,
29
+ requestPermissions,
30
+ reset,
31
+ revert,
32
+ sendTransaction,
33
+ sendUnsignedTransaction,
34
+ setAutomine,
35
+ setBalance,
36
+ setBlockGasLimit,
37
+ setBlockTimestampInterval,
38
+ setCode,
39
+ setCoinbase,
40
+ setIntervalMining,
41
+ setLoggingEnabled,
42
+ setMinGasPrice,
43
+ setNextBlockBaseFeePerGas,
44
+ setNextBlockTimestamp,
45
+ setNonce,
46
+ setStorageAt,
47
+ signMessage,
48
+ snapshot,
49
+ stopImpersonatingAccount,
50
+ switchChain,
51
+ uninstallFilter,
52
+ waitForTransactionReceipt,
53
+ watchAsset,
54
+ watchBlockNumber,
55
+ watchBlocks,
56
+ watchPendingTransactions
57
+ } from "./chunk-JSYJDK4W.js";
58
+ import {
59
+ UrlRequiredError,
60
+ createClient,
61
+ createPublicClient,
62
+ createTestClient,
63
+ createTransport,
64
+ createWalletClient,
65
+ ethereumProvider,
66
+ http,
67
+ webSocket
68
+ } from "./chunk-OPR6LKYX.js";
69
+ import {
70
+ BaseError,
71
+ HttpRequestError,
72
+ InternalRpcError,
73
+ InvalidInputRpcError,
74
+ InvalidParamsRpcError,
75
+ InvalidRequestRpcError,
76
+ JsonRpcVersionUnsupportedError,
77
+ LimitExceededRpcError,
78
+ MethodNotFoundRpcError,
79
+ MethodNotSupportedRpcError,
80
+ ParseRpcError,
81
+ ResourceNotFoundRpcError,
82
+ ResourceUnavailableRpcError,
83
+ RpcError,
84
+ RpcRequestError,
85
+ TimeoutError,
86
+ TransactionRejectedRpcError,
87
+ boolToBytes,
88
+ boolToHex,
89
+ bytesToBigint,
90
+ bytesToBool,
91
+ bytesToHex,
92
+ bytesToNumber,
93
+ bytesToString,
94
+ decodeBytes,
95
+ decodeHex,
96
+ decodeRlp,
97
+ encodeBytes,
98
+ encodeHex,
99
+ encodeRlp,
100
+ etherUnits,
101
+ formatBlock,
102
+ formatEther,
103
+ formatGwei,
104
+ formatTransaction,
105
+ formatTransactionRequest,
106
+ formatUnit,
107
+ getAddress,
108
+ getContractAddress,
109
+ getCreate2Address,
110
+ getCreateAddress,
111
+ getEventSignature,
112
+ getFunctionSignature,
113
+ gweiUnits,
114
+ hexToBigInt,
115
+ hexToBool,
116
+ hexToBytes,
117
+ hexToNumber,
118
+ hexToString,
119
+ isAddress,
120
+ isAddressEqual,
121
+ isBytes,
122
+ isHex,
123
+ keccak256,
124
+ numberToBytes,
125
+ numberToHex,
126
+ pad,
127
+ padBytes,
128
+ padHex,
129
+ parseEther,
130
+ parseGwei,
131
+ parseUnit,
132
+ size,
133
+ slice,
134
+ sliceBytes,
135
+ sliceHex,
136
+ stringToBytes,
137
+ stringToHex,
138
+ transactionType,
139
+ trim,
140
+ weiUnits
141
+ } from "./chunk-GI67STNV.js";
142
+ export {
143
+ BaseError,
144
+ HttpRequestError,
145
+ InternalRpcError,
146
+ InvalidInputRpcError,
147
+ InvalidParamsRpcError,
148
+ InvalidRequestRpcError,
149
+ JsonRpcVersionUnsupportedError,
150
+ LimitExceededRpcError,
151
+ MethodNotFoundRpcError,
152
+ MethodNotSupportedRpcError,
153
+ ParseRpcError,
154
+ ResourceNotFoundRpcError,
155
+ ResourceUnavailableRpcError,
156
+ RpcError,
157
+ RpcRequestError,
158
+ TimeoutError,
159
+ TransactionRejectedRpcError,
160
+ UrlRequiredError,
161
+ addChain,
162
+ boolToBytes,
163
+ boolToHex,
164
+ bytesToBigint,
165
+ bytesToBool,
166
+ bytesToHex,
167
+ bytesToNumber,
168
+ bytesToString,
169
+ call,
170
+ createBlockFilter,
171
+ createClient,
172
+ createPendingTransactionFilter,
173
+ createPublicClient,
174
+ createTestClient,
175
+ createTransport,
176
+ createWalletClient,
177
+ decodeBytes,
178
+ decodeHex,
179
+ decodeRlp,
180
+ dropTransaction,
181
+ encodeBytes,
182
+ encodeHex,
183
+ encodeRlp,
184
+ estimateGas,
185
+ etherUnits,
186
+ ethereumProvider,
187
+ formatBlock,
188
+ formatEther,
189
+ formatGwei,
190
+ formatTransaction,
191
+ formatTransactionRequest,
192
+ formatUnit,
193
+ getAddress,
194
+ getAutomine,
195
+ getBalance,
196
+ getBlock,
197
+ getBlockNumber,
198
+ getBlockTransactionCount,
199
+ getChainId,
200
+ getContractAddress,
201
+ getCreate2Address,
202
+ getCreateAddress,
203
+ getEventSignature,
204
+ getFeeHistory,
205
+ getFunctionSignature,
206
+ getGasPrice,
207
+ getPermissions,
208
+ getTransaction,
209
+ getTransactionConfirmations,
210
+ getTransactionCount,
211
+ getTransactionReceipt,
212
+ getTxpoolContent,
213
+ getTxpoolStatus,
214
+ gweiUnits,
215
+ hexToBigInt,
216
+ hexToBool,
217
+ hexToBytes,
218
+ hexToNumber,
219
+ hexToString,
220
+ http,
221
+ impersonateAccount,
222
+ increaseTime,
223
+ inspectTxpool,
224
+ isAddress,
225
+ isAddressEqual,
226
+ isBytes,
227
+ isHex,
228
+ keccak256,
229
+ mine,
230
+ numberToBytes,
231
+ numberToHex,
232
+ pad,
233
+ padBytes,
234
+ padHex,
235
+ parseEther,
236
+ parseGwei,
237
+ parseUnit,
238
+ removeBlockTimestampInterval,
239
+ requestAccounts,
240
+ requestPermissions,
241
+ reset,
242
+ revert,
243
+ sendTransaction,
244
+ sendUnsignedTransaction,
245
+ setAutomine,
246
+ setBalance,
247
+ setBlockGasLimit,
248
+ setBlockTimestampInterval,
249
+ setCode,
250
+ setCoinbase,
251
+ setIntervalMining,
252
+ setLoggingEnabled,
253
+ setMinGasPrice,
254
+ setNextBlockBaseFeePerGas,
255
+ setNextBlockTimestamp,
256
+ setNonce,
257
+ setStorageAt,
258
+ signMessage,
259
+ size,
260
+ slice,
261
+ sliceBytes,
262
+ sliceHex,
263
+ snapshot,
264
+ stopImpersonatingAccount,
265
+ stringToBytes,
266
+ stringToHex,
267
+ switchChain,
268
+ transactionType,
269
+ trim,
270
+ uninstallFilter,
271
+ waitForTransactionReceipt,
272
+ watchAsset,
273
+ watchBlockNumber,
274
+ watchBlocks,
275
+ watchPendingTransactions,
276
+ webSocket,
277
+ weiUnits
278
+ };
@@ -0,0 +1,275 @@
1
+ import { A as Address, f as ByteArray, H as Hex } from './rpc-655c0ba4.js';
2
+ import { B as BaseError } from './BaseError-7688f84e.js';
3
+ import { R as RpcError } from './rpc-3c0e3985.js';
4
+
5
+ declare function getAddress(address: Address): `0x${string}`;
6
+
7
+ type GetCreateAddressOptions = {
8
+ from: Address;
9
+ nonce: bigint;
10
+ };
11
+ type GetCreate2AddressOptions = {
12
+ bytecode: ByteArray | Hex;
13
+ from: Address;
14
+ salt: ByteArray | Hex;
15
+ };
16
+ type GetContractAddressOptions = ({
17
+ opcode?: 'CREATE';
18
+ } & GetCreateAddressOptions) | ({
19
+ opcode: 'CREATE2';
20
+ } & GetCreate2AddressOptions);
21
+ declare function getContractAddress(opts: GetContractAddressOptions): `0x${string}`;
22
+ declare function getCreateAddress(opts: GetCreateAddressOptions): `0x${string}`;
23
+ declare function getCreate2Address(opts: GetCreate2AddressOptions): `0x${string}`;
24
+
25
+ declare function isAddress(address: Address): boolean;
26
+
27
+ declare function isAddressEqual(a: Address, b: Address): boolean;
28
+
29
+ declare function buildRequest<TRequest extends (args: any) => Promise<any>>(request: TRequest): TRequest;
30
+ declare class RequestError extends BaseError {
31
+ constructor(err: Error, { docsPath, humanMessage }: {
32
+ docsPath?: string;
33
+ humanMessage: string;
34
+ });
35
+ }
36
+ declare class RpcRequestError extends RequestError {
37
+ code: number;
38
+ constructor(err: RpcError, { docsPath, humanMessage }: {
39
+ docsPath?: string;
40
+ humanMessage: string;
41
+ });
42
+ }
43
+ declare class ParseRpcError extends RpcRequestError {
44
+ name: string;
45
+ code: number;
46
+ constructor(err: RpcError);
47
+ }
48
+ declare class InvalidRequestRpcError extends RpcRequestError {
49
+ name: string;
50
+ code: number;
51
+ constructor(err: RpcError);
52
+ }
53
+ declare class MethodNotFoundRpcError extends RpcRequestError {
54
+ name: string;
55
+ code: number;
56
+ constructor(err: RpcError);
57
+ }
58
+ declare class InvalidParamsRpcError extends RpcRequestError {
59
+ name: string;
60
+ code: number;
61
+ constructor(err: RpcError);
62
+ }
63
+ declare class InternalRpcError extends RpcRequestError {
64
+ name: string;
65
+ code: number;
66
+ constructor(err: RpcError);
67
+ }
68
+ declare class InvalidInputRpcError extends RpcRequestError {
69
+ name: string;
70
+ code: number;
71
+ constructor(err: RpcError);
72
+ }
73
+ declare class ResourceNotFoundRpcError extends RpcRequestError {
74
+ name: string;
75
+ code: number;
76
+ constructor(err: RpcError);
77
+ }
78
+ declare class ResourceUnavailableRpcError extends RpcRequestError {
79
+ name: string;
80
+ code: number;
81
+ constructor(err: RpcError);
82
+ }
83
+ declare class TransactionRejectedRpcError extends RpcRequestError {
84
+ name: string;
85
+ code: number;
86
+ constructor(err: RpcError);
87
+ }
88
+ declare class MethodNotSupportedRpcError extends RpcRequestError {
89
+ name: string;
90
+ code: number;
91
+ constructor(err: RpcError);
92
+ }
93
+ declare class LimitExceededRpcError extends RpcRequestError {
94
+ name: string;
95
+ code: number;
96
+ constructor(err: RpcError);
97
+ }
98
+ declare class JsonRpcVersionUnsupportedError extends RpcRequestError {
99
+ name: string;
100
+ code: number;
101
+ constructor(err: RpcError);
102
+ }
103
+
104
+ declare function isBytes(value: any): boolean;
105
+
106
+ declare function isHex(value: any): boolean;
107
+
108
+ type PadOptions = {
109
+ dir?: 'left' | 'right';
110
+ size?: number;
111
+ };
112
+ declare function pad(hexOrBytes: Hex | ByteArray, { dir, size }?: PadOptions): `0x${string}` | Uint8Array;
113
+ declare function padHex(hex_: Hex, { dir, size }?: PadOptions): `0x${string}`;
114
+ declare function padBytes(bytes: ByteArray, { dir, size }?: PadOptions): Uint8Array;
115
+
116
+ type TrimOptions = {
117
+ dir?: 'left' | 'right';
118
+ };
119
+ declare function trim(hexOrBytes: Hex | ByteArray, { dir }?: TrimOptions): string | Uint8Array;
120
+
121
+ /**
122
+ * @description Retrieves the size of the value (in bytes).
123
+ *
124
+ * @param value The value (hex or byte array) to retrieve the size of.
125
+ * @returns The size of the value (in bytes).
126
+ */
127
+ declare function size(value: Hex | ByteArray): number;
128
+
129
+ type SliceResult<TValue extends ByteArray | Hex> = TValue extends Hex ? Hex : ByteArray;
130
+ /**
131
+ * @description Returns a section of the hex or byte array given a start/end bytes offset.
132
+ *
133
+ * @param value The hex or byte array to slice.
134
+ * @param start The start offset (in bytes).
135
+ * @param end The end offset (in bytes).
136
+ */
137
+ declare function slice<TValue extends ByteArray | Hex>(value: TValue, start?: number, end?: number): SliceResult<TValue>;
138
+ /**
139
+ * @description Returns a section of the byte array given a start/end bytes offset.
140
+ *
141
+ * @param value The byte array to slice.
142
+ * @param start The start offset (in bytes).
143
+ * @param end The end offset (in bytes).
144
+ */
145
+ declare function sliceBytes(value: ByteArray, start?: number, end?: number): Uint8Array;
146
+ /**
147
+ * @description Returns a section of the hex value given a start/end bytes offset.
148
+ *
149
+ * @param value The hex value to slice.
150
+ * @param start The start offset (in bytes).
151
+ * @param end The end offset (in bytes).
152
+ */
153
+ declare function sliceHex(value_: Hex, start?: number, end?: number): string;
154
+
155
+ /**
156
+ * @description Encodes a boolean into a hex string
157
+ */
158
+ declare function boolToHex(value: boolean): Hex;
159
+ /**
160
+ * @description Encodes a bytes array into a hex string
161
+ */
162
+ declare function bytesToHex(value: ByteArray): Hex;
163
+ /**
164
+ * @description Encodes a string, number, bigint, or ByteArray into a hex string
165
+ */
166
+ declare function encodeHex(value: string | number | bigint | boolean | ByteArray): Hex;
167
+ type NumberToHexOpts = {
168
+ signed?: boolean;
169
+ size: number;
170
+ } | {
171
+ signed?: never;
172
+ size?: never;
173
+ };
174
+ /**
175
+ * @description Encodes a number or bigint into a hex string
176
+ */
177
+ declare function numberToHex(value_: number | bigint, opts?: NumberToHexOpts): Hex;
178
+ /**
179
+ * @description Encodes a UTF-8 string into a hex string
180
+ */
181
+ declare function stringToHex(value: string): Hex;
182
+
183
+ /**
184
+ * @description Encodes a boolean into a byte array.
185
+ */
186
+ declare function boolToBytes(value: boolean): Uint8Array;
187
+ /** @description Encodes a UTF-8 string, hex value, bigint, number or boolean to a byte array. */
188
+ declare function encodeBytes(value: string | bigint | number | boolean | Hex): ByteArray;
189
+ /**
190
+ * @description Encodes a hex string into a byte array.
191
+ */
192
+ declare function hexToBytes(hex_: Hex): ByteArray;
193
+ /**
194
+ * @description Encodes a number into a byte array.
195
+ */
196
+ declare function numberToBytes(value: bigint | number, opts?: NumberToHexOpts): Uint8Array;
197
+ /**
198
+ * @description Encodes a UTF-8 string into a byte array.
199
+ */
200
+ declare function stringToBytes(value: string): ByteArray;
201
+
202
+ type RecursiveArray<T> = T | Array<RecursiveArray<T>>;
203
+ type To$1 = 'hex' | 'bytes';
204
+ type EncodeRlpResponse<TTo extends To$1> = TTo extends 'bytes' ? ByteArray : TTo extends 'hex' ? Hex : never;
205
+ declare function encodeRlp<TTo extends To$1 = 'hex'>(hexOrBytes: RecursiveArray<Hex> | RecursiveArray<ByteArray>, to_?: TTo): EncodeRlpResponse<TTo>;
206
+
207
+ type DecodeBytesResponse<TTo> = TTo extends 'string' ? string : TTo extends 'hex' ? Hex : TTo extends 'bigint' ? bigint : TTo extends 'number' ? number : TTo extends 'boolean' ? boolean : never;
208
+ /**
209
+ * @description Decodes a byte array into a UTF-8 string, hex value, number, bigint or boolean.
210
+ */
211
+ declare function decodeBytes<TTo extends 'string' | 'hex' | 'bigint' | 'number' | 'boolean'>(bytes: ByteArray, to: TTo): DecodeBytesResponse<TTo>;
212
+ /**
213
+ * @description Decodes a byte array into a bigint.
214
+ */
215
+ declare function bytesToBigint(bytes: ByteArray): bigint;
216
+ /**
217
+ * @description Decodes a byte array into a boolean.
218
+ */
219
+ declare function bytesToBool(bytes: ByteArray): boolean;
220
+
221
+ /**
222
+ * @description Decodes a byte array into a number.
223
+ */
224
+ declare function bytesToNumber(bytes: ByteArray): number;
225
+ /**
226
+ * @description Decodes a byte array into a UTF-8 string.
227
+ */
228
+ declare function bytesToString(bytes: ByteArray): string;
229
+
230
+ type DecodeHexResponse<TTo> = TTo extends 'string' ? string : TTo extends 'bigint' ? bigint : TTo extends 'number' ? number : TTo extends 'bytes' ? ByteArray : TTo extends 'boolean' ? boolean : never;
231
+ /**
232
+ * @description Decodes a hex string into a string, number, bigint, boolean, or bytes32 array.
233
+ */
234
+ declare function decodeHex<TTo extends 'string' | 'bigint' | 'number' | 'bytes' | 'boolean'>(hex: Hex, to: TTo): DecodeHexResponse<TTo>;
235
+ /**
236
+ * @description Decodes a hex string into a bigint.
237
+ */
238
+ declare function hexToBigInt(hex: Hex): bigint;
239
+ /**
240
+ * @description Decodes a hex string into a boolean.
241
+ */
242
+ declare function hexToBool(hex: Hex): boolean;
243
+ /**
244
+ * @description Decodes a hex string into a number.
245
+ */
246
+ declare function hexToNumber(hex: Hex): number;
247
+ /**
248
+ * @description Decodes a hex string into a UTF-8 string.
249
+ */
250
+ declare function hexToString(hex: Hex): string;
251
+
252
+ type DecodeRlpResponse<TTo> = TTo extends 'bytes' ? ByteArray : TTo extends 'hex' ? Hex : never;
253
+ declare function decodeRlp<TTo extends 'bytes' | 'hex'>(value: ByteArray | Hex, to: TTo): RecursiveArray<DecodeRlpResponse<TTo>>;
254
+
255
+ declare const getEventSignature: (event: `${string}(${string})`) => `0x${string}`;
256
+
257
+ declare const getFunctionSignature: (fn: string) => string;
258
+
259
+ type To = 'hex' | 'bytes';
260
+ type Keccak256Hash<TTo extends To> = TTo extends 'bytes' ? ByteArray : TTo extends 'hex' ? Hex : never;
261
+ declare function keccak256<TTo extends To = 'hex'>(value: ByteArray, to_?: TTo): Keccak256Hash<TTo>;
262
+
263
+ declare function formatEther(wei: bigint, unit?: 'wei' | 'gwei'): string;
264
+
265
+ declare function formatGwei(wei: bigint, unit?: 'wei'): string;
266
+
267
+ declare function formatUnit(value: bigint, decimals: number): string;
268
+
269
+ declare function parseUnit(value: `${number}`, decimals: number): bigint;
270
+
271
+ declare function parseEther(ether: `${number}`, unit?: 'wei' | 'gwei'): bigint;
272
+
273
+ declare function parseGwei(ether: `${number}`, unit?: 'wei'): bigint;
274
+
275
+ export { formatGwei as $, getFunctionSignature as A, formatEther as B, isAddress as C, isAddressEqual as D, EncodeRlpResponse as E, isBytes as F, GetContractAddressOptions as G, isHex as H, InternalRpcError as I, JsonRpcVersionUnsupportedError as J, hexToBigInt as K, LimitExceededRpcError as L, MethodNotFoundRpcError as M, hexToBool as N, hexToBytes as O, ParseRpcError as P, hexToString as Q, ResourceNotFoundRpcError as R, keccak256 as S, TransactionRejectedRpcError as T, numberToBytes as U, pad as V, padBytes as W, padHex as X, parseEther as Y, parseGwei as Z, parseUnit as _, GetCreateAddressOptions as a, formatUnit as a0, hexToNumber as a1, numberToHex as a2, size as a3, slice as a4, sliceBytes as a5, sliceHex as a6, stringToBytes as a7, stringToHex as a8, trim as a9, buildRequest as aa, GetCreate2AddressOptions as b, InvalidInputRpcError as c, InvalidParamsRpcError as d, InvalidRequestRpcError as e, MethodNotSupportedRpcError as f, ResourceUnavailableRpcError as g, RpcRequestError as h, bytesToHex as i, bytesToString as j, boolToBytes as k, boolToHex as l, bytesToBigint as m, bytesToBool as n, bytesToNumber as o, decodeBytes as p, decodeHex as q, decodeRlp as r, encodeBytes as s, encodeHex as t, encodeRlp as u, getAddress as v, getContractAddress as w, getCreateAddress as x, getCreate2Address as y, getEventSignature as z };
@@ -0,0 +1,98 @@
1
+ import { B as BaseError } from './BaseError-7688f84e.js';
2
+
3
+ type SuccessResult<T> = {
4
+ method?: never;
5
+ result: T;
6
+ error?: never;
7
+ };
8
+ type ErrorResult<T> = {
9
+ method?: never;
10
+ result?: never;
11
+ error: T;
12
+ };
13
+ type Subscription<TResult, TError> = {
14
+ method: 'eth_subscription';
15
+ error?: never;
16
+ result?: never;
17
+ params: {
18
+ subscription: string;
19
+ } & ({
20
+ result: TResult;
21
+ error?: never;
22
+ } | {
23
+ result?: never;
24
+ error: TError;
25
+ });
26
+ };
27
+ type RpcRequest = {
28
+ method: string;
29
+ params?: any[];
30
+ };
31
+ type RpcResponse<TResult = any, TError = any> = {
32
+ jsonrpc: `${number}`;
33
+ id: number;
34
+ } & (SuccessResult<TResult> | ErrorResult<TError> | Subscription<TResult, TError>);
35
+ declare function http(url: string, { body, retryDelay, retryCount, timeout, }: {
36
+ body: RpcRequest;
37
+ retryDelay?: number;
38
+ retryCount?: number;
39
+ timeout?: number;
40
+ }): Promise<RpcResponse<any, any>>;
41
+ type Id = string | number;
42
+ type CallbackFn = (message: any) => void;
43
+ type CallbackMap = Map<Id, CallbackFn>;
44
+ type Socket = WebSocket & {
45
+ requests: CallbackMap;
46
+ subscriptions: CallbackMap;
47
+ };
48
+ declare function webSocket(socket: Socket, { body, onData, onError, }: {
49
+ body: RpcRequest;
50
+ onData?: (message: RpcResponse) => void;
51
+ onError?: (message: RpcResponse['error']) => void;
52
+ }): Socket;
53
+ declare function webSocketAsync(socket: Socket, { body, timeout, }: {
54
+ body: RpcRequest;
55
+ timeout?: number;
56
+ }): Promise<RpcResponse<any, any>>;
57
+ declare const rpc: {
58
+ http: typeof http;
59
+ webSocket: typeof webSocket;
60
+ webSocketAsync: typeof webSocketAsync;
61
+ };
62
+ declare class HttpRequestError extends BaseError {
63
+ name: string;
64
+ status: number;
65
+ constructor({ body, details, status, url, }: {
66
+ body: {
67
+ [key: string]: unknown;
68
+ };
69
+ details: string;
70
+ status: number;
71
+ url: string;
72
+ });
73
+ }
74
+ declare class RpcError extends BaseError {
75
+ code: number;
76
+ name: string;
77
+ constructor({ body, error, url, }: {
78
+ body: {
79
+ [key: string]: unknown;
80
+ };
81
+ error: {
82
+ code: number;
83
+ message: string;
84
+ };
85
+ url: string;
86
+ });
87
+ }
88
+ declare class TimeoutError extends BaseError {
89
+ name: string;
90
+ constructor({ body, url, }: {
91
+ body: {
92
+ [key: string]: unknown;
93
+ };
94
+ url: string;
95
+ });
96
+ }
97
+
98
+ export { HttpRequestError as H, RpcError as R, TimeoutError as T, RpcResponse as a, rpc as r };