eip-1193 0.6.5 → 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.
- package/index.d.ts +1007 -247
- package/package.json +10 -2
package/index.d.ts
CHANGED
|
@@ -1,77 +1,219 @@
|
|
|
1
1
|
// ------------------------------------------------------------------------------------------------
|
|
2
|
-
//
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
32
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
|
|
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
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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[];
|
|
379
|
+
};
|
|
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[];
|
|
131
400
|
};
|
|
132
401
|
|
|
402
|
+
// ------------------------------------------------------------------------------------------------
|
|
403
|
+
// LOGS & RECEIPTS
|
|
404
|
+
// ------------------------------------------------------------------------------------------------
|
|
405
|
+
|
|
133
406
|
export type EIP1193Log = {
|
|
134
407
|
removed: boolean;
|
|
135
408
|
logIndex: EIP1193QUANTITY | null;
|
|
@@ -137,6 +410,21 @@ export type EIP1193Log = {
|
|
|
137
410
|
transactionHash: EIP1193DATA | null;
|
|
138
411
|
blockHash: EIP1193DATA | null;
|
|
139
412
|
blockNumber: EIP1193QUANTITY | null;
|
|
413
|
+
/**
|
|
414
|
+
* The timestamp of the block this log is in.
|
|
415
|
+
*
|
|
416
|
+
* Added to the `Log` schema by ethereum/execution-apis#639. It is OPTIONAL in
|
|
417
|
+
* the spec (the schema's only required field is `transactionHash`) and it is
|
|
418
|
+
* optional here for the same reason: it exists to save the extra
|
|
419
|
+
* `eth_getBlockByHash` round-trip per block, but not every node emits it yet.
|
|
420
|
+
* Served by go-ethereum (>= 1.16.0), reth, besu, erigon, anvil and ethereumjs;
|
|
421
|
+
* notably NOT by Hardhat's EDR as of hardhat 3.14.0.
|
|
422
|
+
*
|
|
423
|
+
* Consumers must treat `undefined` as "this node does not provide it" and fall
|
|
424
|
+
* back, rather than defaulting it to 0: a missing timestamp is recoverable, a
|
|
425
|
+
* wrong one is not.
|
|
426
|
+
*/
|
|
427
|
+
blockTimestamp?: EIP1193QUANTITY;
|
|
140
428
|
address: EIP1193Account;
|
|
141
429
|
data: EIP1193DATA;
|
|
142
430
|
topics: EIP1193DATA[];
|
|
@@ -148,63 +436,170 @@ export type EIP1193TransactionReceipt = {
|
|
|
148
436
|
blockHash: EIP1193DATA;
|
|
149
437
|
blockNumber: EIP1193QUANTITY;
|
|
150
438
|
from: EIP1193Account;
|
|
151
|
-
|
|
439
|
+
/** `null` for a contract-creation transaction. */
|
|
440
|
+
to: EIP1193Account | null;
|
|
152
441
|
cumulativeGasUsed: EIP1193QUANTITY;
|
|
153
442
|
effectiveGasPrice: EIP1193QUANTITY;
|
|
154
443
|
gasUsed: EIP1193QUANTITY;
|
|
155
|
-
|
|
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;
|
|
156
450
|
logs: EIP1193Log[];
|
|
157
451
|
logsBloom: EIP1193DATA;
|
|
158
|
-
type:
|
|
159
|
-
|
|
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. */
|
|
160
460
|
status: EIP1193QUANTITY;
|
|
161
461
|
};
|
|
162
462
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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;
|
|
168
476
|
};
|
|
169
477
|
|
|
170
|
-
|
|
171
|
-
|
|
478
|
+
// ------------------------------------------------------------------------------------------------
|
|
479
|
+
// PROOFS & SYNC
|
|
480
|
+
// ------------------------------------------------------------------------------------------------
|
|
481
|
+
|
|
482
|
+
export type EIP1193StorageProof = {
|
|
483
|
+
key: EIP1193DATA;
|
|
484
|
+
value: EIP1193QUANTITY;
|
|
485
|
+
proof: EIP1193DATA[];
|
|
172
486
|
};
|
|
173
487
|
|
|
174
|
-
export type
|
|
175
|
-
|
|
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[];
|
|
176
496
|
};
|
|
177
497
|
|
|
178
|
-
type
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
data?: EIP1193DATA;
|
|
183
|
-
nonce?: EIP1193QUANTITY;
|
|
498
|
+
export type EIP1193SyncingStatus = {
|
|
499
|
+
startingBlock: EIP1193QUANTITY;
|
|
500
|
+
currentBlock: EIP1193QUANTITY;
|
|
501
|
+
highestBlock: EIP1193QUANTITY;
|
|
184
502
|
};
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
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
|
+
};
|
|
188
519
|
};
|
|
189
520
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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[];
|
|
193
543
|
};
|
|
194
544
|
|
|
195
|
-
export type
|
|
196
|
-
|
|
197
|
-
|
|
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
|
+
};
|
|
198
554
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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};
|
|
206
575
|
};
|
|
207
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. */
|
|
208
603
|
export type EIP1193AddChainParam = {
|
|
209
604
|
chainId: EIP1193ChainId;
|
|
210
605
|
rpcUrls?: string[];
|
|
@@ -218,93 +613,287 @@ export type EIP1193AddChainParam = {
|
|
|
218
613
|
};
|
|
219
614
|
};
|
|
220
615
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
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
|
+
};
|
|
227
630
|
};
|
|
228
631
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
632
|
+
/** EIP-2255 permission request: `{[methodName]: {[caveatName]: value}}`. */
|
|
633
|
+
export type EIP1193PermissionRequest = {
|
|
634
|
+
[methodName: string]: {[caveatName: string]: any};
|
|
635
|
+
};
|
|
636
|
+
|
|
637
|
+
export type EIP1193Caveat = {
|
|
638
|
+
type: string;
|
|
639
|
+
value: any;
|
|
235
640
|
};
|
|
236
641
|
|
|
237
|
-
|
|
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
|
+
};
|
|
238
649
|
|
|
239
|
-
|
|
650
|
+
/** EIP-2255 permission, as returned by `wallet_requestPermissions`. */
|
|
651
|
+
export type EIP1193RequestedPermission = {
|
|
652
|
+
parentCapability: string;
|
|
653
|
+
date?: number;
|
|
654
|
+
};
|
|
240
655
|
|
|
241
|
-
|
|
242
|
-
|
|
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;
|
|
660
|
+
};
|
|
661
|
+
|
|
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};
|
|
243
676
|
};
|
|
244
677
|
|
|
245
|
-
export type
|
|
246
|
-
|
|
678
|
+
export type EIP1193SendCallsResult = {
|
|
679
|
+
id: string;
|
|
680
|
+
capabilities?: {[name: string]: any};
|
|
247
681
|
};
|
|
248
682
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
4900 Disconnected The Provider is disconnected from all chains.
|
|
255
|
-
4901 Chain Disconnected The Provider is not connected to the requested chain.
|
|
256
|
-
*/
|
|
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 & {});
|
|
257
688
|
|
|
258
|
-
type
|
|
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}};
|
|
259
709
|
|
|
260
710
|
// ------------------------------------------------------------------------------------------------
|
|
261
|
-
//
|
|
711
|
+
// ERRORS
|
|
262
712
|
// ------------------------------------------------------------------------------------------------
|
|
263
713
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
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;
|
|
270
744
|
|
|
271
|
-
export
|
|
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};
|
|
272
856
|
web3_clientVersion: {result: string};
|
|
273
|
-
|
|
274
|
-
net_version: {result: EIP1193ChainId};
|
|
275
|
-
net_listening: {result: boolean};
|
|
276
|
-
net_peerCount: {result: EIP1193QUANTITY};
|
|
277
|
-
eth_protocolVersion: {result: string};
|
|
278
|
-
eth_syncing: {result: EIP1193SyncingStatus | false};
|
|
279
|
-
eth_coinbase: {result: EIP1193Account};
|
|
280
|
-
eth_mining: {result: boolean}; // TODO check
|
|
281
|
-
eth_hashrate: {result: unknown}; // TODO
|
|
857
|
+
web3_sha3: {params: [EIP1193DATA]; result: EIP1193DATA};
|
|
282
858
|
};
|
|
283
859
|
|
|
860
|
+
/** Chain reads available on both a browser wallet and a plain JSON-RPC endpoint. */
|
|
284
861
|
export type ReadMethods = {
|
|
285
|
-
eth_gasPrice: {result: EIP1193QUANTITY};
|
|
286
|
-
|
|
287
862
|
eth_blockNumber: {result: EIP1193QUANTITY};
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
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;
|
|
292
871
|
};
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
eth_estimateGas: {params: [EIP1193CallParam
|
|
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
|
+
*/
|
|
302
887
|
eth_getBlockByHash:
|
|
303
|
-
| {params: [EIP1193DATA,
|
|
304
|
-
| {params: [EIP1193DATA,
|
|
888
|
+
| {params: [EIP1193DATA, false?]; result: EIP1193Block | null}
|
|
889
|
+
| {params: [EIP1193DATA, true]; result: EIP1193BlockWithTransactions | null};
|
|
305
890
|
eth_getBlockByNumber:
|
|
306
|
-
| {params: [EIP1193BlockTag,
|
|
307
|
-
| {params: [EIP1193BlockTag,
|
|
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
|
+
|
|
308
897
|
eth_getTransactionByHash: {params: [EIP1193DATA]; result: EIP1193Transaction | null};
|
|
309
898
|
eth_getTransactionByBlockHashAndIndex: {params: [EIP1193DATA, EIP1193QUANTITY]; result: EIP1193Transaction | null};
|
|
310
899
|
eth_getTransactionByBlockNumberAndIndex: {
|
|
@@ -313,116 +902,216 @@ export type ReadMethods = {
|
|
|
313
902
|
};
|
|
314
903
|
|
|
315
904
|
eth_getTransactionReceipt: {params: [EIP1193DATA]; result: EIP1193TransactionReceipt | null};
|
|
316
|
-
|
|
317
|
-
|
|
905
|
+
eth_getBlockReceipts: {params: [EIP1898BlockTag]; result: EIP1193TransactionReceipt[] | null};
|
|
906
|
+
|
|
318
907
|
eth_getLogs: {params: [EIP1193LogsParam]; result: EIP1193Log[]};
|
|
319
|
-
|
|
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};
|
|
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
|
+
};
|
|
320
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 = {
|
|
321
954
|
eth_subscribe:
|
|
322
|
-
| {params: ['newHeads'
|
|
323
|
-
| {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
topics: (EIP1193DATA[] | EIP1193DATA)[];
|
|
329
|
-
}
|
|
330
|
-
];
|
|
331
|
-
result: string;
|
|
332
|
-
};
|
|
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};
|
|
333
961
|
eth_unsubscribe: {params: [EIP1193DATA]; result: boolean};
|
|
334
|
-
|
|
962
|
+
};
|
|
335
963
|
|
|
336
|
-
|
|
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};
|
|
337
983
|
};
|
|
338
984
|
|
|
985
|
+
/** Submission of an already-signed transaction. Needs no key. */
|
|
339
986
|
export type WriteMethods = {
|
|
340
987
|
eth_sendRawTransaction: {params: [EIP1193DATA]; result: EIP1193DATA};
|
|
341
988
|
};
|
|
342
989
|
|
|
990
|
+
/** Anything that requires access to a private key. */
|
|
343
991
|
export type SignerMethods = {
|
|
344
992
|
eth_accounts: {result: EIP1193Accounts};
|
|
993
|
+
/** @deprecated Signs an arbitrary digest. Disabled by default in most wallets. Use `personal_sign`. */
|
|
345
994
|
eth_sign: {params: [EIP1193Account, EIP1193DATA]; result: EIP1193DATA};
|
|
346
995
|
eth_signTransaction: {params: [EIP1193TransactionData]; result: EIP1193DATA};
|
|
347
996
|
|
|
997
|
+
/** Params are `[message, address]`, in that order. */
|
|
348
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};
|
|
349
1010
|
eth_signTypedData_v4: {params: [EIP1193Account, EIP1193TypedSignatureParam]; result: EIP1193DATA};
|
|
350
|
-
eth_signTypedData: {params: [EIP1193Account, EIP1193TypedSignatureParam]; result: EIP1193DATA};
|
|
351
1011
|
};
|
|
352
1012
|
|
|
1013
|
+
/** Requires a key AND a currently selected account. */
|
|
353
1014
|
export type ConnectedAccountMethods = {
|
|
354
1015
|
eth_sendTransaction: {params: [EIP1193TransactionData]; result: EIP1193DATA};
|
|
355
1016
|
};
|
|
356
1017
|
|
|
1018
|
+
/** Wallet UX methods. Only a browser wallet can serve these; a JSON-RPC endpoint cannot. */
|
|
357
1019
|
export type WalletOnlyMethods = {
|
|
1020
|
+
/** EIP-1102. */
|
|
358
1021
|
eth_requestAccounts: {result: EIP1193Accounts};
|
|
359
|
-
wallet_switchEthereumChain: {
|
|
360
|
-
params: [
|
|
361
|
-
{
|
|
362
|
-
chainId: EIP1193ChainId;
|
|
363
|
-
}
|
|
364
|
-
];
|
|
365
|
-
result: EIP1193SwitchChainError | null;
|
|
366
|
-
};
|
|
367
|
-
wallet_addEthereumChain: {params: [EIP1193AddChainParam]; result: EIP1193AddChainError | null};
|
|
368
|
-
};
|
|
369
1022
|
|
|
370
|
-
|
|
371
|
-
|
|
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};
|
|
372
1055
|
};
|
|
373
1056
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
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
|
+
};
|
|
381
1064
|
};
|
|
382
1065
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
data?: unknown;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
export interface EIP1193ConnectInfoMessage {
|
|
390
|
-
readonly chainId: EIP1193ChainId;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
export type EIP1193UnknownMessage = {
|
|
394
|
-
readonly type: string;
|
|
395
|
-
readonly data: unknown;
|
|
396
|
-
};
|
|
1066
|
+
// ------------------------------------------------------------------------------------------------
|
|
1067
|
+
// METHOD SETS
|
|
1068
|
+
// ------------------------------------------------------------------------------------------------
|
|
397
1069
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
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;
|
|
405
1082
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
}
|
|
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;
|
|
426
1115
|
|
|
427
1116
|
// ------------------------------------------------------------------------------------------------
|
|
428
1117
|
// TOOLS
|
|
@@ -439,21 +1128,24 @@ type DeepReadonly<T> = Readonly<{
|
|
|
439
1128
|
DeepReadonly<T[K]>;
|
|
440
1129
|
}>;
|
|
441
1130
|
|
|
442
|
-
export type RPCRequestData = {params?: any; result?: any
|
|
1131
|
+
export type RPCRequestData = {params?: any; result?: any};
|
|
443
1132
|
|
|
1133
|
+
/** A method table. A value may be a UNION of entries, which becomes a union of overloads. */
|
|
444
1134
|
export type RPCMethods = Record<string, RPCRequestData>;
|
|
445
1135
|
|
|
446
1136
|
export type RemoteRequestCallType<
|
|
447
1137
|
Method extends string,
|
|
448
1138
|
Value,
|
|
449
1139
|
Params extends any[] | Record<string, any> | undefined = undefined
|
|
450
|
-
> = Params extends undefined
|
|
1140
|
+
> = [Params] extends [undefined]
|
|
451
1141
|
? {
|
|
452
|
-
|
|
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>;
|
|
453
1145
|
}
|
|
454
|
-
: Params extends []
|
|
1146
|
+
: [Params] extends [readonly []]
|
|
455
1147
|
? {
|
|
456
|
-
request: (req: {method: Method}) => Promise<Value>;
|
|
1148
|
+
request: (req: {method: Method; params?: readonly []}) => Promise<Value>;
|
|
457
1149
|
}
|
|
458
1150
|
: {
|
|
459
1151
|
request: (req: {method: Method; params: DeepReadonly<Params>}) => Promise<Value>;
|
|
@@ -461,37 +1153,97 @@ export type RemoteRequestCallType<
|
|
|
461
1153
|
|
|
462
1154
|
export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
463
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
|
+
|
|
464
1178
|
export type RequestUnion<T extends RPCMethods> = {
|
|
465
|
-
[Property in keyof T]:
|
|
466
|
-
Property extends string ? Property : never,
|
|
467
|
-
T[Property] extends {result: any} ? T[Property]['result'] : undefined,
|
|
468
|
-
T[Property] extends {params: any} ? T[Property]['params'] : undefined
|
|
469
|
-
>;
|
|
1179
|
+
[Property in keyof T]: MethodRequestCallType<Property extends string ? Property : never, T[Property]>;
|
|
470
1180
|
}[keyof T];
|
|
471
1181
|
|
|
472
1182
|
// ------------------------------------------------------------------------------------------------
|
|
473
1183
|
// PROVIDERS
|
|
474
1184
|
// ------------------------------------------------------------------------------------------------
|
|
475
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
|
+
*/
|
|
476
1202
|
export type RequestRPC<T extends RPCMethods> = UnionToIntersection<RequestUnion<T>> & {
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
}): Promise<
|
|
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>;
|
|
481
1207
|
};
|
|
482
1208
|
|
|
1209
|
+
/** A browser wallet provider without the event emitter. */
|
|
483
1210
|
export type EIP1193ProviderWithoutEvents = RequestRPC<Methods>;
|
|
484
1211
|
|
|
485
|
-
|
|
486
|
-
|
|
1212
|
+
/** A browser wallet provider (`window.ethereum`), without events. */
|
|
487
1213
|
export type EIP1193WalletProvider = RequestRPC<WalletMethods>;
|
|
488
1214
|
|
|
1215
|
+
/** A browser wallet provider (`window.ethereum`), with events. */
|
|
489
1216
|
export type EIP1193WindowWalletProvider = EIP1193WalletProvider & EIP1193EventsProvider;
|
|
490
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. */
|
|
491
1225
|
export type EIP1193SignerProvider = RequestRPC<SignerMethods>;
|
|
492
1226
|
|
|
493
|
-
|
|
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
|
+
};
|
|
494
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
|
+
*/
|
|
495
1247
|
export type EIP1193GenericRequestProvider = {
|
|
496
1248
|
request<T = unknown, V extends EIP1193GenericRequest = EIP1193GenericRequest>(args: V): Promise<T>;
|
|
497
1249
|
};
|
|
@@ -512,8 +1264,8 @@ export interface EIP1193OnConnectionProvider {
|
|
|
512
1264
|
}
|
|
513
1265
|
|
|
514
1266
|
export interface EIP1193OnAccountsChangedProvider {
|
|
515
|
-
on(eventName: 'accountsChanged', listener: Listener<
|
|
516
|
-
removeListener(eventName: 'accountsChanged', listener: Listener<
|
|
1267
|
+
on(eventName: 'accountsChanged', listener: Listener<EIP1193Accounts>): this;
|
|
1268
|
+
removeListener(eventName: 'accountsChanged', listener: Listener<EIP1193Accounts>): this;
|
|
517
1269
|
}
|
|
518
1270
|
|
|
519
1271
|
export interface EIP1193OnChainChangedProvider {
|
|
@@ -521,6 +1273,13 @@ export interface EIP1193OnChainChangedProvider {
|
|
|
521
1273
|
removeListener(eventName: 'chainChanged', listener: Listener<EIP1193ChainId>): this;
|
|
522
1274
|
}
|
|
523
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
|
+
*/
|
|
524
1283
|
export interface EIP1193EventsProvider {
|
|
525
1284
|
on(eventName: 'message', listener: Listener<EIP1193Message>): this;
|
|
526
1285
|
removeListener(eventName: 'message', listener: Listener<EIP1193Message>): this;
|
|
@@ -530,11 +1289,12 @@ export interface EIP1193EventsProvider {
|
|
|
530
1289
|
removeListener(eventName: 'connect', listener: Listener<EIP1193ConnectInfoMessage>): this;
|
|
531
1290
|
removeListener(eventName: 'disconnect', listener: Listener<EIP1193ProviderRpcError>): this;
|
|
532
1291
|
|
|
533
|
-
on(eventName: 'accountsChanged', listener: Listener<
|
|
534
|
-
removeListener(eventName: 'accountsChanged', listener: Listener<
|
|
1292
|
+
on(eventName: 'accountsChanged', listener: Listener<EIP1193Accounts>): this;
|
|
1293
|
+
removeListener(eventName: 'accountsChanged', listener: Listener<EIP1193Accounts>): this;
|
|
535
1294
|
|
|
536
1295
|
on(eventName: 'chainChanged', listener: Listener<EIP1193ChainId>): this;
|
|
537
1296
|
removeListener(eventName: 'chainChanged', listener: Listener<EIP1193ChainId>): this;
|
|
538
1297
|
}
|
|
539
1298
|
|
|
1299
|
+
/** An EIP-1193 provider: what a browser wallet injects as `window.ethereum`. */
|
|
540
1300
|
export interface EIP1193Provider extends EIP1193ProviderWithoutEvents, EIP1193EventsProvider {}
|