eip-1193 0.7.1 → 0.7.3
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 +239 -1
- package/package.json +1 -4
package/index.d.ts
CHANGED
|
@@ -219,6 +219,14 @@ type BaseEIP1193TransactionData = {
|
|
|
219
219
|
|
|
220
220
|
export type EIP1193LegacyTransactionData = BaseEIP1193TransactionData & {
|
|
221
221
|
type?: '0x0';
|
|
222
|
+
/**
|
|
223
|
+
* Binds the transaction to a chain (EIP-155 replay protection). Optional on every type,
|
|
224
|
+
* legacy included: execution-apis `GenericTransaction` and `TransactionLegacyUnsigned` both
|
|
225
|
+
* carry an optional `chainId` (`src/schemas/transaction.yaml`), and go-ethereum rejects a
|
|
226
|
+
* `TransactionArgs` whose `chainId` does not match the node's, whatever its type, and fills
|
|
227
|
+
* it in when absent (`internal/ethapi/transaction_args.go`, `setDefaults`).
|
|
228
|
+
*/
|
|
229
|
+
chainId?: EIP1193ChainId;
|
|
222
230
|
gasPrice?: EIP1193QUANTITY;
|
|
223
231
|
};
|
|
224
232
|
|
|
@@ -843,6 +851,12 @@ type Listener<Message> = (message: Message) => unknown;
|
|
|
843
851
|
// LegacyNodeMethods - pre-merge leftovers, removed from execution-apis.
|
|
844
852
|
// DebugOnlyMethods - the debug namespace.
|
|
845
853
|
//
|
|
854
|
+
// Development nodes add their own groups, see DEV-NODE METHOD GROUPS below:
|
|
855
|
+
//
|
|
856
|
+
// DevNodeMethods - served by BOTH Hardhat and Anvil under the same name.
|
|
857
|
+
// HardhatMethods - served by Hardhat only.
|
|
858
|
+
// AnvilMethods - served by Anvil only (its `anvil_*` names and its extra aliases).
|
|
859
|
+
//
|
|
846
860
|
// ------------------------------------------------------------------------------------------------
|
|
847
861
|
|
|
848
862
|
/** Client and network identity. Served by browser wallets as well as nodes. */
|
|
@@ -1063,6 +1077,215 @@ export type DebugOnlyMethods = {
|
|
|
1063
1077
|
};
|
|
1064
1078
|
};
|
|
1065
1079
|
|
|
1080
|
+
// ------------------------------------------------------------------------------------------------
|
|
1081
|
+
// DEV-NODE METHOD GROUPS
|
|
1082
|
+
// ------------------------------------------------------------------------------------------------
|
|
1083
|
+
//
|
|
1084
|
+
// Methods only a local development node serves: time travel, mining control, state edits and
|
|
1085
|
+
// impersonation. No production endpoint answers them, so they are in none of the sets above and
|
|
1086
|
+
// are composed into dedicated provider types instead (EIP1193DevNodeProvider,
|
|
1087
|
+
// EIP1193HardhatProvider, EIP1193AnvilProvider).
|
|
1088
|
+
//
|
|
1089
|
+
// Every entry was checked against the client's own request parser and handler:
|
|
1090
|
+
//
|
|
1091
|
+
// Hardhat: NomicFoundation/edr @ b9bd49fcc746d11e510447448a7f97f9a359ddc5
|
|
1092
|
+
// crates/edr_provider/src/requests/methods.rs (params, results)
|
|
1093
|
+
// crates/edr_provider/src/requests/serde.rs (how each param is parsed)
|
|
1094
|
+
// Anvil: foundry-rs/foundry @ 85d83334d17a1e37c849d954711312480ef876d7
|
|
1095
|
+
// crates/anvil/core/src/eth/mod.rs (`EthRequest`: names, aliases, params)
|
|
1096
|
+
// crates/anvil/src/eth/api.rs (results; a handler returning `()` answers `null`)
|
|
1097
|
+
// crates/common/src/serde_helpers.rs (how each numeric param is parsed)
|
|
1098
|
+
//
|
|
1099
|
+
// DevNodeMethods is disjoint from each client group, so each provider type composes by plain
|
|
1100
|
+
// intersection. HardhatMethods and AnvilMethods are NOT disjoint from each other: both list
|
|
1101
|
+
// `evm_setIntervalMining`, in different units, so do not intersect them. A method both clients
|
|
1102
|
+
// serve under the same name and meaning lives in DevNodeMethods only, typed with the params BOTH
|
|
1103
|
+
// accept and a result covering what EITHER returns. Where they disagree is noted per entry:
|
|
1104
|
+
// Hardhat mostly answers `true` where Anvil answers `null`, which is why many results below are
|
|
1105
|
+
// `boolean | null`.
|
|
1106
|
+
//
|
|
1107
|
+
// Params: a timestamp, a duration or a block count is typed `EIP1193QUANTITY | number`, because
|
|
1108
|
+
// both clients accept a JSON number there as well as a hex string. Other quantities are
|
|
1109
|
+
// `EIP1193QUANTITY` only: Hardhat rejects a JSON number for balances, nonces and storage slots,
|
|
1110
|
+
// and the rest are kept hex for uniformity.
|
|
1111
|
+
//
|
|
1112
|
+
// Omitting `params` is allowed only where it was checked to work. `evm_mine` and `hardhat_mine`
|
|
1113
|
+
// need `params` (pass `[]` for the defaults): Anvil answers `invalid type: null` to an omitted
|
|
1114
|
+
// `params` on `anvil_mine` / `hardhat_mine`, and `evm_mine` requires it too because Hardhat's
|
|
1115
|
+
// handling of an omitted `params` there could not be verified (Anvil accepts it).
|
|
1116
|
+
//
|
|
1117
|
+
// Not covered: `hardhat_reset` is not served by EDR, the engine of Hardhat 3, which removed it
|
|
1118
|
+
// (Hardhat 2 answers it in its JavaScript layer); Anvil's is in AnvilMethods. Methods outside
|
|
1119
|
+
// these tables can still be called through EIP1193GenericRequestProvider.
|
|
1120
|
+
//
|
|
1121
|
+
// ------------------------------------------------------------------------------------------------
|
|
1122
|
+
|
|
1123
|
+
/** The fork the node runs on, as reported by `hardhat_metadata`. */
|
|
1124
|
+
export type EIP1193DevNodeForkedNetwork = {
|
|
1125
|
+
chainId: number;
|
|
1126
|
+
forkBlockNumber: number;
|
|
1127
|
+
forkBlockHash: EIP1193DATA;
|
|
1128
|
+
};
|
|
1129
|
+
|
|
1130
|
+
/**
|
|
1131
|
+
* `hardhat_metadata` result. Numbers are JSON numbers, not hex quantities. Hardhat omits
|
|
1132
|
+
* `forkedNetwork` when not forking; Anvil sends `null`.
|
|
1133
|
+
*/
|
|
1134
|
+
export type EIP1193DevNodeMetadata = {
|
|
1135
|
+
clientVersion: string;
|
|
1136
|
+
chainId: number;
|
|
1137
|
+
/** Unique per run of the node; changes on reset. */
|
|
1138
|
+
instanceId: EIP1193DATA;
|
|
1139
|
+
latestBlockNumber: number;
|
|
1140
|
+
latestBlockHash: EIP1193DATA;
|
|
1141
|
+
forkedNetwork?: EIP1193DevNodeForkedNetwork | null;
|
|
1142
|
+
};
|
|
1143
|
+
|
|
1144
|
+
/** `anvil_metadata` result: the `hardhat_metadata` fields plus Anvil's own. */
|
|
1145
|
+
export type EIP1193AnvilMetadata = EIP1193DevNodeMetadata & {
|
|
1146
|
+
clientSemver: string | null;
|
|
1147
|
+
clientCommitSha: string | null;
|
|
1148
|
+
/** Keyed by snapshot id: `[blockNumber, blockHash]` at the time of the snapshot. */
|
|
1149
|
+
snapshots: {[snapshotId: string]: [number, EIP1193DATA]};
|
|
1150
|
+
};
|
|
1151
|
+
|
|
1152
|
+
/** The fork to reset onto, for `anvil_reset` / Anvil's `hardhat_reset`. */
|
|
1153
|
+
export type EIP1193AnvilForkingParam = {
|
|
1154
|
+
jsonRpcUrl?: string;
|
|
1155
|
+
blockNumber?: EIP1193QUANTITY | number;
|
|
1156
|
+
};
|
|
1157
|
+
|
|
1158
|
+
/** A timestamp, duration or block count: both dev nodes accept a JSON number or a hex string. */
|
|
1159
|
+
type DevNodeNumber = EIP1193QUANTITY | number;
|
|
1160
|
+
|
|
1161
|
+
/**
|
|
1162
|
+
* An entry whose params are all optional, so `params` itself may be omitted from the request.
|
|
1163
|
+
* Two entries, hence two overloads: a required `params` tuple alone would force `params: []`.
|
|
1164
|
+
*/
|
|
1165
|
+
type ParamsMayBeOmitted<P extends any[], R> = {result: R} | {params: P; result: R};
|
|
1166
|
+
|
|
1167
|
+
/**
|
|
1168
|
+
* Served by BOTH Hardhat and Anvil under the same name: the `evm_*` methods both implement, and
|
|
1169
|
+
* the `hardhat_*` methods Anvil accepts as aliases of its `anvil_*` ones.
|
|
1170
|
+
*/
|
|
1171
|
+
export type DevNodeMethods = {
|
|
1172
|
+
/**
|
|
1173
|
+
* Mines one block. The optional param is the block's timestamp. Anvil also accepts
|
|
1174
|
+
* `{timestamp, blocks}`, which Hardhat does not; for several blocks use `hardhat_mine`.
|
|
1175
|
+
* Pass `params: []` for no timestamp. The result is a placeholder: Hardhat answers `'0'`,
|
|
1176
|
+
* Anvil `'0x0'`.
|
|
1177
|
+
*/
|
|
1178
|
+
evm_mine: {params: [timestamp?: DevNodeNumber]; result: string};
|
|
1179
|
+
/** Seconds to add. Returns the total offset: Hardhat as a DECIMAL string, Anvil as a number. */
|
|
1180
|
+
evm_increaseTime: {params: [seconds: DevNodeNumber]; result: string | number};
|
|
1181
|
+
/** Hardhat returns the timestamp as a DECIMAL string, Anvil returns `null`. */
|
|
1182
|
+
evm_setNextBlockTimestamp: {params: [timestamp: DevNodeNumber]; result: string | null};
|
|
1183
|
+
/** Returns the snapshot id, to pass to `evm_revert`. */
|
|
1184
|
+
evm_snapshot: {result: EIP1193QUANTITY};
|
|
1185
|
+
/** `false` if the id is unknown. Reverting consumes the snapshot and every later one. */
|
|
1186
|
+
evm_revert: {params: [snapshotId: EIP1193QUANTITY]; result: boolean};
|
|
1187
|
+
/** Hardhat returns `true`, Anvil `null`. */
|
|
1188
|
+
evm_setAutomine: {params: [enabled: boolean]; result: boolean | null};
|
|
1189
|
+
evm_setBlockGasLimit: {params: [gasLimit: EIP1193QUANTITY]; result: boolean};
|
|
1190
|
+
|
|
1191
|
+
/** Hardhat returns `true`, Anvil `null`. */
|
|
1192
|
+
hardhat_impersonateAccount: {params: [EIP1193Account]; result: boolean | null};
|
|
1193
|
+
/** Hardhat returns whether the account was impersonated, Anvil `null`. */
|
|
1194
|
+
hardhat_stopImpersonatingAccount: {params: [EIP1193Account]; result: boolean | null};
|
|
1195
|
+
hardhat_getAutomine: {result: boolean};
|
|
1196
|
+
/** Mines `blocks` blocks (default 1), `interval` seconds apart (default 1). */
|
|
1197
|
+
hardhat_mine: {params: [blocks?: DevNodeNumber, interval?: DevNodeNumber]; result: boolean | null};
|
|
1198
|
+
hardhat_setBalance: {params: [EIP1193Account, balance: EIP1193QUANTITY]; result: boolean | null};
|
|
1199
|
+
hardhat_setCode: {params: [EIP1193Account, code: EIP1193DATA]; result: boolean | null};
|
|
1200
|
+
hardhat_setNonce: {params: [EIP1193Account, nonce: EIP1193QUANTITY]; result: boolean | null};
|
|
1201
|
+
/** `value` must be exactly 32 bytes. Both clients return `true`. */
|
|
1202
|
+
hardhat_setStorageAt: {params: [EIP1193Account, slot: EIP1193QUANTITY, value: EIP1193DATA]; result: boolean};
|
|
1203
|
+
hardhat_setCoinbase: {params: [EIP1193Account]; result: boolean | null};
|
|
1204
|
+
/**
|
|
1205
|
+
* Removes a pending transaction. Hardhat returns whether it was removed; Anvil returns the
|
|
1206
|
+
* removed transaction's hash, or `null` if there was none.
|
|
1207
|
+
*/
|
|
1208
|
+
hardhat_dropTransaction: {params: [txHash: EIP1193DATA]; result: boolean | EIP1193DATA | null};
|
|
1209
|
+
/** Post-London only (both clients). */
|
|
1210
|
+
hardhat_setNextBlockBaseFeePerGas: {params: [baseFee: EIP1193QUANTITY]; result: boolean | null};
|
|
1211
|
+
/** Pre-London only (both clients). */
|
|
1212
|
+
hardhat_setMinGasPrice: {params: [gasPrice: EIP1193QUANTITY]; result: boolean | null};
|
|
1213
|
+
hardhat_setLoggingEnabled: {params: [enabled: boolean]; result: boolean | null};
|
|
1214
|
+
hardhat_metadata: {result: EIP1193DevNodeMetadata};
|
|
1215
|
+
};
|
|
1216
|
+
|
|
1217
|
+
/** Served by Hardhat (EDR) only. */
|
|
1218
|
+
export type HardhatMethods = {
|
|
1219
|
+
/**
|
|
1220
|
+
* Interval in MILLISECONDS, or a `[min, max]` range for a random interval; `0` disables.
|
|
1221
|
+
* Anvil's `evm_setIntervalMining` takes SECONDS, hence one entry per client.
|
|
1222
|
+
*/
|
|
1223
|
+
evm_setIntervalMining: {params: [interval: number | [min: number, max: number]]; result: boolean};
|
|
1224
|
+
/** Post-merge only. */
|
|
1225
|
+
hardhat_setPrevRandao: {params: [prevRandao: EIP1193DATA]; result: boolean};
|
|
1226
|
+
};
|
|
1227
|
+
|
|
1228
|
+
/**
|
|
1229
|
+
* Served by Anvil only: a selection of its `anvil_*` methods, and of the `evm_*` / `hardhat_*`
|
|
1230
|
+
* aliases Anvil accepts that Hardhat does not serve (or serves with a different meaning). Others
|
|
1231
|
+
* (`anvil_dealERC20`, `anvil_nodeInfo`, `evm_mine_detailed`, ...) are not typed yet.
|
|
1232
|
+
*/
|
|
1233
|
+
export type AnvilMethods = {
|
|
1234
|
+
/** Interval in SECONDS; `0` disables. Hardhat's takes milliseconds. */
|
|
1235
|
+
evm_setIntervalMining: {params: [seconds: DevNodeNumber]; result: null};
|
|
1236
|
+
anvil_setIntervalMining: {params: [seconds: DevNodeNumber]; result: null};
|
|
1237
|
+
/** Sets the clock. Returns the offset to wall-clock time in seconds. */
|
|
1238
|
+
evm_setTime: {params: [timestamp: DevNodeNumber]; result: number};
|
|
1239
|
+
anvil_setTime: {params: [timestamp: DevNodeNumber]; result: number};
|
|
1240
|
+
|
|
1241
|
+
anvil_mine: {params: [blocks?: DevNodeNumber, interval?: DevNodeNumber]; result: null};
|
|
1242
|
+
anvil_increaseTime: {params: [seconds: DevNodeNumber]; result: number};
|
|
1243
|
+
anvil_setNextBlockTimestamp: {params: [timestamp: DevNodeNumber]; result: null};
|
|
1244
|
+
anvil_snapshot: {result: EIP1193QUANTITY};
|
|
1245
|
+
anvil_revert: {params: [snapshotId: EIP1193QUANTITY]; result: boolean};
|
|
1246
|
+
anvil_setAutomine: {params: [enabled: boolean]; result: null};
|
|
1247
|
+
anvil_getAutomine: {result: boolean};
|
|
1248
|
+
anvil_setBlockGasLimit: {params: [gasLimit: EIP1193QUANTITY]; result: boolean};
|
|
1249
|
+
|
|
1250
|
+
anvil_impersonateAccount: {params: [EIP1193Account]; result: null};
|
|
1251
|
+
anvil_stopImpersonatingAccount: {params: [EIP1193Account]; result: null};
|
|
1252
|
+
/** Makes every account impersonated. */
|
|
1253
|
+
anvil_autoImpersonateAccount: {params: [enabled: boolean]; result: null};
|
|
1254
|
+
hardhat_autoImpersonateAccount: {params: [enabled: boolean]; result: null};
|
|
1255
|
+
|
|
1256
|
+
anvil_setBalance: {params: [EIP1193Account, balance: EIP1193QUANTITY]; result: null};
|
|
1257
|
+
anvil_addBalance: {params: [EIP1193Account, amount: EIP1193QUANTITY]; result: null};
|
|
1258
|
+
hardhat_addBalance: {params: [EIP1193Account, amount: EIP1193QUANTITY]; result: null};
|
|
1259
|
+
anvil_setCode: {params: [EIP1193Account, code: EIP1193DATA]; result: null};
|
|
1260
|
+
anvil_setNonce: {params: [EIP1193Account, nonce: EIP1193QUANTITY]; result: null};
|
|
1261
|
+
/** `value` must be exactly 32 bytes. */
|
|
1262
|
+
anvil_setStorageAt: {params: [EIP1193Account, slot: EIP1193QUANTITY, value: EIP1193DATA]; result: boolean};
|
|
1263
|
+
anvil_setCoinbase: {params: [EIP1193Account]; result: null};
|
|
1264
|
+
anvil_setChainId: {params: [chainId: DevNodeNumber]; result: null};
|
|
1265
|
+
|
|
1266
|
+
/** Returns the removed transaction's hash, or `null` if there was none. */
|
|
1267
|
+
anvil_dropTransaction: {params: [txHash: EIP1193DATA]; result: EIP1193DATA | null};
|
|
1268
|
+
anvil_dropAllTransactions: {result: null};
|
|
1269
|
+
hardhat_dropAllTransactions: {result: null};
|
|
1270
|
+
anvil_setNextBlockBaseFeePerGas: {params: [baseFee: EIP1193QUANTITY]; result: null};
|
|
1271
|
+
anvil_setMinGasPrice: {params: [gasPrice: EIP1193QUANTITY]; result: null};
|
|
1272
|
+
anvil_setLoggingEnabled: {params: [enabled: boolean]; result: null};
|
|
1273
|
+
|
|
1274
|
+
/**
|
|
1275
|
+
* Resets the chain, optionally onto a new fork. The fork options may be passed bare or under
|
|
1276
|
+
* a `forking` key. Omit them to reset to the initial state.
|
|
1277
|
+
*/
|
|
1278
|
+
anvil_reset: ParamsMayBeOmitted<[forking?: EIP1193AnvilForkingParam | {forking: EIP1193AnvilForkingParam}], null>;
|
|
1279
|
+
/** Anvil's alias of `anvil_reset`. Hardhat 3 does not serve `hardhat_reset`. */
|
|
1280
|
+
hardhat_reset: ParamsMayBeOmitted<[forking?: EIP1193AnvilForkingParam | {forking: EIP1193AnvilForkingParam}], null>;
|
|
1281
|
+
/** Returns the state as an opaque blob for `anvil_loadState`. */
|
|
1282
|
+
anvil_dumpState: ParamsMayBeOmitted<[preserveHistoricalStates?: boolean], EIP1193DATA>;
|
|
1283
|
+
hardhat_dumpState: ParamsMayBeOmitted<[preserveHistoricalStates?: boolean], EIP1193DATA>;
|
|
1284
|
+
anvil_loadState: {params: [state: EIP1193DATA]; result: boolean};
|
|
1285
|
+
hardhat_loadState: {params: [state: EIP1193DATA]; result: boolean};
|
|
1286
|
+
anvil_metadata: {result: EIP1193AnvilMetadata};
|
|
1287
|
+
};
|
|
1288
|
+
|
|
1066
1289
|
// ------------------------------------------------------------------------------------------------
|
|
1067
1290
|
// METHOD SETS
|
|
1068
1291
|
// ------------------------------------------------------------------------------------------------
|
|
@@ -1127,7 +1350,10 @@ export type CoreMethods = ClientMethods &
|
|
|
1127
1350
|
SignerMethods &
|
|
1128
1351
|
ConnectedAccountMethods;
|
|
1129
1352
|
|
|
1130
|
-
/**
|
|
1353
|
+
/**
|
|
1354
|
+
* Every method in this file, node and wallet and debug, except the dev-node groups (Hardhat and
|
|
1355
|
+
* Anvil disagree on some of them). Permissive; prefer a narrower set.
|
|
1356
|
+
*/
|
|
1131
1357
|
export type AllMethods = NodeMethods & WalletMethods & DebugOnlyMethods;
|
|
1132
1358
|
|
|
1133
1359
|
// ------------------------------------------------------------------------------------------------
|
|
@@ -1250,6 +1476,18 @@ export type EIP1193SignerProvider = RequestRPC<SignerMethods>;
|
|
|
1250
1476
|
/** A node provider with the `debug` namespace enabled. */
|
|
1251
1477
|
export type EIP1193DebugProvider = EIP1193NodeProvider & RequestRPC<DebugOnlyMethods>;
|
|
1252
1478
|
|
|
1479
|
+
/**
|
|
1480
|
+
* Any local development node, Hardhat or Anvil: the {@link CoreMethods} plus the dev-node
|
|
1481
|
+
* methods both serve ({@link DevNodeMethods}). Use it for code that runs against either.
|
|
1482
|
+
*/
|
|
1483
|
+
export type EIP1193DevNodeProvider = EIP1193CoreProvider & RequestRPC<DevNodeMethods>;
|
|
1484
|
+
|
|
1485
|
+
/** A Hardhat node: a JSON-RPC node plus {@link DevNodeMethods} and {@link HardhatMethods}. */
|
|
1486
|
+
export type EIP1193HardhatProvider = EIP1193NodeProvider & RequestRPC<DevNodeMethods & HardhatMethods>;
|
|
1487
|
+
|
|
1488
|
+
/** An Anvil node: a JSON-RPC node plus {@link DevNodeMethods} and {@link AnvilMethods}. */
|
|
1489
|
+
export type EIP1193AnvilProvider = EIP1193NodeProvider & RequestRPC<DevNodeMethods & AnvilMethods>;
|
|
1490
|
+
|
|
1253
1491
|
/** Every method in this file. Permissive; prefer a narrower provider type. */
|
|
1254
1492
|
export type EIP1193AllMethodsProvider = RequestRPC<AllMethods>;
|
|
1255
1493
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eip-1193",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "Types for EIP-1193 ethereum provider",
|
|
5
5
|
"keywords": ["ethereum", "eip-1193"],
|
|
6
6
|
"author": "Ronan Sandford",
|
|
@@ -16,9 +16,6 @@
|
|
|
16
16
|
"types": "index.d.ts",
|
|
17
17
|
"files": ["index.d.ts"],
|
|
18
18
|
"packageManager": "pnpm@11.25.0",
|
|
19
|
-
"engines": {
|
|
20
|
-
"pnpm": ">=11"
|
|
21
|
-
},
|
|
22
19
|
"scripts": {
|
|
23
20
|
"test": "tsc -p test-d/tsconfig.json",
|
|
24
21
|
"format": "prettier --write ."
|