eip-1193 0.4.0 → 0.4.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.
Files changed (2) hide show
  1. package/index.d.ts +317 -208
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -32,27 +32,28 @@ export type EIP1193LegacyTransactionData = BaseEIP1193TransactionData & {
32
32
  gasPrice?: EIP1193QUANTITY;
33
33
  };
34
34
 
35
-
36
35
  export type EIP1193TransactionDataOfType1 = BaseEIP1193TransactionData & {
37
- type: "0x1",
36
+ type: '0x1';
38
37
  chainId?: EIP1193ChainId;
39
38
  accessList?: EIP1193AccessList;
40
39
  gasPrice?: EIP1193QUANTITY;
41
- }
42
-
40
+ };
43
41
 
44
- export type EIP1193AccessListEntry = { address: EIP1193Account; storageKeys: EIP1193DATA[] };
42
+ export type EIP1193AccessListEntry = {address: EIP1193Account; storageKeys: EIP1193DATA[]};
45
43
  export type EIP1193AccessList = EIP1193AccessListEntry[];
46
44
 
47
45
  export type EIP1193TransactionDataOfType2 = BaseEIP1193TransactionData & {
48
- type: "0x2",
46
+ type: '0x2';
49
47
  chainId?: EIP1193ChainId;
50
48
  accessList?: EIP1193AccessList;
51
49
  maxFeePerGas?: EIP1193QUANTITY;
52
- maxPriorityFeePerGas?: EIP1193QUANTITY
53
- }
50
+ maxPriorityFeePerGas?: EIP1193QUANTITY;
51
+ };
54
52
 
55
- export type EIP1193TransactionData = EIP1193LegacyTransactionData | EIP1193TransactionDataOfType1 | EIP1193TransactionDataOfType2;
53
+ export type EIP1193TransactionData =
54
+ | EIP1193LegacyTransactionData
55
+ | EIP1193TransactionDataOfType1
56
+ | EIP1193TransactionDataOfType2;
56
57
 
57
58
  export type EIP1193SyncingStatus = {
58
59
  startingBlock: EIP1193QUANTITY;
@@ -111,7 +112,7 @@ export type EIP1193TransactionReceipt = {
111
112
  status: EIP1193QUANTITY;
112
113
  };
113
114
 
114
- export type EIP1193PendingBlock = EIP1193Block & {
115
+ export type EIP1193PendingBlock = Omit<EIP1193Block, 'number' | 'hash' | 'nonce' | 'logsBloom'> & {
115
116
  number: null;
116
117
  hash: null;
117
118
  nonce: null;
@@ -133,17 +134,15 @@ type EIP1193BaseTransactionEIP1193DATA = {
133
134
  data?: EIP1193DATA;
134
135
  nonce?: EIP1193QUANTITY;
135
136
  };
136
- export type EIP1193NormalTransactionEIP1193DATA =
137
- EIP1193BaseTransactionEIP1193DATA & {
138
- from: EIP1193Account;
139
- to: EIP1193Account;
140
- };
137
+ export type EIP1193NormalTransactionEIP1193DATA = EIP1193BaseTransactionEIP1193DATA & {
138
+ from: EIP1193Account;
139
+ to: EIP1193Account;
140
+ };
141
141
 
142
- export type EIP1193TransactionContractCreationEIP1193DATA =
143
- EIP1193BaseTransactionEIP1193DATA & {
144
- from: EIP1193Account;
145
- data: EIP1193DATA;
146
- };
142
+ export type EIP1193TransactionContractCreationEIP1193DATA = EIP1193BaseTransactionEIP1193DATA & {
143
+ from: EIP1193Account;
144
+ data: EIP1193DATA;
145
+ };
147
146
 
148
147
  export type EIP1193TransactionEIP1193DATA =
149
148
  | EIP1193NormalTransactionEIP1193DATA
@@ -179,178 +178,176 @@ export type EIP1193LogsParam = {
179
178
  blockhash?: EIP1193DATA;
180
179
  };
181
180
 
182
- export type EIP1193TypedSignatureParam = { [field: string]: any }; // TODO
181
+ export type EIP1193TypedSignatureParam = {[field: string]: any}; // TODO
183
182
  // ------------------------------------------------------------------------------------------------
184
183
  // REQUEST TYPES
185
184
  // ------------------------------------------------------------------------------------------------
186
185
 
187
186
  export type EIP1193Web3ClientVersionRequest = {
188
- readonly method: "web3_clientVersion";
187
+ readonly method: 'web3_clientVersion';
189
188
  };
190
189
 
191
190
  export type EIP1193Web3SHARequest = {
192
- readonly method: "web3_sha";
191
+ readonly method: 'web3_sha';
193
192
  readonly params: [EIP1193DATA];
194
193
  };
195
194
 
196
195
  export type EIP1193NetVersionRequest = {
197
- readonly method: "net_version";
196
+ readonly method: 'net_version';
198
197
  };
199
198
 
200
199
  export type EIP1193NetListeningRequest = {
201
- readonly method: "net_listening";
200
+ readonly method: 'net_listening';
202
201
  };
203
202
 
204
203
  export type EIP1193NetPeerCountRequest = {
205
- readonly method: "net_peerCount";
204
+ readonly method: 'net_peerCount';
206
205
  };
207
206
 
208
207
  export type EIP1193ProtocolVersionRequest = {
209
- readonly method: "eth_protocolVersion";
208
+ readonly method: 'eth_protocolVersion';
210
209
  };
211
210
 
212
211
  export type EIP1193SyncingRequest = {
213
- readonly method: "eth_syncing";
212
+ readonly method: 'eth_syncing';
214
213
  };
215
214
 
216
215
  export type EIP1193CoinbaseRequest = {
217
- readonly method: "eth_coinbase";
216
+ readonly method: 'eth_coinbase';
218
217
  };
219
218
 
220
219
  export type EIP1193MiningRequest = {
221
- readonly method: "eth_mining";
220
+ readonly method: 'eth_mining';
222
221
  };
223
222
 
224
223
  export type EIP1193HashrateRequest = {
225
- readonly method: "eth_hashrate";
224
+ readonly method: 'eth_hashrate';
226
225
  };
227
226
 
228
227
  export type EIP1193GasPriceRequest = {
229
- readonly method: "eth_gasPrice";
228
+ readonly method: 'eth_gasPrice';
230
229
  };
231
230
 
232
231
  export type EIP1193AccountsRequest = {
233
- readonly method: "eth_accounts";
232
+ readonly method: 'eth_accounts';
234
233
  };
235
234
 
236
235
  export type EIP1193BlockNumberRequest = {
237
- readonly method: "eth_blockNumber";
236
+ readonly method: 'eth_blockNumber';
238
237
  };
239
238
 
240
239
  export type EIP1193GetBalanceRequest = {
241
- readonly method: "eth_getBalance";
240
+ readonly method: 'eth_getBalance';
242
241
  readonly params: [EIP1193Account] | [EIP1193Account, EIP1898BlockTag];
243
242
  };
244
243
 
245
244
  export type EIP1193GetStorageAtRequest = {
246
- readonly method: "eth_getStorageAt";
247
- readonly params:
248
- | [EIP1193Account, EIP1193QUANTITY]
249
- | [EIP1193Account, EIP1193QUANTITY, EIP1898BlockTag];
245
+ readonly method: 'eth_getStorageAt';
246
+ readonly params: [EIP1193Account, EIP1193QUANTITY] | [EIP1193Account, EIP1193QUANTITY, EIP1898BlockTag];
250
247
  };
251
248
 
252
249
  export type EIP1193GetTransactionCountRequest = {
253
- readonly method: "eth_getTransactionCount";
250
+ readonly method: 'eth_getTransactionCount';
254
251
  readonly params: [EIP1193Account] | [EIP1193Account, EIP1898BlockTag];
255
252
  };
256
253
 
257
254
  export type EIP1193GetTransactionCountByHashRequest = {
258
- readonly method: "eth_getBlockTransactionCountByHash";
255
+ readonly method: 'eth_getBlockTransactionCountByHash';
259
256
  readonly params: [EIP1193DATA];
260
257
  };
261
258
 
262
259
  export type EIP1193GetTransactionCountByNumberRequest = {
263
- readonly method: "eth_getBlockTransactionCountByNumber";
260
+ readonly method: 'eth_getBlockTransactionCountByNumber';
264
261
  readonly params: [EIP1193BlockTag];
265
262
  };
266
263
 
267
264
  export type EIP1193GetUncleCountByBlockHashRequest = {
268
- readonly method: "eth_getUncleCountByBlockHash";
265
+ readonly method: 'eth_getUncleCountByBlockHash';
269
266
  readonly params: [EIP1193DATA];
270
267
  };
271
268
 
272
269
  export type EIP1193GetUncleCountByBlockNumberRequest = {
273
- readonly method: "eth_getUncleCountByBlockNumber";
270
+ readonly method: 'eth_getUncleCountByBlockNumber';
274
271
  readonly params: [EIP1193BlockTag];
275
272
  };
276
273
 
277
274
  export type EIP1193GetCodeRequest = {
278
- readonly method: "eth_getCode";
275
+ readonly method: 'eth_getCode';
279
276
  readonly params: [EIP1193Account] | [EIP1193Account, EIP1898BlockTag];
280
277
  };
281
278
 
282
279
  export type EIP1193LegacySignRequest = {
283
- readonly method: "eth_sign";
280
+ readonly method: 'eth_sign';
284
281
  readonly params: [EIP1193Account, EIP1193DATA];
285
282
  };
286
283
 
287
284
  export type EIP1193SignTransactionRequest = {
288
- readonly method: "eth_signTransaction";
285
+ readonly method: 'eth_signTransaction';
289
286
  readonly params: [EIP1193TransactionData];
290
287
  };
291
288
 
292
289
  export type EIP1193SendTransactionRequest = {
293
- readonly method: "eth_sendTransaction";
290
+ readonly method: 'eth_sendTransaction';
294
291
  readonly params: [EIP1193TransactionData];
295
292
  };
296
293
 
297
294
  export type EIP1193SendRawTransactionRequest = {
298
- readonly method: "eth_sendRawTransaction";
295
+ readonly method: 'eth_sendRawTransaction';
299
296
  readonly params: [EIP1193DATA];
300
297
  };
301
298
 
302
299
  export type EIP1193CallRequest = {
303
- readonly method: "eth_call";
300
+ readonly method: 'eth_call';
304
301
  readonly params: [EIP1193CallParam] | [EIP1193CallParam, EIP1898BlockTag];
305
302
  };
306
303
 
307
304
  export type EIP1193EstimateGasRequest = {
308
- readonly method: "eth_estimateGas";
305
+ readonly method: 'eth_estimateGas';
309
306
  readonly params: [EIP1193CallParam] | [EIP1193CallParam, EIP1193BlockTag]; // EIP1898BlockTag ?
310
307
  };
311
308
 
312
309
  export type EIP1193GetBlockByHashRequest<T extends boolean = false> = {
313
- readonly method: "eth_getBlockByHash";
310
+ readonly method: 'eth_getBlockByHash';
314
311
  readonly params: [EIP1193DATA, T];
315
312
  };
316
313
 
317
314
  export type EIP1193GetBlockByNumberRequest<T = false> = {
318
- readonly method: "eth_getBlockByNumber";
315
+ readonly method: 'eth_getBlockByNumber';
319
316
  readonly params: [EIP1193BlockTag, T];
320
317
  };
321
318
 
322
319
  export type EIP1193GetTransactionByHashRequest = {
323
- readonly method: "eth_getTransactionByHash";
320
+ readonly method: 'eth_getTransactionByHash';
324
321
  readonly params: [EIP1193DATA];
325
322
  };
326
323
 
327
324
  export type EIP1193GetTransactionByBlockHashAndIndexRequest = {
328
- readonly method: "eth_getTransactionByBlockHashAndIndex";
325
+ readonly method: 'eth_getTransactionByBlockHashAndIndex';
329
326
  readonly params: [EIP1193DATA, EIP1193QUANTITY];
330
327
  };
331
328
 
332
329
  export type EIP1193GetTransactionByBlockNumberAndIndexRequest = {
333
- readonly method: "eth_getTransactionByBlockNumberAndIndex";
330
+ readonly method: 'eth_getTransactionByBlockNumberAndIndex';
334
331
  readonly params: [EIP1193BlockTag, EIP1193QUANTITY];
335
332
  };
336
333
 
337
334
  export type EIP1193GetTransactionReceiptRequest = {
338
- readonly method: "eth_getTransactionReceipt";
335
+ readonly method: 'eth_getTransactionReceipt';
339
336
  readonly params: [EIP1193DATA];
340
337
  };
341
338
 
342
339
  export type EIP1193GetUncleByBlockHashAndIndexRequest = {
343
- readonly method: "eth_getUncleByBlockHashAndIndex";
340
+ readonly method: 'eth_getUncleByBlockHashAndIndex';
344
341
  readonly params: [EIP1193DATA, EIP1193QUANTITY];
345
342
  };
346
343
 
347
344
  export type EIP1193GetUncleByBlockNumberAndIndexRequest = {
348
- readonly method: "eth_getUncleByBlockNumberAndIndex";
345
+ readonly method: 'eth_getUncleByBlockNumberAndIndex';
349
346
  readonly params: [EIP1193BlockTag, EIP1193QUANTITY];
350
347
  };
351
348
 
352
349
  export type EIP1193GetLogsRequest = {
353
- readonly method: "eth_getLogs";
350
+ readonly method: 'eth_getLogs';
354
351
  readonly params: [EIP1193LogsParam];
355
352
  };
356
353
 
@@ -359,30 +356,30 @@ export type EIP1193GetLogsRequest = {
359
356
  // ------------------------------------------------------------------------------------------------
360
357
 
361
358
  export type EIP1193PersonalSignRequest = {
362
- readonly method: "personal_sign";
359
+ readonly method: 'personal_sign';
363
360
  readonly params: [EIP1193DATA, EIP1193Account];
364
361
  };
365
362
 
366
363
  export type EIP1193PTypedSignv4Request = {
367
- readonly method: "eth_signTypedData_v4";
364
+ readonly method: 'eth_signTypedData_v4';
368
365
  readonly params: [EIP1193Account, EIP1193TypedSignatureParam];
369
366
  };
370
367
 
371
368
  export type EIP1193PTypedSignRequest = {
372
- readonly method: "eth_signTypedData";
369
+ readonly method: 'eth_signTypedData';
373
370
  readonly params: [EIP1193Account, EIP1193TypedSignatureParam];
374
371
  };
375
372
 
376
373
  export type EIP1193ChainIdRequest = {
377
- readonly method: "eth_chainId";
374
+ readonly method: 'eth_chainId';
378
375
  };
379
376
 
380
377
  export type EIP1193RequestAccountsRequest = {
381
- readonly method: "eth_requestAccounts";
378
+ readonly method: 'eth_requestAccounts';
382
379
  };
383
380
 
384
381
  export type ERIP1193SwitchChainRequest = {
385
- readonly method: "wallet_switchEthereumChain";
382
+ readonly method: 'wallet_switchEthereumChain';
386
383
  readonly params: [
387
384
  {
388
385
  chainId: EIP1193ChainId;
@@ -390,19 +387,19 @@ export type ERIP1193SwitchChainRequest = {
390
387
  ];
391
388
  };
392
389
  export type ERIP1193AddChainRequest = {
393
- readonly method: "wallet_addEthereumChain";
390
+ readonly method: 'wallet_addEthereumChain';
394
391
  readonly params: [EIP1193AddChainParam];
395
392
  };
396
393
 
397
394
  export type EIP1193OtherSubscribeRequest = {
398
- readonly method: "eth_subscribe";
399
- readonly params: ["newHeads" | "newPendingTransactions" | "syncing"];
395
+ readonly method: 'eth_subscribe';
396
+ readonly params: ['newHeads' | 'newPendingTransactions' | 'syncing'];
400
397
  };
401
398
 
402
399
  export type EIP1193LogsSubscribeRequest = {
403
- readonly method: "eth_subscribe";
400
+ readonly method: 'eth_subscribe';
404
401
  readonly params: [
405
- "logs",
402
+ 'logs',
406
403
  {
407
404
  address: EIP1193Account | EIP1193Account[];
408
405
  topics: (EIP1193DATA[] | EIP1193DATA)[];
@@ -410,20 +407,16 @@ export type EIP1193LogsSubscribeRequest = {
410
407
  ];
411
408
  };
412
409
 
413
- export type EIP1193SubscribeRequest =
414
- | EIP1193LogsSubscribeRequest
415
- | EIP1193OtherSubscribeRequest;
410
+ export type EIP1193SubscribeRequest = EIP1193LogsSubscribeRequest | EIP1193OtherSubscribeRequest;
416
411
 
417
412
  export type EIP1193UnsubscribeRequest = {
418
- readonly method: "eth_unsubscribe";
413
+ readonly method: 'eth_unsubscribe';
419
414
  readonly params: [EIP1193DATA];
420
415
  };
421
416
 
422
417
  export type EIP1193GetProofRequest = {
423
- readonly method: "eth_getProof";
424
- readonly params:
425
- | [EIP1193DATA, EIP1193DATA[]]
426
- | [EIP1193DATA, EIP1193DATA[], EIP1898BlockTag];
418
+ readonly method: 'eth_getProof';
419
+ readonly params: [EIP1193DATA, EIP1193DATA[]] | [EIP1193DATA, EIP1193DATA[], EIP1898BlockTag];
427
420
  };
428
421
 
429
422
  // ------------------------------------------------------------------------------------------------
@@ -479,12 +472,16 @@ export type EIP1193Request =
479
472
 
480
473
  export type EIP1193Response =
481
474
  | EIP1193ChainId
482
- | EIP1193SyncingStatus | false
475
+ | EIP1193SyncingStatus
476
+ | false
483
477
  | EIP1193QUANTITY
484
478
  | EIP1193BlockWithTransactions
485
- | EIP1193Transaction | null
486
- | EIP1193TransactionReceipt | null
487
- | EIP1193Block | null
479
+ | EIP1193Transaction
480
+ | null
481
+ | EIP1193TransactionReceipt
482
+ | null
483
+ | EIP1193Block
484
+ | null
488
485
  | EIP1193Log[]
489
486
  | EIP1193DATA
490
487
  | EIP1193ChainId
@@ -515,7 +512,7 @@ export type EIP1193UnknownMessage = {
515
512
  };
516
513
 
517
514
  export type EIP1193UnknownSubscriptionMessage = EIP1193UnknownMessage & {
518
- readonly type: "eth_subscription";
515
+ readonly type: 'eth_subscription';
519
516
  readonly data: {
520
517
  readonly subscription: EIP1193DATA;
521
518
  readonly result: unknown;
@@ -523,7 +520,7 @@ export type EIP1193UnknownSubscriptionMessage = EIP1193UnknownMessage & {
523
520
  };
524
521
 
525
522
  export type EIP1193KnownSubscriptionMessage = EIP1193UnknownMessage & {
526
- readonly type: "eth_subscription";
523
+ readonly type: 'eth_subscription';
527
524
  readonly data: {
528
525
  readonly subscription: EIP1193DATA;
529
526
  readonly result:
@@ -543,9 +540,7 @@ export type EIP1193KnownSubscriptionMessage = EIP1193UnknownMessage & {
543
540
  };
544
541
  };
545
542
 
546
- export type EIP1193SubscriptionMessage =
547
- | EIP1193KnownSubscriptionMessage
548
- | EIP1193UnknownSubscriptionMessage;
543
+ export type EIP1193SubscriptionMessage = EIP1193KnownSubscriptionMessage | EIP1193UnknownSubscriptionMessage;
549
544
 
550
545
  export type EIP1193Message = EIP1193SubscriptionMessage | EIP1193UnknownMessage;
551
546
 
@@ -568,84 +563,215 @@ export type EIP1193SwitchChainError = {
568
563
 
569
564
  type Listener<Message> = (message: Message) => unknown | Promise<unknown>;
570
565
 
571
- export type EIP1193ProviderWithoutEvents<T = EIP1193Request> = {
566
+ export type EIP1193Web3ClientVersionProvider = {
572
567
  request(args: EIP1193Web3ClientVersionRequest): Promise<string>;
568
+ };
569
+
570
+ export type EIP1193Web3SHAProvider = {
573
571
  request(args: EIP1193Web3SHARequest): Promise<EIP1193DATA>;
572
+ };
573
+
574
+ export type EIP1193NetVersionProvider = {
574
575
  request(args: EIP1193NetVersionRequest): Promise<EIP1193ChainId>;
576
+ };
577
+
578
+ export type EIP1193NetListeningProvider = {
575
579
  request(args: EIP1193NetListeningRequest): Promise<boolean>;
580
+ };
581
+
582
+ export type EIP1193NetPeerCountProvider = {
576
583
  request(args: EIP1193NetPeerCountRequest): Promise<EIP1193QUANTITY>;
584
+ };
585
+
586
+ export type EIP1193ProtocolVersionProvider = {
577
587
  request(args: EIP1193ProtocolVersionRequest): Promise<string>;
588
+ };
589
+
590
+ export type EIP1193SyncingProvider = {
578
591
  request(args: EIP1193SyncingRequest): Promise<EIP1193SyncingStatus | false>;
592
+ };
593
+ export type EIP1193CoinbaseProvider = {
579
594
  request(args: EIP1193CoinbaseRequest): Promise<EIP1193Account>;
595
+ };
596
+ export type EIP1193GasPriceProvider = {
580
597
  request(args: EIP1193GasPriceRequest): Promise<EIP1193QUANTITY>;
598
+ };
599
+ export type EIP1193AccountsProvider = {
581
600
  request(args: EIP1193AccountsRequest): Promise<EIP1193Accounts>;
601
+ };
602
+ export type EIP1193BlockNumberProvider = {
582
603
  request(args: EIP1193BlockNumberRequest): Promise<EIP1193QUANTITY>;
604
+ };
605
+ export type EIP1193GetBalanceProvider = {
583
606
  request(args: EIP1193GetBalanceRequest): Promise<EIP1193QUANTITY>;
607
+ };
608
+ export type EIP1193GetStorageAtProvider = {
584
609
  request(args: EIP1193GetStorageAtRequest): Promise<EIP1193DATA>;
610
+ };
611
+ export type EIP1193GetTransactionCountProvider = {
585
612
  request(args: EIP1193GetTransactionCountRequest): Promise<EIP1193QUANTITY>;
586
- request(
587
- args: EIP1193GetTransactionCountByHashRequest
588
- ): Promise<EIP1193QUANTITY>;
589
- request(
590
- args: EIP1193GetTransactionCountByNumberRequest
591
- ): Promise<EIP1193QUANTITY>;
592
-
593
- request(
594
- args: EIP1193GetUncleCountByBlockHashRequest
595
- ): Promise<EIP1193QUANTITY>;
596
- request(
597
- args: EIP1193GetUncleCountByBlockNumberRequest
598
- ): Promise<EIP1193QUANTITY>;
613
+ };
614
+ export type EIP1193GetTransactionCountByHashProvider = {
615
+ request(args: EIP1193GetTransactionCountByHashRequest): Promise<EIP1193QUANTITY>;
616
+ };
617
+ export type EIP1193GetTransactionCountByNumberProvider = {
618
+ request(args: EIP1193GetTransactionCountByNumberRequest): Promise<EIP1193QUANTITY>;
619
+ };
620
+
621
+ export type EIP1193GetUncleCountByBlockHashProvider = {
622
+ request(args: EIP1193GetUncleCountByBlockHashRequest): Promise<EIP1193QUANTITY>;
623
+ };
624
+
625
+ export type EIP1193GetUncleCountByBlockNumberProvider = {
626
+ request(args: EIP1193GetUncleCountByBlockNumberRequest): Promise<EIP1193QUANTITY>;
627
+ };
628
+
629
+ export type EIP1193GetCodeProvider = {
599
630
  request(args: EIP1193GetCodeRequest): Promise<EIP1193DATA>;
631
+ };
632
+
633
+ export type EIP1193LegacySignProvider = {
600
634
  request(args: EIP1193LegacySignRequest): Promise<EIP1193DATA>;
635
+ };
636
+
637
+ export type EIP1193SignTransactionProvider = {
601
638
  request(args: EIP1193SignTransactionRequest): Promise<EIP1193DATA>;
639
+ };
640
+
641
+ export type EIP1193SendTransactionProvider = {
602
642
  request(args: EIP1193SendTransactionRequest): Promise<EIP1193DATA>;
643
+ };
644
+
645
+ export type EIP1193SendRawTransactionProvider = {
603
646
  request(args: EIP1193SendRawTransactionRequest): Promise<EIP1193DATA>;
647
+ };
648
+
649
+ export type EIP1193CallProvider = {
604
650
  request(args: EIP1193CallRequest): Promise<EIP1193DATA>;
651
+ };
652
+
653
+ export type EIP1193EstimateGasProvider = {
605
654
  request(args: EIP1193EstimateGasRequest): Promise<EIP1193QUANTITY>;
655
+ };
656
+
657
+ export type EIP1193GetBlockByHashProvider = {
606
658
  request(args: EIP1193GetBlockByHashRequest): Promise<EIP1193Block | null>;
659
+ request(args: EIP1193GetBlockByHashRequest<true>): Promise<EIP1193BlockWithTransactions | null>;
660
+ };
661
+
662
+ export type EIP1193GetBlockByNumberProvider = {
607
663
  request(args: EIP1193GetBlockByNumberRequest): Promise<EIP1193Block | null>;
608
- request(
609
- args: EIP1193GetBlockByHashRequest<true>
610
- ): Promise<EIP1193BlockWithTransactions | null>;
611
- request(
612
- args: EIP1193GetBlockByNumberRequest<true>
613
- ): Promise<EIP1193BlockWithTransactions | null>;
664
+ request(args: EIP1193GetBlockByNumberRequest<true>): Promise<EIP1193BlockWithTransactions | null>;
665
+ };
666
+
667
+ export type EIP1193GetTransactionByHashProvider = {
614
668
  request(args: EIP1193GetTransactionByHashRequest): Promise<EIP1193Transaction | null>;
615
- request(
616
- args: EIP1193GetTransactionByBlockHashAndIndexRequest
617
- ): Promise<EIP1193Transaction | null>;
618
- request(
619
- args: EIP1193GetTransactionByBlockNumberAndIndexRequest
620
- ): Promise<EIP1193Transaction | null>;
621
- request(
622
- args: EIP1193GetTransactionReceiptRequest
623
- ): Promise<EIP1193TransactionReceipt | null>;
624
- request(
625
- args: EIP1193GetUncleByBlockHashAndIndexRequest
626
- ): Promise<EIP1193Block | null>;
627
- request(
628
- args: EIP1193GetUncleByBlockNumberAndIndexRequest
629
- ): Promise<EIP1193Block | null>;
669
+ };
670
+ export type EIP1193GetTransactionByBlockHashAndIndexProvider = {
671
+ request(args: EIP1193GetTransactionByBlockHashAndIndexRequest): Promise<EIP1193Transaction | null>;
672
+ };
673
+ export type EIP1193GetTransactionByBlockNumberAndIndexProvider = {
674
+ request(args: EIP1193GetTransactionByBlockNumberAndIndexRequest): Promise<EIP1193Transaction | null>;
675
+ };
676
+ export type EIP1193GetTransactionReceiptProvider = {
677
+ request(args: EIP1193GetTransactionReceiptRequest): Promise<EIP1193TransactionReceipt | null>;
678
+ };
679
+ export type EIP1193GetUncleByBlockHashAndIndexProvider = {
680
+ request(args: EIP1193GetUncleByBlockHashAndIndexRequest): Promise<EIP1193Block | null>;
681
+ };
682
+ export type EIP1193GetUncleByBlockNumberAndIndexProvider = {
683
+ request(args: EIP1193GetUncleByBlockNumberAndIndexRequest): Promise<EIP1193Block | null>;
684
+ };
685
+ export type EIP1193GetLogsProvider = {
630
686
  request(args: EIP1193GetLogsRequest): Promise<EIP1193Log[]>;
687
+ };
688
+ export type EIP1193PersonalSignProvider = {
631
689
  request(args: EIP1193PersonalSignRequest): Promise<EIP1193DATA>;
690
+ };
691
+ export type EIP1193PTypedSignv4Provider = {
632
692
  request(args: EIP1193PTypedSignv4Request): Promise<EIP1193DATA>;
693
+ };
694
+
695
+ export type EIP1193PTypedSignProvider = {
633
696
  request(args: EIP1193PTypedSignRequest): Promise<EIP1193DATA>;
697
+ };
698
+
699
+ export type EIP1193ChainIdProvider = {
634
700
  request(args: EIP1193ChainIdRequest): Promise<EIP1193ChainId>;
701
+ };
702
+
703
+ export type EIP1193RequestAccountsProvider = {
635
704
  request(args: EIP1193RequestAccountsRequest): Promise<EIP1193Accounts>;
636
- request(
637
- args: ERIP1193SwitchChainRequest
638
- ): Promise<EIP1193SwitchChainError | null>;
705
+ };
706
+
707
+ export type ERIP1193SwitchChainProvider = {
708
+ request(args: ERIP1193SwitchChainRequest): Promise<EIP1193SwitchChainError | null>;
709
+ };
710
+
711
+ export type ERIP1193AddChainProvider = {
639
712
  request(args: ERIP1193AddChainRequest): Promise<EIP1193AddChainError | null>;
713
+ };
714
+
715
+ export type EIP1193SubscribtionProvider = {
640
716
  request(args: EIP1193SubscribeRequest): Promise<string>;
641
717
  request(args: EIP1193UnsubscribeRequest): Promise<boolean>;
642
-
643
- request(args: T): Promise<unknown>;
644
- // request(args: EIP1193GenericRequest): Promise<unknown>;
645
718
  };
646
719
 
720
+ export type EIP1193RequestProvider = {
721
+ request<T extends EIP1193GenericRequest>(args: T): Promise<unknown>;
722
+ };
723
+
724
+ export type EIP1193GenericRequestProvider = {
725
+ request(args: EIP1193GenericRequest): Promise<unknown>;
726
+ };
727
+
728
+ export type EIP1193ProviderWithoutEvents = EIP1193Web3ClientVersionProvider &
729
+ EIP1193Web3SHAProvider &
730
+ EIP1193NetVersionProvider &
731
+ EIP1193NetListeningProvider &
732
+ EIP1193NetPeerCountProvider &
733
+ EIP1193ProtocolVersionProvider &
734
+ EIP1193SyncingProvider &
735
+ EIP1193CoinbaseProvider &
736
+ EIP1193GasPriceProvider &
737
+ EIP1193AccountsProvider &
738
+ EIP1193BlockNumberProvider &
739
+ EIP1193GetBalanceProvider &
740
+ EIP1193GetStorageAtProvider &
741
+ EIP1193GetTransactionCountProvider &
742
+ EIP1193GetTransactionCountByHashProvider &
743
+ EIP1193GetTransactionCountByNumberProvider &
744
+ EIP1193GetUncleCountByBlockHashProvider &
745
+ EIP1193GetUncleCountByBlockNumberProvider &
746
+ EIP1193GetCodeProvider &
747
+ EIP1193LegacySignProvider &
748
+ EIP1193SignTransactionProvider &
749
+ EIP1193SendTransactionProvider &
750
+ EIP1193SendRawTransactionProvider &
751
+ EIP1193CallProvider &
752
+ EIP1193EstimateGasProvider &
753
+ EIP1193GetBlockByHashProvider &
754
+ EIP1193GetBlockByNumberProvider &
755
+ EIP1193GetTransactionByHashProvider &
756
+ EIP1193GetTransactionByBlockHashAndIndexProvider &
757
+ EIP1193GetTransactionByBlockNumberAndIndexProvider &
758
+ EIP1193GetTransactionReceiptProvider &
759
+ EIP1193GetUncleByBlockHashAndIndexProvider &
760
+ EIP1193GetUncleByBlockNumberAndIndexProvider &
761
+ EIP1193GetLogsProvider &
762
+ EIP1193PersonalSignProvider &
763
+ EIP1193PTypedSignv4Provider &
764
+ EIP1193PTypedSignProvider &
765
+ EIP1193ChainIdProvider &
766
+ EIP1193RequestAccountsProvider &
767
+ ERIP1193SwitchChainProvider &
768
+ ERIP1193AddChainProvider &
769
+ EIP1193SubscribtionProvider &
770
+ EIP1193RequestProvider; // &
771
+ // EIP1193GenericRequestProvider;
772
+
647
773
  export type EIP1193DebugTraceTransactionRequest = {
648
- readonly method: "debug_traceTransaction";
774
+ readonly method: 'debug_traceTransaction';
649
775
  readonly params: [EIP1193DATA];
650
776
  };
651
777
 
@@ -655,94 +781,77 @@ export type EIP1193TracedTransaction = {
655
781
  returnValue: EIP1193DATA;
656
782
  structLogs: any[]; // TODO
657
783
  // TODO more
658
- }
784
+ };
659
785
 
660
- export type EIP1193ProviderExtraMethods = {
786
+ export type EIP1193DebugTraceTransactionProvider = {
661
787
  request(args: EIP1193DebugTraceTransactionRequest): Promise<EIP1193TracedTransaction>;
662
788
  };
663
789
 
664
- // export interface EIP1193ProviderWithBasicEvents<T = EIP1193Request>
665
- // extends BareEIP1193Provider<T> {
666
- // on(
667
- // eventName: "disconnect",
668
- // listener: Listener<EIP1193ProviderRpcError>
669
- // ): this;
670
- // on(eventName: "accountsChanged", listener: Listener<EIP1193Account[]>): this;
671
- // on(eventName: "chainChanged", listener: Listener<EIP1193ChainId>): this;
672
- // on(eventName: "connect", listener: Listener<EIP1193ConnectInfoMessage>): this;
673
-
674
- // removeListener(
675
- // eventName: "disconnect",
676
- // listener: Listener<EIP1193ProviderRpcError>
677
- // ): this;
678
- // removeListener(
679
- // eventName: "accountsChanged",
680
- // listener: Listener<EIP1193Account[]>
681
- // ): this;
682
- // removeListener(
683
- // eventName: "chainChanged",
684
- // listener: Listener<EIP1193ChainId>
685
- // ): this;
686
- // removeListener(
687
- // eventName: "connect",
688
- // listener: Listener<EIP1193ConnectInfoMessage>
689
- // ): this;
690
- // }
691
-
692
- export interface EIP1193Provider<T = EIP1193Request>
693
- extends EIP1193ProviderWithoutEvents<T> {
694
- on(eventName: "message", listener: Listener<EIP1193Message>): this;
695
- on(
696
- eventName: "disconnect",
697
- listener: Listener<EIP1193ProviderRpcError>
698
- ): this;
699
- on(eventName: "accountsChanged", listener: Listener<EIP1193Account[]>): this;
700
- on(eventName: "chainChanged", listener: Listener<EIP1193ChainId>): this;
701
- on(eventName: "connect", listener: Listener<EIP1193ConnectInfoMessage>): this;
702
- removeListener(
703
- eventName: "message",
704
- listener: Listener<EIP1193Message>
705
- ): this;
706
- removeListener(
707
- eventName: "disconnect",
708
- listener: Listener<EIP1193ProviderRpcError>
709
- ): this;
710
- removeListener(
711
- eventName: "accountsChanged",
712
- listener: Listener<EIP1193Account[]>
713
- ): this;
714
- removeListener(
715
- eventName: "chainChanged",
716
- listener: Listener<EIP1193ChainId>
717
- ): this;
718
- removeListener(
719
- eventName: "connect",
720
- listener: Listener<EIP1193ConnectInfoMessage>
721
- ): this;
722
- // removeListener(
723
- // eventName: string | symbol,
724
- // listener: Listener<unknown>
725
- // ): this;
790
+ export type EIP1193WalletProvider = EIP1193Provider;
791
+
792
+ export type EIP1193SignerProvider = EIP1193AccountsProvider &
793
+ EIP1193LegacySignProvider &
794
+ EIP1193SignTransactionProvider &
795
+ EIP1193PersonalSignProvider &
796
+ EIP1193PTypedSignv4Provider &
797
+ EIP1193PTypedSignProvider;
798
+
799
+ export type EIP1193DebugProvider = EIP1193ProviderWithoutEvents &
800
+ EIP1193GenericRequestProvider &
801
+ EIP1193DebugTraceTransactionProvider;
802
+
803
+ export interface EIP1193OnMessageProvider {
804
+ on(eventName: 'message', listener: Listener<EIP1193Message>): this;
805
+ removeListener(eventName: 'message', listener: Listener<EIP1193Message>): this;
806
+ }
807
+
808
+ export interface EIP1193OnConnectionProvider {
809
+ on(eventName: 'connect', listener: Listener<EIP1193ConnectInfoMessage>): this;
810
+ on(eventName: 'disconnect', listener: Listener<EIP1193ProviderRpcError>): this;
811
+ removeListener(eventName: 'connect', listener: Listener<EIP1193ConnectInfoMessage>): this;
812
+ removeListener(eventName: 'disconnect', listener: Listener<EIP1193ProviderRpcError>): this;
813
+ }
814
+
815
+ export interface EIP1193OnAccountsChangedProvider {
816
+ on(eventName: 'accountsChanged', listener: Listener<EIP1193Account[]>): this;
817
+ removeListener(eventName: 'accountsChanged', listener: Listener<EIP1193Account[]>): this;
818
+ }
819
+
820
+ export interface EIP1193OnChainChangedProvider {
821
+ on(eventName: 'chainChanged', listener: Listener<EIP1193ChainId>): this;
822
+ removeListener(eventName: 'chainChanged', listener: Listener<EIP1193ChainId>): this;
823
+ }
824
+
825
+ export interface EIP1193EventsProvider {
826
+ on(eventName: 'message', listener: Listener<EIP1193Message>): this;
827
+ removeListener(eventName: 'message', listener: Listener<EIP1193Message>): this;
828
+
829
+ on(eventName: 'connect', listener: Listener<EIP1193ConnectInfoMessage>): this;
830
+ on(eventName: 'disconnect', listener: Listener<EIP1193ProviderRpcError>): this;
831
+ removeListener(eventName: 'connect', listener: Listener<EIP1193ConnectInfoMessage>): this;
832
+ removeListener(eventName: 'disconnect', listener: Listener<EIP1193ProviderRpcError>): this;
833
+
834
+ on(eventName: 'accountsChanged', listener: Listener<EIP1193Account[]>): this;
835
+ removeListener(eventName: 'accountsChanged', listener: Listener<EIP1193Account[]>): this;
836
+
837
+ on(eventName: 'chainChanged', listener: Listener<EIP1193ChainId>): this;
838
+ removeListener(eventName: 'chainChanged', listener: Listener<EIP1193ChainId>): this;
726
839
  }
727
840
 
841
+ export interface EIP1193Provider extends EIP1193ProviderWithoutEvents, EIP1193EventsProvider {}
842
+
728
843
  export type EIP1193DATA = `0x${string}`;
729
- export type EIP1193BlockTag =
730
- | EIP1193QUANTITY
731
- | "latest"
732
- | "earliest"
733
- | "pending"
734
- | "safe"
735
- | "finalized";
844
+ export type EIP1193BlockTag = EIP1193QUANTITY | 'latest' | 'earliest' | 'pending' | 'safe' | 'finalized';
736
845
 
737
846
  export type EIP1898BlockTag =
738
847
  | EIP1193QUANTITY
739
- | "latest"
740
- | "earliest"
741
- | "pending"
742
- | "safe"
743
- | "finalized"
744
- | { blockHash: EIP1193QUANTITY; requireCanonical?: boolean } // EIP-1898
745
- | { blockNumber: EIP1193QUANTITY }; // EIP-1898
848
+ | 'latest'
849
+ | 'earliest'
850
+ | 'pending'
851
+ | 'safe'
852
+ | 'finalized'
853
+ | {blockHash: EIP1193QUANTITY; requireCanonical?: boolean} // EIP-1898
854
+ | {blockNumber: EIP1193QUANTITY}; // EIP-1898
746
855
 
747
856
  export type EIP1193QUANTITY = `0x${string}`;
748
857
  export type EIP1193ChainId = `0x${string}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eip-1193",
3
- "version": "0.4.0",
3
+ "version": "0.4.3",
4
4
  "description": "Types for EIP-1193 ethereum provider",
5
5
  "keywords": ["ethereum", "eip-1193"],
6
6
  "author": "Ronan Sandford",