@tomo-inc/inject-providers 0.0.13 → 0.0.15
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.cjs +32 -23
- package/dist/index.d.cts +513 -10
- package/dist/index.d.ts +513 -10
- package/dist/index.js +32 -23
- package/package.json +2 -2
- package/src/btc/index.ts +2 -2
- package/src/btc/types.ts +8 -3
- package/src/btc/unisat.ts +14 -8
- package/src/dogecoin/dogecoin.ts +4 -4
- package/src/dogecoin/interface.ts +331 -0
- package/src/evm/interface.ts +189 -0
- package/src/evm/metamask.ts +7 -7
- package/src/index.ts +6 -2
- package/src/solana/phantom.ts +3 -4
- package/src/tron/tronLink.ts +12 -9
- package/src/tron/types.ts +5 -2
- package/src/types/index.ts +2 -13
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
|
+
import { ChainTypeEnum } from '@tomo-inc/wallet-utils';
|
|
2
3
|
import { JsonRpcRequest, JsonRpcResponse } from 'json-rpc-engine';
|
|
3
4
|
import { Cluster, PublicKey, VersionedTransaction, Transaction } from '@solana/web3.js';
|
|
4
|
-
import { TronWeb } from 'tronweb';
|
|
5
|
-
import { Transaction as Transaction$1 } from 'tronweb/lib/esm/types/Transaction';
|
|
5
|
+
import { TronWeb as TronWeb$1 } from 'tronweb';
|
|
6
|
+
import { Transaction as Transaction$1, SignedTransaction } from 'tronweb/lib/esm/types/Transaction';
|
|
7
|
+
import { TronLinkWallet, TronWeb } from '@tronweb3/tronwallet-adapter-tronlink';
|
|
6
8
|
|
|
7
9
|
interface IProductInfo {
|
|
8
10
|
name: string;
|
|
@@ -21,6 +23,32 @@ type Balance = {
|
|
|
21
23
|
unconfirmed: number;
|
|
22
24
|
total: number;
|
|
23
25
|
};
|
|
26
|
+
type SignMessageType = "ecdsa" | "bip322-simple";
|
|
27
|
+
interface IBitcoinProvider {
|
|
28
|
+
type: ChainTypeEnum.BITCOIN;
|
|
29
|
+
connect: () => Promise<any>;
|
|
30
|
+
disconnect: () => Promise<any>;
|
|
31
|
+
requestAccounts: () => Promise<any>;
|
|
32
|
+
getAccounts: () => Promise<any>;
|
|
33
|
+
getPublicKey: () => Promise<any>;
|
|
34
|
+
getBalance: () => Promise<any>;
|
|
35
|
+
getTransactionStatus: (params: {
|
|
36
|
+
txId: string;
|
|
37
|
+
}) => Promise<any>;
|
|
38
|
+
signMessage: (text: string, type: SignMessageType) => Promise<any>;
|
|
39
|
+
getNetwork: () => Promise<any>;
|
|
40
|
+
switchNetwork: (network: Network) => Promise<any>;
|
|
41
|
+
getChain: () => Promise<any>;
|
|
42
|
+
switchChain: (chainId: any) => Promise<any>;
|
|
43
|
+
networkChanged?: (network: Network) => Promise<any>;
|
|
44
|
+
chainChanged?: (chainId: ChainId) => Promise<any>;
|
|
45
|
+
signPsbt: (psbtHex: string, options?: any) => Promise<any>;
|
|
46
|
+
signPsbts?: (psbtHexs: string[], options?: any[]) => Promise<any>;
|
|
47
|
+
signTx: (rawtx: string) => Promise<any>;
|
|
48
|
+
pushTx: (rawtx: string) => Promise<any>;
|
|
49
|
+
sendTransaction: (params: any) => Promise<any>;
|
|
50
|
+
sendBitcoin: (rawtx: string) => Promise<any>;
|
|
51
|
+
}
|
|
24
52
|
|
|
25
53
|
interface StateProvider$3 {
|
|
26
54
|
accounts: string[] | null;
|
|
@@ -29,7 +57,8 @@ interface StateProvider$3 {
|
|
|
29
57
|
initialized: boolean;
|
|
30
58
|
isPermanentlyDisconnected: boolean;
|
|
31
59
|
}
|
|
32
|
-
declare class
|
|
60
|
+
declare class BitcoinProvider extends EventEmitter implements IBitcoinProvider {
|
|
61
|
+
type: ChainTypeEnum.BITCOIN;
|
|
33
62
|
_selectedAddress: string | null;
|
|
34
63
|
_isConnected: boolean;
|
|
35
64
|
_initialized: boolean;
|
|
@@ -70,7 +99,7 @@ declare class BtcProvider extends EventEmitter {
|
|
|
70
99
|
getTransactionStatus: ({ txId }: {
|
|
71
100
|
txId: string;
|
|
72
101
|
}) => Promise<any>;
|
|
73
|
-
signMessage: (text: string, type?:
|
|
102
|
+
signMessage: (text: string, type?: SignMessageType) => Promise<string>;
|
|
74
103
|
getNetwork: () => Promise<any>;
|
|
75
104
|
switchNetwork: (network: Network) => Promise<any>;
|
|
76
105
|
getChain: () => Promise<any>;
|
|
@@ -83,6 +112,311 @@ declare class BtcProvider extends EventEmitter {
|
|
|
83
112
|
}) => Promise<string>;
|
|
84
113
|
signTx: (rawtx: string) => Promise<any>;
|
|
85
114
|
pushTx: (rawtx: string) => Promise<string>;
|
|
115
|
+
sendTransaction: (params: any) => Promise<any>;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Balance response interface
|
|
120
|
+
*/
|
|
121
|
+
interface IDogecoinBalance {
|
|
122
|
+
confirmed: number;
|
|
123
|
+
unconfirmed: number;
|
|
124
|
+
total: number;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Transaction status response interface
|
|
128
|
+
*/
|
|
129
|
+
interface ITransactionStatus {
|
|
130
|
+
status: string;
|
|
131
|
+
confirmations: number;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Signed message response interface
|
|
135
|
+
*/
|
|
136
|
+
interface ISignedMessage {
|
|
137
|
+
signedMessage: string;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Decrypted message response interface
|
|
141
|
+
*/
|
|
142
|
+
interface IDecryptedMessage {
|
|
143
|
+
decryptedMessage: string;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* PSBT request parameters interface
|
|
147
|
+
*/
|
|
148
|
+
interface IRequestPsbtParams {
|
|
149
|
+
rawTx: string;
|
|
150
|
+
indexes?: [];
|
|
151
|
+
feeOnly?: boolean;
|
|
152
|
+
signOnly?: boolean;
|
|
153
|
+
partial?: boolean;
|
|
154
|
+
sighashType?: string;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* PSBT response interface
|
|
158
|
+
*/
|
|
159
|
+
interface IPsbtResponse {
|
|
160
|
+
signedRawTx?: string;
|
|
161
|
+
txId?: string;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Send options interface
|
|
165
|
+
*/
|
|
166
|
+
interface ISendOptions {
|
|
167
|
+
feeRate?: number;
|
|
168
|
+
memo?: string;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Connection status response interface
|
|
172
|
+
*/
|
|
173
|
+
interface IConnectionStatus {
|
|
174
|
+
connected: boolean;
|
|
175
|
+
address: string;
|
|
176
|
+
selectedWalletAddress: string;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* DRC20 balance response interface
|
|
180
|
+
*/
|
|
181
|
+
interface IDRC20Balance {
|
|
182
|
+
availableBalance: number;
|
|
183
|
+
transferableBalance: number;
|
|
184
|
+
ticker: string;
|
|
185
|
+
address: string;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Transferable DRC20 response interface
|
|
189
|
+
*/
|
|
190
|
+
interface ITransferableDRC20 {
|
|
191
|
+
inscriptions: any[];
|
|
192
|
+
ticker: string;
|
|
193
|
+
address: string;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* DRC20 transaction response interface
|
|
197
|
+
*/
|
|
198
|
+
interface IDRC20Transaction {
|
|
199
|
+
txId: string;
|
|
200
|
+
ticker: string;
|
|
201
|
+
amount: number;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Dunes balance response interface
|
|
205
|
+
*/
|
|
206
|
+
interface IDunesBalance {
|
|
207
|
+
balance: number;
|
|
208
|
+
ticker: string;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Main interface for DogecoinProvider
|
|
212
|
+
* Extends EventEmitter to support event handling
|
|
213
|
+
*/
|
|
214
|
+
interface IDogecoinProvider extends EventEmitter {
|
|
215
|
+
type: ChainTypeEnum.DOGECOIN;
|
|
216
|
+
rdns: string;
|
|
217
|
+
name: string;
|
|
218
|
+
/**
|
|
219
|
+
* Connect to the wallet
|
|
220
|
+
* @returns Promise resolving to connection result with address, approved, balance, publicKey
|
|
221
|
+
*/
|
|
222
|
+
connect(): Promise<any>;
|
|
223
|
+
/**
|
|
224
|
+
* Disconnect from the wallet
|
|
225
|
+
* @returns Promise resolving to disconnect result with disconnected status
|
|
226
|
+
*/
|
|
227
|
+
disconnect(): Promise<any>;
|
|
228
|
+
/**
|
|
229
|
+
* Get connection status
|
|
230
|
+
* @returns Promise resolving to connection status with connected, address, selectedWalletAddress
|
|
231
|
+
*/
|
|
232
|
+
getConnectionStatus(): Promise<IConnectionStatus>;
|
|
233
|
+
/**
|
|
234
|
+
* Request accounts from the wallet
|
|
235
|
+
* @returns Promise resolving to array of account addresses
|
|
236
|
+
*/
|
|
237
|
+
requestAccounts(): Promise<string[]>;
|
|
238
|
+
/**
|
|
239
|
+
* Get current accounts
|
|
240
|
+
* @returns Promise resolving to array of account addresses
|
|
241
|
+
*/
|
|
242
|
+
getAccounts(): Promise<string[]>;
|
|
243
|
+
/**
|
|
244
|
+
* Get public key
|
|
245
|
+
* @returns Promise resolving to public key string
|
|
246
|
+
*/
|
|
247
|
+
getPublicKey(): Promise<string>;
|
|
248
|
+
/**
|
|
249
|
+
* Get balance
|
|
250
|
+
* @returns Promise resolving to balance object with confirmed, unconfirmed, and total
|
|
251
|
+
*/
|
|
252
|
+
getBalance(): Promise<IDogecoinBalance>;
|
|
253
|
+
/**
|
|
254
|
+
* Get transaction status
|
|
255
|
+
* @param params - Transaction status parameters
|
|
256
|
+
* @param params.txId - Transaction ID
|
|
257
|
+
* @returns Promise resolving to transaction status
|
|
258
|
+
*/
|
|
259
|
+
getTransactionStatus(params: {
|
|
260
|
+
txId: string;
|
|
261
|
+
}): Promise<ITransactionStatus>;
|
|
262
|
+
/**
|
|
263
|
+
* Request a transaction
|
|
264
|
+
* @param params - Transaction parameters
|
|
265
|
+
* @param params.recipientAddress - Recipient address
|
|
266
|
+
* @param params.dogeAmount - Amount in DOGE
|
|
267
|
+
* @returns Promise resolving to transaction result with txId
|
|
268
|
+
*/
|
|
269
|
+
requestTransaction(params: {
|
|
270
|
+
recipientAddress: string;
|
|
271
|
+
dogeAmount: number;
|
|
272
|
+
}): Promise<{
|
|
273
|
+
txId: string;
|
|
274
|
+
}>;
|
|
275
|
+
/**
|
|
276
|
+
* Send DOGE
|
|
277
|
+
* @param toAddress - Recipient address
|
|
278
|
+
* @param satoshis - Amount in satoshis (optional)
|
|
279
|
+
* @param options - Send options (optional)
|
|
280
|
+
* @returns Promise resolving to transaction ID
|
|
281
|
+
*/
|
|
282
|
+
send(toAddress: string, satoshis?: number, options?: ISendOptions): Promise<string>;
|
|
283
|
+
/**
|
|
284
|
+
* Send DOGE (alias for send)
|
|
285
|
+
* @param toAddress - Recipient address
|
|
286
|
+
* @param satoshis - Amount in satoshis (optional)
|
|
287
|
+
* @param options - Send options (optional)
|
|
288
|
+
* @returns Promise resolving to transaction ID
|
|
289
|
+
*/
|
|
290
|
+
sendDogecoin(toAddress: string, satoshis?: number, options?: ISendOptions): Promise<string>;
|
|
291
|
+
/**
|
|
292
|
+
* Request signed message
|
|
293
|
+
* @param params - Sign message parameters
|
|
294
|
+
* @param params.message - Message to sign
|
|
295
|
+
* @param params.type - Message type (optional)
|
|
296
|
+
* @returns Promise resolving to signed message result
|
|
297
|
+
*/
|
|
298
|
+
requestSignedMessage(params: {
|
|
299
|
+
message: string;
|
|
300
|
+
type?: string;
|
|
301
|
+
}): Promise<ISignedMessage>;
|
|
302
|
+
/**
|
|
303
|
+
* Sign message
|
|
304
|
+
* @param message - Message to sign
|
|
305
|
+
* @param type - Message type (optional)
|
|
306
|
+
* @returns Promise resolving to signed message string
|
|
307
|
+
*/
|
|
308
|
+
signMessage(message: string, type?: string): Promise<string>;
|
|
309
|
+
/**
|
|
310
|
+
* Request decrypted message
|
|
311
|
+
* @param params - Decrypt message parameters
|
|
312
|
+
* @param params.message - Message to decrypt
|
|
313
|
+
* @returns Promise resolving to decrypted message result
|
|
314
|
+
*/
|
|
315
|
+
requestDecryptedMessage(params: {
|
|
316
|
+
message: string;
|
|
317
|
+
}): Promise<IDecryptedMessage>;
|
|
318
|
+
/**
|
|
319
|
+
* Request PSBT
|
|
320
|
+
* @param params - PSBT request parameters
|
|
321
|
+
* @returns Promise resolving to PSBT result with signedRawTx and/or txId
|
|
322
|
+
*/
|
|
323
|
+
requestPsbt(params: IRequestPsbtParams): Promise<IPsbtResponse>;
|
|
324
|
+
/**
|
|
325
|
+
* Sign PSBT
|
|
326
|
+
* @param psbtHex - PSBT hex string
|
|
327
|
+
* @param options - Sign options (optional)
|
|
328
|
+
* @returns Promise resolving to signed PSBT hex string
|
|
329
|
+
*/
|
|
330
|
+
signPsbt(psbtHex: string, options?: any): Promise<string>;
|
|
331
|
+
/**
|
|
332
|
+
* Sign multiple PSBTs
|
|
333
|
+
* @param psbtHexs - Array of PSBT hex strings
|
|
334
|
+
* @param options - Sign options (optional)
|
|
335
|
+
* @returns Promise resolving to signed PSBTs
|
|
336
|
+
*/
|
|
337
|
+
signPsbts(psbtHexs: string[], options?: any): Promise<any>;
|
|
338
|
+
/**
|
|
339
|
+
* Get DRC20 balances
|
|
340
|
+
* @param address - Address to query
|
|
341
|
+
* @param ticker - Token ticker (optional)
|
|
342
|
+
* @returns Promise resolving to DRC20 balances
|
|
343
|
+
*/
|
|
344
|
+
getDRC20Balances(address: string, ticker?: string): Promise<any>;
|
|
345
|
+
/**
|
|
346
|
+
* Get DRC20 balance
|
|
347
|
+
* @param params - Balance query parameters
|
|
348
|
+
* @param params.ticker - Token ticker (optional)
|
|
349
|
+
* @returns Promise resolving to DRC20 balance
|
|
350
|
+
*/
|
|
351
|
+
getDRC20Balance(params: {
|
|
352
|
+
ticker?: string;
|
|
353
|
+
}): Promise<IDRC20Balance>;
|
|
354
|
+
/**
|
|
355
|
+
* Get transferable DRC20
|
|
356
|
+
* @param params - Transferable query parameters
|
|
357
|
+
* @param params.ticker - Token ticker (optional)
|
|
358
|
+
* @returns Promise resolving to transferable DRC20
|
|
359
|
+
*/
|
|
360
|
+
getTransferableDRC20(params: {
|
|
361
|
+
ticker?: string;
|
|
362
|
+
}): Promise<ITransferableDRC20>;
|
|
363
|
+
/**
|
|
364
|
+
* Request available DRC20 transaction
|
|
365
|
+
* @param params - Transaction parameters
|
|
366
|
+
* @param params.ticker - Token ticker
|
|
367
|
+
* @param params.amount - Amount to transfer
|
|
368
|
+
* @returns Promise resolving to DRC20 transaction result
|
|
369
|
+
*/
|
|
370
|
+
requestAvailableDRC20Transaction(params: {
|
|
371
|
+
ticker: string;
|
|
372
|
+
amount: number;
|
|
373
|
+
}): Promise<IDRC20Transaction>;
|
|
374
|
+
/**
|
|
375
|
+
* Request inscription transaction
|
|
376
|
+
* @param params - Inscription transaction parameters
|
|
377
|
+
* @param params.location - Inscription location
|
|
378
|
+
* @param params.recipientAddress - Recipient address
|
|
379
|
+
* @returns Promise resolving to transaction result with txId
|
|
380
|
+
*/
|
|
381
|
+
requestInscriptionTransaction(params: {
|
|
382
|
+
location: string;
|
|
383
|
+
recipientAddress: string;
|
|
384
|
+
}): Promise<{
|
|
385
|
+
txId: string;
|
|
386
|
+
}>;
|
|
387
|
+
/**
|
|
388
|
+
* Get Dunes balance
|
|
389
|
+
* @param params - Balance query parameters
|
|
390
|
+
* @param params.ticker - Token ticker
|
|
391
|
+
* @returns Promise resolving to Dunes balance
|
|
392
|
+
*/
|
|
393
|
+
getDunesBalance(params: {
|
|
394
|
+
ticker: string;
|
|
395
|
+
}): Promise<IDunesBalance>;
|
|
396
|
+
/**
|
|
397
|
+
* Request Dunes transaction
|
|
398
|
+
* @param params - Transaction parameters
|
|
399
|
+
* @param params.ticker - Token ticker
|
|
400
|
+
* @param params.amount - Amount to transfer
|
|
401
|
+
* @param params.recipientAddress - Recipient address
|
|
402
|
+
* @returns Promise resolving to transaction result
|
|
403
|
+
*/
|
|
404
|
+
requestDunesTransaction(params: {
|
|
405
|
+
ticker: string;
|
|
406
|
+
amount: number;
|
|
407
|
+
recipientAddress: string;
|
|
408
|
+
}): Promise<any>;
|
|
409
|
+
/**
|
|
410
|
+
* Generic request method
|
|
411
|
+
* @param params - Request parameters
|
|
412
|
+
* @param params.method - RPC method name
|
|
413
|
+
* @param params.params - Method parameters
|
|
414
|
+
* @returns Promise resolving to request result
|
|
415
|
+
*/
|
|
416
|
+
request(params: {
|
|
417
|
+
method: string;
|
|
418
|
+
params: any;
|
|
419
|
+
}): Promise<any>;
|
|
86
420
|
}
|
|
87
421
|
|
|
88
422
|
interface StateProvider$2 {
|
|
@@ -92,7 +426,8 @@ interface StateProvider$2 {
|
|
|
92
426
|
initialized: boolean;
|
|
93
427
|
isPermanentlyDisconnected: boolean;
|
|
94
428
|
}
|
|
95
|
-
declare class DogecoinProvider extends EventEmitter {
|
|
429
|
+
declare class DogecoinProvider extends EventEmitter implements IDogecoinProvider {
|
|
430
|
+
type: ChainTypeEnum.DOGECOIN;
|
|
96
431
|
_selectedAddress: string | null;
|
|
97
432
|
_network: string | null;
|
|
98
433
|
_isConnected: boolean;
|
|
@@ -217,7 +552,158 @@ interface SendSyncJsonRpcRequest extends JsonRpcRequest<unknown> {
|
|
|
217
552
|
method: "eth_accounts" | "eth_coinbase" | "eth_uninstallFilter" | "net_version";
|
|
218
553
|
}
|
|
219
554
|
|
|
220
|
-
|
|
555
|
+
/**
|
|
556
|
+
* Connect event data interface
|
|
557
|
+
*/
|
|
558
|
+
interface IConnectEvent {
|
|
559
|
+
chainId?: string;
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* Disconnect event data interface
|
|
563
|
+
*/
|
|
564
|
+
interface IDisconnectEvent {
|
|
565
|
+
code: number;
|
|
566
|
+
message: string;
|
|
567
|
+
data?: unknown;
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* Main interface for EvmProvider
|
|
571
|
+
* Extends EventEmitter to support event handling
|
|
572
|
+
* Implements EIP-1193 standard
|
|
573
|
+
*/
|
|
574
|
+
interface IEvmProvider extends EventEmitter {
|
|
575
|
+
type: ChainTypeEnum.EVM;
|
|
576
|
+
/**
|
|
577
|
+
* The chain ID of the currently connected Ethereum chain.
|
|
578
|
+
* See https://chainid.network for more information.
|
|
579
|
+
*/
|
|
580
|
+
chainId: string | null;
|
|
581
|
+
/**
|
|
582
|
+
* The user's currently selected Ethereum address.
|
|
583
|
+
* If null, wallet is either locked or the user has not permitted any
|
|
584
|
+
* addresses to be viewed.
|
|
585
|
+
*/
|
|
586
|
+
selectedAddress: string | null;
|
|
587
|
+
/**
|
|
588
|
+
* Provider name
|
|
589
|
+
*/
|
|
590
|
+
name: string;
|
|
591
|
+
/**
|
|
592
|
+
* Provider icon
|
|
593
|
+
*/
|
|
594
|
+
icon: string;
|
|
595
|
+
/**
|
|
596
|
+
* Returns whether the provider can process RPC requests.
|
|
597
|
+
* @returns true if connected, false otherwise
|
|
598
|
+
*/
|
|
599
|
+
isConnected(): boolean;
|
|
600
|
+
/**
|
|
601
|
+
* Submits an RPC request for the given method, with the given params.
|
|
602
|
+
* Resolves with the result of the method call, or rejects on error.
|
|
603
|
+
*
|
|
604
|
+
* @param args - The RPC request arguments.
|
|
605
|
+
* @param args.method - The RPC method name.
|
|
606
|
+
* @param args.params - The parameters for the RPC method.
|
|
607
|
+
* @returns A Promise that resolves with the result of the RPC method,
|
|
608
|
+
* or rejects if an error is encountered.
|
|
609
|
+
*/
|
|
610
|
+
request<T = unknown>(args: RequestArguments): Promise<Maybe<T>>;
|
|
611
|
+
/**
|
|
612
|
+
* Connect to the wallet
|
|
613
|
+
* Equivalent to: ethereum.request('eth_requestAccounts')
|
|
614
|
+
* @returns Promise resolving to array of account addresses
|
|
615
|
+
*/
|
|
616
|
+
connect(): Promise<string[]>;
|
|
617
|
+
/**
|
|
618
|
+
* Disconnect from the wallet
|
|
619
|
+
* @returns Promise resolving to boolean indicating disconnect status
|
|
620
|
+
*/
|
|
621
|
+
disconnect(): Promise<boolean>;
|
|
622
|
+
/**
|
|
623
|
+
* Equivalent to: ethereum.request('eth_requestAccounts')
|
|
624
|
+
* @deprecated Use request({ method: 'eth_requestAccounts' }) instead.
|
|
625
|
+
* @returns Promise resolving to array of addresses
|
|
626
|
+
*/
|
|
627
|
+
enable(): Promise<string[]>;
|
|
628
|
+
/**
|
|
629
|
+
* Submits an RPC request for the given method, with the given params.
|
|
630
|
+
* @deprecated Use request() instead.
|
|
631
|
+
* @param method - The method to request.
|
|
632
|
+
* @param params - Any params for the method.
|
|
633
|
+
* @returns A Promise that resolves with the JSON-RPC response object for the request.
|
|
634
|
+
*/
|
|
635
|
+
send<T>(method: string, params?: T[]): Promise<JsonRpcResponse<T>>;
|
|
636
|
+
/**
|
|
637
|
+
* Submits an RPC request per the given JSON-RPC request object.
|
|
638
|
+
* @deprecated Use request() instead.
|
|
639
|
+
* @param payload - A JSON-RPC request object.
|
|
640
|
+
* @param callback - An error-first callback that will receive the JSON-RPC response object.
|
|
641
|
+
*/
|
|
642
|
+
send<T>(payload: JsonRpcRequest<unknown>, callback: (error: Error | null, result?: JsonRpcResponse<T>) => void): void;
|
|
643
|
+
/**
|
|
644
|
+
* Accepts a JSON-RPC request object, and synchronously returns the cached result
|
|
645
|
+
* for the given method. Only supports 4 specific RPC methods.
|
|
646
|
+
* @deprecated Use request() instead.
|
|
647
|
+
* @param payload - A JSON-RPC request object.
|
|
648
|
+
* @returns A JSON-RPC response object.
|
|
649
|
+
*/
|
|
650
|
+
send<T>(payload: SendSyncJsonRpcRequest): JsonRpcResponse<T>;
|
|
651
|
+
/**
|
|
652
|
+
* Adds a listener for the specified event.
|
|
653
|
+
* @param eventName - Event name
|
|
654
|
+
* @param listener - Event listener function
|
|
655
|
+
* @returns This instance for chaining
|
|
656
|
+
*/
|
|
657
|
+
on(eventName: string, listener: (...args: unknown[]) => void): this;
|
|
658
|
+
/**
|
|
659
|
+
* Adds a one-time listener for the specified event.
|
|
660
|
+
* @param eventName - Event name
|
|
661
|
+
* @param listener - Event listener function
|
|
662
|
+
* @returns This instance for chaining
|
|
663
|
+
*/
|
|
664
|
+
once(eventName: string, listener: (...args: unknown[]) => void): this;
|
|
665
|
+
/**
|
|
666
|
+
* Emitted when the provider connects to a chain.
|
|
667
|
+
* @event
|
|
668
|
+
*/
|
|
669
|
+
on(event: "connect", listener: (connectInfo: IConnectEvent) => void): this;
|
|
670
|
+
/**
|
|
671
|
+
* Emitted when the provider disconnects from a chain.
|
|
672
|
+
* @event
|
|
673
|
+
*/
|
|
674
|
+
on(event: "disconnect", listener: (error: IDisconnectEvent) => void): this;
|
|
675
|
+
/**
|
|
676
|
+
* Emitted when the chain ID changes.
|
|
677
|
+
* @event
|
|
678
|
+
*/
|
|
679
|
+
on(event: "chainChanged", listener: (chainId: string) => void): this;
|
|
680
|
+
/**
|
|
681
|
+
* Emitted when accounts change.
|
|
682
|
+
* @event
|
|
683
|
+
*/
|
|
684
|
+
on(event: "accountsChanged", listener: (accounts: string[]) => void): this;
|
|
685
|
+
/**
|
|
686
|
+
* Emitted when the connection closes (deprecated).
|
|
687
|
+
* @event
|
|
688
|
+
* @deprecated
|
|
689
|
+
*/
|
|
690
|
+
on(event: "close", listener: (error: IDisconnectEvent) => void): this;
|
|
691
|
+
/**
|
|
692
|
+
* Emitted when data is received (deprecated).
|
|
693
|
+
* @event
|
|
694
|
+
* @deprecated
|
|
695
|
+
*/
|
|
696
|
+
on(event: "data", listener: (payload: unknown) => void): this;
|
|
697
|
+
/**
|
|
698
|
+
* Emitted when the network changes (deprecated).
|
|
699
|
+
* @event
|
|
700
|
+
* @deprecated
|
|
701
|
+
*/
|
|
702
|
+
on(event: "networkChanged", listener: (networkId: string) => void): this;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
declare class EvmProvider extends EventEmitter implements IEvmProvider {
|
|
706
|
+
type: ChainTypeEnum.EVM;
|
|
221
707
|
private readonly _log;
|
|
222
708
|
private _state;
|
|
223
709
|
private _rpcEngine;
|
|
@@ -282,7 +768,7 @@ declare class EvmProvider extends EventEmitter {
|
|
|
282
768
|
* addListener, on, once, prependListener, prependOnceListener
|
|
283
769
|
*/
|
|
284
770
|
addListener(eventName: string, listener: (...args: unknown[]) => void): this;
|
|
285
|
-
on(eventName: string, listener: (...args:
|
|
771
|
+
on(eventName: string, listener: (...args: any[]) => void): this;
|
|
286
772
|
once(eventName: string, listener: (...args: unknown[]) => void): this;
|
|
287
773
|
prependListener(eventName: string, listener: (...args: unknown[]) => void): this;
|
|
288
774
|
prependOnceListener(eventName: string, listener: (...args: unknown[]) => void): this;
|
|
@@ -443,6 +929,7 @@ interface StateProvider$1 {
|
|
|
443
929
|
isPermanentlyDisconnected: boolean;
|
|
444
930
|
}
|
|
445
931
|
declare class PhantomProvider extends EventEmitter {
|
|
932
|
+
chainType: ChainTypeEnum;
|
|
446
933
|
_isUnlocked: boolean;
|
|
447
934
|
name: string;
|
|
448
935
|
icon: string;
|
|
@@ -488,6 +975,17 @@ declare class PhantomProvider extends EventEmitter {
|
|
|
488
975
|
sendToken: (tx: OriginTransaction) => Promise<any>;
|
|
489
976
|
}
|
|
490
977
|
|
|
978
|
+
interface ITomoTronProvider extends TronLinkWallet {
|
|
979
|
+
type: ChainTypeEnum.TRON;
|
|
980
|
+
tronWeb: TronWeb;
|
|
981
|
+
address: string | null;
|
|
982
|
+
connect(options?: Record<string, unknown>): Promise<void | any>;
|
|
983
|
+
disconnect(): Promise<void | any>;
|
|
984
|
+
signMessage(message: string, privateKey?: string): Promise<any>;
|
|
985
|
+
signTransaction(transaction: Transaction$1, privateKey?: string): Promise<SignedTransaction>;
|
|
986
|
+
switchChain?: (chainId: string) => Promise<void>;
|
|
987
|
+
}
|
|
988
|
+
|
|
491
989
|
interface StateProvider {
|
|
492
990
|
accounts: any[] | null;
|
|
493
991
|
isConnected: boolean;
|
|
@@ -495,12 +993,14 @@ interface StateProvider {
|
|
|
495
993
|
initialized: boolean;
|
|
496
994
|
isPermanentlyDisconnected: boolean;
|
|
497
995
|
}
|
|
498
|
-
declare class TomoTronProvider extends EventEmitter {
|
|
996
|
+
declare class TomoTronProvider extends EventEmitter implements ITomoTronProvider {
|
|
997
|
+
type: ChainTypeEnum.TRON;
|
|
499
998
|
_isUnlocked: boolean;
|
|
500
999
|
name: string;
|
|
501
1000
|
icon: string;
|
|
502
1001
|
ready: boolean;
|
|
503
|
-
tronWeb: TronWeb
|
|
1002
|
+
tronWeb: TronWeb$1;
|
|
1003
|
+
address: string;
|
|
504
1004
|
sendRequest: (chainType: string, data: any) => void;
|
|
505
1005
|
onResponse: any;
|
|
506
1006
|
events: {
|
|
@@ -511,6 +1011,7 @@ declare class TomoTronProvider extends EventEmitter {
|
|
|
511
1011
|
_state: StateProvider;
|
|
512
1012
|
private _requestPromise;
|
|
513
1013
|
constructor(productInfo: IProductInfo, { sendRequest, onResponse }: IConnectors);
|
|
1014
|
+
switchChain?: ((chainId: string) => Promise<void>) | undefined;
|
|
514
1015
|
private _initTronWeb;
|
|
515
1016
|
initialize: () => Promise<void>;
|
|
516
1017
|
subscribeWalletEventsCallback: ({ method, data }: {
|
|
@@ -533,4 +1034,6 @@ declare class TomoTronProvider extends EventEmitter {
|
|
|
533
1034
|
sendToken: (params: any) => Promise<any>;
|
|
534
1035
|
}
|
|
535
1036
|
|
|
536
|
-
|
|
1037
|
+
type WalletProvider = IDogecoinProvider | IEvmProvider;
|
|
1038
|
+
|
|
1039
|
+
export { BitcoinProvider, DogecoinProvider, EvmProvider, PhantomProvider as SolanaProvider, TomoTronProvider as TronProvider, type WalletProvider };
|