eip-1193 0.6.6 → 0.7.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 (2) hide show
  1. package/index.d.ts +992 -247
  2. package/package.json +10 -2
package/index.d.ts CHANGED
@@ -1,77 +1,219 @@
1
1
  // ------------------------------------------------------------------------------------------------
2
- // TYPES
2
+ // PRIMITIVES
3
3
  // ------------------------------------------------------------------------------------------------
4
- export type EIP1193DATA = `0x${string}`;
5
- export type EIP1193BlockTag = EIP1193QUANTITY | 'latest' | 'earliest' | 'pending' | 'safe' | 'finalized';
6
-
7
- export type EIP1193INTEGER = EIP1193DATA | number;
8
4
 
9
- export type EIP1898BlockTag =
10
- | EIP1193QUANTITY
11
- | 'latest'
12
- | 'earliest'
13
- | 'pending'
14
- | 'safe'
15
- | 'finalized'
16
- | {blockHash: EIP1193QUANTITY; requireCanonical?: boolean} // EIP-1898
17
- | {blockNumber: EIP1193QUANTITY}; // EIP-1898
5
+ /**
6
+ * Unformatted binary data, hex-encoded with a `0x` prefix.
7
+ *
8
+ * NOTE: `EIP1193DATA` and `EIP1193QUANTITY` are the SAME structural type. The distinction is
9
+ * documentation only: TypeScript cannot tell them apart, so mislabelling one as the other is
10
+ * invisible to the compiler. That is exactly how several fields in this file drifted away from
11
+ * the spec in the past. `test-d/index.test-d.ts` exists to catch that drift by asserting against
12
+ * real payload shapes.
13
+ */
14
+ export type EIP1193DATA = `0x${string}`;
18
15
 
16
+ /**
17
+ * An unsigned integer, hex-encoded with a `0x` prefix and no leading zeroes.
18
+ * See the note on {@link EIP1193DATA}: structurally identical, semantically different.
19
+ */
19
20
  export type EIP1193QUANTITY = `0x${string}`;
21
+
22
+ /** An EIP-155 chain id, hex-encoded per EIP-695. */
20
23
  export type EIP1193ChainId = `0x${string}`;
24
+
25
+ /** A 20-byte address. */
21
26
  export type EIP1193Account = `0x${string}`;
27
+
22
28
  export type EIP1193Accounts = EIP1193Account[];
23
29
 
30
+ /** A list of addresses, e.g. as a log-filter constraint. Unrelated to owned accounts. */
31
+ export type EIP1193AddressList = EIP1193Account[];
32
+
33
+ export type EIP1193BlockTag = EIP1193QUANTITY | 'latest' | 'earliest' | 'pending' | 'safe' | 'finalized';
34
+
35
+ /**
36
+ * A block tag that also accepts a block hash.
37
+ *
38
+ * Two spellings are accepted in the wild:
39
+ * - the EIP-1898 object forms (`{blockHash, requireCanonical?}` / `{blockNumber}`)
40
+ * - a bare 32-byte block hash, which is what `execution-apis` now specifies
41
+ * (`BlockNumberOrTagOrHash`)
42
+ *
43
+ * The bare-hash form is already covered by `EIP1193QUANTITY`, since both are `0x${string}`.
44
+ */
45
+ export type EIP1898BlockTag =
46
+ | EIP1193BlockTag
47
+ | EIP1193DATA // bare block hash, per `BlockNumberOrTagOrHash`
48
+ | {blockHash: EIP1193DATA; requireCanonical?: boolean} // EIP-1898
49
+ | {blockNumber: EIP1193QUANTITY}; // EIP-1898
50
+
51
+ // ------------------------------------------------------------------------------------------------
52
+ // FEES
53
+ // ------------------------------------------------------------------------------------------------
54
+
55
+ /**
56
+ * Result of `eth_feeHistory`.
57
+ *
58
+ * `gasUsedRatio` / `blobGasUsedRatio` are raw JSON floats (`0.945886...`), NOT hex quantities.
59
+ * `reward` is only returned when `rewardPercentiles` was supplied in the request.
60
+ */
24
61
  export type EIP1193FeeHistory = {
25
- oldestBlock: string;
26
- reward: EIP1193QUANTITY[][];
27
- baseFeePerGas: string[];
28
- gasUsedRatio: string[];
62
+ /** Lowest numbered block of the returned range. */
63
+ oldestBlock: EIP1193QUANTITY;
64
+ /** One entry per returned block, PLUS one for the next block after the newest. */
65
+ baseFeePerGas: EIP1193QUANTITY[];
66
+ /** Ratio of gasUsed to gasLimit, as a float between 0 and 1. */
67
+ gasUsedRatio: number[];
68
+ /** EIP-4844. Same "+1 entry" rule as `baseFeePerGas`. Absent on pre-Cancun clients. */
69
+ baseFeePerBlobGas?: EIP1193QUANTITY[];
70
+ /** EIP-4844, as a float between 0 and 1. Absent on pre-Cancun clients. */
71
+ blobGasUsedRatio?: number[];
72
+ /** Only present when `rewardPercentiles` was passed. Outer array: blocks. Inner: percentiles. */
73
+ reward?: EIP1193QUANTITY[][];
29
74
  };
30
75
 
31
- type BaseEIP1193Transaction = {
32
- blockHash: EIP1193DATA;
76
+ // ------------------------------------------------------------------------------------------------
77
+ // ACCESS LISTS / AUTHORIZATIONS
78
+ // ------------------------------------------------------------------------------------------------
79
+
80
+ export type EIP1193AccessListEntry = {address: EIP1193Account; storageKeys: EIP1193DATA[]};
81
+ export type EIP1193AccessList = EIP1193AccessListEntry[];
82
+
83
+ /** A single EIP-7702 authorization tuple, as returned inside a type `0x4` transaction. */
84
+ export type EIP1193Authorization = {
85
+ chainId: EIP1193QUANTITY;
86
+ address: EIP1193Account;
87
+ nonce: EIP1193QUANTITY;
88
+ yParity: EIP1193QUANTITY;
89
+ r: EIP1193QUANTITY;
90
+ s: EIP1193QUANTITY;
91
+ };
92
+ export type EIP1193AuthorizationList = EIP1193Authorization[];
93
+
94
+ // ------------------------------------------------------------------------------------------------
95
+ // TRANSACTIONS (as returned by the node)
96
+ // ------------------------------------------------------------------------------------------------
97
+
98
+ /** Fields a node attaches to a transaction on top of the signed transaction itself. */
99
+ type EIP1193TransactionContext = {
100
+ /** `null` while the transaction is still pending. */
101
+ blockHash: EIP1193DATA | null;
102
+ /** `null` while the transaction is still pending. */
33
103
  blockNumber: EIP1193QUANTITY | null;
104
+ /** `null` while the transaction is still pending. */
105
+ transactionIndex: EIP1193QUANTITY | null;
106
+ /**
107
+ * Timestamp of the block this transaction is in.
108
+ * Added to `TransactionInfo` by execution-apis; not emitted by every client yet, so treat
109
+ * `undefined` as "this node does not provide it" and fall back rather than defaulting to 0.
110
+ */
111
+ blockTimestamp?: EIP1193QUANTITY;
112
+ hash: EIP1193DATA;
34
113
  from: EIP1193Account;
114
+ /** `null` for a contract-creation transaction. */
115
+ to: EIP1193Account | null;
35
116
  gas: EIP1193QUANTITY;
36
- hash: EIP1193DATA;
37
117
  input: EIP1193DATA;
38
118
  nonce: EIP1193QUANTITY;
39
- to: EIP1193Account | null;
40
- transactionIndex: EIP1193QUANTITY | null;
41
119
  value: EIP1193QUANTITY;
42
- v: EIP1193QUANTITY;
43
120
  r: EIP1193QUANTITY;
44
121
  s: EIP1193QUANTITY;
45
122
  };
46
123
 
47
- export type EIP1193TransactionType0 = BaseEIP1193Transaction & {
48
- type?: '0x0';
49
- gasPrice: EIP1193QUANTITY;
124
+ /** Legacy (pre EIP-2718) signature: `v` carries the parity, EIP-155-encoded with the chain id. */
125
+ type EIP1193LegacySignature = {
126
+ v: EIP1193QUANTITY;
127
+ yParity?: never;
50
128
  };
51
129
 
52
- export type EIP1193TransactionType1 = BaseEIP1193Transaction & {
53
- type: '0x1';
54
- gasPrice: EIP1193QUANTITY;
55
- chainId: EIP1193ChainId;
56
- accessList?: EIP1193AccessList;
130
+ /** Typed-transaction signature: `yParity` is authoritative, `v` is a deprecated alias. */
131
+ type EIP1193TypedSignature = {
132
+ yParity: EIP1193QUANTITY;
133
+ /** @deprecated Provided for backwards compatibility. Use `yParity`. */
134
+ v?: EIP1193QUANTITY;
57
135
  };
58
136
 
59
- export type EIP1193TransactionType2 = BaseEIP1193Transaction & {
60
- type: '0x2';
61
- chainId: EIP1193ChainId;
62
- accessList?: EIP1193AccessList;
63
- maxFeePerGas: EIP1193QUANTITY;
64
- maxPriorityFeePerGas: EIP1193QUANTITY;
65
- };
137
+ export type EIP1193TransactionType0 = EIP1193TransactionContext &
138
+ EIP1193LegacySignature & {
139
+ /** Omitted by some clients for legacy transactions. */
140
+ type?: '0x0';
141
+ gasPrice: EIP1193QUANTITY;
142
+ /** Present only for EIP-155 replay-protected legacy transactions. */
143
+ chainId?: EIP1193ChainId;
144
+ };
145
+
146
+ /** EIP-2930 access-list transaction. */
147
+ export type EIP1193TransactionType1 = EIP1193TransactionContext &
148
+ EIP1193TypedSignature & {
149
+ type: '0x1';
150
+ chainId: EIP1193ChainId;
151
+ gasPrice: EIP1193QUANTITY;
152
+ accessList: EIP1193AccessList;
153
+ };
154
+
155
+ /** EIP-1559 fee-market transaction. */
156
+ export type EIP1193TransactionType2 = EIP1193TransactionContext &
157
+ EIP1193TypedSignature & {
158
+ type: '0x2';
159
+ chainId: EIP1193ChainId;
160
+ accessList: EIP1193AccessList;
161
+ maxFeePerGas: EIP1193QUANTITY;
162
+ maxPriorityFeePerGas: EIP1193QUANTITY;
163
+ /** @deprecated The effective gas price. Prefer `effectiveGasPrice` on the receipt. */
164
+ gasPrice?: EIP1193QUANTITY;
165
+ };
166
+
167
+ /** EIP-4844 blob transaction. Cannot be a contract creation, so `to` is never `null`. */
168
+ export type EIP1193TransactionType3 = Omit<EIP1193TransactionContext, 'to'> &
169
+ EIP1193TypedSignature & {
170
+ type: '0x3';
171
+ to: EIP1193Account;
172
+ chainId: EIP1193ChainId;
173
+ accessList: EIP1193AccessList;
174
+ maxFeePerGas: EIP1193QUANTITY;
175
+ maxPriorityFeePerGas: EIP1193QUANTITY;
176
+ maxFeePerBlobGas: EIP1193QUANTITY;
177
+ blobVersionedHashes: EIP1193DATA[];
178
+ /** @deprecated The effective gas price. Prefer `effectiveGasPrice` on the receipt. */
179
+ gasPrice?: EIP1193QUANTITY;
180
+ };
181
+
182
+ /** EIP-7702 set-code transaction. Cannot be a contract creation, so `to` is never `null`. */
183
+ export type EIP1193TransactionType4 = Omit<EIP1193TransactionContext, 'to'> &
184
+ EIP1193TypedSignature & {
185
+ type: '0x4';
186
+ to: EIP1193Account;
187
+ chainId: EIP1193ChainId;
188
+ accessList: EIP1193AccessList;
189
+ maxFeePerGas: EIP1193QUANTITY;
190
+ maxPriorityFeePerGas: EIP1193QUANTITY;
191
+ authorizationList: EIP1193AuthorizationList;
192
+ /** @deprecated The effective gas price. Prefer `effectiveGasPrice` on the receipt. */
193
+ gasPrice?: EIP1193QUANTITY;
194
+ };
195
+
196
+ export type EIP1193Transaction =
197
+ | EIP1193TransactionType0
198
+ | EIP1193TransactionType1
199
+ | EIP1193TransactionType2
200
+ | EIP1193TransactionType3
201
+ | EIP1193TransactionType4;
66
202
 
67
- export type EIP1193Transaction = EIP1193TransactionType0 | EIP1193TransactionType1 | EIP1193TransactionType2;
203
+ // ------------------------------------------------------------------------------------------------
204
+ // TRANSACTIONS (as submitted by the caller)
205
+ // ------------------------------------------------------------------------------------------------
68
206
 
69
207
  type BaseEIP1193TransactionData = {
70
208
  from: EIP1193Account;
209
+ /** Omit for a contract creation. */
71
210
  to?: EIP1193Account;
72
211
  gas?: EIP1193QUANTITY;
73
212
  value?: EIP1193QUANTITY;
213
+ /** The calldata. `execution-apis` names this field `input`; both spellings are accepted. */
74
214
  data?: EIP1193DATA;
215
+ /** Alias of `data`, matching the `execution-apis` `GenericTransaction` schema. */
216
+ input?: EIP1193DATA;
75
217
  nonce?: EIP1193QUANTITY;
76
218
  };
77
219
 
@@ -87,9 +229,6 @@ export type EIP1193TransactionDataOfType1 = BaseEIP1193TransactionData & {
87
229
  gasPrice?: EIP1193QUANTITY;
88
230
  };
89
231
 
90
- export type EIP1193AccessListEntry = {address: EIP1193Account; storageKeys: EIP1193DATA[]};
91
- export type EIP1193AccessList = EIP1193AccessListEntry[];
92
-
93
232
  export type EIP1193TransactionDataOfType2 = BaseEIP1193TransactionData & {
94
233
  type: '0x2';
95
234
  chainId?: EIP1193ChainId;
@@ -98,38 +237,172 @@ export type EIP1193TransactionDataOfType2 = BaseEIP1193TransactionData & {
98
237
  maxPriorityFeePerGas?: EIP1193QUANTITY;
99
238
  };
100
239
 
240
+ /** EIP-4844 blob transaction. */
241
+ export type EIP1193TransactionDataOfType3 = BaseEIP1193TransactionData & {
242
+ type: '0x3';
243
+ to: EIP1193Account;
244
+ chainId?: EIP1193ChainId;
245
+ accessList?: EIP1193AccessList;
246
+ maxFeePerGas?: EIP1193QUANTITY;
247
+ maxPriorityFeePerGas?: EIP1193QUANTITY;
248
+ maxFeePerBlobGas?: EIP1193QUANTITY;
249
+ blobVersionedHashes?: EIP1193DATA[];
250
+ blobs?: EIP1193DATA[];
251
+ commitments?: EIP1193DATA[];
252
+ proofs?: EIP1193DATA[];
253
+ };
254
+
255
+ /** EIP-7702 set-code transaction. */
256
+ export type EIP1193TransactionDataOfType4 = BaseEIP1193TransactionData & {
257
+ type: '0x4';
258
+ to: EIP1193Account;
259
+ chainId?: EIP1193ChainId;
260
+ accessList?: EIP1193AccessList;
261
+ maxFeePerGas?: EIP1193QUANTITY;
262
+ maxPriorityFeePerGas?: EIP1193QUANTITY;
263
+ authorizationList?: EIP1193AuthorizationList;
264
+ };
265
+
101
266
  export type EIP1193TransactionData =
102
267
  | EIP1193LegacyTransactionData
103
268
  | EIP1193TransactionDataOfType1
104
- | EIP1193TransactionDataOfType2;
269
+ | EIP1193TransactionDataOfType2
270
+ | EIP1193TransactionDataOfType3
271
+ | EIP1193TransactionDataOfType4;
272
+
273
+ /**
274
+ * The `GenericTransaction` object accepted by `eth_call`, `eth_estimateGas` and
275
+ * `eth_createAccessList`. Every field is optional: a call with only `data` is a
276
+ * contract-creation simulation, and a call with only `to` is a plain read.
277
+ */
278
+ export type EIP1193CallParam = {
279
+ type?: EIP1193QUANTITY;
280
+ nonce?: EIP1193QUANTITY;
281
+ from?: EIP1193Account;
282
+ to?: EIP1193Account | null;
283
+ gas?: EIP1193QUANTITY;
284
+ value?: EIP1193QUANTITY;
285
+ /** The calldata. `execution-apis` names this field `input`; both spellings are accepted. */
286
+ data?: EIP1193DATA;
287
+ /** Alias of `data`, matching the `execution-apis` `GenericTransaction` schema. */
288
+ input?: EIP1193DATA;
289
+ gasPrice?: EIP1193QUANTITY;
290
+ maxFeePerGas?: EIP1193QUANTITY;
291
+ maxPriorityFeePerGas?: EIP1193QUANTITY;
292
+ maxFeePerBlobGas?: EIP1193QUANTITY;
293
+ accessList?: EIP1193AccessList;
294
+ blobVersionedHashes?: EIP1193DATA[];
295
+ blobs?: EIP1193DATA[];
296
+ commitments?: EIP1193DATA[];
297
+ proofs?: EIP1193DATA[];
298
+ chainId?: EIP1193ChainId;
299
+ authorizationList?: EIP1193AuthorizationList;
300
+ };
105
301
 
106
- export type EIP1193SyncingStatus = {
107
- startingBlock: EIP1193QUANTITY;
108
- currentBlock: EIP1193QUANTITY;
109
- highestBlock: EIP1193QUANTITY;
302
+ /** Per-account entry of the `eth_call` / `eth_estimateGas` state override set. */
303
+ export type EIP1193AccountOverride = {
304
+ balance?: EIP1193QUANTITY;
305
+ nonce?: EIP1193QUANTITY;
306
+ code?: EIP1193DATA;
307
+ /** Replaces the account's entire storage. Mutually exclusive with `stateDiff`. */
308
+ state?: {[slot: EIP1193DATA]: EIP1193DATA};
309
+ /** Overrides individual slots. Mutually exclusive with `state`. */
310
+ stateDiff?: {[slot: EIP1193DATA]: EIP1193DATA};
311
+ movePrecompileToAddress?: EIP1193Account;
312
+ };
313
+
314
+ /**
315
+ * Optional third parameter of `eth_call` / `eth_estimateGas`.
316
+ * Not part of `execution-apis` yet, but implemented by go-ethereum, erigon, reth, anvil and hardhat.
317
+ */
318
+ export type EIP1193StateOverride = {[address: EIP1193Account]: EIP1193AccountOverride};
319
+
320
+ // ------------------------------------------------------------------------------------------------
321
+ // BLOCKS
322
+ // ------------------------------------------------------------------------------------------------
323
+
324
+ export type EIP1193Withdrawal = {
325
+ index: EIP1193QUANTITY;
326
+ validatorIndex: EIP1193QUANTITY;
327
+ address: EIP1193Account;
328
+ amount: EIP1193QUANTITY;
110
329
  };
111
330
 
112
- export type EIP1193Block = {
331
+ /** A block header, i.e. a block without its body. This is what a `newHeads` subscription pushes. */
332
+ export type EIP1193BlockHeader = {
113
333
  number: EIP1193QUANTITY;
114
334
  hash: EIP1193DATA;
115
335
  parentHash: EIP1193DATA;
116
336
  nonce: EIP1193DATA;
337
+ mixHash: EIP1193DATA;
117
338
  sha3Uncles: EIP1193DATA;
118
339
  logsBloom: EIP1193DATA;
119
340
  transactionsRoot: EIP1193DATA;
120
341
  stateRoot: EIP1193DATA;
121
342
  receiptsRoot: EIP1193DATA;
122
343
  miner: EIP1193Account;
344
+ /** Always `0x0` after the merge, but still emitted by every client. */
123
345
  difficulty: EIP1193QUANTITY;
124
- totalDifficulty: EIP1193QUANTITY;
346
+ /**
347
+ * @deprecated Removed from `execution-apis` and no longer emitted by go-ethereum (>= 1.14).
348
+ * Do not rely on it being present.
349
+ */
350
+ totalDifficulty?: EIP1193QUANTITY;
125
351
  extraData: EIP1193DATA;
126
- size: EIP1193QUANTITY;
127
352
  gasLimit: EIP1193QUANTITY;
128
353
  gasUsed: EIP1193QUANTITY;
129
354
  timestamp: EIP1193QUANTITY;
355
+ /** EIP-1559. Absent on pre-London blocks. */
356
+ baseFeePerGas?: EIP1193QUANTITY;
357
+ /** EIP-4895. Absent on pre-Shanghai blocks. */
358
+ withdrawalsRoot?: EIP1193DATA;
359
+ /** EIP-4844. Absent on pre-Cancun blocks. */
360
+ blobGasUsed?: EIP1193QUANTITY;
361
+ /** EIP-4844. Absent on pre-Cancun blocks. */
362
+ excessBlobGas?: EIP1193QUANTITY;
363
+ /** EIP-4788. Absent on pre-Cancun blocks. */
364
+ parentBeaconBlockRoot?: EIP1193DATA;
365
+ /** EIP-7685. Absent on pre-Prague blocks. */
366
+ requestsHash?: EIP1193DATA;
367
+ };
368
+
369
+ /**
370
+ * A block as returned by `eth_getBlockByHash` / `eth_getBlockByNumber` with the hydrated flag
371
+ * set to `false` (or omitted): `transactions` is a list of transaction HASHES.
372
+ */
373
+ export type EIP1193Block = EIP1193BlockHeader & {
374
+ size: EIP1193QUANTITY;
375
+ transactions: EIP1193DATA[];
130
376
  uncles: EIP1193DATA[];
377
+ /** EIP-4895. Absent on pre-Shanghai blocks. */
378
+ withdrawals?: EIP1193Withdrawal[];
131
379
  };
132
380
 
381
+ /**
382
+ * A block as returned with the hydrated flag set to `true`: `transactions` holds the full
383
+ * transaction objects.
384
+ */
385
+ export type EIP1193BlockWithTransactions = Omit<EIP1193Block, 'transactions'> & {
386
+ transactions: EIP1193Transaction[];
387
+ };
388
+
389
+ type EIP1193PendingBlockOverrides = {
390
+ number: null;
391
+ hash: null;
392
+ nonce: null;
393
+ logsBloom: null;
394
+ };
395
+
396
+ export type EIP1193PendingBlock = Omit<EIP1193Block, keyof EIP1193PendingBlockOverrides> & EIP1193PendingBlockOverrides;
397
+
398
+ export type EIP1193PendingBlockWithTransactions = Omit<EIP1193PendingBlock, 'transactions'> & {
399
+ transactions: EIP1193Transaction[];
400
+ };
401
+
402
+ // ------------------------------------------------------------------------------------------------
403
+ // LOGS & RECEIPTS
404
+ // ------------------------------------------------------------------------------------------------
405
+
133
406
  export type EIP1193Log = {
134
407
  removed: boolean;
135
408
  logIndex: EIP1193QUANTITY | null;
@@ -163,63 +436,170 @@ export type EIP1193TransactionReceipt = {
163
436
  blockHash: EIP1193DATA;
164
437
  blockNumber: EIP1193QUANTITY;
165
438
  from: EIP1193Account;
166
- to: EIP1193Account;
439
+ /** `null` for a contract-creation transaction. */
440
+ to: EIP1193Account | null;
167
441
  cumulativeGasUsed: EIP1193QUANTITY;
168
442
  effectiveGasPrice: EIP1193QUANTITY;
169
443
  gasUsed: EIP1193QUANTITY;
170
- contractAddress: EIP1193Account;
444
+ /** EIP-4844. Only present for blob transactions. */
445
+ blobGasUsed?: EIP1193QUANTITY;
446
+ /** EIP-4844. Only present for blob transactions. */
447
+ blobGasPrice?: EIP1193QUANTITY;
448
+ /** The address of the created contract, or `null` if this was not a contract creation. */
449
+ contractAddress: EIP1193Account | null;
171
450
  logs: EIP1193Log[];
172
451
  logsBloom: EIP1193DATA;
173
- type: EIP1193DATA;
174
- root: EIP1193DATA;
452
+ type: EIP1193QUANTITY;
453
+ /**
454
+ * The post-transaction state root. Only present for transactions included BEFORE the
455
+ * Byzantium upgrade (2017), where it takes the place of `status`. Effectively never present
456
+ * on any chain in current use, which is why `status` is kept required here.
457
+ */
458
+ root?: EIP1193DATA;
459
+ /** `0x1` on success, `0x0` on failure. Present since Byzantium. */
175
460
  status: EIP1193QUANTITY;
176
461
  };
177
462
 
178
- export type EIP1193PendingBlock = Omit<EIP1193Block, 'number' | 'hash' | 'nonce' | 'logsBloom'> & {
179
- number: null;
180
- hash: null;
181
- nonce: null;
182
- logsBloom: null;
463
+ /** The filter object accepted by `eth_getLogs`, `eth_newFilter` and `eth_subscribe('logs', ...)`. */
464
+ export type EIP1193LogsParam = {
465
+ fromBlock?: EIP1193BlockTag;
466
+ toBlock?: EIP1193BlockTag;
467
+ address?: EIP1193Account | EIP1193AddressList | null;
468
+ topics?: (EIP1193DATA | EIP1193DATA[] | null)[] | null;
469
+ /**
470
+ * Restricts the query to a single block. Mutually exclusive with `fromBlock`/`toBlock`.
471
+ *
472
+ * NOTE the casing: it is `blockHash`, not `blockhash`. Both `execution-apis` (`filter.yaml`)
473
+ * and go-ethereum (`FilterCriteria.UnmarshalJSON`) use camelCase.
474
+ */
475
+ blockHash?: EIP1193DATA;
183
476
  };
184
477
 
185
- export type EIP1193BlockWithTransactions = EIP1193Block & {
186
- transactions: EIP1193Transaction[];
478
+ // ------------------------------------------------------------------------------------------------
479
+ // PROOFS & SYNC
480
+ // ------------------------------------------------------------------------------------------------
481
+
482
+ export type EIP1193StorageProof = {
483
+ key: EIP1193DATA;
484
+ value: EIP1193QUANTITY;
485
+ proof: EIP1193DATA[];
187
486
  };
188
487
 
189
- export type EIP1193PendingBlockWithTransactions = EIP1193PendingBlock & {
190
- transactions: EIP1193Transaction[];
488
+ export type EIP1193AccountProof = {
489
+ address: EIP1193Account;
490
+ accountProof: EIP1193DATA[];
491
+ balance: EIP1193QUANTITY;
492
+ codeHash: EIP1193DATA;
493
+ nonce: EIP1193QUANTITY;
494
+ storageHash: EIP1193DATA;
495
+ storageProof: EIP1193StorageProof[];
191
496
  };
192
497
 
193
- type EIP1193BaseTransactionEIP1193DATA = {
194
- gas?: EIP1193QUANTITY;
195
- gasPrice?: EIP1193QUANTITY;
196
- value?: EIP1193QUANTITY;
197
- data?: EIP1193DATA;
198
- nonce?: EIP1193QUANTITY;
498
+ export type EIP1193SyncingStatus = {
499
+ startingBlock: EIP1193QUANTITY;
500
+ currentBlock: EIP1193QUANTITY;
501
+ highestBlock: EIP1193QUANTITY;
199
502
  };
200
- export type EIP1193NormalTransactionEIP1193DATA = EIP1193BaseTransactionEIP1193DATA & {
201
- from: EIP1193Account;
202
- to: EIP1193Account;
503
+
504
+ /**
505
+ * Payload pushed by a `syncing` subscription.
506
+ *
507
+ * NOTE: unlike the `eth_syncing` RESULT, go-ethereum pushes plain JSON numbers here, not hex
508
+ * quantities. That asymmetry is in the client, not a mistake in these types.
509
+ */
510
+ export type EIP1193SyncingSubscriptionStatus = {
511
+ syncing: boolean;
512
+ status: {
513
+ startingBlock: number;
514
+ currentBlock: number;
515
+ highestBlock: number;
516
+ pulledStates: number;
517
+ knownStates: number;
518
+ };
203
519
  };
204
520
 
205
- export type EIP1193TransactionContractCreationEIP1193DATA = EIP1193BaseTransactionEIP1193DATA & {
206
- from: EIP1193Account;
207
- data: EIP1193DATA;
521
+ // ------------------------------------------------------------------------------------------------
522
+ // TRACING
523
+ // ------------------------------------------------------------------------------------------------
524
+
525
+ export type EIP1193StructLog = {
526
+ pc: number;
527
+ op: string;
528
+ gas: number;
529
+ gasCost: number;
530
+ depth: number;
531
+ error?: string;
532
+ stack?: EIP1193DATA[];
533
+ memory?: EIP1193DATA[];
534
+ storage?: {[slot: string]: EIP1193DATA};
535
+ refund?: number;
536
+ };
537
+
538
+ export type EIP1193TracedTransaction = {
539
+ failed: boolean;
540
+ gas: number;
541
+ returnValue: string;
542
+ structLogs: EIP1193StructLog[];
208
543
  };
209
544
 
210
- export type EIP1193TransactionEIP1193DATA =
211
- | EIP1193NormalTransactionEIP1193DATA
212
- | EIP1193TransactionContractCreationEIP1193DATA;
545
+ export type EIP1193TraceConfig = {
546
+ tracer?: string;
547
+ tracerConfig?: {[key: string]: unknown};
548
+ timeout?: string;
549
+ disableStack?: boolean;
550
+ disableStorage?: boolean;
551
+ enableMemory?: boolean;
552
+ enableReturnData?: boolean;
553
+ };
213
554
 
214
- export type EIP1193CallParam = {
215
- from?: EIP1193Account;
216
- to: EIP1193Account;
217
- gas?: EIP1193QUANTITY;
218
- gasPrice?: EIP1193QUANTITY;
219
- value?: EIP1193QUANTITY;
220
- data?: EIP1193DATA;
555
+ // ------------------------------------------------------------------------------------------------
556
+ // SIGNING
557
+ // ------------------------------------------------------------------------------------------------
558
+
559
+ export type EIP712TypedDataField = {name: string; type: string};
560
+
561
+ export type EIP712Domain = {
562
+ name?: string;
563
+ version?: string;
564
+ chainId?: number | EIP1193ChainId;
565
+ verifyingContract?: EIP1193Account;
566
+ salt?: EIP1193DATA;
567
+ };
568
+
569
+ /** An EIP-712 typed-data payload, as passed to `eth_signTypedData_v4`. */
570
+ export type EIP1193TypedData = {
571
+ types: {[typeName: string]: EIP712TypedDataField[]};
572
+ primaryType: string;
573
+ domain: EIP712Domain;
574
+ message: {[field: string]: any};
221
575
  };
222
576
 
577
+ /**
578
+ * The typed-data parameter of `eth_signTypedData_v3` / `eth_signTypedData_v4`.
579
+ *
580
+ * MetaMask's canonical form is a JSON STRING (`JSON.stringify(typedData)`); other wallets and
581
+ * most libraries accept the object directly. Both are allowed here.
582
+ */
583
+ export type EIP1193TypedSignatureParam = EIP1193TypedData | string;
584
+
585
+ /** A single field of the legacy V1 `eth_signTypedData` payload. */
586
+ export type EIP1193TypedDataV1Field = {
587
+ name: string;
588
+ type: string;
589
+ value: any;
590
+ };
591
+
592
+ /**
593
+ * The legacy V1 `eth_signTypedData` payload: a flat ARRAY of fields, not an EIP-712 object.
594
+ * Note that V1 also takes its parameters in the opposite order to v3/v4.
595
+ */
596
+ export type EIP1193TypedDataV1 = EIP1193TypedDataV1Field[];
597
+
598
+ // ------------------------------------------------------------------------------------------------
599
+ // WALLET METHOD PARAMS (EIP-3085 / 3326 / 747 / 2255 / 5792)
600
+ // ------------------------------------------------------------------------------------------------
601
+
602
+ /** EIP-3085. Only `chainId` is required by the EIP, but wallets in practice require more. */
223
603
  export type EIP1193AddChainParam = {
224
604
  chainId: EIP1193ChainId;
225
605
  rpcUrls?: string[];
@@ -233,93 +613,287 @@ export type EIP1193AddChainParam = {
233
613
  };
234
614
  };
235
615
 
236
- export type EIP1193LogsParam = {
237
- fromBlock?: EIP1193BlockTag;
238
- toBlock?: EIP1193BlockTag;
239
- address?: EIP1193Account | EIP1193Accounts;
240
- topics?: (EIP1193DATA | EIP1193DATA[])[];
241
- blockhash?: EIP1193DATA;
616
+ /** EIP-3326. */
617
+ export type EIP1193SwitchChainParam = {chainId: EIP1193ChainId};
618
+
619
+ /** EIP-747. `type` is open-ended by design; the three below are what wallets ship today. */
620
+ export type EIP1193WatchAssetParam = {
621
+ type: 'ERC20' | 'ERC721' | 'ERC1155' | (string & {});
622
+ options: {
623
+ address: EIP1193Account;
624
+ symbol?: string;
625
+ decimals?: number;
626
+ image?: string;
627
+ tokenId?: string;
628
+ chainId?: number;
629
+ };
242
630
  };
243
631
 
244
- export type EIP1193TracedTransaction = {
245
- failed: boolean;
246
- gas: EIP1193QUANTITY;
247
- returnValue: EIP1193DATA;
248
- structLogs: any[]; // TODO
249
- // TODO more
632
+ /** EIP-2255 permission request: `{[methodName]: {[caveatName]: value}}`. */
633
+ export type EIP1193PermissionRequest = {
634
+ [methodName: string]: {[caveatName: string]: any};
250
635
  };
251
636
 
252
- export type EIP1193SubscriptionMessage = EIP1193KnownSubscriptionMessage | EIP1193UnknownSubscriptionMessage;
637
+ export type EIP1193Caveat = {
638
+ type: string;
639
+ value: any;
640
+ };
253
641
 
254
- export type EIP1193Message = EIP1193SubscriptionMessage | EIP1193UnknownMessage;
642
+ /** EIP-2255 permission, as returned by `wallet_getPermissions`. */
643
+ export type EIP1193Permission = {
644
+ invoker: string;
645
+ parentCapability: string;
646
+ caveats: EIP1193Caveat[];
647
+ date?: number;
648
+ };
255
649
 
256
- export type EIP1193AddChainError = {
257
- // TODO
650
+ /** EIP-2255 permission, as returned by `wallet_requestPermissions`. */
651
+ export type EIP1193RequestedPermission = {
652
+ parentCapability: string;
653
+ date?: number;
258
654
  };
259
655
 
260
- export type EIP1193SwitchChainError = {
261
- // TODO
656
+ /** EIP-5792 capability entry. `optional: true` lets a wallet ignore one it does not support. */
657
+ export type EIP1193Capability = {
658
+ optional?: boolean;
659
+ [key: string]: unknown;
262
660
  };
263
661
 
264
- /*
265
- // TODO
266
- 4001 User Rejected Request The user rejected the request.
267
- 4100 Unauthorized The requested method and/or account has not been authorized by the user.
268
- 4200 Unsupported Method The Provider does not support the requested method.
269
- 4900 Disconnected The Provider is disconnected from all chains.
270
- 4901 Chain Disconnected The Provider is not connected to the requested chain.
271
- */
662
+ /** EIP-5792 `wallet_sendCalls` parameter. */
663
+ export type EIP1193SendCallsParam = {
664
+ version: string;
665
+ id?: string;
666
+ from?: EIP1193Account;
667
+ chainId: EIP1193ChainId;
668
+ atomicRequired: boolean;
669
+ calls: {
670
+ to?: EIP1193Account;
671
+ data?: EIP1193DATA;
672
+ value?: EIP1193QUANTITY;
673
+ capabilities?: {[name: string]: EIP1193Capability};
674
+ }[];
675
+ capabilities?: {[name: string]: EIP1193Capability};
676
+ };
677
+
678
+ export type EIP1193SendCallsResult = {
679
+ id: string;
680
+ capabilities?: {[name: string]: any};
681
+ };
682
+
683
+ /**
684
+ * EIP-5792 batch status codes.
685
+ * 100 pending, 200 confirmed, 400 offchain failure, 500 fully reverted, 600 partially reverted.
686
+ */
687
+ export type EIP1193CallsStatusCode = 100 | 200 | 400 | 500 | 600 | (number & {});
272
688
 
273
- type Listener<Message> = (message: Message) => unknown | Promise<unknown>;
689
+ export type EIP1193CallsStatus = {
690
+ version: string;
691
+ id: EIP1193DATA;
692
+ chainId: EIP1193ChainId;
693
+ status: EIP1193CallsStatusCode;
694
+ atomic: boolean;
695
+ /** A strict subset of `eth_getTransactionReceipt`, restricted to the submitted calls. */
696
+ receipts?: {
697
+ logs: {address: EIP1193Account; data: EIP1193DATA; topics: EIP1193DATA[]}[];
698
+ status: EIP1193QUANTITY;
699
+ blockHash: EIP1193DATA;
700
+ blockNumber: EIP1193QUANTITY;
701
+ gasUsed: EIP1193QUANTITY;
702
+ transactionHash: EIP1193DATA;
703
+ }[];
704
+ capabilities?: {[name: string]: any};
705
+ };
706
+
707
+ /** EIP-5792 `wallet_getCapabilities` result, keyed by chain id. */
708
+ export type EIP1193Capabilities = {[chainId: EIP1193ChainId]: {[name: string]: any}};
274
709
 
275
710
  // ------------------------------------------------------------------------------------------------
276
- // REQUEST TYPES
711
+ // ERRORS
277
712
  // ------------------------------------------------------------------------------------------------
278
713
 
279
- export type Methods = ReadMethods &
280
- NodeOnlyReadMethods &
281
- WriteMethods &
282
- SignerMethods &
283
- ConnectedAccountMethods &
284
- WalletOnlyMethods;
714
+ /** EIP-1193 provider error codes. */
715
+ export type EIP1193ProviderErrorCode =
716
+ /** The user rejected the request. */
717
+ | 4001
718
+ /** The requested method and/or account has not been authorized by the user. */
719
+ | 4100
720
+ /** The Provider does not support the requested method. */
721
+ | 4200
722
+ /** The Provider is disconnected from all chains. */
723
+ | 4900
724
+ /** The Provider is not connected to the requested chain. */
725
+ | 4901;
726
+
727
+ /** JSON-RPC 2.0 and EIP-1474 error codes. */
728
+ export type EIP1193RpcErrorCode =
729
+ | -32700 // Parse error
730
+ | -32600 // Invalid request
731
+ | -32601 // Method not found
732
+ | -32602 // Invalid params
733
+ | -32603 // Internal error
734
+ | -32000 // Invalid input
735
+ | -32001 // Resource not found
736
+ | -32002 // Resource unavailable (MetaMask: a request is already pending)
737
+ | -32003 // Transaction rejected
738
+ | -32004 // Method not supported
739
+ | -32005 // Limit exceeded
740
+ | -32006 // JSON-RPC version not supported
741
+ | 3; // Execution reverted; the raw revert data is in `data`
742
+
743
+ export type EIP1193ErrorCode = EIP1193ProviderErrorCode | EIP1193RpcErrorCode;
285
744
 
286
- export type NodeOnlyReadMethods = {
745
+ export interface EIP1193ProviderRpcError extends Error {
746
+ /** `EIP1193ErrorCode` lists the standardized values; any integer is legal. */
747
+ code: EIP1193ErrorCode | (number & {});
748
+ data?: unknown;
749
+ }
750
+
751
+ /**
752
+ * @deprecated `wallet_addEthereumChain` resolves with `null` and THROWS on failure (EIP-3085),
753
+ * so there is no error-shaped result to type. Catch an {@link EIP1193ProviderRpcError} instead.
754
+ */
755
+ export type EIP1193AddChainError = EIP1193ProviderRpcError;
756
+
757
+ /**
758
+ * @deprecated `wallet_switchEthereumChain` resolves with `null` and THROWS on failure (EIP-3326),
759
+ * so there is no error-shaped result to type. Catch an {@link EIP1193ProviderRpcError} instead.
760
+ */
761
+ export type EIP1193SwitchChainError = EIP1193ProviderRpcError;
762
+
763
+ // ------------------------------------------------------------------------------------------------
764
+ // EVENTS
765
+ // ------------------------------------------------------------------------------------------------
766
+
767
+ export interface EIP1193ConnectInfoMessage {
768
+ readonly chainId: EIP1193ChainId;
769
+ }
770
+
771
+ /** Payloads a subscription can push, depending on the subscription kind. */
772
+ export type EIP1193SubscriptionResult =
773
+ | EIP1193BlockHeader // newHeads
774
+ | EIP1193Log // logs
775
+ | EIP1193DATA // newPendingTransactions (hash form)
776
+ | EIP1193Transaction // newPendingTransactions (full form)
777
+ | EIP1193TransactionReceipt[] // transactionReceipts
778
+ | EIP1193SyncingSubscriptionStatus; // syncing
779
+
780
+ /** The `eth_subscription` message, the only `message` payload standardized by EIP-1193. */
781
+ export type EIP1193SubscriptionMessage = {
782
+ readonly type: 'eth_subscription';
783
+ readonly data: {
784
+ readonly subscription: EIP1193DATA;
785
+ readonly result: EIP1193SubscriptionResult;
786
+ };
787
+ };
788
+
789
+ /** Any other, non-standard message a provider may choose to emit. */
790
+ export type EIP1193UnknownMessage = {
791
+ readonly type: string;
792
+ readonly data: unknown;
793
+ };
794
+
795
+ /**
796
+ * The `message` event payload.
797
+ *
798
+ * This is deliberately NOT `EIP1193SubscriptionMessage | EIP1193UnknownMessage`. A union member
799
+ * typed `{type: string; data: unknown}` absorbs the literal member, so
800
+ * `if (m.type === 'eth_subscription')` would leave `m.data` as `unknown` and the discriminated
801
+ * union would buy you nothing. `eth_subscription` is the only standardized type, so it is the
802
+ * default here.
803
+ *
804
+ * If your provider emits non-standard message types, widen at the call site. That is allowed,
805
+ * because a listener accepting a wider parameter is assignable to a narrower listener:
806
+ *
807
+ * provider.on('message', (m: EIP1193AnyMessage) => { ... });
808
+ */
809
+ export type EIP1193Message = EIP1193SubscriptionMessage;
810
+
811
+ /** The honest, unnarrowable union. Opt in when you need to handle non-standard messages. */
812
+ export type EIP1193AnyMessage = EIP1193SubscriptionMessage | EIP1193UnknownMessage;
813
+
814
+ /** @deprecated Renamed to {@link EIP1193SubscriptionMessage}. */
815
+ export type EIP1193KnownSubscriptionMessage = EIP1193SubscriptionMessage;
816
+
817
+ /**
818
+ * @deprecated Renamed to {@link EIP1193SubscriptionMessage}. The previous "known" / "unknown"
819
+ * split described the same `eth_subscription` shape twice and never narrowed.
820
+ */
821
+ export type EIP1193UnknownSubscriptionMessage = EIP1193SubscriptionMessage;
822
+
823
+ /** The return value of a listener is ignored by the provider. */
824
+ type Listener<Message> = (message: Message) => unknown;
825
+
826
+ // ------------------------------------------------------------------------------------------------
827
+ // METHOD GROUPS
828
+ // ------------------------------------------------------------------------------------------------
829
+ //
830
+ // Groups are split by WHO can serve a method, so a provider type never claims a method its
831
+ // implementation does not have:
832
+ //
833
+ // ClientMethods - client/network identity. Browser wallets AND nodes.
834
+ // ReadMethods - chain reads. Browser wallets AND nodes.
835
+ // WriteMethods - raw submission. Browser wallets AND nodes.
836
+ // SignerMethods - anything needing a key. Wallets, and nodes with unlocked accounts.
837
+ // ConnectedAccountMethods - needs a key AND a currently selected account.
838
+ // WalletOnlyMethods - the wallet-namespaced UX methods. Browser wallets only.
839
+ // NodeOnlyReadMethods - node introspection and heavy reads. JSON-RPC endpoints only.
840
+ // FilterMethods - poll-based log filters. Stateful transports.
841
+ // SubscriptionMethods - push subscriptions. Browser wallets AND WS/IPC nodes, but NOT
842
+ // plain HTTP endpoints.
843
+ // LegacyNodeMethods - pre-merge leftovers, removed from execution-apis.
844
+ // DebugOnlyMethods - the debug namespace.
845
+ //
846
+ // ------------------------------------------------------------------------------------------------
847
+
848
+ /** Client and network identity. Served by browser wallets as well as nodes. */
849
+ export type ClientMethods = {
850
+ eth_chainId: {result: EIP1193ChainId};
851
+ /**
852
+ * The network id as a DECIMAL string (`'1'`), NOT a hex quantity.
853
+ * `execution-apis` types this as `uintDecimal`.
854
+ */
855
+ net_version: {result: string};
287
856
  web3_clientVersion: {result: string};
288
- web3_sha: {params: [EIP1193DATA]; result: EIP1193DATA};
289
- net_version: {result: EIP1193ChainId};
290
- net_listening: {result: boolean};
291
- net_peerCount: {result: EIP1193QUANTITY};
292
- eth_protocolVersion: {result: string};
293
- eth_syncing: {result: EIP1193SyncingStatus | false};
294
- eth_coinbase: {result: EIP1193Account};
295
- eth_mining: {result: boolean}; // TODO check
296
- eth_hashrate: {result: unknown}; // TODO
857
+ web3_sha3: {params: [EIP1193DATA]; result: EIP1193DATA};
297
858
  };
298
859
 
860
+ /** Chain reads available on both a browser wallet and a plain JSON-RPC endpoint. */
299
861
  export type ReadMethods = {
300
- eth_gasPrice: {result: EIP1193QUANTITY};
301
-
302
862
  eth_blockNumber: {result: EIP1193QUANTITY};
303
- eth_getBalance: {params: [EIP1193Account] | [EIP1193Account, EIP1898BlockTag]; result: EIP1193QUANTITY};
304
- eth_getStorageAt: {
305
- params: [EIP1193Account, EIP1193QUANTITY] | [EIP1193Account, EIP1193QUANTITY, EIP1898BlockTag];
306
- result: EIP1193DATA;
863
+
864
+ eth_gasPrice: {result: EIP1193QUANTITY};
865
+ eth_maxPriorityFeePerGas: {result: EIP1193QUANTITY};
866
+ /** EIP-4844. */
867
+ eth_blobBaseFee: {result: EIP1193QUANTITY};
868
+ eth_feeHistory: {
869
+ params: [blockCount: EIP1193QUANTITY, newestBlock: EIP1193BlockTag, rewardPercentiles: number[]];
870
+ result: EIP1193FeeHistory;
307
871
  };
308
- eth_getTransactionCount: {params: [EIP1193Account] | [EIP1193Account, EIP1898BlockTag]; result: EIP1193QUANTITY};
309
- eth_getBlockTransactionCountByHash: {params: [EIP1193DATA]; result: EIP1193QUANTITY};
310
- eth_getBlockTransactionCountByNumber: {params: [EIP1193BlockTag]; result: EIP1193QUANTITY};
311
- eth_getUncleCountByBlockHash: {params: [EIP1193DATA]; result: EIP1193QUANTITY};
312
- eth_getUncleCountByBlockNumber: {params: [EIP1193BlockTag]; result: EIP1193QUANTITY};
313
- eth_getCode: {params: [EIP1193Account] | [EIP1193Account, EIP1898BlockTag]; result: EIP1193DATA};
314
-
315
- eth_call: {params: [EIP1193CallParam] | [EIP1193CallParam, EIP1898BlockTag]; result: EIP1193DATA};
316
- eth_estimateGas: {params: [EIP1193CallParam] | [EIP1193CallParam, EIP1193BlockTag]; result: EIP1193QUANTITY}; // EIP1898BlockTag ?
872
+
873
+ eth_getBalance: {params: [EIP1193Account, EIP1898BlockTag?]; result: EIP1193QUANTITY};
874
+ eth_getCode: {params: [EIP1193Account, EIP1898BlockTag?]; result: EIP1193DATA};
875
+ eth_getStorageAt: {params: [EIP1193Account, EIP1193DATA, EIP1898BlockTag?]; result: EIP1193DATA};
876
+ eth_getTransactionCount: {params: [EIP1193Account, EIP1898BlockTag?]; result: EIP1193QUANTITY};
877
+
878
+ eth_call: {params: [EIP1193CallParam, EIP1898BlockTag?, EIP1193StateOverride?]; result: EIP1193DATA};
879
+ /** Note: unlike `eth_call`, the block parameter here does NOT accept a block hash. */
880
+ eth_estimateGas: {params: [EIP1193CallParam, EIP1193BlockTag?, EIP1193StateOverride?]; result: EIP1193QUANTITY};
881
+
882
+ /**
883
+ * The second parameter selects the shape of the result, so these are two separate call
884
+ * signatures rather than one signature returning a union. Pass a LITERAL `true` / `false`
885
+ * (a value of type `boolean` cannot be narrowed and will not match either signature).
886
+ */
317
887
  eth_getBlockByHash:
318
- | {params: [EIP1193DATA, true]; result: EIP1193BlockWithTransactions | null}
319
- | {params: [EIP1193DATA, false]; result: EIP1193Block | null};
888
+ | {params: [EIP1193DATA, false?]; result: EIP1193Block | null}
889
+ | {params: [EIP1193DATA, true]; result: EIP1193BlockWithTransactions | null};
320
890
  eth_getBlockByNumber:
321
- | {params: [EIP1193BlockTag, true]; result: EIP1193BlockWithTransactions | null}
322
- | {params: [EIP1193BlockTag, false]; result: EIP1193Block | null};
891
+ | {params: [EIP1193BlockTag, false?]; result: EIP1193Block | null}
892
+ | {params: [EIP1193BlockTag, true]; result: EIP1193BlockWithTransactions | null};
893
+
894
+ eth_getBlockTransactionCountByHash: {params: [EIP1193DATA]; result: EIP1193QUANTITY | null};
895
+ eth_getBlockTransactionCountByNumber: {params: [EIP1193BlockTag]; result: EIP1193QUANTITY | null};
896
+
323
897
  eth_getTransactionByHash: {params: [EIP1193DATA]; result: EIP1193Transaction | null};
324
898
  eth_getTransactionByBlockHashAndIndex: {params: [EIP1193DATA, EIP1193QUANTITY]; result: EIP1193Transaction | null};
325
899
  eth_getTransactionByBlockNumberAndIndex: {
@@ -328,116 +902,216 @@ export type ReadMethods = {
328
902
  };
329
903
 
330
904
  eth_getTransactionReceipt: {params: [EIP1193DATA]; result: EIP1193TransactionReceipt | null};
331
- eth_getUncleByBlockHashAndIndex: {params: [EIP1193DATA, EIP1193QUANTITY]; result: EIP1193Block | null};
332
- eth_getUncleByBlockNumberAndIndex: {params: [EIP1193BlockTag, EIP1193QUANTITY]; result: EIP1193Block | null};
905
+ eth_getBlockReceipts: {params: [EIP1898BlockTag]; result: EIP1193TransactionReceipt[] | null};
906
+
333
907
  eth_getLogs: {params: [EIP1193LogsParam]; result: EIP1193Log[]};
334
- eth_chainId: {result: EIP1193ChainId};
908
+ };
909
+
910
+ /** Node introspection and heavy reads. Browser wallets generally reject these. */
911
+ export type NodeOnlyReadMethods = {
912
+ net_listening: {result: boolean};
913
+ net_peerCount: {result: EIP1193QUANTITY};
914
+
915
+ eth_syncing: {result: EIP1193SyncingStatus | false};
916
+ eth_coinbase: {result: EIP1193Account};
335
917
 
918
+ eth_getProof: {
919
+ params: [EIP1193Account, EIP1193DATA[], EIP1898BlockTag?];
920
+ result: EIP1193AccountProof;
921
+ };
922
+ eth_createAccessList: {
923
+ params: [EIP1193CallParam, EIP1193BlockTag?];
924
+ result: {accessList: EIP1193AccessList; gasUsed: EIP1193QUANTITY; error?: string};
925
+ };
926
+ };
927
+
928
+ /**
929
+ * Poll-based log filters. Stateful, so not available on naively load-balanced endpoints.
930
+ * Served by browser wallets too (MetaMask ships `eth-json-rpc-filters`).
931
+ */
932
+ export type FilterMethods = {
933
+ eth_newFilter: {params: [EIP1193LogsParam]; result: EIP1193QUANTITY};
934
+ eth_newBlockFilter: {result: EIP1193QUANTITY};
935
+ eth_newPendingTransactionFilter: {result: EIP1193QUANTITY};
936
+ eth_uninstallFilter: {params: [EIP1193QUANTITY]; result: boolean};
937
+ /** Block/transaction hashes for block and pending-transaction filters, logs for log filters. */
938
+ eth_getFilterChanges: {params: [EIP1193QUANTITY]; result: EIP1193DATA[] | EIP1193Log[]};
939
+ eth_getFilterLogs: {params: [EIP1193QUANTITY]; result: EIP1193Log[]};
940
+ };
941
+
942
+ /**
943
+ * Push subscriptions.
944
+ *
945
+ * Requires a transport that can deliver server-initiated notifications: WebSocket, IPC, or an
946
+ * injected browser wallet with an internal event channel. NOT available over plain HTTP.
947
+ * Browser wallets DO serve these (they are listed in MetaMask's own api-specs), and EIP-1193
948
+ * specifies the `message` event precisely to carry their notifications, so they are part of the
949
+ * default wallet surface.
950
+ *
951
+ * Notifications arrive through the `message` event as {@link EIP1193SubscriptionMessage}.
952
+ */
953
+ export type SubscriptionMethods = {
336
954
  eth_subscribe:
337
- | {params: ['newHeads' | 'newPendingTransactions' | 'syncing']; result: string}
338
- | {
339
- params: [
340
- 'logs',
341
- {
342
- address: EIP1193Account | EIP1193Account[];
343
- topics: (EIP1193DATA[] | EIP1193DATA)[];
344
- }
345
- ];
346
- result: string;
347
- };
955
+ | {params: ['newHeads']; result: EIP1193DATA}
956
+ | {params: ['logs', EIP1193LogsParam?]; result: EIP1193DATA}
957
+ | {params: ['newPendingTransactions', boolean?]; result: EIP1193DATA}
958
+ | {params: ['transactionReceipts', {transactionHashes?: EIP1193DATA[]}?]; result: EIP1193DATA}
959
+ /** Not in execution-apis, but implemented by go-ethereum. */
960
+ | {params: ['syncing']; result: EIP1193DATA};
348
961
  eth_unsubscribe: {params: [EIP1193DATA]; result: boolean};
349
- eth_getProof: {params: [EIP1193DATA, EIP1193DATA[]] | [EIP1193DATA, EIP1193DATA[], EIP1898BlockTag]; result: unknown}; // TODO
962
+ };
350
963
 
351
- eth_feeHistory: {params: [EIP1193QUANTITY, EIP1193BlockTag, number[]]; result: EIP1193FeeHistory};
964
+ /**
965
+ * Pre-merge leftovers. Removed from `execution-apis`, still answered by some clients.
966
+ * Uncles are always empty after the merge.
967
+ */
968
+ export type LegacyNodeMethods = {
969
+ /** @deprecated Removed from execution-apis. */
970
+ eth_protocolVersion: {result: string};
971
+ /** @deprecated Always `false` after the merge. */
972
+ eth_mining: {result: boolean};
973
+ /** @deprecated Always `0x0` after the merge. */
974
+ eth_hashrate: {result: EIP1193QUANTITY};
975
+ /** @deprecated Always `0x0` after the merge. */
976
+ eth_getUncleCountByBlockHash: {params: [EIP1193DATA]; result: EIP1193QUANTITY | null};
977
+ /** @deprecated Always `0x0` after the merge. */
978
+ eth_getUncleCountByBlockNumber: {params: [EIP1193BlockTag]; result: EIP1193QUANTITY | null};
979
+ /** @deprecated Always `null` after the merge. */
980
+ eth_getUncleByBlockHashAndIndex: {params: [EIP1193DATA, EIP1193QUANTITY]; result: EIP1193Block | null};
981
+ /** @deprecated Always `null` after the merge. */
982
+ eth_getUncleByBlockNumberAndIndex: {params: [EIP1193BlockTag, EIP1193QUANTITY]; result: EIP1193Block | null};
352
983
  };
353
984
 
985
+ /** Submission of an already-signed transaction. Needs no key. */
354
986
  export type WriteMethods = {
355
987
  eth_sendRawTransaction: {params: [EIP1193DATA]; result: EIP1193DATA};
356
988
  };
357
989
 
990
+ /** Anything that requires access to a private key. */
358
991
  export type SignerMethods = {
359
992
  eth_accounts: {result: EIP1193Accounts};
993
+ /** @deprecated Signs an arbitrary digest. Disabled by default in most wallets. Use `personal_sign`. */
360
994
  eth_sign: {params: [EIP1193Account, EIP1193DATA]; result: EIP1193DATA};
361
995
  eth_signTransaction: {params: [EIP1193TransactionData]; result: EIP1193DATA};
362
996
 
997
+ /** Params are `[message, address]`, in that order. */
363
998
  personal_sign: {params: [EIP1193DATA, EIP1193Account]; result: EIP1193DATA};
999
+ personal_ecRecover: {params: [EIP1193DATA, EIP1193DATA]; result: EIP1193Account};
1000
+
1001
+ /**
1002
+ * The legacy V1 API. Takes `[typedData, address]` -- the REVERSE of v3/v4 -- and a flat array
1003
+ * of `{name, type, value}` fields rather than an EIP-712 object.
1004
+ *
1005
+ * @deprecated Use `eth_signTypedData_v4`.
1006
+ */
1007
+ eth_signTypedData: {params: [EIP1193TypedDataV1 | string, EIP1193Account]; result: EIP1193DATA};
1008
+ /** @deprecated Does not handle arrays or nested structs correctly. Use `eth_signTypedData_v4`. */
1009
+ eth_signTypedData_v3: {params: [EIP1193Account, EIP1193TypedSignatureParam]; result: EIP1193DATA};
364
1010
  eth_signTypedData_v4: {params: [EIP1193Account, EIP1193TypedSignatureParam]; result: EIP1193DATA};
365
- eth_signTypedData: {params: [EIP1193Account, EIP1193TypedSignatureParam]; result: EIP1193DATA};
366
1011
  };
367
1012
 
1013
+ /** Requires a key AND a currently selected account. */
368
1014
  export type ConnectedAccountMethods = {
369
1015
  eth_sendTransaction: {params: [EIP1193TransactionData]; result: EIP1193DATA};
370
1016
  };
371
1017
 
1018
+ /** Wallet UX methods. Only a browser wallet can serve these; a JSON-RPC endpoint cannot. */
372
1019
  export type WalletOnlyMethods = {
1020
+ /** EIP-1102. */
373
1021
  eth_requestAccounts: {result: EIP1193Accounts};
374
- wallet_switchEthereumChain: {
375
- params: [
376
- {
377
- chainId: EIP1193ChainId;
378
- }
379
- ];
380
- result: EIP1193SwitchChainError | null;
381
- };
382
- wallet_addEthereumChain: {params: [EIP1193AddChainParam]; result: EIP1193AddChainError | null};
383
- };
384
1022
 
385
- export type DebugOnlyMethods = {
386
- debug_traceTransaction: {params: [EIP1193DATA]; result: EIP1193TracedTransaction};
1023
+ /** EIP-3326. Resolves with `null` on success; failures are THROWN, not returned. */
1024
+ wallet_switchEthereumChain: {params: [EIP1193SwitchChainParam]; result: null};
1025
+ /** EIP-3085. Resolves with `null` on success; failures are THROWN, not returned. */
1026
+ wallet_addEthereumChain: {params: [EIP1193AddChainParam]; result: null};
1027
+ /** EIP-747. Returns `true` if the request was valid, regardless of the user's answer. */
1028
+ wallet_watchAsset: {params: [EIP1193WatchAssetParam]; result: boolean};
1029
+
1030
+ /** EIP-2255. */
1031
+ wallet_getPermissions: {result: EIP1193Permission[]};
1032
+ /** EIP-2255. */
1033
+ wallet_requestPermissions: {params: [EIP1193PermissionRequest]; result: EIP1193RequestedPermission[]};
1034
+ /** Not standardized as an EIP, but implemented by MetaMask and others. */
1035
+ wallet_revokePermissions: {params: [EIP1193PermissionRequest]; result: null};
1036
+
1037
+ /** EIP-5792. */
1038
+ wallet_sendCalls: {params: [EIP1193SendCallsParam]; result: EIP1193SendCallsResult};
1039
+ /** EIP-5792. */
1040
+ wallet_getCallsStatus: {params: [string]; result: EIP1193CallsStatus};
1041
+ /** EIP-5792. */
1042
+ wallet_showCallsStatus: {params: [string]; result: null};
1043
+ /** EIP-5792. */
1044
+ wallet_getCapabilities: {params: [EIP1193Account, EIP1193ChainId[]?]; result: EIP1193Capabilities};
1045
+
1046
+ /** MetaMask-specific. Registers the site as the onboarding initiator. */
1047
+ wallet_registerOnboarding: {result: boolean};
1048
+ /** MetaMask-specific. Opens the QR scanner and returns the scanned value. */
1049
+ wallet_scanQRCode: {params: [string?]; result: string};
1050
+
1051
+ /** @deprecated Removed from MetaMask. Was used for eth-sig-util encryption. */
1052
+ eth_getEncryptionPublicKey: {params: [EIP1193Account]; result: string};
1053
+ /** @deprecated Removed from MetaMask. Was used for eth-sig-util encryption. */
1054
+ eth_decrypt: {params: [EIP1193DATA, EIP1193Account]; result: string};
387
1055
  };
388
1056
 
389
- export type WalletMethods = ReadMethods & WriteMethods & SignerMethods & ConnectedAccountMethods & WalletOnlyMethods;
390
-
391
- export type EIP1193TypedSignatureParam = {[field: string]: any}; // TODO
392
-
393
- export type EIP1193GenericRequest = {
394
- method: string;
395
- params?: Readonly<unknown[]>;
1057
+ /** The `debug` namespace. Only exposed by nodes explicitly started with it enabled. */
1058
+ export type DebugOnlyMethods = {
1059
+ debug_traceTransaction: {params: [EIP1193DATA, EIP1193TraceConfig?]; result: EIP1193TracedTransaction};
1060
+ debug_traceCall: {
1061
+ params: [EIP1193CallParam, EIP1898BlockTag?, EIP1193TraceConfig?];
1062
+ result: EIP1193TracedTransaction;
1063
+ };
396
1064
  };
397
1065
 
398
- export interface EIP1193ProviderRpcError extends Error {
399
- message: string;
400
- code: number;
401
- data?: unknown;
402
- }
403
-
404
- export interface EIP1193ConnectInfoMessage {
405
- readonly chainId: EIP1193ChainId;
406
- }
407
-
408
- export type EIP1193UnknownMessage = {
409
- readonly type: string;
410
- readonly data: unknown;
411
- };
1066
+ // ------------------------------------------------------------------------------------------------
1067
+ // METHOD SETS
1068
+ // ------------------------------------------------------------------------------------------------
412
1069
 
413
- export type EIP1193UnknownSubscriptionMessage = EIP1193UnknownMessage & {
414
- readonly type: 'eth_subscription';
415
- readonly data: {
416
- readonly subscription: EIP1193DATA;
417
- readonly result: unknown;
418
- };
419
- };
1070
+ /**
1071
+ * Everything a browser wallet provider exposes. This is the surface EIP-1193 actually describes,
1072
+ * so it is also the default {@link Methods}.
1073
+ */
1074
+ export type WalletMethods = ClientMethods &
1075
+ ReadMethods &
1076
+ FilterMethods &
1077
+ SubscriptionMethods &
1078
+ WriteMethods &
1079
+ SignerMethods &
1080
+ ConnectedAccountMethods &
1081
+ WalletOnlyMethods;
420
1082
 
421
- export type EIP1193KnownSubscriptionMessage = EIP1193UnknownMessage & {
422
- readonly type: 'eth_subscription';
423
- readonly data: {
424
- readonly subscription: EIP1193DATA;
425
- readonly result:
426
- | EIP1193Log
427
- | EIP1193Block
428
- | EIP1193DATA // transaction hash
429
- | {
430
- syncing: boolean;
431
- status: {
432
- startingBlock: number;
433
- currentBlock: number;
434
- highestBlock: number;
435
- pulledStates: number;
436
- knownStates: number;
437
- };
438
- };
439
- };
440
- };
1083
+ /**
1084
+ * Everything a full JSON-RPC node exposes. Note this includes the signer methods (a node with
1085
+ * unlocked accounts serves them) but NOT the `wallet_*` namespace, which has no meaning
1086
+ * server-side.
1087
+ */
1088
+ export type NodeMethods = ClientMethods &
1089
+ ReadMethods &
1090
+ NodeOnlyReadMethods &
1091
+ FilterMethods &
1092
+ SubscriptionMethods &
1093
+ LegacyNodeMethods &
1094
+ WriteMethods &
1095
+ SignerMethods &
1096
+ ConnectedAccountMethods;
1097
+
1098
+ /**
1099
+ * The default method set: a browser wallet provider.
1100
+ *
1101
+ * If you are typing a plain JSON-RPC endpoint rather than a wallet, use {@link NodeMethods} /
1102
+ * {@link EIP1193NodeProvider}. If you genuinely want the union of everything, use
1103
+ * {@link AllMethods}.
1104
+ */
1105
+ export type Methods = WalletMethods;
1106
+
1107
+ /**
1108
+ * A plain HTTP JSON-RPC endpoint: {@link NodeMethods} minus the push subscriptions, which need a
1109
+ * transport that can deliver server-initiated notifications.
1110
+ */
1111
+ export type HttpNodeMethods = Omit<NodeMethods, keyof SubscriptionMethods>;
1112
+
1113
+ /** Every method in this file, node and wallet and debug. Permissive; prefer a narrower set. */
1114
+ export type AllMethods = NodeMethods & WalletMethods & DebugOnlyMethods;
441
1115
 
442
1116
  // ------------------------------------------------------------------------------------------------
443
1117
  // TOOLS
@@ -454,21 +1128,24 @@ type DeepReadonly<T> = Readonly<{
454
1128
  DeepReadonly<T[K]>;
455
1129
  }>;
456
1130
 
457
- export type RPCRequestData = {params?: any; result?: any; errors?: any};
1131
+ export type RPCRequestData = {params?: any; result?: any};
458
1132
 
1133
+ /** A method table. A value may be a UNION of entries, which becomes a union of overloads. */
459
1134
  export type RPCMethods = Record<string, RPCRequestData>;
460
1135
 
461
1136
  export type RemoteRequestCallType<
462
1137
  Method extends string,
463
1138
  Value,
464
1139
  Params extends any[] | Record<string, any> | undefined = undefined
465
- > = Params extends undefined
1140
+ > = [Params] extends [undefined]
466
1141
  ? {
467
- request: (req: {method: Method}) => Promise<Value>;
1142
+ // no-param methods: `params` may be omitted, or sent as an empty array, which is what
1143
+ // most JSON-RPC transports do on the wire.
1144
+ request: (req: {method: Method; params?: readonly []}) => Promise<Value>;
468
1145
  }
469
- : Params extends []
1146
+ : [Params] extends [readonly []]
470
1147
  ? {
471
- request: (req: {method: Method}) => Promise<Value>;
1148
+ request: (req: {method: Method; params?: readonly []}) => Promise<Value>;
472
1149
  }
473
1150
  : {
474
1151
  request: (req: {method: Method; params: DeepReadonly<Params>}) => Promise<Value>;
@@ -476,37 +1153,97 @@ export type RemoteRequestCallType<
476
1153
 
477
1154
  export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
478
1155
 
1156
+ /**
1157
+ * Builds ONE call signature per entry.
1158
+ *
1159
+ * `Entry` is a naked type parameter, so this conditional DISTRIBUTES over a union of entries.
1160
+ * That is what makes a method declared as
1161
+ *
1162
+ * eth_getBlockByNumber:
1163
+ * | {params: [tag, false?]; result: Block | null}
1164
+ * | {params: [tag, true]; result: BlockWithTransactions | null}
1165
+ *
1166
+ * produce two real overloads instead of collapsing into a single signature whose result is
1167
+ * `Block | BlockWithTransactions | null`. Indexing `T[Property]['result']` directly, as an
1168
+ * earlier version did, does NOT distribute and loses the narrowing.
1169
+ */
1170
+ type MethodRequestCallType<Method extends string, Entry> = Entry extends RPCRequestData
1171
+ ? RemoteRequestCallType<
1172
+ Method,
1173
+ Entry extends {result: any} ? Entry['result'] : undefined,
1174
+ Entry extends {params: any} ? Entry['params'] : undefined
1175
+ >
1176
+ : never;
1177
+
479
1178
  export type RequestUnion<T extends RPCMethods> = {
480
- [Property in keyof T]: RemoteRequestCallType<
481
- Property extends string ? Property : never,
482
- T[Property] extends {result: any} ? T[Property]['result'] : undefined,
483
- T[Property] extends {params: any} ? T[Property]['params'] : undefined
484
- >;
1179
+ [Property in keyof T]: MethodRequestCallType<Property extends string ? Property : never, T[Property]>;
485
1180
  }[keyof T];
486
1181
 
487
1182
  // ------------------------------------------------------------------------------------------------
488
1183
  // PROVIDERS
489
1184
  // ------------------------------------------------------------------------------------------------
490
1185
 
1186
+ /**
1187
+ * Turns a method table into a `{request(...)}` object with one overload per method.
1188
+ *
1189
+ * There is deliberately NO `request(req: {method: string; ...})` catch-all overload here. A
1190
+ * catch-all matches every call, so a typo like `eth_blockNumbr` used to compile away into
1191
+ * `Promise<unknown>`, and every genuine mistake was reported as an unreadable "No overload
1192
+ * matches this call / Index signature for type 'string' is missing" against the catch-all
1193
+ * instead of against the method you actually called.
1194
+ *
1195
+ * To call a method that is not in the table, either extend the table:
1196
+ *
1197
+ * type MyMethods = Methods & {my_method: {params: [string]; result: boolean}};
1198
+ * declare const provider: RequestRPC<MyMethods> & EIP1193EventsProvider;
1199
+ *
1200
+ * or reach for the untyped escape hatch: {@link EIP1193GenericRequestProvider}.
1201
+ */
491
1202
  export type RequestRPC<T extends RPCMethods> = UnionToIntersection<RequestUnion<T>> & {
492
- request<U extends {params?: any; result?: any}>(req: {
493
- method: string;
494
- params: DeepReadonly<U['params']>;
495
- }): Promise<U['result']>;
1203
+ // Diagnostic-only overload, deliberately LAST and deliberately unsatisfiable (`params: never`).
1204
+ // TypeScript reports the last overload when no overload matches, so this is what turns
1205
+ // "No overload matches this call" into a message that names the method you actually meant.
1206
+ request(req: {method: keyof T & string; params: never}): Promise<any>;
496
1207
  };
497
1208
 
1209
+ /** A browser wallet provider without the event emitter. */
498
1210
  export type EIP1193ProviderWithoutEvents = RequestRPC<Methods>;
499
1211
 
500
- // export type EIP1193WindowWalletProvider = EIP1193Provider;
501
-
1212
+ /** A browser wallet provider (`window.ethereum`), without events. */
502
1213
  export type EIP1193WalletProvider = RequestRPC<WalletMethods>;
503
1214
 
1215
+ /** A browser wallet provider (`window.ethereum`), with events. */
504
1216
  export type EIP1193WindowWalletProvider = EIP1193WalletProvider & EIP1193EventsProvider;
505
1217
 
1218
+ /** A JSON-RPC node endpoint: node methods, no `wallet_*` namespace, no events. */
1219
+ export type EIP1193NodeProvider = RequestRPC<NodeMethods>;
1220
+
1221
+ /** A node reached over plain HTTP, where `eth_subscribe` cannot work. */
1222
+ export type EIP1193HttpNodeProvider = RequestRPC<HttpNodeMethods>;
1223
+
1224
+ /** Just the key-holding methods. */
506
1225
  export type EIP1193SignerProvider = RequestRPC<SignerMethods>;
507
1226
 
508
- export type EIP1193DebugProvider = EIP1193ProviderWithoutEvents & RequestRPC<DebugOnlyMethods>;
1227
+ /** A node provider with the `debug` namespace enabled. */
1228
+ export type EIP1193DebugProvider = EIP1193NodeProvider & RequestRPC<DebugOnlyMethods>;
1229
+
1230
+ /** Every method in this file. Permissive; prefer a narrower provider type. */
1231
+ export type EIP1193AllMethodsProvider = RequestRPC<AllMethods>;
1232
+
1233
+ export type EIP1193GenericRequest = {
1234
+ method: string;
1235
+ /** EIP-1193 allows either positional or named parameters. */
1236
+ params?: Readonly<unknown[]> | Record<string, unknown>;
1237
+ };
509
1238
 
1239
+ /**
1240
+ * The untyped escape hatch, for proxies and for methods not covered by any table here.
1241
+ *
1242
+ * Intersecting this with a typed provider would reintroduce the catch-all overload problem
1243
+ * described on {@link RequestRPC}, so cast at the point of use instead:
1244
+ *
1245
+ * await (provider as unknown as EIP1193GenericRequestProvider).request({method, params});
1246
+ */
510
1247
  export type EIP1193GenericRequestProvider = {
511
1248
  request<T = unknown, V extends EIP1193GenericRequest = EIP1193GenericRequest>(args: V): Promise<T>;
512
1249
  };
@@ -527,8 +1264,8 @@ export interface EIP1193OnConnectionProvider {
527
1264
  }
528
1265
 
529
1266
  export interface EIP1193OnAccountsChangedProvider {
530
- on(eventName: 'accountsChanged', listener: Listener<EIP1193Account[]>): this;
531
- removeListener(eventName: 'accountsChanged', listener: Listener<EIP1193Account[]>): this;
1267
+ on(eventName: 'accountsChanged', listener: Listener<EIP1193Accounts>): this;
1268
+ removeListener(eventName: 'accountsChanged', listener: Listener<EIP1193Accounts>): this;
532
1269
  }
533
1270
 
534
1271
  export interface EIP1193OnChainChangedProvider {
@@ -536,6 +1273,13 @@ export interface EIP1193OnChainChangedProvider {
536
1273
  removeListener(eventName: 'chainChanged', listener: Listener<EIP1193ChainId>): this;
537
1274
  }
538
1275
 
1276
+ /**
1277
+ * The five events EIP-1193 requires, via the two methods it requires (`on` / `removeListener`).
1278
+ *
1279
+ * Wallets commonly also ship the rest of the Node `EventEmitter` surface (`once`, `off`,
1280
+ * `addListener`, `removeAllListeners`), but EIP-1193 does not mandate them, so they are not
1281
+ * declared here.
1282
+ */
539
1283
  export interface EIP1193EventsProvider {
540
1284
  on(eventName: 'message', listener: Listener<EIP1193Message>): this;
541
1285
  removeListener(eventName: 'message', listener: Listener<EIP1193Message>): this;
@@ -545,11 +1289,12 @@ export interface EIP1193EventsProvider {
545
1289
  removeListener(eventName: 'connect', listener: Listener<EIP1193ConnectInfoMessage>): this;
546
1290
  removeListener(eventName: 'disconnect', listener: Listener<EIP1193ProviderRpcError>): this;
547
1291
 
548
- on(eventName: 'accountsChanged', listener: Listener<EIP1193Account[]>): this;
549
- removeListener(eventName: 'accountsChanged', listener: Listener<EIP1193Account[]>): this;
1292
+ on(eventName: 'accountsChanged', listener: Listener<EIP1193Accounts>): this;
1293
+ removeListener(eventName: 'accountsChanged', listener: Listener<EIP1193Accounts>): this;
550
1294
 
551
1295
  on(eventName: 'chainChanged', listener: Listener<EIP1193ChainId>): this;
552
1296
  removeListener(eventName: 'chainChanged', listener: Listener<EIP1193ChainId>): this;
553
1297
  }
554
1298
 
1299
+ /** An EIP-1193 provider: what a browser wallet injects as `window.ethereum`. */
555
1300
  export interface EIP1193Provider extends EIP1193ProviderWithoutEvents, EIP1193EventsProvider {}