eip-1193 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +97 -38
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -358,9 +358,29 @@ export type ERIP1193AddChainRequest = {
|
|
|
358
358
|
readonly params: [EIP1193AddChainParam];
|
|
359
359
|
};
|
|
360
360
|
|
|
361
|
-
export type
|
|
361
|
+
export type EIP1193OtherSubscribeRequest = {
|
|
362
362
|
readonly method: "eth_subscribe";
|
|
363
|
-
readonly params: ["newHeads"];
|
|
363
|
+
readonly params: ["newHeads" | "newPendingTransactions" | "syncing"];
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
export type EIP1193LogsSubscribeRequest = {
|
|
367
|
+
readonly method: "eth_subscribe";
|
|
368
|
+
readonly params: [
|
|
369
|
+
"logs",
|
|
370
|
+
{
|
|
371
|
+
address: EIP1193Account | EIP1193Account[];
|
|
372
|
+
topics: (EIP1193DATA[] | EIP1193DATA)[];
|
|
373
|
+
}
|
|
374
|
+
];
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
export type EIP1193SubscribeRequest =
|
|
378
|
+
| EIP1193LogsSubscribeRequest
|
|
379
|
+
| EIP1193OtherSubscribeRequest;
|
|
380
|
+
|
|
381
|
+
export type EIP1193UnsubscribeRequest = {
|
|
382
|
+
readonly method: "eth_unsubscribe";
|
|
383
|
+
readonly params: [EIP1193DATA];
|
|
364
384
|
};
|
|
365
385
|
|
|
366
386
|
// ------------------------------------------------------------------------------------------------
|
|
@@ -409,7 +429,9 @@ export type EIP1193Request =
|
|
|
409
429
|
| EIP1193ChainIdRequest
|
|
410
430
|
| EIP1193RequestAccountsRequest
|
|
411
431
|
| ERIP1193SwitchChainRequest
|
|
412
|
-
| ERIP1193AddChainRequest
|
|
432
|
+
| ERIP1193AddChainRequest
|
|
433
|
+
| EIP1193SubscribeRequest
|
|
434
|
+
| EIP1193UnsubscribeRequest;
|
|
413
435
|
|
|
414
436
|
export type EIP1193GenericRequest = {
|
|
415
437
|
method: string;
|
|
@@ -422,22 +444,49 @@ export interface EIP1193ProviderRpcError extends Error {
|
|
|
422
444
|
data?: unknown;
|
|
423
445
|
}
|
|
424
446
|
|
|
425
|
-
export interface
|
|
447
|
+
export interface EIP1193ConnectInfoMessage {
|
|
448
|
+
readonly chainId: EIP1193ChainId;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
export type EIP1193UnknownMessage = {
|
|
426
452
|
readonly type: string;
|
|
427
453
|
readonly data: unknown;
|
|
428
|
-
}
|
|
454
|
+
};
|
|
429
455
|
|
|
430
|
-
export
|
|
456
|
+
export type EIP1193UnknownSubscriptionMessage = EIP1193UnknownMessage & {
|
|
431
457
|
readonly type: "eth_subscription";
|
|
432
458
|
readonly data: {
|
|
433
|
-
readonly subscription:
|
|
459
|
+
readonly subscription: EIP1193DATA;
|
|
434
460
|
readonly result: unknown;
|
|
435
461
|
};
|
|
436
|
-
}
|
|
462
|
+
};
|
|
437
463
|
|
|
438
|
-
export
|
|
439
|
-
readonly
|
|
440
|
-
|
|
464
|
+
export type EIP1193KnownSubscriptionMessage = EIP1193UnknownMessage & {
|
|
465
|
+
readonly type: "eth_subscription";
|
|
466
|
+
readonly data: {
|
|
467
|
+
readonly subscription: EIP1193DATA;
|
|
468
|
+
readonly result:
|
|
469
|
+
| EIP1193Log
|
|
470
|
+
| EIP1193Block
|
|
471
|
+
| EIP1193Transaction
|
|
472
|
+
| {
|
|
473
|
+
syncing: boolean;
|
|
474
|
+
status: {
|
|
475
|
+
startingBlock: number;
|
|
476
|
+
currentBlock: number;
|
|
477
|
+
highestBlock: number;
|
|
478
|
+
pulledStates: number;
|
|
479
|
+
knownStates: number;
|
|
480
|
+
};
|
|
481
|
+
};
|
|
482
|
+
};
|
|
483
|
+
};
|
|
484
|
+
|
|
485
|
+
export type EIP1193SubscriptionMessage =
|
|
486
|
+
| EIP1193KnownSubscriptionMessage
|
|
487
|
+
| EIP1193UnknownSubscriptionMessage;
|
|
488
|
+
|
|
489
|
+
export type EIP1193Message = EIP1193SubscriptionMessage | EIP1193UnknownMessage;
|
|
441
490
|
|
|
442
491
|
export type EIP1193AddChainError = {
|
|
443
492
|
// TODO
|
|
@@ -528,37 +577,47 @@ export type EIP1193ProviderWithoutEvents<T = EIP1193Request> = {
|
|
|
528
577
|
): Promise<EIP1193SwitchChainError | null>;
|
|
529
578
|
request(args: ERIP1193AddChainRequest): Promise<EIP1193AddChainError | null>;
|
|
530
579
|
request(args: EIP1193SubscribeRequest): Promise<string>;
|
|
580
|
+
request(args: EIP1193UnsubscribeRequest): Promise<boolean>;
|
|
581
|
+
|
|
531
582
|
request(args: T): Promise<unknown>;
|
|
532
583
|
// request(args: EIP1193GenericRequest): Promise<unknown>;
|
|
533
584
|
};
|
|
534
585
|
|
|
535
|
-
export
|
|
536
|
-
EIP1193ProviderWithoutEvents<T>
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
586
|
+
export interface EIP1193Provider<T = EIP1193Request>
|
|
587
|
+
extends EIP1193ProviderWithoutEvents<T> {
|
|
588
|
+
on(eventName: "message", listener: Listener<EIP1193Message>): this;
|
|
589
|
+
on(
|
|
590
|
+
eventName: "disconnect",
|
|
591
|
+
listener: Listener<EIP1193ProviderRpcError>
|
|
592
|
+
): this;
|
|
593
|
+
on(eventName: "accountsChanged", listener: Listener<EIP1193Account[]>): this;
|
|
594
|
+
on(eventName: "chainChanged", listener: Listener<EIP1193ChainId>): this;
|
|
595
|
+
on(eventName: "connect", listener: Listener<EIP1193ConnectInfoMessage>): this;
|
|
596
|
+
removeListener(
|
|
597
|
+
eventName: "message",
|
|
598
|
+
listener: Listener<EIP1193Message>
|
|
599
|
+
): this;
|
|
600
|
+
removeListener(
|
|
601
|
+
eventName: "disconnect",
|
|
602
|
+
listener: Listener<EIP1193ProviderRpcError>
|
|
603
|
+
): this;
|
|
604
|
+
removeListener(
|
|
605
|
+
eventName: "accountsChanged",
|
|
606
|
+
listener: Listener<EIP1193Account[]>
|
|
607
|
+
): this;
|
|
608
|
+
removeListener(
|
|
609
|
+
eventName: "chainChanged",
|
|
610
|
+
listener: Listener<EIP1193ChainId>
|
|
611
|
+
): this;
|
|
612
|
+
removeListener(
|
|
613
|
+
eventName: "connect",
|
|
614
|
+
listener: Listener<EIP1193ConnectInfoMessage>
|
|
615
|
+
): this;
|
|
616
|
+
// removeListener(
|
|
617
|
+
// eventName: string | symbol,
|
|
618
|
+
// listener: Listener<unknown>
|
|
619
|
+
// ): this;
|
|
620
|
+
}
|
|
562
621
|
|
|
563
622
|
export type EIP1193DATA = `0x${string}`;
|
|
564
623
|
export type EIP1193BlockTag =
|