@tomo-inc/inject-providers 0.0.12 → 0.0.14
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/README.md +9 -0
- package/dist/index.d.cts +457 -1
- package/dist/index.d.ts +457 -1
- package/package.json +2 -2
- package/src/dogecoin/interface.ts +330 -0
- package/src/evm/interface.ts +189 -0
- package/src/index.ts +4 -0
package/README.md
CHANGED
|
@@ -33,6 +33,15 @@ solana: "solana",
|
|
|
33
33
|
xxxx: "xxxx",
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
+
## WalletProvider interface
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
import { WalletProvider } from "@tomo-inc/inject-providers"
|
|
40
|
+
|
|
41
|
+
WalletProvider = IDogecoinProvider | IEvmProvider;
|
|
42
|
+
WalletProvider.type = "evm" | "dogecoin";
|
|
43
|
+
```
|
|
44
|
+
|
|
36
45
|
## how to use?
|
|
37
46
|
|
|
38
47
|
### 1. namespaces + product info
|
package/dist/index.d.cts
CHANGED
|
@@ -533,4 +533,460 @@ declare class TomoTronProvider extends EventEmitter {
|
|
|
533
533
|
sendToken: (params: any) => Promise<any>;
|
|
534
534
|
}
|
|
535
535
|
|
|
536
|
-
|
|
536
|
+
/**
|
|
537
|
+
* Balance response interface
|
|
538
|
+
*/
|
|
539
|
+
interface IDogecoinBalance {
|
|
540
|
+
confirmed: number;
|
|
541
|
+
unconfirmed: number;
|
|
542
|
+
total: number;
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* Transaction status response interface
|
|
546
|
+
*/
|
|
547
|
+
interface ITransactionStatus {
|
|
548
|
+
status: string;
|
|
549
|
+
confirmations: number;
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* Signed message response interface
|
|
553
|
+
*/
|
|
554
|
+
interface ISignedMessage {
|
|
555
|
+
signedMessage: string;
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* Decrypted message response interface
|
|
559
|
+
*/
|
|
560
|
+
interface IDecryptedMessage {
|
|
561
|
+
decryptedMessage: string;
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* PSBT request parameters interface
|
|
565
|
+
*/
|
|
566
|
+
interface IRequestPsbtParams {
|
|
567
|
+
rawTx: string;
|
|
568
|
+
indexes?: [];
|
|
569
|
+
feeOnly?: boolean;
|
|
570
|
+
signOnly?: boolean;
|
|
571
|
+
partial?: boolean;
|
|
572
|
+
sighashType?: string;
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* PSBT response interface
|
|
576
|
+
*/
|
|
577
|
+
interface IPsbtResponse {
|
|
578
|
+
signedRawTx?: string;
|
|
579
|
+
txId?: string;
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Send options interface
|
|
583
|
+
*/
|
|
584
|
+
interface ISendOptions {
|
|
585
|
+
feeRate?: number;
|
|
586
|
+
memo?: string;
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* Connection status response interface
|
|
590
|
+
*/
|
|
591
|
+
interface IConnectionStatus {
|
|
592
|
+
connected: boolean;
|
|
593
|
+
address: string;
|
|
594
|
+
selectedWalletAddress: string;
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* DRC20 balance response interface
|
|
598
|
+
*/
|
|
599
|
+
interface IDRC20Balance {
|
|
600
|
+
availableBalance: number;
|
|
601
|
+
transferableBalance: number;
|
|
602
|
+
ticker: string;
|
|
603
|
+
address: string;
|
|
604
|
+
}
|
|
605
|
+
/**
|
|
606
|
+
* Transferable DRC20 response interface
|
|
607
|
+
*/
|
|
608
|
+
interface ITransferableDRC20 {
|
|
609
|
+
inscriptions: any[];
|
|
610
|
+
ticker: string;
|
|
611
|
+
address: string;
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* DRC20 transaction response interface
|
|
615
|
+
*/
|
|
616
|
+
interface IDRC20Transaction {
|
|
617
|
+
txId: string;
|
|
618
|
+
ticker: string;
|
|
619
|
+
amount: number;
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* Dunes balance response interface
|
|
623
|
+
*/
|
|
624
|
+
interface IDunesBalance {
|
|
625
|
+
balance: number;
|
|
626
|
+
ticker: string;
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Main interface for DogecoinProvider
|
|
630
|
+
* Extends EventEmitter to support event handling
|
|
631
|
+
*/
|
|
632
|
+
interface IDogecoinProvider extends EventEmitter {
|
|
633
|
+
type: "dogecoin";
|
|
634
|
+
rdns: string;
|
|
635
|
+
name: string;
|
|
636
|
+
/**
|
|
637
|
+
* Connect to the wallet
|
|
638
|
+
* @returns Promise resolving to connection result with address, approved, balance, publicKey
|
|
639
|
+
*/
|
|
640
|
+
connect(): Promise<any>;
|
|
641
|
+
/**
|
|
642
|
+
* Disconnect from the wallet
|
|
643
|
+
* @returns Promise resolving to disconnect result with disconnected status
|
|
644
|
+
*/
|
|
645
|
+
disconnect(): Promise<any>;
|
|
646
|
+
/**
|
|
647
|
+
* Get connection status
|
|
648
|
+
* @returns Promise resolving to connection status with connected, address, selectedWalletAddress
|
|
649
|
+
*/
|
|
650
|
+
getConnectionStatus(): Promise<IConnectionStatus>;
|
|
651
|
+
/**
|
|
652
|
+
* Request accounts from the wallet
|
|
653
|
+
* @returns Promise resolving to array of account addresses
|
|
654
|
+
*/
|
|
655
|
+
requestAccounts(): Promise<string[]>;
|
|
656
|
+
/**
|
|
657
|
+
* Get current accounts
|
|
658
|
+
* @returns Promise resolving to array of account addresses
|
|
659
|
+
*/
|
|
660
|
+
getAccounts(): Promise<string[]>;
|
|
661
|
+
/**
|
|
662
|
+
* Get public key
|
|
663
|
+
* @returns Promise resolving to public key string
|
|
664
|
+
*/
|
|
665
|
+
getPublicKey(): Promise<string>;
|
|
666
|
+
/**
|
|
667
|
+
* Get balance
|
|
668
|
+
* @returns Promise resolving to balance object with confirmed, unconfirmed, and total
|
|
669
|
+
*/
|
|
670
|
+
getBalance(): Promise<IDogecoinBalance>;
|
|
671
|
+
/**
|
|
672
|
+
* Get transaction status
|
|
673
|
+
* @param params - Transaction status parameters
|
|
674
|
+
* @param params.txId - Transaction ID
|
|
675
|
+
* @returns Promise resolving to transaction status
|
|
676
|
+
*/
|
|
677
|
+
getTransactionStatus(params: {
|
|
678
|
+
txId: string;
|
|
679
|
+
}): Promise<ITransactionStatus>;
|
|
680
|
+
/**
|
|
681
|
+
* Request a transaction
|
|
682
|
+
* @param params - Transaction parameters
|
|
683
|
+
* @param params.recipientAddress - Recipient address
|
|
684
|
+
* @param params.dogeAmount - Amount in DOGE
|
|
685
|
+
* @returns Promise resolving to transaction result with txId
|
|
686
|
+
*/
|
|
687
|
+
requestTransaction(params: {
|
|
688
|
+
recipientAddress: string;
|
|
689
|
+
dogeAmount: number;
|
|
690
|
+
}): Promise<{
|
|
691
|
+
txId: string;
|
|
692
|
+
}>;
|
|
693
|
+
/**
|
|
694
|
+
* Send DOGE
|
|
695
|
+
* @param toAddress - Recipient address
|
|
696
|
+
* @param satoshis - Amount in satoshis (optional)
|
|
697
|
+
* @param options - Send options (optional)
|
|
698
|
+
* @returns Promise resolving to transaction ID
|
|
699
|
+
*/
|
|
700
|
+
send(toAddress: string, satoshis?: number, options?: ISendOptions): Promise<string>;
|
|
701
|
+
/**
|
|
702
|
+
* Send DOGE (alias for send)
|
|
703
|
+
* @param toAddress - Recipient address
|
|
704
|
+
* @param satoshis - Amount in satoshis (optional)
|
|
705
|
+
* @param options - Send options (optional)
|
|
706
|
+
* @returns Promise resolving to transaction ID
|
|
707
|
+
*/
|
|
708
|
+
sendDogecoin(toAddress: string, satoshis?: number, options?: ISendOptions): Promise<string>;
|
|
709
|
+
/**
|
|
710
|
+
* Request signed message
|
|
711
|
+
* @param params - Sign message parameters
|
|
712
|
+
* @param params.message - Message to sign
|
|
713
|
+
* @param params.type - Message type (optional)
|
|
714
|
+
* @returns Promise resolving to signed message result
|
|
715
|
+
*/
|
|
716
|
+
requestSignedMessage(params: {
|
|
717
|
+
message: string;
|
|
718
|
+
type?: string;
|
|
719
|
+
}): Promise<ISignedMessage>;
|
|
720
|
+
/**
|
|
721
|
+
* Sign message
|
|
722
|
+
* @param message - Message to sign
|
|
723
|
+
* @param type - Message type (optional)
|
|
724
|
+
* @returns Promise resolving to signed message string
|
|
725
|
+
*/
|
|
726
|
+
signMessage(message: string, type?: string): Promise<string>;
|
|
727
|
+
/**
|
|
728
|
+
* Request decrypted message
|
|
729
|
+
* @param params - Decrypt message parameters
|
|
730
|
+
* @param params.message - Message to decrypt
|
|
731
|
+
* @returns Promise resolving to decrypted message result
|
|
732
|
+
*/
|
|
733
|
+
requestDecryptedMessage(params: {
|
|
734
|
+
message: string;
|
|
735
|
+
}): Promise<IDecryptedMessage>;
|
|
736
|
+
/**
|
|
737
|
+
* Request PSBT
|
|
738
|
+
* @param params - PSBT request parameters
|
|
739
|
+
* @returns Promise resolving to PSBT result with signedRawTx and/or txId
|
|
740
|
+
*/
|
|
741
|
+
requestPsbt(params: IRequestPsbtParams): Promise<IPsbtResponse>;
|
|
742
|
+
/**
|
|
743
|
+
* Sign PSBT
|
|
744
|
+
* @param psbtHex - PSBT hex string
|
|
745
|
+
* @param options - Sign options (optional)
|
|
746
|
+
* @returns Promise resolving to signed PSBT hex string
|
|
747
|
+
*/
|
|
748
|
+
signPsbt(psbtHex: string, options?: any): Promise<string>;
|
|
749
|
+
/**
|
|
750
|
+
* Sign multiple PSBTs
|
|
751
|
+
* @param psbtHexs - Array of PSBT hex strings
|
|
752
|
+
* @param options - Sign options (optional)
|
|
753
|
+
* @returns Promise resolving to signed PSBTs
|
|
754
|
+
*/
|
|
755
|
+
signPsbts(psbtHexs: string[], options?: any): Promise<any>;
|
|
756
|
+
/**
|
|
757
|
+
* Get DRC20 balances
|
|
758
|
+
* @param address - Address to query
|
|
759
|
+
* @param ticker - Token ticker (optional)
|
|
760
|
+
* @returns Promise resolving to DRC20 balances
|
|
761
|
+
*/
|
|
762
|
+
getDRC20Balances(address: string, ticker?: string): Promise<any>;
|
|
763
|
+
/**
|
|
764
|
+
* Get DRC20 balance
|
|
765
|
+
* @param params - Balance query parameters
|
|
766
|
+
* @param params.ticker - Token ticker (optional)
|
|
767
|
+
* @returns Promise resolving to DRC20 balance
|
|
768
|
+
*/
|
|
769
|
+
getDRC20Balance(params: {
|
|
770
|
+
ticker?: string;
|
|
771
|
+
}): Promise<IDRC20Balance>;
|
|
772
|
+
/**
|
|
773
|
+
* Get transferable DRC20
|
|
774
|
+
* @param params - Transferable query parameters
|
|
775
|
+
* @param params.ticker - Token ticker (optional)
|
|
776
|
+
* @returns Promise resolving to transferable DRC20
|
|
777
|
+
*/
|
|
778
|
+
getTransferableDRC20(params: {
|
|
779
|
+
ticker?: string;
|
|
780
|
+
}): Promise<ITransferableDRC20>;
|
|
781
|
+
/**
|
|
782
|
+
* Request available DRC20 transaction
|
|
783
|
+
* @param params - Transaction parameters
|
|
784
|
+
* @param params.ticker - Token ticker
|
|
785
|
+
* @param params.amount - Amount to transfer
|
|
786
|
+
* @returns Promise resolving to DRC20 transaction result
|
|
787
|
+
*/
|
|
788
|
+
requestAvailableDRC20Transaction(params: {
|
|
789
|
+
ticker: string;
|
|
790
|
+
amount: number;
|
|
791
|
+
}): Promise<IDRC20Transaction>;
|
|
792
|
+
/**
|
|
793
|
+
* Request inscription transaction
|
|
794
|
+
* @param params - Inscription transaction parameters
|
|
795
|
+
* @param params.location - Inscription location
|
|
796
|
+
* @param params.recipientAddress - Recipient address
|
|
797
|
+
* @returns Promise resolving to transaction result with txId
|
|
798
|
+
*/
|
|
799
|
+
requestInscriptionTransaction(params: {
|
|
800
|
+
location: string;
|
|
801
|
+
recipientAddress: string;
|
|
802
|
+
}): Promise<{
|
|
803
|
+
txId: string;
|
|
804
|
+
}>;
|
|
805
|
+
/**
|
|
806
|
+
* Get Dunes balance
|
|
807
|
+
* @param params - Balance query parameters
|
|
808
|
+
* @param params.ticker - Token ticker
|
|
809
|
+
* @returns Promise resolving to Dunes balance
|
|
810
|
+
*/
|
|
811
|
+
getDunesBalance(params: {
|
|
812
|
+
ticker: string;
|
|
813
|
+
}): Promise<IDunesBalance>;
|
|
814
|
+
/**
|
|
815
|
+
* Request Dunes transaction
|
|
816
|
+
* @param params - Transaction parameters
|
|
817
|
+
* @param params.ticker - Token ticker
|
|
818
|
+
* @param params.amount - Amount to transfer
|
|
819
|
+
* @param params.recipientAddress - Recipient address
|
|
820
|
+
* @returns Promise resolving to transaction result
|
|
821
|
+
*/
|
|
822
|
+
requestDunesTransaction(params: {
|
|
823
|
+
ticker: string;
|
|
824
|
+
amount: number;
|
|
825
|
+
recipientAddress: string;
|
|
826
|
+
}): Promise<any>;
|
|
827
|
+
/**
|
|
828
|
+
* Generic request method
|
|
829
|
+
* @param params - Request parameters
|
|
830
|
+
* @param params.method - RPC method name
|
|
831
|
+
* @param params.params - Method parameters
|
|
832
|
+
* @returns Promise resolving to request result
|
|
833
|
+
*/
|
|
834
|
+
request(params: {
|
|
835
|
+
method: string;
|
|
836
|
+
params: any;
|
|
837
|
+
}): Promise<any>;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
/**
|
|
841
|
+
* Connect event data interface
|
|
842
|
+
*/
|
|
843
|
+
interface IConnectEvent {
|
|
844
|
+
chainId?: string;
|
|
845
|
+
}
|
|
846
|
+
/**
|
|
847
|
+
* Disconnect event data interface
|
|
848
|
+
*/
|
|
849
|
+
interface IDisconnectEvent {
|
|
850
|
+
code: number;
|
|
851
|
+
message: string;
|
|
852
|
+
data?: unknown;
|
|
853
|
+
}
|
|
854
|
+
/**
|
|
855
|
+
* Main interface for EvmProvider
|
|
856
|
+
* Extends EventEmitter to support event handling
|
|
857
|
+
* Implements EIP-1193 standard
|
|
858
|
+
*/
|
|
859
|
+
interface IEvmProvider extends EventEmitter {
|
|
860
|
+
type: "evm";
|
|
861
|
+
/**
|
|
862
|
+
* The chain ID of the currently connected Ethereum chain.
|
|
863
|
+
* See https://chainid.network for more information.
|
|
864
|
+
*/
|
|
865
|
+
chainId: string | null;
|
|
866
|
+
/**
|
|
867
|
+
* The user's currently selected Ethereum address.
|
|
868
|
+
* If null, wallet is either locked or the user has not permitted any
|
|
869
|
+
* addresses to be viewed.
|
|
870
|
+
*/
|
|
871
|
+
selectedAddress: string | null;
|
|
872
|
+
/**
|
|
873
|
+
* Provider name
|
|
874
|
+
*/
|
|
875
|
+
name: string;
|
|
876
|
+
/**
|
|
877
|
+
* Provider icon
|
|
878
|
+
*/
|
|
879
|
+
icon: string;
|
|
880
|
+
/**
|
|
881
|
+
* Returns whether the provider can process RPC requests.
|
|
882
|
+
* @returns true if connected, false otherwise
|
|
883
|
+
*/
|
|
884
|
+
isConnected(): boolean;
|
|
885
|
+
/**
|
|
886
|
+
* Submits an RPC request for the given method, with the given params.
|
|
887
|
+
* Resolves with the result of the method call, or rejects on error.
|
|
888
|
+
*
|
|
889
|
+
* @param args - The RPC request arguments.
|
|
890
|
+
* @param args.method - The RPC method name.
|
|
891
|
+
* @param args.params - The parameters for the RPC method.
|
|
892
|
+
* @returns A Promise that resolves with the result of the RPC method,
|
|
893
|
+
* or rejects if an error is encountered.
|
|
894
|
+
*/
|
|
895
|
+
request<T = unknown>(args: RequestArguments): Promise<Maybe<T>>;
|
|
896
|
+
/**
|
|
897
|
+
* Connect to the wallet
|
|
898
|
+
* Equivalent to: ethereum.request('eth_requestAccounts')
|
|
899
|
+
* @returns Promise resolving to array of account addresses
|
|
900
|
+
*/
|
|
901
|
+
connect(): Promise<string[]>;
|
|
902
|
+
/**
|
|
903
|
+
* Disconnect from the wallet
|
|
904
|
+
* @returns Promise resolving to boolean indicating disconnect status
|
|
905
|
+
*/
|
|
906
|
+
disconnect(): Promise<boolean>;
|
|
907
|
+
/**
|
|
908
|
+
* Equivalent to: ethereum.request('eth_requestAccounts')
|
|
909
|
+
* @deprecated Use request({ method: 'eth_requestAccounts' }) instead.
|
|
910
|
+
* @returns Promise resolving to array of addresses
|
|
911
|
+
*/
|
|
912
|
+
enable(): Promise<string[]>;
|
|
913
|
+
/**
|
|
914
|
+
* Submits an RPC request for the given method, with the given params.
|
|
915
|
+
* @deprecated Use request() instead.
|
|
916
|
+
* @param method - The method to request.
|
|
917
|
+
* @param params - Any params for the method.
|
|
918
|
+
* @returns A Promise that resolves with the JSON-RPC response object for the request.
|
|
919
|
+
*/
|
|
920
|
+
send<T>(method: string, params?: T[]): Promise<JsonRpcResponse<T>>;
|
|
921
|
+
/**
|
|
922
|
+
* Submits an RPC request per the given JSON-RPC request object.
|
|
923
|
+
* @deprecated Use request() instead.
|
|
924
|
+
* @param payload - A JSON-RPC request object.
|
|
925
|
+
* @param callback - An error-first callback that will receive the JSON-RPC response object.
|
|
926
|
+
*/
|
|
927
|
+
send<T>(payload: JsonRpcRequest<unknown>, callback: (error: Error | null, result?: JsonRpcResponse<T>) => void): void;
|
|
928
|
+
/**
|
|
929
|
+
* Accepts a JSON-RPC request object, and synchronously returns the cached result
|
|
930
|
+
* for the given method. Only supports 4 specific RPC methods.
|
|
931
|
+
* @deprecated Use request() instead.
|
|
932
|
+
* @param payload - A JSON-RPC request object.
|
|
933
|
+
* @returns A JSON-RPC response object.
|
|
934
|
+
*/
|
|
935
|
+
send<T>(payload: SendSyncJsonRpcRequest): JsonRpcResponse<T>;
|
|
936
|
+
/**
|
|
937
|
+
* Adds a listener for the specified event.
|
|
938
|
+
* @param eventName - Event name
|
|
939
|
+
* @param listener - Event listener function
|
|
940
|
+
* @returns This instance for chaining
|
|
941
|
+
*/
|
|
942
|
+
on(eventName: string, listener: (...args: unknown[]) => void): this;
|
|
943
|
+
/**
|
|
944
|
+
* Adds a one-time listener for the specified event.
|
|
945
|
+
* @param eventName - Event name
|
|
946
|
+
* @param listener - Event listener function
|
|
947
|
+
* @returns This instance for chaining
|
|
948
|
+
*/
|
|
949
|
+
once(eventName: string, listener: (...args: unknown[]) => void): this;
|
|
950
|
+
/**
|
|
951
|
+
* Emitted when the provider connects to a chain.
|
|
952
|
+
* @event
|
|
953
|
+
*/
|
|
954
|
+
on(event: "connect", listener: (connectInfo: IConnectEvent) => void): this;
|
|
955
|
+
/**
|
|
956
|
+
* Emitted when the provider disconnects from a chain.
|
|
957
|
+
* @event
|
|
958
|
+
*/
|
|
959
|
+
on(event: "disconnect", listener: (error: IDisconnectEvent) => void): this;
|
|
960
|
+
/**
|
|
961
|
+
* Emitted when the chain ID changes.
|
|
962
|
+
* @event
|
|
963
|
+
*/
|
|
964
|
+
on(event: "chainChanged", listener: (chainId: string) => void): this;
|
|
965
|
+
/**
|
|
966
|
+
* Emitted when accounts change.
|
|
967
|
+
* @event
|
|
968
|
+
*/
|
|
969
|
+
on(event: "accountsChanged", listener: (accounts: string[]) => void): this;
|
|
970
|
+
/**
|
|
971
|
+
* Emitted when the connection closes (deprecated).
|
|
972
|
+
* @event
|
|
973
|
+
* @deprecated
|
|
974
|
+
*/
|
|
975
|
+
on(event: "close", listener: (error: IDisconnectEvent) => void): this;
|
|
976
|
+
/**
|
|
977
|
+
* Emitted when data is received (deprecated).
|
|
978
|
+
* @event
|
|
979
|
+
* @deprecated
|
|
980
|
+
*/
|
|
981
|
+
on(event: "data", listener: (payload: unknown) => void): this;
|
|
982
|
+
/**
|
|
983
|
+
* Emitted when the network changes (deprecated).
|
|
984
|
+
* @event
|
|
985
|
+
* @deprecated
|
|
986
|
+
*/
|
|
987
|
+
on(event: "networkChanged", listener: (networkId: string) => void): this;
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
type WalletProvider = IDogecoinProvider | IEvmProvider;
|
|
991
|
+
|
|
992
|
+
export { BtcProvider, DogecoinProvider, EvmProvider, PhantomProvider as SolanaProvider, TomoTronProvider as TronProvider, type WalletProvider };
|