viem 0.2.0-main.20230401T004104 → 0.2.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.
Files changed (75) hide show
  1. package/accounts/package.json +4 -0
  2. package/dist/abi.d.ts +3 -3
  3. package/dist/abi.js +2 -2
  4. package/dist/abi.mjs +1 -1
  5. package/dist/accounts/index.d.ts +81 -0
  6. package/dist/accounts/index.js +142 -0
  7. package/dist/accounts/index.js.map +1 -0
  8. package/dist/accounts/index.mjs +142 -0
  9. package/dist/accounts/index.mjs.map +1 -0
  10. package/dist/{chain-1b53ef88.d.ts → chain-5507c6f0.d.ts} +212 -148
  11. package/dist/{chain-ec8c485d.d.ts → chain-fe47467d.d.ts} +1 -1
  12. package/dist/chains.d.ts +867 -99
  13. package/dist/chains.js +115 -63
  14. package/dist/chains.js.map +1 -1
  15. package/dist/chains.mjs +58 -6
  16. package/dist/chains.mjs.map +1 -1
  17. package/dist/chunk-63WKWOMO.js +31 -0
  18. package/dist/chunk-63WKWOMO.js.map +1 -0
  19. package/dist/{chunk-U5Z7JOWV.mjs → chunk-FSIBCQFR.mjs} +1886 -261
  20. package/dist/chunk-FSIBCQFR.mjs.map +1 -0
  21. package/dist/chunk-KON3DHPC.mjs +31 -0
  22. package/dist/chunk-KON3DHPC.mjs.map +1 -0
  23. package/dist/{chunk-HBDMIBEO.js → chunk-YDNKDSST.js} +1942 -317
  24. package/dist/chunk-YDNKDSST.js.map +1 -0
  25. package/dist/contract.d.ts +9 -7
  26. package/dist/contract.js +2 -2
  27. package/dist/contract.mjs +1 -1
  28. package/dist/{createTransport-e3eba9f7.d.ts → createTransport-21a0d2b3.d.ts} +24 -10
  29. package/dist/{eip1193-4f4e240c.d.ts → eip1193-2f3a9cd2.d.ts} +1 -1
  30. package/dist/{encodeFunctionResult-1f324375.d.ts → encodeFunctionResult-c5185b98.d.ts} +15 -15
  31. package/dist/{encodePacked-d5d5264a.d.ts → encodePacked-98f67d09.d.ts} +1 -1
  32. package/dist/ens.d.ts +6 -4
  33. package/dist/ens.js +8 -3
  34. package/dist/ens.js.map +1 -1
  35. package/dist/ens.mjs +7 -2
  36. package/dist/ens.mjs.map +1 -1
  37. package/dist/ethers.d.ts +5 -6
  38. package/dist/ethers.js +7 -5
  39. package/dist/ethers.js.map +1 -1
  40. package/dist/ethers.mjs +7 -5
  41. package/dist/ethers.mjs.map +1 -1
  42. package/dist/{formatAbiItem-15e8817d.d.ts → formatAbiItem-56dff508.d.ts} +1 -1
  43. package/dist/{getAbiItem-3e809ff9.d.ts → getAbiItem-bfba73d1.d.ts} +3 -3
  44. package/dist/getEnsResolver-9e26c596.d.ts +876 -0
  45. package/dist/index.d.ts +132 -15
  46. package/dist/index.js +150 -103
  47. package/dist/index.js.map +1 -1
  48. package/dist/index.mjs +96 -49
  49. package/dist/index.mjs.map +1 -1
  50. package/dist/{parseGwei-361e8a12.d.ts → parseGwei-d2147f8b.d.ts} +95 -15
  51. package/dist/public.d.ts +6 -4
  52. package/dist/public.js +2 -2
  53. package/dist/public.mjs +1 -1
  54. package/dist/publicKeyToAddress-623eb398.d.ts +16 -0
  55. package/dist/test-b67569fe.d.ts +198 -0
  56. package/dist/test.d.ts +11 -11
  57. package/dist/test.js +2 -2
  58. package/dist/test.mjs +1 -1
  59. package/dist/typedData-46b4d81f.d.ts +93 -0
  60. package/dist/utils/index.d.ts +22 -30
  61. package/dist/utils/index.js +28 -2
  62. package/dist/utils/index.mjs +31 -5
  63. package/dist/wallet.d.ts +6 -4
  64. package/dist/wallet.js +2 -2
  65. package/dist/wallet.mjs +1 -1
  66. package/dist/window.d.ts +2 -2
  67. package/package.json +13 -4
  68. package/dist/chunk-HBDMIBEO.js.map +0 -1
  69. package/dist/chunk-I5QGTPHV.mjs +0 -186
  70. package/dist/chunk-I5QGTPHV.mjs.map +0 -1
  71. package/dist/chunk-LWNOZI6J.js +0 -186
  72. package/dist/chunk-LWNOZI6J.js.map +0 -1
  73. package/dist/chunk-U5Z7JOWV.mjs.map +0 -1
  74. package/dist/createPublicClient-31d44569.d.ts +0 -841
  75. package/dist/test-67630299.d.ts +0 -205
@@ -1,10 +1,5 @@
1
1
  import { Chain as Chain$1 } from '@wagmi/chains';
2
- import { Abi, AbiFunction, ExtractAbiFunction, AbiParametersToPrimitiveTypes, AbiConstructor, AbiError, ExtractAbiError, AbiEvent, ExtractAbiEvent, ExtractAbiErrorNames, ExtractAbiEventNames, AbiStateMutability, ExtractAbiFunctionNames, Narrow, Address, AbiParameter, AbiParameterToPrimitiveType } from 'abitype';
3
-
4
- type ByteArray = Uint8Array;
5
- type Hex = `0x${string}`;
6
- type Hash = `0x${string}`;
7
- type LogTopic = Hex | Hex[] | null;
2
+ import { Abi, AbiStateMutability, Narrow, Address, AbiFunction, ExtractAbiFunction, AbiParametersToPrimitiveTypes, ExtractAbiErrorNames, ExtractAbiEventNames, ExtractAbiFunctionNames, AbiConstructor, AbiError, ExtractAbiError, AbiEvent, ExtractAbiEvent, AbiParameter, AbiParameterToPrimitiveType } from 'abitype';
8
3
 
9
4
  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
5
  type FormatOptions<TSource, TTarget> = {
@@ -41,7 +36,7 @@ declare function defineFormatter<TSource extends Record<string, unknown>, TForma
41
36
  [key: string]: unknown;
42
37
  }) => TFormatted & ReturnType<TFormat> & { [K in TExclude[number]]: never; };
43
38
 
44
- type TransactionFormatter<TChain extends Chain = Chain> = ExtractFormatter<TChain, 'transaction', NonNullable<Formatters['transaction']>>;
39
+ type TransactionFormatter<TChain extends Chain | undefined = Chain> = TChain extends Chain ? ExtractFormatter<TChain, 'transaction', NonNullable<Formatters['transaction']>> : Formatters['transaction'];
45
40
  type FormattedTransaction<TFormatter extends Formatter | undefined = Formatter> = Formatted<TFormatter, Transaction>;
46
41
  declare const transactionType: {
47
42
  readonly '0x0': "legacy";
@@ -51,27 +46,88 @@ declare const transactionType: {
51
46
  declare function formatTransaction(transaction: Partial<RpcTransaction>): Transaction<bigint, number>;
52
47
  declare const defineTransaction: <TFormat extends Formatter<Partial<RpcTransaction>, Partial<Transaction<bigint, number>> & {
53
48
  [key: string]: unknown;
54
- }>, TExclude extends ("type" | "value" | "blockHash" | "blockNumber" | "from" | "gasPrice" | "maxFeePerGas" | "maxPriorityFeePerGas" | "gas" | "nonce" | "to" | "accessList" | "hash" | "chainId" | "input" | "r" | "s" | "transactionIndex" | "v")[] = []>({ exclude, format: formatOverride, }: {
49
+ }>, TExclude extends ("type" | "value" | "blockHash" | "blockNumber" | "chainId" | "gasPrice" | "maxFeePerGas" | "maxPriorityFeePerGas" | "from" | "accessList" | "to" | "gas" | "nonce" | "transactionIndex" | "hash" | "input" | "r" | "s" | "v")[] = []>({ exclude, format: formatOverride, }: {
55
50
  exclude?: TExclude | undefined;
56
51
  format?: TFormat | undefined;
57
52
  }) => (data: Partial<RpcTransaction> & {
58
53
  [key: string]: unknown;
59
54
  }) => Transaction<bigint, number> & ReturnType<TFormat> & { [K in TExclude[number]]: never; };
60
55
 
56
+ type ByteArray = Uint8Array;
57
+ type Hex = `0x${string}`;
58
+ type Hash = `0x${string}`;
59
+ type LogTopic = Hex | Hex[] | null;
60
+ type Signature = {
61
+ r: Hex;
62
+ s: Hex;
63
+ v: bigint;
64
+ };
65
+
66
+ type FeeHistory<TQuantity = bigint> = {
67
+ /**
68
+ * An array of block base fees per gas (in wei). This includes the next block after
69
+ * the newest of the returned range, because this value can be derived from the newest block.
70
+ * Zeroes are returned for pre-EIP-1559 blocks. */
71
+ baseFeePerGas: TQuantity[];
72
+ /** An array of block gas used ratios. These are calculated as the ratio of gasUsed and gasLimit. */
73
+ gasUsedRatio: number[];
74
+ /** Lowest number block of the returned range. */
75
+ oldestBlock: TQuantity;
76
+ /** 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. */
77
+ reward?: TQuantity[][];
78
+ };
79
+ type FeeValuesLegacy<TQuantity = bigint> = {
80
+ /** Base fee per gas. */
81
+ gasPrice: TQuantity;
82
+ maxFeePerGas?: never;
83
+ maxPriorityFeePerGas?: never;
84
+ };
85
+ type FeeValuesEIP1559<TQuantity = bigint> = {
86
+ gasPrice?: never;
87
+ /** Total fee per gas in wei (gasPrice/baseFeePerGas + maxPriorityFeePerGas). */
88
+ maxFeePerGas: TQuantity;
89
+ /** Max priority fee per gas (in wei). */
90
+ maxPriorityFeePerGas: TQuantity;
91
+ };
92
+ type FeeValues<TQuantity = bigint> = FeeValuesLegacy<TQuantity> | FeeValuesEIP1559<TQuantity>;
93
+
61
94
  /**
62
- * @description Excludes empty attributes from T if TMaybeExclude is true.
95
+ * Filters out all members of {@link T} that are not {@link P}
63
96
  *
64
- * @example
65
- * MaybeExcludeEmpty<{ a: string, b: number, c: [] }, true>
66
- * => { a: string, b: number }
97
+ * @param T - Items to filter
98
+ * @param P - Type to filter out
99
+ * @returns Filtered items
67
100
  *
68
- * MaybeExcludeEmpty<{ a: string, b: number, c: [] }, false>
69
- * => { a: string, b: number, c: [] }
70
- *
71
- * MaybeExcludeEmpty<{ a: string, b: number, c: undefined }, true>
72
- * => { a: string, b: number }
101
+ * @example
102
+ * type Result = Filter<['a', 'b', 'c'], 'b'>
103
+ * // ^? type Result = ['a', 'c']
104
+ */
105
+ type Filter<T extends readonly unknown[], P, Acc extends readonly unknown[] = []> = T extends readonly [infer F, ...infer Rest extends readonly unknown[]] ? [F] extends [P] ? Filter<Rest, P, [...Acc, F]> : Filter<Rest, P, Acc> : readonly [...Acc];
106
+ /**
107
+ * @description Checks if {@link T} can be narrowed further than {@link U}
108
+ * @param T - Type to check
109
+ * @param U - Type to against
110
+ * @example
111
+ * type Result = IsNarrowable<'foo', string>
112
+ * // ^? true
113
+ */
114
+ type IsNarrowable<T, U> = IsNever<(T extends U ? true : false) & (U extends T ? false : true)> extends true ? false : true;
115
+ /**
116
+ * @description Checks if {@link T} is `never`
117
+ * @param T - Type to check
118
+ * @example
119
+ * type Result = IsNever<never>
120
+ * // ^? type Result = true
121
+ */
122
+ type IsNever<T> = [T] extends [never] ? true : false;
123
+ /**
124
+ * @description Checks if {@link T} is `undefined`
125
+ * @param T - Type to check
126
+ * @example
127
+ * type Result = IsUndefined<undefined>
128
+ * // ^? type Result = true
73
129
  */
74
- type MaybeExcludeEmpty<T, TMaybeExclude extends boolean> = TMaybeExclude extends true ? Exclude<T, [] | null | undefined> : T;
130
+ type IsUndefined<T> = [undefined] extends [T] ? true : false;
75
131
  /**
76
132
  * @description Makes attributes on the type T required if TRequired is true.
77
133
  *
@@ -105,14 +161,6 @@ type OptionalNullable<T> = {
105
161
  } & {
106
162
  [K in keyof T as T[K] extends NonNullable<unknown> ? never : K]?: T[K];
107
163
  };
108
- /**
109
- * @description Constructs a type by excluding `undefined` from `T`.
110
- *
111
- * @example
112
- * NoUndefined<string | undefined>
113
- * => string
114
- */
115
- type NoUndefined<T> = T extends undefined ? never : T;
116
164
  /**
117
165
  * @description Combines members of an intersection into a readable type.
118
166
  *
@@ -133,69 +181,32 @@ type Prettify<T> = {
133
181
  */
134
182
  type ValueOf<T> = T[keyof T];
135
183
 
136
- type EventParametersConfig = {
137
- enableUnion: boolean;
138
- indexedOnly: boolean;
139
- required: boolean;
140
- };
141
- type EventParametersDefaultConfig = {
142
- enableUnion: true;
143
- indexedOnly: true;
144
- required: false;
145
- };
146
184
  type AbiItem = Abi[number];
147
185
  type EventDefinition = `${string}(${string})`;
148
- type HashedEventTypes = 'string' | 'bytes' | 'tuple' | `${string}[${string}]`;
149
- type EventTopicParam<TPrimitiveType = Hex, TTopic extends LogTopic = LogTopic> = NoUndefined<(TTopic extends Hex ? TPrimitiveType : undefined) | (TTopic extends Hex[] ? TPrimitiveType[] : undefined) | (TTopic extends null ? null : undefined)>;
150
- type AbiEventParameterToPrimitiveType<TParam extends AbiParameter, TConfig extends EventParametersConfig = EventParametersDefaultConfig> = TConfig extends {
151
- enableUnion: true;
152
- } ? EventTopicParam<AbiParameterToPrimitiveType<TParam>> : AbiParameterToPrimitiveType<TParam>;
153
- type AbiEventParametersToPrimitiveTypes<TAbiParameters extends readonly AbiParameter[], TConfig extends EventParametersConfig = EventParametersDefaultConfig, TBase = TAbiParameters[0] extends {
154
- name: string;
155
- } ? {} : []> = Prettify<TAbiParameters extends readonly [infer Head, ...infer Tail] ? Head extends {
156
- indexed: true;
157
- } ? Head extends AbiParameter ? Head extends {
158
- name: infer Name;
159
- } ? Name extends string ? MaybeRequired<{
160
- [name in Name]?: AbiEventParameterToPrimitiveType<Head, TConfig>;
161
- }, TConfig['required']> & (Tail extends readonly [] ? {} : Tail extends readonly AbiParameter[] ? AbiEventParametersToPrimitiveTypes<Tail, TConfig> : {}) : never : MaybeExcludeEmpty<(TConfig extends {
162
- enableUnion: true;
163
- } ? [AbiEventParameterToPrimitiveType<Head, TConfig>] : []) | [
164
- AbiEventParameterToPrimitiveType<Head, TConfig>,
165
- ...(Tail extends readonly [] ? [] : Tail extends readonly AbiParameter[] ? AbiEventParametersToPrimitiveTypes<Tail, TConfig> : [])
166
- ], TConfig['required']> : TBase : TConfig extends {
167
- indexedOnly: false;
168
- } ? Head extends AbiParameter ? Head extends {
169
- name: infer Name;
170
- } ? Name extends string ? {
171
- [name in Name]: AbiParameterToPrimitiveType<Head>;
172
- } & (Tail extends readonly [] ? {} : Tail extends readonly AbiParameter[] ? AbiEventParametersToPrimitiveTypes<Tail, TConfig> : {}) : never : [
173
- AbiParameterToPrimitiveType<Head>,
174
- ...(Tail extends readonly [] ? [] : Tail extends readonly AbiParameter[] ? AbiEventParametersToPrimitiveTypes<Tail, TConfig> : [])
175
- ] : TBase : Tail extends readonly [] ? TBase : Tail extends readonly AbiParameter[] ? AbiEventParametersToPrimitiveTypes<Tail, TConfig> : TBase : TBase>;
176
- type AbiEventTopicToPrimitiveType<TParam extends AbiParameter, TTopic extends LogTopic, TPrimitiveType = TParam['type'] extends HashedEventTypes ? TTopic : AbiParameterToPrimitiveType<TParam>> = EventTopicParam<TPrimitiveType, TTopic>;
177
- type AbiEventTopicsToPrimitiveTypes<TAbiParameters extends readonly AbiParameter[], TTopics extends LogTopic[] | undefined = undefined, TData extends Hex | undefined = undefined, TBase = TAbiParameters[0] extends {
178
- name: string;
179
- } ? {} : []> = Prettify<TAbiParameters extends readonly [infer Head, ...infer Tail] ? TTopics extends readonly [infer TopicHead, ...infer TopicTail] ? Head extends {
180
- indexed: true;
181
- } ? Head extends AbiParameter ? Head extends {
182
- name: infer Name;
183
- } ? Name extends string ? {
184
- [name in Name]: TopicHead extends LogTopic ? AbiEventTopicToPrimitiveType<Head, TopicHead> : never;
185
- } & (Tail extends readonly [] ? {} : Tail extends readonly AbiParameter[] ? TopicTail extends LogTopic[] ? AbiEventTopicsToPrimitiveTypes<Tail, TopicTail, TData> : {} : {}) : never : [
186
- TopicHead extends LogTopic ? AbiEventTopicToPrimitiveType<Head, TopicHead> : never,
187
- ...(Tail extends readonly [] ? [] : Tail extends readonly AbiParameter[] ? TopicTail extends LogTopic[] ? AbiEventTopicsToPrimitiveTypes<Tail, TopicTail, TData> : [] : [])
188
- ] : TBase : TBase : TTopics extends readonly [] ? TData extends '0x' ? TBase : TData extends Hex ? Head extends AbiParameter ? Head extends {
189
- indexed: true;
190
- } ? Tail extends readonly AbiParameter[] ? AbiEventTopicsToPrimitiveTypes<Tail, [], TData> : TBase : Head extends {
191
- name: infer Name;
192
- } ? Name extends string ? {
193
- [name in Name]: AbiParameterToPrimitiveType<Head>;
194
- } & (Tail extends readonly [] ? {} : Tail extends readonly AbiParameter[] ? AbiEventTopicsToPrimitiveTypes<Tail, [], TData> : {}) : never : [
195
- AbiParameterToPrimitiveType<Head>,
196
- ...(Tail extends readonly [] ? [] : Tail extends readonly AbiParameter[] ? AbiEventTopicsToPrimitiveTypes<Tail, [], TData> : [])
197
- ] : TBase : TBase : TBase : undefined>;
198
- type ExtractArgsFromAbi<TAbi extends Abi | readonly unknown[], TFunctionName extends string, TAbiFunction extends AbiFunction = TAbi extends Abi ? ExtractAbiFunction<TAbi, TFunctionName> : AbiFunction, TArgs = AbiParametersToPrimitiveTypes<TAbiFunction['inputs']>, FailedToParseArgs = ([TArgs] extends [never] ? true : false) | (readonly unknown[] extends TArgs ? true : false)> = true extends FailedToParseArgs ? {
186
+ type ContractFunctionConfig<TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string, TAbiStateMutability extends AbiStateMutability = AbiStateMutability> = {
187
+ /** Contract ABI */
188
+ abi: Narrow<TAbi>;
189
+ /** Contract address */
190
+ address: Address;
191
+ /** Function to invoke on the contract */
192
+ functionName: InferFunctionName<TAbi, TFunctionName, TAbiStateMutability>;
193
+ } & GetFunctionArgs<TAbi, TFunctionName>;
194
+ type ContractFunctionResult<TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string, TAbiFunction extends AbiFunction & {
195
+ type: 'function';
196
+ } = TAbi extends Abi ? ExtractAbiFunction<TAbi, TFunctionName> : AbiFunction, TArgs = AbiParametersToPrimitiveTypes<TAbiFunction['outputs']>, FailedToParseArgs = ([TArgs] extends [never] ? true : false) | (readonly unknown[] extends TArgs ? true : false)> = true extends FailedToParseArgs ? unknown : TArgs extends readonly [] ? void : TArgs extends readonly [infer Arg] ? Arg : TArgs;
197
+ type GetValue<TAbi extends Abi | readonly unknown[], TFunctionName extends string, TValueType = TransactionRequest['value'], TAbiFunction extends AbiFunction = TAbi extends Abi ? ExtractAbiFunction<TAbi, TFunctionName> : AbiFunction> = TAbiFunction['stateMutability'] extends 'payable' ? {
198
+ value?: TValueType;
199
+ } : TAbiFunction['payable'] extends true ? {
200
+ value?: TValueType;
201
+ } : unknown;
202
+ type MaybeAbiEventName<TAbiEvent extends AbiEvent | undefined> = TAbiEvent extends AbiEvent ? TAbiEvent['name'] : undefined;
203
+ type MaybeExtractEventArgsFromAbi<TAbi extends Abi | readonly unknown[] = Abi, TEventName extends string | undefined = undefined> = TEventName extends string ? GetEventArgs<TAbi, TEventName> : undefined;
204
+ type InferErrorName<TAbi extends Abi | readonly unknown[] = Abi, TErrorName extends string = string> = TAbi extends Abi ? ExtractAbiErrorNames<TAbi> extends infer AbiErrorNames ? AbiErrorNames | (TErrorName extends AbiErrorNames ? TErrorName : never) | (Abi extends TAbi ? string : never) : never : TErrorName;
205
+ type InferEventName<TAbi extends Abi | readonly unknown[] = Abi, TEventName extends string | undefined = string> = TAbi extends Abi ? ExtractAbiEventNames<TAbi> extends infer AbiEventNames ? AbiEventNames | (TEventName extends AbiEventNames ? TEventName : never) : never : TEventName;
206
+ type InferFunctionName<TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string, TAbiStateMutability extends AbiStateMutability = AbiStateMutability> = TAbi extends Abi ? ExtractAbiFunctionNames<TAbi, TAbiStateMutability> extends infer AbiFunctionNames ? AbiFunctionNames | (TFunctionName extends AbiFunctionNames ? TFunctionName : never) | (Abi extends TAbi ? string : never) : never : TFunctionName;
207
+ type InferItemName<TAbi extends Abi | readonly unknown[] = Abi, TName extends string = string> = TAbi extends Abi ? ExtractAbiItemNames<TAbi> extends infer AbiNames ? AbiNames | (TName extends AbiNames ? TName : never) | (Abi extends TAbi ? string : never) : never : TName;
208
+ type ExtractAbiItemNames<TAbi extends Abi> = ExtractAbiFunctionNames<TAbi> | ExtractAbiEventNames<TAbi> | ExtractAbiErrorNames<TAbi>;
209
+ type GetFunctionArgs<TAbi extends Abi | readonly unknown[], TFunctionName extends string, TAbiFunction extends AbiFunction = TAbi extends Abi ? ExtractAbiFunction<TAbi, TFunctionName> : AbiFunction, TArgs = AbiParametersToPrimitiveTypes<TAbiFunction['inputs']>, FailedToParseArgs = ([TArgs] extends [never] ? true : false) | (readonly unknown[] extends TArgs ? true : false)> = true extends FailedToParseArgs ? {
199
210
  /**
200
211
  * Arguments to pass contract method
201
212
  *
@@ -207,11 +218,11 @@ type ExtractArgsFromAbi<TAbi extends Abi | readonly unknown[], TFunctionName ext
207
218
  } : {
208
219
  /** Arguments to pass contract method */ args: TArgs;
209
220
  };
210
- type ExtractConstructorArgsFromAbi<TAbi extends Abi | readonly unknown[], TAbiFunction extends AbiConstructor = TAbi extends Abi ? Extract<TAbi[number], {
221
+ type GetConstructorArgs<TAbi extends Abi | readonly unknown[], TAbiConstructor extends AbiConstructor = TAbi extends Abi ? Extract<TAbi[number], {
211
222
  type: 'constructor';
212
- }> : AbiConstructor, TArgs = AbiParametersToPrimitiveTypes<TAbiFunction['inputs']>, FailedToParseArgs = ([TArgs] extends [never] ? true : false) | (readonly unknown[] extends TArgs ? true : false)> = true extends FailedToParseArgs ? {
223
+ }> : AbiConstructor, TArgs = AbiParametersToPrimitiveTypes<TAbiConstructor['inputs']>, FailedToParseArgs = ([TArgs] extends [never] ? true : false) | (readonly unknown[] extends TArgs ? true : false)> = true extends FailedToParseArgs ? {
213
224
  /**
214
- * Arguments to pass contract method
225
+ * Arguments to pass contract constructor
215
226
  *
216
227
  * Use a [const assertion](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#const-assertions) on {@link abi} for type inference.
217
228
  */
@@ -219,9 +230,9 @@ type ExtractConstructorArgsFromAbi<TAbi extends Abi | readonly unknown[], TAbiFu
219
230
  } : TArgs extends readonly [] ? {
220
231
  args?: never;
221
232
  } : {
222
- /** Arguments to pass contract method */ args: TArgs;
233
+ /** Arguments to pass contract constructor */ args: TArgs;
223
234
  };
224
- type ExtractErrorArgsFromAbi<TAbi extends Abi | readonly unknown[], TErrorName extends string, TAbiError extends AbiError = TAbi extends Abi ? ExtractAbiError<TAbi, TErrorName> : AbiError, TArgs = AbiParametersToPrimitiveTypes<TAbiError['inputs']>, FailedToParseArgs = ([TArgs] extends [never] ? true : false) | (readonly unknown[] extends TArgs ? true : false)> = true extends FailedToParseArgs ? {
235
+ type GetErrorArgs<TAbi extends Abi | readonly unknown[], TErrorName extends string, TAbiError extends AbiError = TAbi extends Abi ? ExtractAbiError<TAbi, TErrorName> : AbiError, TArgs = AbiParametersToPrimitiveTypes<TAbiError['inputs']>, FailedToParseArgs = ([TArgs] extends [never] ? true : false) | (readonly unknown[] extends TArgs ? true : false)> = true extends FailedToParseArgs ? {
225
236
  /**
226
237
  * Arguments to pass contract method
227
238
  *
@@ -233,12 +244,12 @@ type ExtractErrorArgsFromAbi<TAbi extends Abi | readonly unknown[], TErrorName e
233
244
  } : {
234
245
  /** Arguments to pass contract method */ args: TArgs;
235
246
  };
236
- type ExtractEventArgsFromAbi<TAbi extends Abi | readonly unknown[], TEventName extends string, TConfig extends EventParametersConfig = EventParametersDefaultConfig, TAbiEvent extends AbiEvent & {
247
+ type GetEventArgs<TAbi extends Abi | readonly unknown[], TEventName extends string, TConfig extends EventParameterOptions = DefaultEventParameterOptions, TAbiEvent extends AbiEvent & {
237
248
  type: 'event';
238
249
  } = TAbi extends Abi ? ExtractAbiEvent<TAbi, TEventName> : AbiEvent & {
239
250
  type: 'event';
240
251
  }, TArgs = AbiEventParametersToPrimitiveTypes<TAbiEvent['inputs'], TConfig>, FailedToParseArgs = ([TArgs] extends [never] ? true : false) | (readonly unknown[] extends TArgs ? true : false)> = true extends FailedToParseArgs ? readonly unknown[] : TArgs extends readonly [] ? never : TArgs;
241
- type ExtractEventArgsFromTopics<TAbi extends Abi | readonly unknown[], TEventName extends string, TTopics extends LogTopic[], TData extends Hex | undefined, TAbiEvent extends AbiEvent & {
252
+ type GetEventArgsFromTopics<TAbi extends Abi | readonly unknown[], TEventName extends string, TTopics extends LogTopic[], TData extends Hex | undefined, TAbiEvent extends AbiEvent & {
242
253
  type: 'event';
243
254
  } = TAbi extends Abi ? ExtractAbiEvent<TAbi, TEventName> : AbiEvent & {
244
255
  type: 'event';
@@ -249,67 +260,92 @@ type ExtractEventArgsFromTopics<TAbi extends Abi | readonly unknown[], TEventNam
249
260
  } : {
250
261
  args?: TArgs;
251
262
  };
252
- type ExtractErrorNameFromAbi<TAbi extends Abi | readonly unknown[] = Abi, TErrorName extends string = string> = TAbi extends Abi ? ExtractAbiErrorNames<TAbi> extends infer AbiErrorNames ? AbiErrorNames | (TErrorName extends AbiErrorNames ? TErrorName : never) | (Abi extends TAbi ? string : never) : never : TErrorName;
253
- type ExtractEventNameFromAbi<TAbi extends Abi | readonly unknown[] = Abi, TEventName extends string | undefined = string> = TAbi extends Abi ? ExtractAbiEventNames<TAbi> extends infer AbiEventNames ? AbiEventNames | (TEventName extends AbiEventNames ? TEventName : never) : never : TEventName;
254
- type ExtractFunctionNameFromAbi<TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string, TAbiStateMutability extends AbiStateMutability = AbiStateMutability> = TAbi extends Abi ? ExtractAbiFunctionNames<TAbi, TAbiStateMutability> extends infer AbiFunctionNames ? AbiFunctionNames | (TFunctionName extends AbiFunctionNames ? TFunctionName : never) | (Abi extends TAbi ? string : never) : never : TFunctionName;
255
- type ExtractNames<TAbi extends Abi> = ExtractAbiFunctionNames<TAbi> | ExtractAbiEventNames<TAbi> | ExtractAbiErrorNames<TAbi>;
256
- type ExtractNameFromAbi<TAbi extends Abi | readonly unknown[] = Abi, TName extends string = string> = TAbi extends Abi ? ExtractNames<TAbi> extends infer AbiNames ? AbiNames | (TName extends AbiNames ? TName : never) | (Abi extends TAbi ? string : never) : never : TName;
257
- type ExtractResultFromAbi<TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string, TAbiFunction extends AbiFunction & {
258
- type: 'function';
259
- } = TAbi extends Abi ? ExtractAbiFunction<TAbi, TFunctionName> : AbiFunction, TArgs = AbiParametersToPrimitiveTypes<TAbiFunction['outputs']>, FailedToParseArgs = ([TArgs] extends [never] ? true : false) | (readonly unknown[] extends TArgs ? true : false)> = true extends FailedToParseArgs ? unknown : TArgs extends readonly [] ? void : TArgs extends readonly [infer Arg] ? Arg : TArgs;
260
- type MaybeAbiEventName<TAbiEvent extends AbiEvent | undefined> = TAbiEvent extends AbiEvent ? TAbiEvent['name'] : undefined;
261
- type MaybeExtractEventArgsFromAbi<TAbi extends Abi | readonly unknown[] = Abi, TEventName extends string | undefined = undefined> = TEventName extends string ? ExtractEventArgsFromAbi<TAbi, TEventName> : undefined;
262
- type ContractConfig<TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string, TAbiStateMutability extends AbiStateMutability = AbiStateMutability> = {
263
- /** Contract ABI */
264
- abi: Narrow<TAbi>;
265
- /** Contract address */
266
- address: Address;
267
- /** Function to invoke on the contract */
268
- functionName: ExtractFunctionNameFromAbi<TAbi, TFunctionName, TAbiStateMutability>;
269
- } & ExtractArgsFromAbi<TAbi, TFunctionName>;
270
- type GetValue<TAbi extends Abi | readonly unknown[], TFunctionName extends string, TValueType = TransactionRequest['value'], TAbiFunction extends AbiFunction = TAbi extends Abi ? ExtractAbiFunction<TAbi, TFunctionName> : AbiFunction> = TAbiFunction['stateMutability'] extends 'payable' ? TValueType : TAbiFunction['payable'] extends true ? TValueType : never;
271
-
272
- type FeeHistory<TQuantity = bigint> = {
273
- /**
274
- * An array of block base fees per gas (in wei). This includes the next block after
275
- * the newest of the returned range, because this value can be derived from the newest block.
276
- * Zeroes are returned for pre-EIP-1559 blocks. */
277
- baseFeePerGas: TQuantity[];
278
- /** An array of block gas used ratios. These are calculated as the ratio of gasUsed and gasLimit. */
279
- gasUsedRatio: number[];
280
- /** Lowest number block of the returned range. */
281
- oldestBlock: TQuantity;
282
- /** 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. */
283
- reward?: TQuantity[][];
284
- };
285
- type FeeValuesLegacy<TQuantity = bigint> = {
286
- /** Base fee per gas. */
287
- gasPrice: TQuantity;
288
- maxFeePerGas?: never;
289
- maxPriorityFeePerGas?: never;
263
+ type EventParameterOptions = {
264
+ EnableUnion?: boolean;
265
+ IndexedOnly?: boolean;
266
+ Required?: boolean;
290
267
  };
291
- type FeeValuesEIP1559<TQuantity = bigint> = {
292
- gasPrice?: never;
293
- /** Total fee per gas in wei (gasPrice/baseFeePerGas + maxPriorityFeePerGas). */
294
- maxFeePerGas: TQuantity;
295
- /** Max priority fee per gas (in wei). */
296
- maxPriorityFeePerGas: TQuantity;
268
+ type DefaultEventParameterOptions = {
269
+ EnableUnion: true;
270
+ IndexedOnly: true;
271
+ Required: false;
297
272
  };
298
- type FeeValues<TQuantity = bigint> = FeeValuesLegacy<TQuantity> | FeeValuesEIP1559<TQuantity>;
273
+ type HashedEventTypes = 'bytes' | 'string' | 'tuple' | `${string}[${string}]`;
274
+ type _HasUnnamedAbiParameter<TAbiParameters extends readonly AbiParameter[]> = TAbiParameters extends readonly [
275
+ infer Head extends AbiParameter,
276
+ ...infer Tail extends readonly AbiParameter[]
277
+ ] ? Head extends {
278
+ name: string;
279
+ } ? Head['name'] extends '' ? true : _HasUnnamedAbiParameter<Tail> : true : false;
280
+ /**
281
+ * @internal
282
+ */
283
+ type LogTopicType<TPrimitiveType = Hex, TTopic extends LogTopic = LogTopic> = TTopic extends Hex ? TPrimitiveType : TTopic extends Hex[] ? TPrimitiveType[] : TTopic extends null ? null : never;
284
+ /**
285
+ * @internal
286
+ */
287
+ type AbiEventParameterToPrimitiveType<TAbiParameter extends AbiParameter, Options extends EventParameterOptions = DefaultEventParameterOptions, _Type = AbiParameterToPrimitiveType<TAbiParameter>> = Options['EnableUnion'] extends true ? LogTopicType<_Type> : _Type;
288
+ /**
289
+ * @internal
290
+ */
291
+ type AbiEventTopicToPrimitiveType<TAbiParameter extends AbiParameter, TTopic extends LogTopic, TPrimitiveType = TAbiParameter['type'] extends HashedEventTypes ? TTopic : AbiParameterToPrimitiveType<TAbiParameter>> = LogTopicType<TPrimitiveType, TTopic>;
292
+ type AbiEventParametersToPrimitiveTypes<TAbiParameters extends readonly AbiParameter[], Options extends EventParameterOptions = DefaultEventParameterOptions> = TAbiParameters extends readonly [] ? readonly [] : Filter<TAbiParameters, Options['IndexedOnly'] extends true ? {
293
+ indexed: true;
294
+ } : object> extends infer Filtered extends readonly AbiParameter[] ? _HasUnnamedAbiParameter<Filtered> extends true ? readonly [
295
+ ...{
296
+ [K in keyof Filtered]: AbiEventParameterToPrimitiveType<Filtered[K], Options>;
297
+ }
298
+ ] | (Options['Required'] extends true ? never : Filtered extends readonly [
299
+ ...infer Head extends readonly AbiParameter[],
300
+ infer _
301
+ ] ? AbiEventParametersToPrimitiveTypes<readonly [...{
302
+ [K in keyof Head]: Omit<Head[K], 'name'>;
303
+ }], Options> : never) : {
304
+ [Parameter in Filtered[number] as Parameter extends {
305
+ name: infer Name extends string;
306
+ } ? Name : never]?: AbiEventParameterToPrimitiveType<Parameter, Options>;
307
+ } extends infer Mapped ? MaybeRequired<Mapped, Options['Required'] extends boolean ? Options['Required'] : false> : never : never;
308
+ /**
309
+ * @internal
310
+ */
311
+ type AbiEventTopicsToPrimitiveTypes<TAbiParameters extends readonly AbiParameter[], TTopics extends LogTopic[] | undefined = undefined, TData extends Hex | undefined = undefined, TBase = TAbiParameters[0] extends {
312
+ name: string;
313
+ } ? {} : []> = TAbiParameters extends readonly [
314
+ infer Head extends AbiParameter,
315
+ ...infer Tail
316
+ ] ? TTopics extends readonly [infer TopicHead, ...infer TopicTail] ? Head extends {
317
+ indexed: true;
318
+ } ? Head extends {
319
+ name: infer Name extends string;
320
+ } ? {
321
+ [_ in Name]: TopicHead extends LogTopic ? AbiEventTopicToPrimitiveType<Head, TopicHead> : never;
322
+ } & (Tail extends readonly [] ? {} : Tail extends readonly AbiParameter[] ? TopicTail extends LogTopic[] ? AbiEventTopicsToPrimitiveTypes<Tail, TopicTail, TData> : {} : {}) : [
323
+ TopicHead extends LogTopic ? AbiEventTopicToPrimitiveType<Head, TopicHead> : never,
324
+ ...(Tail extends readonly [] ? [] : Tail extends readonly AbiParameter[] ? TopicTail extends LogTopic[] ? AbiEventTopicsToPrimitiveTypes<Tail, TopicTail, TData> : [] : [])
325
+ ] : TBase : TTopics extends readonly [] ? TData extends '0x' ? TBase : TData extends Hex ? Head extends AbiParameter ? Head extends {
326
+ indexed: true;
327
+ } ? Tail extends readonly AbiParameter[] ? AbiEventTopicsToPrimitiveTypes<Tail, [], TData> : TBase : Head extends {
328
+ name: infer Name extends string;
329
+ } ? {
330
+ [_ in Name]: AbiParameterToPrimitiveType<Head>;
331
+ } & (Tail extends readonly [] ? {} : Tail extends readonly AbiParameter[] ? AbiEventTopicsToPrimitiveTypes<Tail, [], TData> : {}) : [
332
+ AbiParameterToPrimitiveType<Head>,
333
+ ...(Tail extends readonly [] ? [] : Tail extends readonly AbiParameter[] ? AbiEventTopicsToPrimitiveTypes<Tail, [], TData> : [])
334
+ ] : TBase : TBase : TBase : undefined;
299
335
 
300
336
  type DecodedAbiEvent<TAbiEvent extends AbiEvent | undefined = undefined, TAbi extends Abi | readonly unknown[] = [TAbiEvent], TEventName extends string | undefined = TAbiEvent extends AbiEvent ? TAbiEvent['name'] : undefined> = TAbi extends Abi ? TEventName extends string ? {
301
- args: ExtractEventArgsFromAbi<TAbi, TEventName, {
302
- enableUnion: false;
303
- indexedOnly: false;
304
- required: true;
337
+ args: GetEventArgs<TAbi, TEventName, {
338
+ EnableUnion: false;
339
+ IndexedOnly: false;
340
+ Required: true;
305
341
  }>;
306
342
  /** The event name decoded from `topics`. */
307
343
  eventName: TEventName;
308
344
  } : {
309
- args: ExtractEventArgsFromAbi<TAbi, string, {
310
- enableUnion: false;
311
- indexedOnly: false;
312
- required: true;
345
+ args: GetEventArgs<TAbi, string, {
346
+ EnableUnion: false;
347
+ IndexedOnly: false;
348
+ Required: true;
313
349
  }>;
314
350
  /** The event name decoded from `topics`. */
315
351
  eventName: ExtractAbiEventNames<TAbi>;
@@ -437,6 +473,29 @@ type TransactionRequestEIP1559<TQuantity = bigint, TIndex = number> = Transactio
437
473
  accessList?: AccessList;
438
474
  };
439
475
  type TransactionRequest<TQuantity = bigint, TIndex = number> = TransactionRequestLegacy<TQuantity, TIndex> | TransactionRequestEIP2930<TQuantity, TIndex> | TransactionRequestEIP1559<TQuantity, TIndex>;
476
+ type TransactionSerializedEIP1559 = `0x02${string}`;
477
+ type TransactionSerializedEIP2930 = `0x01${string}`;
478
+ type TransactionSerializedLegacy = Hex;
479
+ type TransactionSerialized<TType extends TransactionType$1 = 'legacy'> = (TType extends 'eip1559' ? TransactionSerializedEIP1559 : never) | (TType extends 'eip2930' ? TransactionSerializedEIP2930 : never) | (TType extends 'legacy' ? TransactionSerializedLegacy : never);
480
+ type TransactionSerializableBase<TQuantity = bigint, TIndex = number> = Omit<TransactionRequestBase<TQuantity, TIndex>, 'from'> & Partial<Signature>;
481
+ type TransactionSerializableLegacy<TQuantity = bigint, TIndex = number> = TransactionSerializableBase<TQuantity, TIndex> & Partial<FeeValuesLegacy<TQuantity>> & {
482
+ accessList?: never;
483
+ chainId?: number;
484
+ type?: 'legacy';
485
+ };
486
+ type TransactionSerializableEIP2930<TQuantity = bigint, TIndex = number> = TransactionSerializableBase<TQuantity, TIndex> & Partial<FeeValuesLegacy<TQuantity>> & {
487
+ accessList?: AccessList;
488
+ chainId: number;
489
+ type?: 'eip2930';
490
+ yParity?: number;
491
+ };
492
+ type TransactionSerializableEIP1559<TQuantity = bigint, TIndex = number> = TransactionSerializableBase<TQuantity, TIndex> & Partial<FeeValuesEIP1559<TQuantity>> & {
493
+ accessList?: AccessList;
494
+ chainId: number;
495
+ type?: 'eip1559';
496
+ yParity?: number;
497
+ };
498
+ type TransactionSerializable<TQuantity = bigint, TIndex = number> = TransactionSerializableLegacy<TQuantity, TIndex> | TransactionSerializableEIP2930<TQuantity, TIndex> | TransactionSerializableEIP1559<TQuantity, TIndex>;
440
499
 
441
500
  type Block<TQuantity = bigint, TTransaction = Transaction> = {
442
501
  /** Base fee per gas */
@@ -525,5 +584,10 @@ type Formatters = {
525
584
  type Chain<TFormatters extends Formatters = Formatters> = Chain$1 & {
526
585
  formatters?: TFormatters;
527
586
  };
587
+ type GetChain<TChain extends Chain | undefined, TChainOverride extends Chain | undefined = undefined> = IsUndefined<TChain> extends true ? {
588
+ chain: TChainOverride | null;
589
+ } : {
590
+ chain?: TChainOverride | null;
591
+ };
528
592
 
529
- export { formatTransaction as $, AbiItem as A, ByteArray as B, Chain as C, RpcTransactionRequest as D, ExtractArgsFromAbi as E, FeeHistory as F, RpcUncle as G, Hex as H, TransactionRequest as I, TransactionRequestBase as J, TransactionRequestEIP1559 as K, Log as L, TransactionRequestEIP2930 as M, TransactionRequestLegacy as N, Transaction as O, TransactionBase as P, TransactionEIP1559 as Q, RpcBlock as R, TransactionEIP2930 as S, TransactionReceipt as T, TransactionLegacy as U, Uncle as V, ExtractFormatter as W, Formatted as X, FormattedTransaction as Y, TransactionFormatter as Z, defineTransaction as _, Hash as a, transactionType as a0, Formatters as a1, Formatter as a2, TransactionType$1 as a3, MergeIntersectionProperties as a4, GetValue as a5, MaybeAbiEventName as a6, MaybeExtractEventArgsFromAbi as a7, Prettify as a8, Quantity as a9, EventDefinition as aa, LogTopic as ab, defineFormatter as ac, format as ad, AccessList as b, Block as c, BlockIdentifier as d, BlockNumber as e, BlockTag as f, ContractConfig as g, ExtractConstructorArgsFromAbi as h, ExtractErrorArgsFromAbi as i, ExtractErrorNameFromAbi as j, ExtractEventArgsFromAbi as k, ExtractEventArgsFromTopics as l, ExtractEventNameFromAbi as m, ExtractFunctionNameFromAbi as n, ExtractNameFromAbi as o, ExtractResultFromAbi as p, FeeValues as q, FeeValuesEIP1559 as r, FeeValuesLegacy as s, RpcBlockIdentifier as t, RpcBlockNumber as u, RpcFeeHistory as v, RpcFeeValues as w, RpcLog as x, RpcTransaction as y, RpcTransactionReceipt as z };
593
+ export { TransactionSerializable as $, AbiItem as A, ByteArray as B, Chain as C, RpcLog as D, RpcTransaction as E, FeeHistory as F, GetConstructorArgs as G, Hex as H, IsNarrowable as I, RpcTransactionReceipt as J, RpcTransactionRequest as K, Log as L, MaybeExtractEventArgsFromAbi as M, RpcUncle as N, TransactionBase as O, Prettify as P, TransactionEIP1559 as Q, RpcBlock as R, TransactionEIP2930 as S, Transaction as T, TransactionLegacy as U, TransactionReceipt as V, TransactionRequest as W, TransactionRequestBase as X, TransactionRequestEIP1559 as Y, TransactionRequestEIP2930 as Z, TransactionRequestLegacy as _, Hash as a, TransactionSerializableBase as a0, TransactionSerializableEIP1559 as a1, TransactionSerializableEIP2930 as a2, TransactionSerializableLegacy as a3, TransactionSerialized as a4, TransactionSerializedEIP1559 as a5, TransactionSerializedEIP2930 as a6, TransactionSerializedLegacy as a7, TransactionType$1 as a8, Uncle as a9, ExtractFormatter as aa, Formatted as ab, FormattedTransaction as ac, TransactionFormatter as ad, defineTransaction as ae, formatTransaction as af, transactionType as ag, Formatters as ah, Formatter as ai, GetChain as aj, MergeIntersectionProperties as ak, GetValue as al, MaybeAbiEventName as am, Quantity as an, EventDefinition as ao, Signature as ap, LogTopic as aq, defineFormatter as ar, format as as, IsNever as b, IsUndefined as c, AbiEventParametersToPrimitiveTypes as d, AccessList as e, Block as f, BlockIdentifier as g, BlockNumber as h, BlockTag as i, ContractFunctionConfig as j, ContractFunctionResult as k, FeeValues as l, FeeValuesEIP1559 as m, FeeValuesLegacy as n, GetErrorArgs as o, GetEventArgs as p, GetEventArgsFromTopics as q, GetFunctionArgs as r, InferErrorName as s, InferEventName as t, InferFunctionName as u, InferItemName as v, RpcBlockIdentifier as w, RpcBlockNumber as x, RpcFeeHistory as y, RpcFeeValues as z };
@@ -1,4 +1,4 @@
1
- import { a1 as Formatters, C as Chain } from './chain-1b53ef88.js';
1
+ import { ah as Formatters, C as Chain } from './chain-5507c6f0.js';
2
2
 
3
3
  declare function defineChain<TFormatters extends Formatters = Formatters, TChain extends Chain<TFormatters> = Chain<TFormatters>>(chain: TChain): TChain;
4
4
  declare function getChainContractAddress({ blockNumber, chain, contract: name, }: {