viem 0.0.1-alpha.3 → 0.0.1-alpha.31

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 (101) hide show
  1. package/chains/package.json +1 -1
  2. package/contract/package.json +4 -0
  3. package/dist/chain-00b37e4e.d.ts +543 -0
  4. package/dist/chain-38182d92.d.ts +5 -0
  5. package/dist/chains.d.ts +1305 -74
  6. package/dist/chains.js +125 -130
  7. package/dist/chains.js.map +1 -0
  8. package/dist/chains.mjs +129 -0
  9. package/dist/chains.mjs.map +1 -0
  10. package/dist/chunk-5STAX3WF.js +265 -0
  11. package/dist/chunk-5STAX3WF.js.map +1 -0
  12. package/dist/chunk-6ZFIUYGC.mjs +3436 -0
  13. package/dist/chunk-6ZFIUYGC.mjs.map +1 -0
  14. package/dist/chunk-APXHGB76.mjs +197 -0
  15. package/dist/chunk-APXHGB76.mjs.map +1 -0
  16. package/dist/chunk-C54QK7K3.mjs +210 -0
  17. package/dist/chunk-C54QK7K3.mjs.map +1 -0
  18. package/dist/{chunk-YZEQFYZ3.js → chunk-IBWRBL2I.mjs} +725 -556
  19. package/dist/chunk-IBWRBL2I.mjs.map +1 -0
  20. package/dist/chunk-J7QHQ26Y.js +3436 -0
  21. package/dist/chunk-J7QHQ26Y.js.map +1 -0
  22. package/dist/chunk-MYFKW55L.js +210 -0
  23. package/dist/chunk-MYFKW55L.js.map +1 -0
  24. package/dist/chunk-NCPBWOQA.js +1216 -0
  25. package/dist/chunk-NCPBWOQA.js.map +1 -0
  26. package/dist/chunk-QBB3DFIB.mjs +265 -0
  27. package/dist/chunk-QBB3DFIB.mjs.map +1 -0
  28. package/dist/chunk-UUULPQHV.js +197 -0
  29. package/dist/chunk-UUULPQHV.js.map +1 -0
  30. package/dist/contract.d.ts +11 -0
  31. package/dist/contract.js +57 -0
  32. package/dist/contract.js.map +1 -0
  33. package/dist/contract.mjs +57 -0
  34. package/dist/contract.mjs.map +1 -0
  35. package/dist/createClient-5258d590.d.ts +70 -0
  36. package/dist/createPublicClient-99be385b.d.ts +650 -0
  37. package/dist/{eip1193-8b4d90ce.d.ts → eip1193-fcdeee04.d.ts} +13 -10
  38. package/dist/ens.d.ts +22 -0
  39. package/dist/ens.js +22 -0
  40. package/dist/ens.js.map +1 -0
  41. package/dist/ens.mjs +22 -0
  42. package/dist/ens.mjs.map +1 -0
  43. package/dist/formatAbiItem-50cb39d8.d.ts +14 -0
  44. package/dist/getAbiItem-6d4f64d2.d.ts +97 -0
  45. package/dist/index.d.ts +251 -67
  46. package/dist/index.js +769 -344
  47. package/dist/index.js.map +1 -0
  48. package/dist/index.mjs +769 -0
  49. package/dist/index.mjs.map +1 -0
  50. package/dist/namehash-88f4639d.d.ts +22 -0
  51. package/dist/parseGwei-8af7a0a6.d.ts +509 -0
  52. package/dist/public.d.ts +29 -0
  53. package/dist/public.js +60 -0
  54. package/dist/public.js.map +1 -0
  55. package/dist/public.mjs +60 -0
  56. package/dist/public.mjs.map +1 -0
  57. package/dist/test-79ec416c.d.ts +213 -0
  58. package/dist/test.d.ts +20 -0
  59. package/dist/test.js +62 -0
  60. package/dist/test.js.map +1 -0
  61. package/dist/test.mjs +62 -0
  62. package/dist/test.mjs.map +1 -0
  63. package/dist/utils/index.d.ts +52 -7
  64. package/dist/utils/index.js +187 -126
  65. package/dist/utils/index.js.map +1 -0
  66. package/dist/utils/index.mjs +187 -0
  67. package/dist/utils/index.mjs.map +1 -0
  68. package/dist/wallet-cf5c8351.d.ts +115 -0
  69. package/dist/wallet.d.ts +7 -0
  70. package/dist/wallet.js +24 -0
  71. package/dist/wallet.js.map +1 -0
  72. package/dist/wallet.mjs +24 -0
  73. package/dist/wallet.mjs.map +1 -0
  74. package/dist/window.d.ts +5 -2
  75. package/dist/window.js +1 -0
  76. package/dist/window.js.map +1 -0
  77. package/dist/window.mjs +1 -0
  78. package/dist/window.mjs.map +1 -0
  79. package/ens/package.json +4 -0
  80. package/package.json +46 -73
  81. package/public/package.json +4 -0
  82. package/test/package.json +4 -0
  83. package/utils/package.json +1 -1
  84. package/wallet/package.json +4 -0
  85. package/window/package.json +1 -1
  86. package/actions/package.json +0 -4
  87. package/clients/package.json +0 -4
  88. package/dist/actions/index.d.ts +0 -7
  89. package/dist/actions/index.js +0 -124
  90. package/dist/chunk-SRDTRROA.js +0 -1214
  91. package/dist/chunk-TLEMV4T3.js +0 -258
  92. package/dist/chunk-WZITKXV3.js +0 -996
  93. package/dist/clients/index.d.ts +0 -7
  94. package/dist/clients/index.js +0 -23
  95. package/dist/createWalletClient-15ad1601.d.ts +0 -130
  96. package/dist/parseGwei-0f85e8ca.d.ts +0 -248
  97. package/dist/rpc-15b85963.d.ts +0 -292
  98. package/dist/rpc-26932bae.d.ts +0 -61
  99. package/dist/transactionRequest-f538ea86.d.ts +0 -44
  100. package/dist/watchAsset-0c9d01e2.d.ts +0 -522
  101. package/dist/webSocket-b55b0951.d.ts +0 -83
@@ -1,7 +0,0 @@
1
- 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-15ad1601.js';
2
- 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-b55b0951.js';
3
- import '../chains.js';
4
- import '../rpc-15b85963.js';
5
- import '@wagmi/chains';
6
- import '../eip1193-8b4d90ce.js';
7
- import '../rpc-26932bae.js';
@@ -1,23 +0,0 @@
1
- import {
2
- createClient,
3
- createPublicClient,
4
- createTestClient,
5
- createTransport,
6
- createWalletClient,
7
- custom,
8
- fallback,
9
- http,
10
- webSocket
11
- } from "../chunk-TLEMV4T3.js";
12
- import "../chunk-WZITKXV3.js";
13
- export {
14
- createClient,
15
- createPublicClient,
16
- createTestClient,
17
- createTransport,
18
- createWalletClient,
19
- custom,
20
- fallback,
21
- http,
22
- webSocket
23
- };
@@ -1,130 +0,0 @@
1
- import { Chain } from './chains.js';
2
- import { R as Requests, P as PublicRequests, T as TestRequests, S as SignableRequests, b as WalletRequests } from './eip1193-8b4d90ce.js';
3
-
4
- type BaseRpcRequests = {
5
- request(...args: any): Promise<any>;
6
- };
7
- type TransportConfig<TType extends string = string, TRequests extends BaseRpcRequests['request'] = Requests['request']> = {
8
- /** The name of the transport. */
9
- name: string;
10
- /** The key of the transport. */
11
- key: string;
12
- /** The JSON-RPC request function that matches the EIP-1193 request spec. */
13
- request: TRequests;
14
- /** The type of the transport. */
15
- type: TType;
16
- };
17
- type Transport<TType extends string = string, TRpcAttributes = Record<string, any>> = <TChain extends Chain = Chain>({ chain, }: {
18
- chain?: TChain;
19
- }) => {
20
- config: TransportConfig<TType>;
21
- value?: TRpcAttributes;
22
- };
23
- /**
24
- * @description Creates an transport intended to be used with a client.
25
- */
26
- declare function createTransport<TType extends string = string, TRpcAttributes = any>(config: TransportConfig<TType>, value?: TRpcAttributes): ReturnType<Transport<TType, TRpcAttributes>>;
27
-
28
- type Client<TTransport extends Transport = Transport, TChain extends Chain = Chain, TRequests extends BaseRpcRequests = Requests> = {
29
- /** Chain for the client. */
30
- chain?: TChain;
31
- /** A key for the client. */
32
- key: string;
33
- /** A name for the client. */
34
- name: string;
35
- /** Frequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds. */
36
- pollingInterval: number;
37
- /** Request function wrapped with friendly error handling */
38
- request: TRequests['request'];
39
- /** The RPC transport (http, webSocket, custom, etc) */
40
- transport: ReturnType<TTransport>['config'] & ReturnType<TTransport>['value'];
41
- /** The type of client. */
42
- type: string;
43
- /** A unique ID for the client. */
44
- uid: string;
45
- };
46
- type ClientConfig<TTransport extends Transport = Transport, TChain extends Chain = Chain, TRequests extends BaseRpcRequests = Requests> = Partial<Pick<Client<TTransport, TChain, TRequests>, 'chain' | 'key' | 'name' | 'pollingInterval' | 'type'>> & {
47
- transport: TTransport;
48
- };
49
- /**
50
- * @description Creates a base RPC client with the given transport.
51
- *
52
- * - Intended to be used as a base for other RPC clients.
53
- * - Has access to _all_ EIP-1474 RPC methods.
54
- *
55
- * @example
56
- * import { mainnet } from 'viem/chains'
57
- * import { createClient, http } from 'viem/clients'
58
- * const client = createClient(http({ chain: mainnet }))
59
- */
60
- declare function createClient<TTransport extends Transport, TChain extends Chain, TRequests extends BaseRpcRequests>({ chain, key, name, pollingInterval, transport, type, }: ClientConfig<TTransport, TChain, TRequests>): Client<TTransport, TChain, TRequests>;
61
-
62
- type PublicClientConfig<TTransport extends Transport = Transport, TChain extends Chain = Chain> = Pick<ClientConfig<TTransport, TChain>, 'chain' | 'key' | 'name' | 'pollingInterval' | 'transport'>;
63
- type PublicClient<TTransport extends Transport = Transport, TChain extends Chain = Chain> = Client<TTransport, TChain, PublicRequests>;
64
- /**
65
- * @description Creates a public client with a given transport.
66
- *
67
- * - Only has access to "public" EIP-1474 RPC methods (ie. `eth_blockNumber`, etc).
68
- *
69
- * @example
70
- * import { mainnet } from 'viem/chains'
71
- * import { createPublicClient, http } from 'viem/clients'
72
- * const client = createPublicClient(http({ chain: mainnet }))
73
- */
74
- declare function createPublicClient<TTransport extends Transport, TChain extends Chain>({ chain, key, name, transport, pollingInterval, }: PublicClientConfig<TTransport, TChain>): PublicClient<TTransport, TChain>;
75
-
76
- type TestClientModes = 'anvil' | 'hardhat';
77
- type TestClientConfig<TTransport extends Transport = Transport, TChain extends Chain = Chain, TMode extends TestClientModes = TestClientModes> = {
78
- chain?: ClientConfig<TTransport, TChain>['chain'];
79
- /** The key of the client. */
80
- key?: ClientConfig['key'];
81
- /** Mode of the test client. Available: "anvil" | "hardhat" */
82
- mode: TMode;
83
- /** The name of the client. */
84
- name?: ClientConfig['name'];
85
- /** Frequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds. */
86
- pollingInterval?: ClientConfig['pollingInterval'];
87
- transport: ClientConfig<TTransport, TChain>['transport'];
88
- };
89
- type TestClient<TTransport extends Transport = Transport, TChain extends Chain = Chain, TMode extends TestClientModes = TestClientModes> = Client<TTransport, TChain, TestRequests<TMode>> & {
90
- mode: TMode;
91
- };
92
- /**
93
- * @description Creates a test client with a given transport.
94
- *
95
- * - Only has access to "test" RPC methods (ie. `anvil_setBalance`,
96
- * `evm_mine`, etc).
97
- *
98
- * @example
99
- * import { createTestClient, http } from 'viem'
100
- * import { local } from 'viem/chains'
101
- * const client = createTestClient({ chain: local, mode: 'anvil', transport: http() })
102
- */
103
- declare function createTestClient<TTransport extends Transport, TChain extends Chain, TMode extends TestClientModes>({ chain, key, name, mode, pollingInterval, transport, }: TestClientConfig<TTransport, TChain, TMode>): TestClient<TTransport, TChain, TMode>;
104
-
105
- type WalletClientConfig<TTransport extends Transport = Transport, TChain extends Chain = Chain> = {
106
- chain?: ClientConfig<TTransport, TChain>['chain'];
107
- /** The key of the Wallet Client. */
108
- key?: ClientConfig['key'];
109
- /** The name of the Wallet Client. */
110
- name?: ClientConfig['name'];
111
- /** Frequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds. */
112
- pollingInterval?: ClientConfig['pollingInterval'];
113
- transport: ClientConfig<TTransport, TChain>['transport'];
114
- };
115
- type WalletClient<TTransport extends Transport = Transport, TChain extends Chain = Chain> = Client<TTransport, TChain, SignableRequests & WalletRequests>;
116
- /**
117
- * @description Creates a wallet client with a given transport.
118
- *
119
- * - Only has access to "wallet" & "signable" EIP-1474 RPC methods
120
- * (ie. `eth_sendTransaction`, `eth_requestAccounts`, etc).
121
- *
122
- * @example
123
- * import { createWalletClient, custom } from 'viem'
124
- * const client = createWalletClient(
125
- * custom(window.ethereum)
126
- * )
127
- */
128
- declare function createWalletClient<TTransport extends Transport, TChain extends Chain>({ transport, key, name, pollingInterval, }: WalletClientConfig<TTransport, TChain>): WalletClient<TTransport, TChain>;
129
-
130
- export { BaseRpcRequests as B, Client as C, PublicClient as P, TestClient as T, WalletClient as W, ClientConfig as a, PublicClientConfig as b, TestClientConfig as c, Transport as d, TransportConfig as e, WalletClientConfig as f, createClient as g, createPublicClient as h, createTestClient as i, createTransport as j, createWalletClient as k };
@@ -1,248 +0,0 @@
1
- import { Abi, AbiFunction, ExtractAbiFunction, AbiParametersToPrimitiveTypes, AbiParameter, ExtractAbiFunctionNames } from 'abitype';
2
- import { a as Hex, A as Address, B as ByteArray } from './rpc-15b85963.js';
3
-
4
- type ExtractArgsFromAbi<TAbi extends Abi | readonly unknown[], TFunctionName extends string, TAbiFunction extends AbiFunction & {
5
- type: 'function';
6
- } = TAbi extends Abi ? ExtractAbiFunction<TAbi, TFunctionName> : AbiFunction & {
7
- type: 'function';
8
- }, TArgs = AbiParametersToPrimitiveTypes<TAbiFunction['inputs']>, FailedToParseArgs = ([TArgs] extends [never] ? true : false) | (readonly unknown[] extends TArgs ? true : false)> = true extends FailedToParseArgs ? {
9
- /**
10
- * Arguments to pass contract method
11
- *
12
- * Use a [const assertion](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#const-assertions) on {@link abi} for type inference.
13
- */
14
- args?: readonly unknown[];
15
- } : TArgs extends readonly [] ? {
16
- args?: never;
17
- } : {
18
- /** Arguments to pass contract method */ args: TArgs;
19
- };
20
-
21
- declare function decodeAbi<TParams extends readonly AbiParameter[]>({ data, params, }: {
22
- data: Hex;
23
- params: TParams;
24
- }): AbiParametersToPrimitiveTypes<TParams>;
25
-
26
- declare function decodeFunctionData({ abi, data }: {
27
- abi: Abi;
28
- data: Hex;
29
- }): {
30
- functionName: string;
31
- args: readonly unknown[] | undefined;
32
- };
33
-
34
- /**
35
- * @description Encodes a list of primitive values into an ABI-encoded hex value.
36
- */
37
- declare function encodeAbi<TParams extends readonly AbiParameter[]>({ params, values, }: {
38
- params: TParams;
39
- values: AbiParametersToPrimitiveTypes<TParams>;
40
- }): `0x${string}` | undefined;
41
-
42
- declare function encodeFunctionData<TAbi extends Abi = Abi, TFunctionName extends ExtractAbiFunctionNames<TAbi> = any>({ abi, args, functionName, }: {
43
- abi: TAbi;
44
- functionName: TFunctionName;
45
- } & ExtractArgsFromAbi<TAbi, TFunctionName>): `0x${string}`;
46
-
47
- declare function getAddress(address: Address): `0x${string}`;
48
-
49
- type GetCreateAddressOptions = {
50
- from: Address;
51
- nonce: bigint;
52
- };
53
- type GetCreate2AddressOptions = {
54
- bytecode: ByteArray | Hex;
55
- from: Address;
56
- salt: ByteArray | Hex;
57
- };
58
- type GetContractAddressOptions = ({
59
- opcode?: 'CREATE';
60
- } & GetCreateAddressOptions) | ({
61
- opcode: 'CREATE2';
62
- } & GetCreate2AddressOptions);
63
- declare function getContractAddress(opts: GetContractAddressOptions): `0x${string}`;
64
- declare function getCreateAddress(opts: GetCreateAddressOptions): `0x${string}`;
65
- declare function getCreate2Address(opts: GetCreate2AddressOptions): `0x${string}`;
66
-
67
- declare function isAddress(address: Address): boolean;
68
-
69
- declare function isAddressEqual(a: Address, b: Address): boolean;
70
-
71
- declare function isBytes(value: any): boolean;
72
-
73
- declare function isHex(value: any): boolean;
74
-
75
- type PadOptions = {
76
- dir?: 'left' | 'right';
77
- size?: number;
78
- };
79
- type PadResult<TValue extends ByteArray | Hex> = TValue extends Hex ? Hex : ByteArray;
80
- declare function pad<TValue extends ByteArray | Hex>(hexOrBytes: TValue, { dir, size }?: PadOptions): PadResult<TValue>;
81
- declare function padHex(hex_: Hex, { dir, size }?: PadOptions): `0x${string}`;
82
- declare function padBytes(bytes: ByteArray, { dir, size }?: PadOptions): Uint8Array;
83
-
84
- type TrimOptions = {
85
- dir?: 'left' | 'right';
86
- };
87
- type TrimResult<TValue extends ByteArray | Hex> = TValue extends Hex ? Hex : ByteArray;
88
- declare function trim<TValue extends ByteArray | Hex>(hexOrBytes: TValue, { dir }?: TrimOptions): TrimResult<TValue>;
89
-
90
- /**
91
- * @description Retrieves the size of the value (in bytes).
92
- *
93
- * @param value The value (hex or byte array) to retrieve the size of.
94
- * @returns The size of the value (in bytes).
95
- */
96
- declare function size(value: Hex | ByteArray): number;
97
-
98
- type SliceResult<TValue extends ByteArray | Hex> = TValue extends Hex ? Hex : ByteArray;
99
- /**
100
- * @description Returns a section of the hex or byte array given a start/end bytes offset.
101
- *
102
- * @param value The hex or byte array to slice.
103
- * @param start The start offset (in bytes).
104
- * @param end The end offset (in bytes).
105
- */
106
- declare function slice<TValue extends ByteArray | Hex>(value: TValue, start?: number, end?: number): SliceResult<TValue>;
107
- /**
108
- * @description Returns a section of the byte array given a start/end bytes offset.
109
- *
110
- * @param value The byte array to slice.
111
- * @param start The start offset (in bytes).
112
- * @param end The end offset (in bytes).
113
- */
114
- declare function sliceBytes(value: ByteArray, start?: number, end?: number): Uint8Array;
115
- /**
116
- * @description Returns a section of the hex value given a start/end bytes offset.
117
- *
118
- * @param value The hex value to slice.
119
- * @param start The start offset (in bytes).
120
- * @param end The end offset (in bytes).
121
- */
122
- declare function sliceHex(value_: Hex, start?: number, end?: number): string;
123
-
124
- /**
125
- * @description Encodes a boolean into a hex string
126
- */
127
- declare function boolToHex(value: boolean): Hex;
128
- /**
129
- * @description Encodes a bytes array into a hex string
130
- */
131
- declare function bytesToHex(value: ByteArray): Hex;
132
- /**
133
- * @description Encodes a string, number, bigint, or ByteArray into a hex string
134
- */
135
- declare function encodeHex(value: string | number | bigint | boolean | ByteArray): Hex;
136
- type NumberToHexOpts$1 = {
137
- signed?: boolean;
138
- size: number;
139
- } | {
140
- signed?: never;
141
- size?: never;
142
- };
143
- /**
144
- * @description Encodes a number or bigint into a hex string
145
- */
146
- declare function numberToHex(value_: number | bigint, opts?: NumberToHexOpts$1): Hex;
147
- /**
148
- * @description Encodes a UTF-8 string into a hex string
149
- */
150
- declare function stringToHex(value: string): Hex;
151
-
152
- /**
153
- * @description Encodes a boolean into a byte array.
154
- */
155
- declare function boolToBytes(value: boolean): Uint8Array;
156
- /** @description Encodes a UTF-8 string, hex value, bigint, number or boolean to a byte array. */
157
- declare function encodeBytes(value: string | bigint | number | boolean | Hex): ByteArray;
158
- /**
159
- * @description Encodes a hex string into a byte array.
160
- */
161
- declare function hexToBytes(hex_: Hex): ByteArray;
162
- /**
163
- * @description Encodes a number into a byte array.
164
- */
165
- declare function numberToBytes(value: bigint | number, opts?: NumberToHexOpts$1): Uint8Array;
166
- /**
167
- * @description Encodes a UTF-8 string into a byte array.
168
- */
169
- declare function stringToBytes(value: string): ByteArray;
170
-
171
- type RecursiveArray<T> = T | Array<RecursiveArray<T>>;
172
- type To$1 = 'hex' | 'bytes';
173
- type EncodeRlpResponse<TTo extends To$1> = TTo extends 'bytes' ? ByteArray : TTo extends 'hex' ? Hex : never;
174
- declare function encodeRlp<TTo extends To$1 = 'hex'>(hexOrBytes: RecursiveArray<Hex> | RecursiveArray<ByteArray>, to_?: TTo): EncodeRlpResponse<TTo>;
175
-
176
- type DecodeBytesResponse<TTo> = TTo extends 'string' ? string : TTo extends 'hex' ? Hex : TTo extends 'bigint' ? bigint : TTo extends 'number' ? number : TTo extends 'boolean' ? boolean : never;
177
- /**
178
- * @description Decodes a byte array into a UTF-8 string, hex value, number, bigint or boolean.
179
- */
180
- declare function decodeBytes<TTo extends 'string' | 'hex' | 'bigint' | 'number' | 'boolean'>(bytes: ByteArray, to: TTo): DecodeBytesResponse<TTo>;
181
- /**
182
- * @description Decodes a byte array into a bigint.
183
- */
184
- declare function bytesToBigint(bytes: ByteArray): bigint;
185
- /**
186
- * @description Decodes a byte array into a boolean.
187
- */
188
- declare function bytesToBool(bytes: ByteArray): boolean;
189
-
190
- /**
191
- * @description Decodes a byte array into a number.
192
- */
193
- declare function bytesToNumber(bytes: ByteArray): number;
194
- /**
195
- * @description Decodes a byte array into a UTF-8 string.
196
- */
197
- declare function bytesToString(bytes: ByteArray): string;
198
-
199
- type DecodeHexResponse<TTo> = TTo extends 'string' ? string : TTo extends 'bigint' ? bigint : TTo extends 'number' ? number : TTo extends 'bytes' ? ByteArray : TTo extends 'boolean' ? boolean : never;
200
- /**
201
- * @description Decodes a hex string into a string, number, bigint, boolean, or bytes32 array.
202
- */
203
- declare function decodeHex<TTo extends 'string' | 'bigint' | 'number' | 'bytes' | 'boolean'>(hex: Hex, to: TTo): DecodeHexResponse<TTo>;
204
- type HexToBigIntOpts = {
205
- signed?: boolean;
206
- };
207
- /**
208
- * @description Decodes a hex string into a bigint.
209
- */
210
- declare function hexToBigInt(hex: Hex, opts?: HexToBigIntOpts): bigint;
211
- /**
212
- * @description Decodes a hex string into a boolean.
213
- */
214
- declare function hexToBool(hex: Hex): boolean;
215
- type NumberToHexOpts = HexToBigIntOpts;
216
- /**
217
- * @description Decodes a hex string into a number.
218
- */
219
- declare function hexToNumber(hex: Hex, opts?: NumberToHexOpts): number;
220
- /**
221
- * @description Decodes a hex string into a UTF-8 string.
222
- */
223
- declare function hexToString(hex: Hex): string;
224
-
225
- type DecodeRlpResponse<TTo> = TTo extends 'bytes' ? ByteArray : TTo extends 'hex' ? Hex : never;
226
- declare function decodeRlp<TTo extends 'bytes' | 'hex'>(value: ByteArray | Hex, to: TTo): RecursiveArray<DecodeRlpResponse<TTo>>;
227
-
228
- declare const getEventSignature: (event: `${string}(${string})`) => `0x${string}`;
229
-
230
- declare const getFunctionSignature: (fn: string) => `0x${string}`;
231
-
232
- type To = 'hex' | 'bytes';
233
- type Keccak256Hash<TTo extends To> = TTo extends 'bytes' ? ByteArray : TTo extends 'hex' ? Hex : never;
234
- declare function keccak256<TTo extends To = 'hex'>(value: ByteArray, to_?: TTo): Keccak256Hash<TTo>;
235
-
236
- declare function formatEther(wei: bigint, unit?: 'wei' | 'gwei'): string;
237
-
238
- declare function formatGwei(wei: bigint, unit?: 'wei'): string;
239
-
240
- declare function formatUnit(value: bigint, decimals: number): string;
241
-
242
- declare function parseUnit(value: `${number}`, decimals: number): bigint;
243
-
244
- declare function parseEther(ether: `${number}`, unit?: 'wei' | 'gwei'): bigint;
245
-
246
- declare function parseGwei(ether: `${number}`, unit?: 'wei'): bigint;
247
-
248
- export { stringToHex as $, isAddress as A, isAddressEqual as B, isBytes as C, isHex as D, EncodeRlpResponse as E, hexToBigInt as F, GetContractAddressOptions as G, hexToBool as H, hexToBytes as I, hexToString as J, keccak256 as K, numberToBytes as L, pad as M, padBytes as N, padHex as O, parseEther as P, parseGwei as Q, parseUnit as R, formatGwei as S, formatUnit as T, hexToNumber as U, numberToHex as V, size as W, slice as X, sliceBytes as Y, sliceHex as Z, stringToBytes as _, GetCreateAddressOptions as a, trim as a0, GetCreate2AddressOptions as b, bytesToHex as c, bytesToString as d, boolToBytes as e, boolToHex as f, bytesToBigint as g, bytesToBool as h, bytesToNumber as i, decodeAbi as j, decodeBytes as k, decodeFunctionData as l, decodeHex as m, decodeRlp as n, encodeAbi as o, encodeBytes as p, encodeFunctionData as q, encodeHex as r, encodeRlp as s, getAddress as t, getContractAddress as u, getCreateAddress as v, getCreate2Address as w, getEventSignature as x, getFunctionSignature as y, formatEther as z };