viem 0.0.1-alpha.27 → 0.0.1-alpha.28

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 (81) hide show
  1. package/dist/chain-4d46a747.d.ts +543 -0
  2. package/dist/{chain-b0cfb141.d.ts → chain-c7c44165.d.ts} +1 -1
  3. package/dist/chains.d.ts +5 -3
  4. package/dist/chains.js +46 -46
  5. package/dist/chains.mjs +1 -1
  6. package/dist/chunk-67DKKHAV.js +210 -0
  7. package/dist/chunk-67DKKHAV.js.map +1 -0
  8. package/dist/{chunk-JY7JGKSA.js → chunk-7GQB4KE5.js} +219 -157
  9. package/dist/chunk-7GQB4KE5.js.map +1 -0
  10. package/dist/chunk-FPEKYEVU.js +265 -0
  11. package/dist/chunk-FPEKYEVU.js.map +1 -0
  12. package/dist/chunk-GRILGOX5.mjs +210 -0
  13. package/dist/chunk-GRILGOX5.mjs.map +1 -0
  14. package/dist/{chunk-2DSFM32P.js → chunk-JJ4FDDDW.js} +15 -15
  15. package/dist/{chunk-2DSFM32P.js.map → chunk-JJ4FDDDW.js.map} +1 -1
  16. package/dist/chunk-NKO23GXR.mjs +265 -0
  17. package/dist/chunk-NKO23GXR.mjs.map +1 -0
  18. package/dist/{chunk-W7KWIGWO.js → chunk-NYWN5V47.js} +11 -10
  19. package/dist/chunk-NYWN5V47.js.map +1 -0
  20. package/dist/{chunk-LF6P33WQ.mjs → chunk-PVBEFQET.mjs} +3 -3
  21. package/dist/chunk-PVBEFQET.mjs.map +1 -0
  22. package/dist/{chunk-BJJH7RYH.mjs → chunk-RCJJFKTU.mjs} +164 -102
  23. package/dist/chunk-RCJJFKTU.mjs.map +1 -0
  24. package/dist/{chunk-AKGXRZDN.mjs → chunk-TDOKFOQ5.mjs} +11 -10
  25. package/dist/chunk-TDOKFOQ5.mjs.map +1 -0
  26. package/dist/contract.d.ts +12 -128
  27. package/dist/contract.js +6 -4
  28. package/dist/contract.mjs +5 -3
  29. package/dist/{createClient-6689596e.d.ts → createClient-5d5c14d6.d.ts} +5 -3
  30. package/dist/createPublicClient-2b4afeac.d.ts +629 -0
  31. package/dist/{eip1193-617a05ae.d.ts → eip1193-f09a55af.d.ts} +2 -2
  32. package/dist/ens.d.ts +10 -68
  33. package/dist/ens.js +5 -199
  34. package/dist/ens.js.map +1 -1
  35. package/dist/ens.mjs +7 -201
  36. package/dist/ens.mjs.map +1 -1
  37. package/dist/formatAbiItem-d231fef2.d.ts +14 -0
  38. package/dist/{getAbiItem-d2e8bd76.d.ts → getAbiItem-0e085959.d.ts} +15 -15
  39. package/dist/index.d.ts +21 -12
  40. package/dist/index.js +368 -26
  41. package/dist/index.js.map +1 -1
  42. package/dist/index.mjs +358 -16
  43. package/dist/index.mjs.map +1 -1
  44. package/dist/namehash-88f4639d.d.ts +22 -0
  45. package/dist/parseGwei-07adffee.d.ts +344 -0
  46. package/dist/public.d.ts +11 -334
  47. package/dist/public.js +5 -3
  48. package/dist/public.mjs +4 -2
  49. package/dist/test-b9208949.d.ts +213 -0
  50. package/dist/test.d.ts +8 -149
  51. package/dist/test.js +20 -222
  52. package/dist/test.js.map +1 -1
  53. package/dist/test.mjs +30 -232
  54. package/dist/test.mjs.map +1 -1
  55. package/dist/{transactionReceipt-44dbf122.d.ts → transactionReceipt-84fc92e1.d.ts} +1 -1
  56. package/dist/{transactionRequest-f437b4ba.d.ts → transactionRequest-44c539b4.d.ts} +1 -1
  57. package/dist/utils/index.d.ts +12 -238
  58. package/dist/utils/index.js +2 -2
  59. package/dist/utils/index.mjs +1 -1
  60. package/dist/wallet-9b1c6905.d.ts +104 -0
  61. package/dist/wallet.d.ts +7 -41
  62. package/dist/wallet.js +3 -3
  63. package/dist/wallet.mjs +2 -2
  64. package/dist/window.d.ts +4 -2
  65. package/package.json +1 -1
  66. package/dist/call-3476b8ee.d.ts +0 -22
  67. package/dist/chain-42de87e5.d.ts +0 -359
  68. package/dist/chunk-AKGXRZDN.mjs.map +0 -1
  69. package/dist/chunk-BJJH7RYH.mjs.map +0 -1
  70. package/dist/chunk-JY7JGKSA.js.map +0 -1
  71. package/dist/chunk-LF6P33WQ.mjs.map +0 -1
  72. package/dist/chunk-W7KWIGWO.js.map +0 -1
  73. package/dist/contract-9dd2f98b.d.ts +0 -166
  74. package/dist/createPublicClient-fd558574.d.ts +0 -19
  75. package/dist/createTestClient-bc1d9028.d.ts +0 -34
  76. package/dist/createWalletClient-4df88244.d.ts +0 -30
  77. package/dist/decodeErrorResult-ac835649.d.ts +0 -16
  78. package/dist/readContract-c460f23a.d.ts +0 -10
  79. package/dist/rpc-8c10fc98.d.ts +0 -119
  80. package/dist/sendTransaction-7ce442c0.d.ts +0 -12
  81. package/dist/watchEvent-569c9976.d.ts +0 -41
@@ -0,0 +1,104 @@
1
+ import { Abi, Narrow, Address } from 'abitype';
2
+ import { C as Chain, H as Hex, a3 as ExtractConstructorArgsFromAbi, W as Formatter, X as MergeIntersectionProperties, K as Formatted, u as TransactionRequest, a as Hash, A as Address$1, B as ByteArray, Y as GetValue, h as ContractConfig } from './chain-4d46a747.js';
3
+ import { W as WalletPermission, a as WatchAssetParams, S as SignableRequests, b as WalletRequests } from './eip1193-f09a55af.js';
4
+ import { a as Transport, b as ClientConfig, C as Client } from './createClient-5d5c14d6.js';
5
+ import { T as TransactionRequestFormatter } from './transactionRequest-44c539b4.js';
6
+
7
+ type AddChainArgs = {
8
+ chain: Chain;
9
+ };
10
+ declare function addChain(client: WalletClient, { chain }: AddChainArgs): Promise<void>;
11
+
12
+ type DeployContractArgs<TChain extends Chain = Chain, TAbi extends Abi | readonly unknown[] = Abi> = Omit<SendTransactionArgs<TChain>, 'accessList' | 'to' | 'data' | 'value'> & {
13
+ abi: Narrow<TAbi>;
14
+ bytecode: Hex;
15
+ } & ExtractConstructorArgsFromAbi<TAbi>;
16
+ type DeployContractResponse = SendTransactionResponse;
17
+ declare function deployContract<TChain extends Chain, TAbi extends Abi | readonly unknown[]>(walletClient: WalletClient, { abi, args, bytecode, ...request }: DeployContractArgs<TChain, TAbi>): Promise<DeployContractResponse>;
18
+
19
+ type GetAccountsResponse = Address[];
20
+ declare function getAccounts(client: WalletClient): Promise<GetAccountsResponse>;
21
+
22
+ type GetPermissionsResponse = WalletPermission[];
23
+ declare function getPermissions(client: WalletClient): Promise<WalletPermission[]>;
24
+
25
+ type RequestAccountsResponse = Address[];
26
+ declare function requestAccounts(client: WalletClient): Promise<RequestAccountsResponse>;
27
+
28
+ type RequestPermissionsArgs = {
29
+ eth_accounts: Record<string, any>;
30
+ } & {
31
+ [key: string]: Record<string, any>;
32
+ };
33
+ type RequestPermissionsResponse = WalletPermission[];
34
+ declare function requestPermissions(client: WalletClient, permissions: RequestPermissionsArgs): Promise<WalletPermission[]>;
35
+
36
+ type FormattedTransactionRequest<TFormatter extends Formatter | undefined = Formatter> = MergeIntersectionProperties<Formatted<TFormatter, TransactionRequest, true>, TransactionRequest>;
37
+ type SendTransactionArgs<TChain extends Chain = Chain> = FormattedTransactionRequest<TransactionRequestFormatter<TChain>> & {
38
+ chain?: TChain;
39
+ };
40
+ type SendTransactionResponse = Hash;
41
+ declare function sendTransaction<TChain extends Chain>(client: WalletClient, { chain, from, accessList, data, gas, gasPrice, maxFeePerGas, maxPriorityFeePerGas, nonce, to, value, ...rest }: SendTransactionArgs<TChain>): Promise<SendTransactionResponse>;
42
+
43
+ type SignMessageArgs = {
44
+ from: Address$1;
45
+ data: Hex | ByteArray;
46
+ };
47
+ type SignMessageResponse = Hex;
48
+ declare function signMessage(client: WalletClient, { from, data: data_ }: SignMessageArgs): Promise<SignMessageResponse>;
49
+
50
+ type SwitchChainArgs = {
51
+ id: Chain['id'];
52
+ };
53
+ declare function switchChain(client: WalletClient, { id }: SwitchChainArgs): Promise<void>;
54
+
55
+ type WatchAssetArgs = WatchAssetParams;
56
+ type WatchAssetResponse = boolean;
57
+ declare function watchAsset(client: WalletClient, params: WatchAssetParams): Promise<WatchAssetResponse>;
58
+
59
+ type WriteContractArgs<TChain extends Chain = Chain, TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string> = Omit<SendTransactionArgs<TChain>, 'to' | 'data' | 'value'> & {
60
+ value?: GetValue<TAbi, TFunctionName, SendTransactionArgs<TChain>['value']>;
61
+ } & ContractConfig<TAbi, TFunctionName, 'payable' | 'nonpayable'>;
62
+ type WriteContractResponse = SendTransactionResponse;
63
+ 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>;
64
+
65
+ type WalletClientConfig<TTransport extends Transport = Transport, TChain extends Chain = Chain> = {
66
+ chain?: ClientConfig<TTransport, TChain>['chain'];
67
+ /** The key of the Wallet Client. */
68
+ key?: ClientConfig['key'];
69
+ /** The name of the Wallet Client. */
70
+ name?: ClientConfig['name'];
71
+ /** Frequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds. */
72
+ pollingInterval?: ClientConfig['pollingInterval'];
73
+ transport: ClientConfig<TTransport, TChain>['transport'];
74
+ };
75
+ type WalletClient<TTransport extends Transport = Transport, TChain extends Chain = Chain, TIncludeActions extends boolean = true> = Client<TTransport, TChain, SignableRequests & WalletRequests> & (TIncludeActions extends true ? WalletActions<TChain> : {});
76
+ /**
77
+ * @description Creates a wallet client with a given transport.
78
+ *
79
+ * - Only has access to "wallet" & "signable" EIP-1474 RPC methods
80
+ * (ie. `eth_sendTransaction`, `eth_requestAccounts`, etc).
81
+ *
82
+ * @example
83
+ * import { createWalletClient, custom } from 'viem'
84
+ * const client = createWalletClient(
85
+ * custom(window.ethereum)
86
+ * )
87
+ */
88
+ declare function createWalletClient<TTransport extends Transport, TChain extends Chain>({ transport, key, name, pollingInterval, }: WalletClientConfig<TTransport, TChain>): WalletClient<TTransport, TChain, true>;
89
+
90
+ type WalletActions<TChain extends Chain = Chain> = {
91
+ addChain: (args: AddChainArgs) => Promise<void>;
92
+ deployContract: <TAbi extends Abi | readonly unknown[]>(args: DeployContractArgs<TChain, TAbi>) => Promise<DeployContractResponse>;
93
+ getAccounts: () => Promise<GetAccountsResponse>;
94
+ getPermissions: () => Promise<GetPermissionsResponse>;
95
+ requestAccounts: () => Promise<RequestAccountsResponse>;
96
+ requestPermissions: (args: RequestPermissionsArgs) => Promise<RequestPermissionsResponse>;
97
+ sendTransaction: (args: SendTransactionArgs<TChain>) => Promise<SendTransactionResponse>;
98
+ signMessage: (args: SignMessageArgs) => Promise<SignMessageResponse>;
99
+ switchChain: (args: SwitchChainArgs) => Promise<void>;
100
+ watchAsset: (args: WatchAssetArgs) => Promise<WatchAssetResponse>;
101
+ writeContract: <TAbi extends Abi | readonly unknown[], TFunctionName extends string>(args: WriteContractArgs<TChain, TAbi, TFunctionName>) => Promise<WriteContractResponse>;
102
+ };
103
+
104
+ export { AddChainArgs as A, DeployContractArgs as D, FormattedTransactionRequest as F, GetPermissionsResponse as G, RequestAccountsResponse as R, SendTransactionArgs as S, WalletClient as W, WalletClientConfig as a, WriteContractArgs as b, createWalletClient as c, DeployContractResponse as d, WriteContractResponse as e, deployContract as f, addChain as g, getAccounts as h, getPermissions as i, requestPermissions as j, signMessage as k, switchChain as l, watchAsset as m, GetAccountsResponse as n, RequestPermissionsResponse as o, SendTransactionResponse as p, SignMessageArgs as q, requestAccounts as r, sendTransaction as s, SignMessageResponse as t, SwitchChainArgs as u, WatchAssetArgs as v, writeContract as w, WatchAssetResponse as x };
package/dist/wallet.d.ts CHANGED
@@ -1,42 +1,8 @@
1
- import { C as Chain, A as Address, H as Hex, B as ByteArray } from './chain-42de87e5.js';
2
- import { W as WalletClient } from './createWalletClient-4df88244.js';
3
- import { a as WalletPermission, b as WatchAssetParams } from './eip1193-617a05ae.js';
4
- export { F as FormattedTransactionRequest, S as SendTransactionArgs, a as SendTransactionResponse, s as sendTransaction } from './sendTransaction-7ce442c0.js';
1
+ export { A as AddChainArgs, F as FormattedTransactionRequest, n as GetAccountsResponse, G as GetPermissionsResponse, R as RequestAccountsResponse, o as RequestPermissionsResponse, S as SendTransactionArgs, p as SendTransactionResponse, q as SignMessageArgs, t as SignMessageResponse, u as SwitchChainArgs, v as WatchAssetArgs, x as WatchAssetResponse, g as addChain, h as getAccounts, i as getPermissions, r as requestAccounts, j as requestPermissions, s as sendTransaction, k as signMessage, l as switchChain, m as watchAsset } from './wallet-9b1c6905.js';
2
+ import 'abitype';
3
+ import './chain-4d46a747.js';
5
4
  import '@wagmi/chains';
6
- import './createClient-6689596e.js';
7
- import './transactionRequest-f437b4ba.js';
8
-
9
- declare function addChain(client: WalletClient, chain: Chain): Promise<void>;
10
-
11
- declare function getAccounts(client: WalletClient): Promise<`0x${string}`[]>;
12
-
13
- type GetPermissionsResponse = WalletPermission[];
14
- declare function getPermissions(client: WalletClient): Promise<WalletPermission[]>;
15
-
16
- declare function requestAccounts(client: WalletClient): Promise<`0x${string}`[]>;
17
-
18
- type RequestPermissionsArgs = {
19
- eth_accounts: Record<string, any>;
20
- } & {
21
- [key: string]: Record<string, any>;
22
- };
23
- type RequestPermissionsResponse = WalletPermission[];
24
- declare function requestPermissions(client: WalletClient, permissions: RequestPermissionsArgs): Promise<WalletPermission[]>;
25
-
26
- type SignMessageArgs = {
27
- from: Address;
28
- data: Hex | ByteArray;
29
- };
30
- type SignMessageResponse = Hex;
31
- declare function signMessage(client: WalletClient, { from, data: data_ }: SignMessageArgs): Promise<SignMessageResponse>;
32
-
33
- type SwitchChainArgs = {
34
- id: Chain['id'];
35
- };
36
- declare function switchChain(client: WalletClient, { id }: SwitchChainArgs): Promise<void>;
37
-
38
- type WatchAssetArgs = WatchAssetParams;
39
- type WatchAssetResponse = boolean;
40
- declare function watchAsset(client: WalletClient, params: WatchAssetParams): Promise<WatchAssetResponse>;
41
-
42
- export { GetPermissionsResponse, RequestPermissionsResponse, SignMessageArgs, SignMessageResponse, SwitchChainArgs, WatchAssetArgs, WatchAssetResponse, addChain, getAccounts, getPermissions, requestAccounts, requestPermissions, signMessage, switchChain, watchAsset };
5
+ import 'ethers@6/types/providers';
6
+ import './eip1193-f09a55af.js';
7
+ import './createClient-5d5c14d6.js';
8
+ import './transactionRequest-44c539b4.js';
package/dist/wallet.js CHANGED
@@ -8,8 +8,8 @@
8
8
 
9
9
 
10
10
 
11
- var _chunk2DSFM32Pjs = require('./chunk-2DSFM32P.js');
12
- require('./chunk-W7KWIGWO.js');
11
+ var _chunkJJ4FDDDWjs = require('./chunk-JJ4FDDDW.js');
12
+ require('./chunk-NYWN5V47.js');
13
13
 
14
14
 
15
15
 
@@ -20,5 +20,5 @@ require('./chunk-W7KWIGWO.js');
20
20
 
21
21
 
22
22
 
23
- exports.addChain = _chunk2DSFM32Pjs.addChain; exports.getAccounts = _chunk2DSFM32Pjs.getAccounts; exports.getPermissions = _chunk2DSFM32Pjs.getPermissions; exports.requestAccounts = _chunk2DSFM32Pjs.requestAccounts; exports.requestPermissions = _chunk2DSFM32Pjs.requestPermissions; exports.sendTransaction = _chunk2DSFM32Pjs.sendTransaction; exports.signMessage = _chunk2DSFM32Pjs.signMessage; exports.switchChain = _chunk2DSFM32Pjs.switchChain; exports.watchAsset = _chunk2DSFM32Pjs.watchAsset;
23
+ exports.addChain = _chunkJJ4FDDDWjs.addChain; exports.getAccounts = _chunkJJ4FDDDWjs.getAccounts; exports.getPermissions = _chunkJJ4FDDDWjs.getPermissions; exports.requestAccounts = _chunkJJ4FDDDWjs.requestAccounts; exports.requestPermissions = _chunkJJ4FDDDWjs.requestPermissions; exports.sendTransaction = _chunkJJ4FDDDWjs.sendTransaction; exports.signMessage = _chunkJJ4FDDDWjs.signMessage; exports.switchChain = _chunkJJ4FDDDWjs.switchChain; exports.watchAsset = _chunkJJ4FDDDWjs.watchAsset;
24
24
  //# sourceMappingURL=wallet.js.map
package/dist/wallet.mjs CHANGED
@@ -8,8 +8,8 @@ import {
8
8
  signMessage,
9
9
  switchChain,
10
10
  watchAsset
11
- } from "./chunk-LF6P33WQ.mjs";
12
- import "./chunk-AKGXRZDN.mjs";
11
+ } from "./chunk-PVBEFQET.mjs";
12
+ import "./chunk-TDOKFOQ5.mjs";
13
13
  export {
14
14
  addChain,
15
15
  getAccounts,
package/dist/window.d.ts CHANGED
@@ -1,6 +1,8 @@
1
- import { R as Requests, E as Events } from './eip1193-617a05ae.js';
2
- import './chain-42de87e5.js';
1
+ import { R as Requests, E as Events } from './eip1193-f09a55af.js';
2
+ import './chain-4d46a747.js';
3
3
  import '@wagmi/chains';
4
+ import 'abitype';
5
+ import 'ethers@6/types/providers';
4
6
 
5
7
  type WindowProvider = Requests & Events;
6
8
  declare global {
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "isomorphic-ws": "^5.0.0",
10
10
  "ws": "^8.12.0"
11
11
  },
12
- "version": "0.0.1-alpha.27",
12
+ "version": "0.0.1-alpha.28",
13
13
  "files": [
14
14
  "/dist",
15
15
  "/chains",
@@ -1,22 +0,0 @@
1
- import { C as Chain, A as Address, b as BlockTag, H as Hex, M as Formatter, O as MergeIntersectionProperties, S as Formatted, s as TransactionRequest } from './chain-42de87e5.js';
2
- import { P as PublicClient } from './createPublicClient-fd558574.js';
3
- import { T as TransactionRequestFormatter } from './transactionRequest-f437b4ba.js';
4
-
5
- type FormattedCall<TFormatter extends Formatter | undefined = Formatter> = MergeIntersectionProperties<Formatted<TFormatter, TransactionRequest, true>, TransactionRequest>;
6
- type CallArgs<TChain extends Chain = Chain> = FormattedCall<TransactionRequestFormatter<TChain>> & {
7
- from?: Address;
8
- } & ({
9
- /** The balance of the account at a block number. */
10
- blockNumber?: bigint;
11
- blockTag?: never;
12
- } | {
13
- blockNumber?: never;
14
- /** The balance of the account at a block tag. */
15
- blockTag?: BlockTag;
16
- });
17
- type CallResponse = {
18
- data: Hex | undefined;
19
- };
20
- declare function call<TChain extends Chain>(client: PublicClient<any, TChain>, { blockNumber, blockTag, from, accessList, data, gas, gasPrice, maxFeePerGas, maxPriorityFeePerGas, nonce, to, value, ...rest }: CallArgs<TChain>): Promise<CallResponse>;
21
-
22
- export { CallArgs as C, CallResponse as a, call as c };
@@ -1,359 +0,0 @@
1
- import { Chain as Chain$1 } from '@wagmi/chains';
2
-
3
- type Address = `0x${string}`;
4
- type ByteArray = Uint8Array;
5
- type Hex = `0x${string}`;
6
- type Hash = `0x${string}`;
7
- type LogTopic = Hex | Hex[] | null;
8
-
9
- type ExtractFormatter<TChain extends Chain, TKey extends keyof NonNullable<TChain['formatters']>, TFallbackFormatter extends Formatter = Formatter> = NonNullable<TChain['formatters']>[TKey] extends NonNullable<unknown> ? NonNullable<TChain['formatters']>[TKey] : TFallbackFormatter;
10
- type FormatOptions<TSource, TTarget> = {
11
- formatter: Formatter<TSource, TTarget>;
12
- };
13
- /**
14
- * Creates a type that is the result of applying `TFormatter` to `TSource`.
15
- *
16
- * @example
17
- * Formatted<() => { a: undefined, b: bigint }, { a: bigint }>
18
- * => { a: undefined, b: bigint }
19
- *
20
- * @example
21
- * Formatted<() => {}, { a: bigint }>
22
- * => { a: bigint }
23
- *
24
- * @example
25
- * Formatted<() => { a: bigint | undefined, b: bigint }, { a: bigint, b: bigint }, true>
26
- * => { a?: bigint | undefined, b: bigint }
27
- */
28
- type Formatted<TFormatter, TFallback, TAllowOptional = false> = TFormatter extends Formatter ? ReturnType<TFormatter> extends Record<string, never> ? TFallback : TAllowOptional extends true ? OptionalNullable<ReturnType<TFormatter>> : ReturnType<TFormatter> : never;
29
- /**
30
- * @description Formats a data object using the given replacer and an optional formatter.
31
- */
32
- declare function format<TFormatter, TSource extends Record<string, any>, TTarget>(data: TSource, { formatter }: FormatOptions<TSource, TTarget>): Formatted<TFormatter, TTarget, false>;
33
- declare function defineFormatter<TSource extends Record<string, unknown>, TFormatted>({ format, }: {
34
- format: (data: TSource) => TFormatted;
35
- }): <TFormat extends Formatter<TSource, Partial<TFormatted> & {
36
- [key: string]: unknown;
37
- }>, TExclude extends (keyof TSource)[] = []>({ exclude, format: formatOverride, }: {
38
- exclude?: TExclude | undefined;
39
- format?: TFormat | undefined;
40
- }) => (data: TSource & {
41
- [key: string]: unknown;
42
- }) => TFormatted & ReturnType<TFormat> & { [K in TExclude[number]]: never; };
43
-
44
- type TransactionFormatter<TChain extends Chain = Chain> = ExtractFormatter<TChain, 'transaction', NonNullable<Formatters['transaction']>>;
45
- type FormattedTransaction<TFormatter extends Formatter | undefined = Formatter> = Formatted<TFormatter, Transaction>;
46
- declare const transactionType: {
47
- readonly '0x0': "legacy";
48
- readonly '0x1': "eip2930";
49
- readonly '0x2': "eip1559";
50
- };
51
- declare function formatTransaction(transaction: Partial<RpcTransaction>): Transaction<bigint, number>;
52
- declare const defineTransaction: <TFormat extends Formatter<Partial<RpcTransaction>, Partial<Transaction<bigint, number>> & {
53
- [key: string]: unknown;
54
- }>, TExclude extends ("type" | "blockHash" | "blockNumber" | "gas" | "hash" | "value" | "from" | "input" | "nonce" | "r" | "s" | "to" | "transactionIndex" | "v" | "gasPrice" | "maxFeePerGas" | "maxPriorityFeePerGas" | "accessList")[] = []>({ exclude, format: formatOverride, }: {
55
- exclude?: TExclude | undefined;
56
- format?: TFormat | undefined;
57
- }) => (data: Partial<RpcTransaction> & {
58
- [key: string]: unknown;
59
- }) => Transaction<bigint, number> & ReturnType<TFormat> & { [K in TExclude[number]]: never; };
60
-
61
- type FeeHistory<TQuantity = bigint> = {
62
- /**
63
- * An array of block base fees per gas (in wei). This includes the next block after
64
- * the newest of the returned range, because this value can be derived from the newest block.
65
- * Zeroes are returned for pre-EIP-1559 blocks. */
66
- baseFeePerGas: TQuantity[];
67
- /** An array of block gas used ratios. These are calculated as the ratio of gasUsed and gasLimit. */
68
- gasUsedRatio: number[];
69
- /** Lowest number block of the returned range. */
70
- oldestBlock: TQuantity;
71
- /** An array of effective priority fees (in wei) per gas data points from a single block. All zeroes are returned if the block is empty. */
72
- reward?: TQuantity[][];
73
- };
74
- type FeeValuesLegacy<TQuantity = bigint> = {
75
- /** Base fee per gas. */
76
- gasPrice: TQuantity;
77
- maxFeePerGas?: never;
78
- maxPriorityFeePerGas?: never;
79
- };
80
- type FeeValuesEIP1559<TQuantity = bigint> = {
81
- gasPrice?: never;
82
- /** Total fee per gas in wei (gasPrice/baseFeePerGas + maxPriorityFeePerGas). */
83
- maxFeePerGas: TQuantity;
84
- /** Max priority fee per gas (in wei). */
85
- maxPriorityFeePerGas: TQuantity;
86
- };
87
- type FeeValues<TQuantity = bigint> = FeeValuesLegacy<TQuantity> | FeeValuesEIP1559<TQuantity>;
88
-
89
- type Log<TQuantity = bigint, TIndex = number> = {
90
- /** The address from which this log originated */
91
- address: Address;
92
- /** Hash of block containing this log or `null` if pending */
93
- blockHash: Hash | null;
94
- /** Number of block containing this log or `null` if pending */
95
- blockNumber: TQuantity | null;
96
- /** Contains the non-indexed arguments of the log */
97
- data: Hex;
98
- /** Index of this log within its block or `null` if pending */
99
- logIndex: TIndex | null;
100
- /** Hash of the transaction that created this log or `null` if pending */
101
- transactionHash: Hash | null;
102
- /** Index of the transaction that created this log or `null` if pending */
103
- transactionIndex: TIndex | null;
104
- /** List of order-dependent topics */
105
- topics: Hex[];
106
- /** `true` if this filter has been destroyed and is invalid */
107
- removed: boolean;
108
- };
109
-
110
- /**
111
- * @description Merges the intersection properties of T and U.
112
- *
113
- * @example
114
- * MergeIntersectionProperties<{ a: string, b: number }, { a: number, c: boolean }>
115
- * => { a: number, b: number }
116
- */
117
- type MergeIntersectionProperties<T, U> = {
118
- [K in keyof T as K extends keyof U ? U[K] extends void ? never : K : K]: K extends keyof U ? U[K] : T[K];
119
- };
120
- /**
121
- * @description Makes nullable properties from T optional.
122
- *
123
- * @example
124
- * OptionalNullable<{ a: string | undefined, c: number }>
125
- * => { a?: string | undefined, c: number }
126
- */
127
- type OptionalNullable<T> = {
128
- [K in keyof T as T[K] extends NonNullable<unknown> ? K : never]: T[K];
129
- } & {
130
- [K in keyof T as T[K] extends NonNullable<unknown> ? never : K]?: T[K];
131
- };
132
- /**
133
- * @description Constructs a type by excluding `undefined` from `T`.
134
- *
135
- * @example
136
- * NoUndefined<string | undefined>
137
- * => string
138
- */
139
- type NoUndefined<T> = T extends undefined ? never : T;
140
- /**
141
- * @description Combines members of an intersection into a readable type.
142
- *
143
- * @link https://twitter.com/mattpocockuk/status/1622730173446557697?s=20&t=NdpAcmEFXY01xkqU3KO0Mg
144
- * @example
145
- * Prettify<{ a: string } | { b: string } | { c: number, d: bigint }>
146
- * => { a: string, b: string, c: number, d: bigint }
147
- */
148
- type Prettify<T> = {
149
- [K in keyof T]: T[K];
150
- } & {};
151
- type TrimLeft<T, Chars extends string = ' '> = T extends `${Chars}${infer R}` ? TrimLeft<R> : T;
152
- type TrimRight<T, Chars extends string = ' '> = T extends `${infer R}${Chars}` ? TrimRight<R> : T;
153
- /**
154
- * @description Trims empty space from type T.
155
- *
156
- * @example
157
- * Trim<' lol '>
158
- * => 'lol'
159
- */
160
- type Trim<T, Chars extends string = ' '> = TrimLeft<TrimRight<T, Chars>, Chars>;
161
- /**
162
- * @description Creates a type that extracts the values of T.
163
- *
164
- * @example
165
- * ValueOf<{ a: string, b: number }>
166
- * => string | number
167
- */
168
- type ValueOf<T> = T[keyof T];
169
-
170
- type AccessList = Array<{
171
- address: Address;
172
- storageKeys: Array<Hex>;
173
- }>;
174
- type TransactionType$1 = ValueOf<typeof transactionType>;
175
- type TransactionReceipt<TQuantity = bigint, TIndex = number, TStatus = 'success' | 'reverted', TType = TransactionType$1> = {
176
- /** Hash of block containing this transaction */
177
- blockHash: Hash;
178
- /** Number of block containing this transaction */
179
- blockNumber: TQuantity;
180
- /** Address of new contract or `null` if no contract was created */
181
- contractAddress: Address | null;
182
- /** Gas used by this and all preceding transactions in this block */
183
- cumulativeGasUsed: TQuantity;
184
- /** Pre-London, it is equal to the transaction's gasPrice. Post-London, it is equal to the actual gas price paid for inclusion. */
185
- effectiveGasPrice: TQuantity;
186
- /** Transaction sender */
187
- from: Address;
188
- /** Gas used by this transaction */
189
- gasUsed: TQuantity;
190
- /** List of log objects generated by this transaction */
191
- logs: Log<TQuantity, TIndex>[];
192
- /** Logs bloom filter */
193
- logsBloom: Hex;
194
- /** `1` if this transaction was successful or `0` if it failed */
195
- status: TStatus;
196
- /** Transaction recipient or `null` if deploying a contract */
197
- to: Address | null;
198
- /** Hash of this transaction */
199
- transactionHash: Hash;
200
- /** Index of this transaction in the block */
201
- transactionIndex: TIndex;
202
- /** Transaction type */
203
- type: TType;
204
- };
205
- type TransactionBase<TQuantity = bigint, TIndex = number> = {
206
- /** Hash of block containing this transaction or `null` if pending */
207
- blockHash: Hash | null;
208
- /** Number of block containing this transaction or `null` if pending */
209
- blockNumber: TQuantity | null;
210
- /** Transaction sender */
211
- from: Address;
212
- /** Gas provided for transaction execution */
213
- gas: TQuantity;
214
- /** Hash of this transaction */
215
- hash: Hash;
216
- /** Contract code or a hashed method call */
217
- input: Hex;
218
- /** Unique number identifying this transaction */
219
- nonce: TIndex;
220
- /** ECDSA signature r */
221
- r: Hex;
222
- /** ECDSA signature s */
223
- s: Hex;
224
- /** Transaction recipient or `null` if deploying a contract */
225
- to: Address | null;
226
- /** Index of this transaction in the block or `null` if pending */
227
- transactionIndex: TIndex | null;
228
- /** ECDSA recovery ID */
229
- v: TQuantity;
230
- /** Value in wei sent with this transaction */
231
- value: TQuantity;
232
- };
233
- type TransactionLegacy<TQuantity = bigint, TIndex = number, TType = 'legacy'> = TransactionBase<TQuantity, TIndex> & FeeValuesLegacy<TQuantity> & {
234
- accessList?: never;
235
- type: TType;
236
- };
237
- type TransactionEIP2930<TQuantity = bigint, TIndex = number, TType = 'eip2930'> = TransactionBase<TQuantity, TIndex> & FeeValuesLegacy<TQuantity> & {
238
- accessList: AccessList;
239
- type: TType;
240
- };
241
- type TransactionEIP1559<TQuantity = bigint, TIndex = number, TType = 'eip1559'> = TransactionBase<TQuantity, TIndex> & FeeValuesEIP1559<TQuantity> & {
242
- accessList: AccessList;
243
- type: TType;
244
- };
245
- type Transaction<TQuantity = bigint, TIndex = number> = TransactionLegacy<TQuantity, TIndex> | TransactionEIP2930<TQuantity, TIndex> | TransactionEIP1559<TQuantity, TIndex>;
246
- type TransactionRequestBase<TQuantity = bigint, TIndex = number> = {
247
- /** Contract code or a hashed method call with encoded args */
248
- data?: Hex;
249
- /** Transaction sender */
250
- from: Address;
251
- /** Gas provided for transaction execution */
252
- gas?: TQuantity;
253
- /** Unique number identifying this transaction */
254
- nonce?: TIndex;
255
- /** Transaction recipient */
256
- to?: Address;
257
- /** Value in wei sent with this transaction */
258
- value?: TQuantity;
259
- };
260
- type TransactionRequestLegacy<TQuantity = bigint, TIndex = number> = TransactionRequestBase<TQuantity, TIndex> & Partial<FeeValuesLegacy<TQuantity>> & {
261
- accessList?: never;
262
- };
263
- type TransactionRequestEIP2930<TQuantity = bigint, TIndex = number> = TransactionRequestBase<TQuantity, TIndex> & Partial<FeeValuesLegacy<TQuantity>> & {
264
- accessList?: AccessList;
265
- };
266
- type TransactionRequestEIP1559<TQuantity = bigint, TIndex = number> = TransactionRequestBase<TQuantity, TIndex> & Partial<FeeValuesEIP1559<TQuantity>> & {
267
- accessList?: AccessList;
268
- };
269
- type TransactionRequest<TQuantity = bigint, TIndex = number> = TransactionRequestLegacy<TQuantity, TIndex> | TransactionRequestEIP2930<TQuantity, TIndex> | TransactionRequestEIP1559<TQuantity, TIndex>;
270
-
271
- type Block<TQuantity = bigint, TTransaction = Transaction> = {
272
- /** Base fee per gas */
273
- baseFeePerGas: TQuantity | null;
274
- /** Difficulty for this block */
275
- difficulty: TQuantity;
276
- /** "Extra data" field of this block */
277
- extraData: Hex;
278
- /** Maximum gas allowed in this block */
279
- gasLimit: TQuantity;
280
- /** Total used gas by all transactions in this block */
281
- gasUsed: TQuantity;
282
- /** Block hash or `null` if pending */
283
- hash: Hash | null;
284
- /** Logs bloom filter or `null` if pending */
285
- logsBloom: Hex | null;
286
- /** Address that received this block’s mining rewards */
287
- miner: Address;
288
- /** Unique identifier for the block. */
289
- mixHash: Hash;
290
- /** Proof-of-work hash or `null` if pending */
291
- nonce: Hex | null;
292
- /** Block number or `null` if pending */
293
- number: TQuantity | null;
294
- /** Parent block hash */
295
- parentHash: Hash;
296
- /** Root of the this block’s receipts trie */
297
- receiptsRoot: Hex;
298
- sealFields: Hex[];
299
- /** SHA3 of the uncles data in this block */
300
- sha3Uncles: Hash;
301
- /** Size of this block in bytes */
302
- size: TQuantity;
303
- /** Root of this block’s final state trie */
304
- stateRoot: Hash;
305
- /** Unix timestamp of when this block was collated */
306
- timestamp: TQuantity;
307
- /** Total difficulty of the chain until this block */
308
- totalDifficulty: TQuantity | null;
309
- /** List of transaction objects or hashes */
310
- transactions: Hash[] | TTransaction[];
311
- /** Root of this block’s transaction trie */
312
- transactionsRoot: Hash;
313
- /** List of uncle hashes */
314
- uncles: Hash[];
315
- };
316
- type BlockIdentifier<TQuantity = bigint> = {
317
- /** Whether or not to throw an error if the block is not in the canonical chain as described below. Only allowed in conjunction with the blockHash tag. Defaults to false. */
318
- requireCanonical?: boolean;
319
- } & ({
320
- /** The block in the canonical chain with this number */
321
- blockNumber: BlockNumber<TQuantity>;
322
- } | {
323
- /** The block uniquely identified by this hash. The `blockNumber` and `blockHash` properties are mutually exclusive; exactly one of them must be set. */
324
- blockHash: Hash;
325
- });
326
- type BlockNumber<TQuantity = bigint> = TQuantity;
327
- type BlockTag = 'latest' | 'earliest' | 'pending' | 'safe' | 'finalized';
328
- type Uncle<TQuantity = bigint, TTransaction = Transaction> = Block<TQuantity, TTransaction>;
329
-
330
- type Index = `0x${string}`;
331
- type Quantity = `0x${string}`;
332
- type Status = '0x0' | '0x1';
333
- type TransactionType = '0x0' | '0x1' | '0x2';
334
- type RpcBlock = Block<Quantity, RpcTransaction>;
335
- type RpcBlockNumber = BlockNumber<Quantity>;
336
- type RpcBlockIdentifier = BlockIdentifier<Quantity>;
337
- type RpcUncle = Uncle<Quantity>;
338
- type RpcFeeHistory = FeeHistory<Quantity>;
339
- type RpcFeeValues = FeeValues<Quantity>;
340
- type RpcLog = Log<Quantity, Index>;
341
- type RpcTransactionReceipt = TransactionReceipt<Quantity, Index, Status, TransactionType>;
342
- type RpcTransactionRequest = TransactionRequest<Quantity, Index>;
343
- type RpcTransaction = TransactionLegacy<Quantity, Index, '0x0'> | TransactionEIP2930<Quantity, Index, '0x1'> | TransactionEIP1559<Quantity, Index, '0x2'>;
344
-
345
- type Formatter<TSource = any, TTarget = any> = (value: TSource & {
346
- [key: string]: unknown;
347
- }) => TTarget;
348
- type Formatters = {
349
- block?: Formatter<RpcBlock, Block>;
350
- transaction?: Formatter<RpcTransaction, Transaction>;
351
- transactionReceipt?: Formatter<RpcTransactionReceipt, TransactionReceipt>;
352
- transactionRequest?: Formatter<TransactionRequest, RpcTransactionRequest>;
353
- };
354
-
355
- type Chain<TFormatters extends Formatters = Formatters> = Chain$1 & {
356
- formatters?: TFormatters;
357
- };
358
-
359
- export { formatTransaction as $, Address as A, ByteArray as B, Chain as C, TransactionEIP2930 as D, TransactionLegacy as E, FeeHistory as F, LogTopic as G, Hex as H, Trim as I, TransactionType$1 as J, Formatters as K, Log as L, Formatter as M, NoUndefined as N, MergeIntersectionProperties as O, Prettify as P, Quantity as Q, RpcBlock as R, Formatted as S, TransactionReceipt as T, Uncle as U, ExtractFormatter as V, FormattedTransaction as W, TransactionFormatter as X, defineFormatter as Y, defineTransaction as Z, format as _, Hash as a, transactionType as a0, BlockTag as b, AccessList as c, Block as d, BlockIdentifier as e, BlockNumber as f, FeeValues as g, FeeValuesEIP1559 as h, FeeValuesLegacy as i, RpcBlockIdentifier as j, RpcBlockNumber as k, RpcFeeHistory as l, RpcFeeValues as m, RpcLog as n, RpcTransaction as o, RpcTransactionReceipt as p, RpcTransactionRequest as q, RpcUncle as r, TransactionRequest as s, TransactionRequestBase as t, TransactionRequestEIP1559 as u, TransactionRequestEIP2930 as v, TransactionRequestLegacy as w, Transaction as x, TransactionBase as y, TransactionEIP1559 as z };