@tomo-inc/inject-providers 0.0.14 → 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/dist/index.d.cts 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 BtcProvider extends EventEmitter {
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?: "ecdsa" | "bip322-simple") => Promise<string>;
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,586 +112,139 @@ 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>;
86
116
  }
87
117
 
88
- interface StateProvider$2 {
89
- accounts: string[] | null;
90
- isConnected: boolean;
91
- isUnlocked: boolean;
92
- initialized: boolean;
93
- isPermanentlyDisconnected: boolean;
118
+ /**
119
+ * Balance response interface
120
+ */
121
+ interface IDogecoinBalance {
122
+ confirmed: number;
123
+ unconfirmed: number;
124
+ total: number;
94
125
  }
95
- declare class DogecoinProvider extends EventEmitter {
96
- _selectedAddress: string | null;
97
- _network: string | null;
98
- _isConnected: boolean;
99
- _initialized: boolean;
100
- _isUnlocked: boolean;
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;
101
216
  rdns: string;
102
217
  name: string;
103
- sendRequest: (chainType: string, data: any) => void;
104
- onResponse: any;
105
- _state: StateProvider$2;
106
- private _requestPromise;
107
- constructor(productInfo: IProductInfo, { sendRequest, onResponse }: IConnectors);
108
- initialize: () => Promise<void>;
109
218
  /**
110
- * Sending a message to the extension to receive will keep the service worker alive.
219
+ * Connect to the wallet
220
+ * @returns Promise resolving to connection result with address, approved, balance, publicKey
111
221
  */
112
- private keepAlive;
113
- _request: ({ method, params }: {
114
- method: string;
115
- params?: any;
116
- }, adapter?: any) => Promise<any>;
117
- request: ({ method, params }: {
118
- method: string;
119
- params: any;
120
- }) => Promise<any>;
121
- connect: () => Promise<any>;
122
- disconnect: () => Promise<any>;
123
- requestAccounts: () => Promise<string[]>;
124
- getAccounts: () => Promise<string[]>;
125
- getPublicKey: () => Promise<string>;
126
- getBalance: () => Promise<{
127
- confirmed: number;
128
- unconfirmed: number;
129
- total: number;
130
- }>;
131
- getTransactionStatus: ({ txId }: {
132
- txId: string;
133
- }) => Promise<any>;
134
- requestSignedMessage: ({ message, type }: {
135
- message: string;
136
- type?: string;
137
- }) => Promise<any>;
138
- signMessage: (message: string, type?: string) => Promise<string>;
139
- requestDecryptedMessage: ({ message }: {
140
- message: string;
141
- }) => Promise<any>;
142
- requestPsbt: ({ rawTx, indexes, feeOnly, signOnly, partial, sighashType, }: {
143
- rawTx: string;
144
- indexes?: [];
145
- feeOnly?: boolean;
146
- signOnly?: boolean;
147
- partial?: boolean;
148
- sighashType?: string;
149
- }) => Promise<any>;
150
- signPsbt: (psbtHex: string, options?: any) => Promise<string>;
151
- signPsbts: (psbtHexs: string[], options?: any) => Promise<any>;
152
- requestTransaction: ({ recipientAddress, dogeAmount }: {
153
- recipientAddress: string;
154
- dogeAmount: number;
155
- }) => Promise<any>;
156
- send: (toAddress: string, satoshis?: number, options?: {
157
- feeRate: number;
158
- memo?: string;
159
- }) => Promise<string>;
160
- sendDogecoin: (toAddress: string, satoshis?: number, options?: {
161
- feeRate: number;
162
- memo?: string;
163
- }) => Promise<string>;
164
- getConnectionStatus: () => Promise<any>;
165
- getDRC20Balances: (address: string, ticker?: string) => Promise<any>;
166
- getDRC20Balance: ({ ticker }: {
167
- ticker?: string;
168
- }) => Promise<any>;
169
- getTransferableDRC20: ({ ticker }: {
170
- ticker?: string;
171
- }) => Promise<any>;
172
- requestAvailableDRC20Transaction: ({ ticker, amount }: {
173
- ticker: string;
174
- amount: number;
175
- }) => Promise<any>;
176
- requestInscriptionTransaction: ({ location, recipientAddress, }: {
177
- location: string;
178
- recipientAddress: string;
179
- }) => Promise<any>;
180
- getDunesBalance: (params: {
181
- ticker: string;
182
- }) => Promise<any>;
183
- requestDunesTransaction: ({ ticker, amount, recipientAddress, }: {
184
- ticker: string;
185
- amount: number;
186
- recipientAddress: string;
187
- }) => Promise<any>;
188
- }
189
-
190
- type Maybe<T> = Partial<T> | null | undefined;
191
- type ConsoleLike = Pick<Console, "log" | "warn" | "error" | "debug" | "info" | "trace">;
192
-
193
- interface InpageProviderOptions {
222
+ connect(): Promise<any>;
194
223
  /**
195
- * The logging API to use.
224
+ * Disconnect from the wallet
225
+ * @returns Promise resolving to disconnect result with disconnected status
196
226
  */
197
- logger?: ConsoleLike;
198
- jsonRpcStreamName?: any;
227
+ disconnect(): Promise<any>;
199
228
  /**
200
- * The maximum number of event listeners.
229
+ * Get connection status
230
+ * @returns Promise resolving to connection status with connected, address, selectedWalletAddress
201
231
  */
202
- maxEventListeners?: number;
232
+ getConnectionStatus(): Promise<IConnectionStatus>;
203
233
  /**
204
- * Whether the provider should send page metadata.
234
+ * Request accounts from the wallet
235
+ * @returns Promise resolving to array of account addresses
205
236
  */
206
- shouldSendMetadata?: boolean;
207
- sendRequest: (chainType: string, data: any) => void;
208
- onResponse: any;
209
- }
210
- interface RequestArguments {
211
- /** The RPC method to request. */
212
- method: string;
213
- /** The params of the RPC method, if any. */
214
- params?: unknown[] | Record<string, unknown>;
215
- }
216
- interface SendSyncJsonRpcRequest extends JsonRpcRequest<unknown> {
217
- method: "eth_accounts" | "eth_coinbase" | "eth_uninstallFilter" | "net_version";
218
- }
219
-
220
- declare class EvmProvider extends EventEmitter {
221
- private readonly _log;
222
- private _state;
223
- private _rpcEngine;
224
- sendRequest: (chainType: string, data: any) => void;
225
- onResponse: any;
237
+ requestAccounts(): Promise<string[]>;
226
238
  /**
227
- * The chain ID of the currently connected Ethereum chain.
228
- * See [chainId.network]{@link https://chainid.network} for more information.
239
+ * Get current accounts
240
+ * @returns Promise resolving to array of account addresses
229
241
  */
230
- chainId: string | null;
242
+ getAccounts(): Promise<string[]>;
231
243
  /**
232
- * The network ID of the currently connected Ethereum chain.
244
+ * Get public key
245
+ * @returns Promise resolving to public key string
233
246
  */
234
- networkVersion: string | null;
235
- /**
236
- * The user's currently selected Ethereum address.
237
- * If null, is either locked or the user has not permitted any
238
- * addresses to be viewed.
239
- */
240
- selectedAddress: string | null;
241
- /**
242
- * Indicating that this provider is a provider.
243
- */
244
- name: string;
245
- icon: string;
246
- /**
247
- * @param connectionStream - A Node.js duplex stream
248
- * @param options - An options bag
249
- * @param options.jsonRpcStreamName - The name of the internal JSON-RPC stream.
250
- * @param options.logger - The logging API to use. Default: console
251
- * @param options.maxEventListeners - The maximum number of event
252
- * listeners. Default: 100
253
- * @param options.shouldSendMetadata - Whether the provider should
254
- * send page metadata. Default: true
255
- */
256
- constructor(productInfo: IProductInfo, { logger, maxEventListeners, shouldSendMetadata, sendRequest, onResponse, }: InpageProviderOptions);
257
- /**
258
- * Returns whether the provider can process RPC requests.
259
- */
260
- isConnected(): boolean;
261
- /**
262
- * Submits an RPC request for the given method, with the given params.
263
- * Resolves with the result of the method call, or rejects on error.
264
- *
265
- * @param args - The RPC request arguments.
266
- * @param args.method - The RPC method name.
267
- * @param args.params - The parameters for the RPC method.
268
- * @returns A Promise that resolves with the result of the RPC method,
269
- * or rejects if an error is encountered.
270
- */
271
- request<T>(args: RequestArguments): Promise<Maybe<T>>;
272
- /**
273
- * Submits an RPC request per the given JSON-RPC request object.
274
- *
275
- * @param payload - The RPC request object.
276
- * @param cb - The callback function.
277
- */
278
- sendAsync(payload: JsonRpcRequest<unknown>, callback: (error: Error | null, result?: JsonRpcResponse<unknown>) => void): void;
279
- /**
280
- * We override the following event methods so that we can warn consumers
281
- * about deprecated events:
282
- * addListener, on, once, prependListener, prependOnceListener
283
- */
284
- addListener(eventName: string, listener: (...args: unknown[]) => void): this;
285
- on(eventName: string, listener: (...args: unknown[]) => void): this;
286
- once(eventName: string, listener: (...args: unknown[]) => void): this;
287
- prependListener(eventName: string, listener: (...args: unknown[]) => void): this;
288
- prependOnceListener(eventName: string, listener: (...args: unknown[]) => void): this;
289
- /**
290
- * Constructor helper.
291
- * Populates initial state by calling 'getProviderState' and emits
292
- * necessary events.
293
- */
294
- private _initializeState;
295
- private subscribeWalletEventsCallback;
296
- private keepAlive;
297
- /**
298
- * Internal RPC method. Forwards requests to background via the RPC engine.
299
- * Also remap ids inbound and outbound.
300
- *
301
- * @param payload - The RPC request object.
302
- * @param callback - The consumer's callback.
303
- */
304
- private _rpcRequest;
305
- /**
306
- * When the provider becomes connected, updates internal state and emits
307
- * required events. Idempotent.
308
- *
309
- * @param chainId - The ID of the newly connected chain.
310
- * @emits InpageProvider#connect
311
- */
312
- private _handleConnect;
313
- /**
314
- * When the provider becomes disconnected, updates internal state and emits
315
- * required events. Idempotent with respect to the isRecoverable parameter.
316
- *
317
- * Error codes per the CloseEvent status codes as required by EIP-1193:
318
- * https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent#Status_codes
319
- *
320
- * @param isRecoverable - Whether the disconnection is recoverable.
321
- * @param errorMessage - A custom error message.
322
- * @emits InpageProvider#disconnect
323
- */
324
- private _handleDisconnect;
325
- /**
326
- * Called when connection is lost to critical streams.
327
- *
328
- * @emits InpageProvider#disconnect
329
- */
330
- private _handleStreamDisconnect;
331
- /**
332
- * Upon receipt of a new chainId and networkVersion, emits corresponding
333
- * events and sets relevant public state.
334
- * Does nothing if neither the chainId nor the networkVersion are different
335
- * from existing values.
336
- *
337
- * @emits InpageProvider#chainChanged
338
- * @param networkInfo - An object with network info.
339
- * @param networkInfo.chainId - The latest chain ID.
340
- * @param networkInfo.networkVersion - The latest network ID.
341
- */
342
- private _handleChainChanged;
343
- /**
344
- * Called when accounts may have changed. Diffs the new accounts value with
345
- * the current one, updates all state as necessary, and emits the
346
- * accountsChanged event.
347
- *
348
- * @param accounts - The new accounts value.
349
- * @param isEthAccounts - Whether the accounts value was returned by
350
- * a call to eth_accounts.
351
- */
352
- private _handleAccountsChanged;
353
- /**
354
- * Upon receipt of a new isUnlocked state, sets relevant public state.
355
- * Calls the accounts changed handler with the received accounts, or an empty
356
- * array.
357
- *
358
- * Does nothing if the received value is equal to the existing value.
359
- * There are no lock/unlock events.
360
- *
361
- * @param opts - Options bag.
362
- * @param opts.accounts - The exposed accounts, if any.
363
- * @param opts.isUnlocked - The latest isUnlocked value.
364
- */
365
- private _handleUnlockStateChanged;
366
- /**
367
- * Warns of deprecation for the given event, if applicable.
368
- */
369
- private _warnOfDeprecation;
370
- /**
371
- * Equivalent to: ethereum.request('eth_requestAccounts')
372
- *
373
- * @deprecated Use request({ method: 'eth_requestAccounts' }) instead.
374
- * @returns A promise that resolves to an array of addresses.
375
- */
376
- enable(): Promise<string[]>;
377
- setConnectedStatus({ connected, address }: {
378
- connected: boolean;
379
- address: string[];
380
- }): void;
381
- connect(): Promise<string[]>;
382
- disconnect(): Promise<boolean>;
383
- /**
384
- * Submits an RPC request for the given method, with the given params.
385
- *
386
- * @deprecated Use "request" instead.
387
- * @param method - The method to request.
388
- * @param params - Any params for the method.
389
- * @returns A Promise that resolves with the JSON-RPC response object for the
390
- * request.
391
- */
392
- send<T>(method: string, params?: T[]): Promise<JsonRpcResponse<T>>;
393
- /**
394
- * Submits an RPC request per the given JSON-RPC request object.
395
- *
396
- * @deprecated Use "request" instead.
397
- * @param payload - A JSON-RPC request object.
398
- * @param callback - An error-first callback that will receive the JSON-RPC
399
- * response object.
400
- */
401
- send<T>(payload: JsonRpcRequest<unknown>, callback: (error: Error | null, result?: JsonRpcResponse<T>) => void): void;
402
- /**
403
- * Accepts a JSON-RPC request object, and synchronously returns the cached result
404
- * for the given method. Only supports 4 specific RPC methods.
405
- *
406
- * @deprecated Use "request" instead.
407
- * @param payload - A JSON-RPC request object.
408
- * @returns A JSON-RPC response object.
409
- */
410
- send<T>(payload: SendSyncJsonRpcRequest): JsonRpcResponse<T>;
411
- /**
412
- * Internal backwards compatibility method, used in send.
413
- *
414
- * @deprecated
415
- */
416
- private _sendSync;
417
- }
418
-
419
- type SignInInput = {
420
- domain?: string;
421
- statement?: string;
422
- version?: string;
423
- nonce?: string;
424
- chainId?: Cluster;
425
- issuedAt?: string;
426
- resources?: `https://${string}`[];
427
- };
428
- interface OriginTransaction {
429
- from: string;
430
- to: string;
431
- amount: number;
432
- tokenAddress?: string;
433
- decimals?: number;
434
- priorityFee?: number;
435
- chainId?: Cluster;
436
- }
437
-
438
- interface StateProvider$1 {
439
- accounts: any[] | null;
440
- isConnected: boolean;
441
- isUnlocked: boolean;
442
- initialized: boolean;
443
- isPermanentlyDisconnected: boolean;
444
- }
445
- declare class PhantomProvider extends EventEmitter {
446
- _isUnlocked: boolean;
447
- name: string;
448
- icon: string;
449
- publicKey: PublicKey | null;
450
- sendRequest: (chainType: string, data: any) => void;
451
- onResponse: any;
452
- events: {
453
- connect: boolean;
454
- disconnect: boolean;
455
- accountChanged: boolean;
456
- };
457
- _state: StateProvider$1;
458
- private _requestPromise;
459
- constructor(productInfo: IProductInfo, { sendRequest, onResponse }: IConnectors);
460
- initialize: () => Promise<void>;
461
- subscribeWalletEventsCallback: ({ method, data }: {
462
- method: string;
463
- data: any;
464
- }) => void;
465
- /**
466
- * Sending a message to the extension to receive will keep the service worker alive.
467
- */
468
- private keepAlive;
469
- on(eventName: string, listener: (...args: unknown[]) => void): this;
470
- private _handleAccountsChanged;
471
- _request: (data: any, responseAdaptor?: any) => Promise<any>;
472
- request: ({ method, params }: {
473
- method: string;
474
- params: any;
475
- }, responseAdaptor: any) => Promise<any>;
476
- connect: (params?: {
477
- onlyIfTrusted: boolean;
478
- }) => Promise<any>;
479
- disconnect: () => Promise<any>;
480
- getAccount: () => Promise<any>;
481
- signMessage: (message: Uint8Array, display: "utf8" | "hex") => Promise<any>;
482
- signIn: (params?: SignInInput) => Promise<any>;
483
- signTransaction: (tx: VersionedTransaction | Transaction) => Promise<any>;
484
- signAllTransactions: (txs: (VersionedTransaction | Transaction)[]) => Promise<any>;
485
- signAndSendTransaction: (tx: VersionedTransaction | Transaction) => Promise<any>;
486
- signAndSendAllTransactions: (txs: (VersionedTransaction | Transaction)[]) => Promise<any>;
487
- sendSolana: (tx: OriginTransaction) => Promise<any>;
488
- sendToken: (tx: OriginTransaction) => Promise<any>;
489
- }
490
-
491
- interface StateProvider {
492
- accounts: any[] | null;
493
- isConnected: boolean;
494
- isUnlocked: boolean;
495
- initialized: boolean;
496
- isPermanentlyDisconnected: boolean;
497
- }
498
- declare class TomoTronProvider extends EventEmitter {
499
- _isUnlocked: boolean;
500
- name: string;
501
- icon: string;
502
- ready: boolean;
503
- tronWeb: TronWeb | null;
504
- sendRequest: (chainType: string, data: any) => void;
505
- onResponse: any;
506
- events: {
507
- connect: boolean;
508
- disconnect: boolean;
509
- accountChanged: boolean;
510
- };
511
- _state: StateProvider;
512
- private _requestPromise;
513
- constructor(productInfo: IProductInfo, { sendRequest, onResponse }: IConnectors);
514
- private _initTronWeb;
515
- initialize: () => Promise<void>;
516
- subscribeWalletEventsCallback: ({ method, data }: {
517
- method: string;
518
- data: any;
519
- }) => void;
520
- on(eventName: string, listener: (...args: unknown[]) => void): this;
521
- private _handleAccountsChanged;
522
- _request: (data: any, responseAdaptor?: any) => Promise<any>;
523
- request: ({ method, params }: {
524
- method: string;
525
- params: any;
526
- }, responseAdaptor?: any) => Promise<any>;
527
- connect: () => Promise<any>;
528
- disconnect: () => Promise<any>;
529
- signMessage: (message: string) => Promise<any>;
530
- signTransaction: (transaction: Transaction$1) => Promise<any>;
531
- sendRawTransaction: (transaction: Transaction$1) => Promise<any>;
532
- sendTransaction: (params: any) => Promise<any>;
533
- sendToken: (params: any) => Promise<any>;
534
- }
535
-
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>;
247
+ getPublicKey(): Promise<string>;
666
248
  /**
667
249
  * Get balance
668
250
  * @returns Promise resolving to balance object with confirmed, unconfirmed, and total
@@ -803,38 +385,171 @@ interface IDogecoinProvider extends EventEmitter {
803
385
  txId: string;
804
386
  }>;
805
387
  /**
806
- * Get Dunes balance
807
- * @param params - Balance query parameters
808
- * @param params.ticker - Token ticker
809
- * @returns Promise resolving to Dunes balance
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>;
420
+ }
421
+
422
+ interface StateProvider$2 {
423
+ accounts: string[] | null;
424
+ isConnected: boolean;
425
+ isUnlocked: boolean;
426
+ initialized: boolean;
427
+ isPermanentlyDisconnected: boolean;
428
+ }
429
+ declare class DogecoinProvider extends EventEmitter implements IDogecoinProvider {
430
+ type: ChainTypeEnum.DOGECOIN;
431
+ _selectedAddress: string | null;
432
+ _network: string | null;
433
+ _isConnected: boolean;
434
+ _initialized: boolean;
435
+ _isUnlocked: boolean;
436
+ rdns: string;
437
+ name: string;
438
+ sendRequest: (chainType: string, data: any) => void;
439
+ onResponse: any;
440
+ _state: StateProvider$2;
441
+ private _requestPromise;
442
+ constructor(productInfo: IProductInfo, { sendRequest, onResponse }: IConnectors);
443
+ initialize: () => Promise<void>;
444
+ /**
445
+ * Sending a message to the extension to receive will keep the service worker alive.
446
+ */
447
+ private keepAlive;
448
+ _request: ({ method, params }: {
449
+ method: string;
450
+ params?: any;
451
+ }, adapter?: any) => Promise<any>;
452
+ request: ({ method, params }: {
453
+ method: string;
454
+ params: any;
455
+ }) => Promise<any>;
456
+ connect: () => Promise<any>;
457
+ disconnect: () => Promise<any>;
458
+ requestAccounts: () => Promise<string[]>;
459
+ getAccounts: () => Promise<string[]>;
460
+ getPublicKey: () => Promise<string>;
461
+ getBalance: () => Promise<{
462
+ confirmed: number;
463
+ unconfirmed: number;
464
+ total: number;
465
+ }>;
466
+ getTransactionStatus: ({ txId }: {
467
+ txId: string;
468
+ }) => Promise<any>;
469
+ requestSignedMessage: ({ message, type }: {
470
+ message: string;
471
+ type?: string;
472
+ }) => Promise<any>;
473
+ signMessage: (message: string, type?: string) => Promise<string>;
474
+ requestDecryptedMessage: ({ message }: {
475
+ message: string;
476
+ }) => Promise<any>;
477
+ requestPsbt: ({ rawTx, indexes, feeOnly, signOnly, partial, sighashType, }: {
478
+ rawTx: string;
479
+ indexes?: [];
480
+ feeOnly?: boolean;
481
+ signOnly?: boolean;
482
+ partial?: boolean;
483
+ sighashType?: string;
484
+ }) => Promise<any>;
485
+ signPsbt: (psbtHex: string, options?: any) => Promise<string>;
486
+ signPsbts: (psbtHexs: string[], options?: any) => Promise<any>;
487
+ requestTransaction: ({ recipientAddress, dogeAmount }: {
488
+ recipientAddress: string;
489
+ dogeAmount: number;
490
+ }) => Promise<any>;
491
+ send: (toAddress: string, satoshis?: number, options?: {
492
+ feeRate: number;
493
+ memo?: string;
494
+ }) => Promise<string>;
495
+ sendDogecoin: (toAddress: string, satoshis?: number, options?: {
496
+ feeRate: number;
497
+ memo?: string;
498
+ }) => Promise<string>;
499
+ getConnectionStatus: () => Promise<any>;
500
+ getDRC20Balances: (address: string, ticker?: string) => Promise<any>;
501
+ getDRC20Balance: ({ ticker }: {
502
+ ticker?: string;
503
+ }) => Promise<any>;
504
+ getTransferableDRC20: ({ ticker }: {
505
+ ticker?: string;
506
+ }) => Promise<any>;
507
+ requestAvailableDRC20Transaction: ({ ticker, amount }: {
508
+ ticker: string;
509
+ amount: number;
510
+ }) => Promise<any>;
511
+ requestInscriptionTransaction: ({ location, recipientAddress, }: {
512
+ location: string;
513
+ recipientAddress: string;
514
+ }) => Promise<any>;
515
+ getDunesBalance: (params: {
516
+ ticker: string;
517
+ }) => Promise<any>;
518
+ requestDunesTransaction: ({ ticker, amount, recipientAddress, }: {
519
+ ticker: string;
520
+ amount: number;
521
+ recipientAddress: string;
522
+ }) => Promise<any>;
523
+ }
524
+
525
+ type Maybe<T> = Partial<T> | null | undefined;
526
+ type ConsoleLike = Pick<Console, "log" | "warn" | "error" | "debug" | "info" | "trace">;
527
+
528
+ interface InpageProviderOptions {
529
+ /**
530
+ * The logging API to use.
810
531
  */
811
- getDunesBalance(params: {
812
- ticker: string;
813
- }): Promise<IDunesBalance>;
532
+ logger?: ConsoleLike;
533
+ jsonRpcStreamName?: any;
814
534
  /**
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
535
+ * The maximum number of event listeners.
821
536
  */
822
- requestDunesTransaction(params: {
823
- ticker: string;
824
- amount: number;
825
- recipientAddress: string;
826
- }): Promise<any>;
537
+ maxEventListeners?: number;
827
538
  /**
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
539
+ * Whether the provider should send page metadata.
833
540
  */
834
- request(params: {
835
- method: string;
836
- params: any;
837
- }): Promise<any>;
541
+ shouldSendMetadata?: boolean;
542
+ sendRequest: (chainType: string, data: any) => void;
543
+ onResponse: any;
544
+ }
545
+ interface RequestArguments {
546
+ /** The RPC method to request. */
547
+ method: string;
548
+ /** The params of the RPC method, if any. */
549
+ params?: unknown[] | Record<string, unknown>;
550
+ }
551
+ interface SendSyncJsonRpcRequest extends JsonRpcRequest<unknown> {
552
+ method: "eth_accounts" | "eth_coinbase" | "eth_uninstallFilter" | "net_version";
838
553
  }
839
554
 
840
555
  /**
@@ -857,7 +572,7 @@ interface IDisconnectEvent {
857
572
  * Implements EIP-1193 standard
858
573
  */
859
574
  interface IEvmProvider extends EventEmitter {
860
- type: "evm";
575
+ type: ChainTypeEnum.EVM;
861
576
  /**
862
577
  * The chain ID of the currently connected Ethereum chain.
863
578
  * See https://chainid.network for more information.
@@ -870,123 +585,455 @@ interface IEvmProvider extends EventEmitter {
870
585
  */
871
586
  selectedAddress: string | null;
872
587
  /**
873
- * Provider name
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;
707
+ private readonly _log;
708
+ private _state;
709
+ private _rpcEngine;
710
+ sendRequest: (chainType: string, data: any) => void;
711
+ onResponse: any;
712
+ /**
713
+ * The chain ID of the currently connected Ethereum chain.
714
+ * See [chainId.network]{@link https://chainid.network} for more information.
715
+ */
716
+ chainId: string | null;
717
+ /**
718
+ * The network ID of the currently connected Ethereum chain.
719
+ */
720
+ networkVersion: string | null;
721
+ /**
722
+ * The user's currently selected Ethereum address.
723
+ * If null, is either locked or the user has not permitted any
724
+ * addresses to be viewed.
725
+ */
726
+ selectedAddress: string | null;
727
+ /**
728
+ * Indicating that this provider is a provider.
729
+ */
730
+ name: string;
731
+ icon: string;
732
+ /**
733
+ * @param connectionStream - A Node.js duplex stream
734
+ * @param options - An options bag
735
+ * @param options.jsonRpcStreamName - The name of the internal JSON-RPC stream.
736
+ * @param options.logger - The logging API to use. Default: console
737
+ * @param options.maxEventListeners - The maximum number of event
738
+ * listeners. Default: 100
739
+ * @param options.shouldSendMetadata - Whether the provider should
740
+ * send page metadata. Default: true
741
+ */
742
+ constructor(productInfo: IProductInfo, { logger, maxEventListeners, shouldSendMetadata, sendRequest, onResponse, }: InpageProviderOptions);
743
+ /**
744
+ * Returns whether the provider can process RPC requests.
745
+ */
746
+ isConnected(): boolean;
747
+ /**
748
+ * Submits an RPC request for the given method, with the given params.
749
+ * Resolves with the result of the method call, or rejects on error.
750
+ *
751
+ * @param args - The RPC request arguments.
752
+ * @param args.method - The RPC method name.
753
+ * @param args.params - The parameters for the RPC method.
754
+ * @returns A Promise that resolves with the result of the RPC method,
755
+ * or rejects if an error is encountered.
756
+ */
757
+ request<T>(args: RequestArguments): Promise<Maybe<T>>;
758
+ /**
759
+ * Submits an RPC request per the given JSON-RPC request object.
760
+ *
761
+ * @param payload - The RPC request object.
762
+ * @param cb - The callback function.
763
+ */
764
+ sendAsync(payload: JsonRpcRequest<unknown>, callback: (error: Error | null, result?: JsonRpcResponse<unknown>) => void): void;
765
+ /**
766
+ * We override the following event methods so that we can warn consumers
767
+ * about deprecated events:
768
+ * addListener, on, once, prependListener, prependOnceListener
769
+ */
770
+ addListener(eventName: string, listener: (...args: unknown[]) => void): this;
771
+ on(eventName: string, listener: (...args: any[]) => void): this;
772
+ once(eventName: string, listener: (...args: unknown[]) => void): this;
773
+ prependListener(eventName: string, listener: (...args: unknown[]) => void): this;
774
+ prependOnceListener(eventName: string, listener: (...args: unknown[]) => void): this;
775
+ /**
776
+ * Constructor helper.
777
+ * Populates initial state by calling 'getProviderState' and emits
778
+ * necessary events.
779
+ */
780
+ private _initializeState;
781
+ private subscribeWalletEventsCallback;
782
+ private keepAlive;
783
+ /**
784
+ * Internal RPC method. Forwards requests to background via the RPC engine.
785
+ * Also remap ids inbound and outbound.
786
+ *
787
+ * @param payload - The RPC request object.
788
+ * @param callback - The consumer's callback.
789
+ */
790
+ private _rpcRequest;
791
+ /**
792
+ * When the provider becomes connected, updates internal state and emits
793
+ * required events. Idempotent.
794
+ *
795
+ * @param chainId - The ID of the newly connected chain.
796
+ * @emits InpageProvider#connect
797
+ */
798
+ private _handleConnect;
799
+ /**
800
+ * When the provider becomes disconnected, updates internal state and emits
801
+ * required events. Idempotent with respect to the isRecoverable parameter.
802
+ *
803
+ * Error codes per the CloseEvent status codes as required by EIP-1193:
804
+ * https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent#Status_codes
805
+ *
806
+ * @param isRecoverable - Whether the disconnection is recoverable.
807
+ * @param errorMessage - A custom error message.
808
+ * @emits InpageProvider#disconnect
874
809
  */
875
- name: string;
810
+ private _handleDisconnect;
876
811
  /**
877
- * Provider icon
812
+ * Called when connection is lost to critical streams.
813
+ *
814
+ * @emits InpageProvider#disconnect
878
815
  */
879
- icon: string;
816
+ private _handleStreamDisconnect;
880
817
  /**
881
- * Returns whether the provider can process RPC requests.
882
- * @returns true if connected, false otherwise
818
+ * Upon receipt of a new chainId and networkVersion, emits corresponding
819
+ * events and sets relevant public state.
820
+ * Does nothing if neither the chainId nor the networkVersion are different
821
+ * from existing values.
822
+ *
823
+ * @emits InpageProvider#chainChanged
824
+ * @param networkInfo - An object with network info.
825
+ * @param networkInfo.chainId - The latest chain ID.
826
+ * @param networkInfo.networkVersion - The latest network ID.
883
827
  */
884
- isConnected(): boolean;
828
+ private _handleChainChanged;
885
829
  /**
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.
830
+ * Called when accounts may have changed. Diffs the new accounts value with
831
+ * the current one, updates all state as necessary, and emits the
832
+ * accountsChanged event.
888
833
  *
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.
834
+ * @param accounts - The new accounts value.
835
+ * @param isEthAccounts - Whether the accounts value was returned by
836
+ * a call to eth_accounts.
894
837
  */
895
- request<T = unknown>(args: RequestArguments): Promise<Maybe<T>>;
838
+ private _handleAccountsChanged;
896
839
  /**
897
- * Connect to the wallet
898
- * Equivalent to: ethereum.request('eth_requestAccounts')
899
- * @returns Promise resolving to array of account addresses
840
+ * Upon receipt of a new isUnlocked state, sets relevant public state.
841
+ * Calls the accounts changed handler with the received accounts, or an empty
842
+ * array.
843
+ *
844
+ * Does nothing if the received value is equal to the existing value.
845
+ * There are no lock/unlock events.
846
+ *
847
+ * @param opts - Options bag.
848
+ * @param opts.accounts - The exposed accounts, if any.
849
+ * @param opts.isUnlocked - The latest isUnlocked value.
900
850
  */
901
- connect(): Promise<string[]>;
851
+ private _handleUnlockStateChanged;
902
852
  /**
903
- * Disconnect from the wallet
904
- * @returns Promise resolving to boolean indicating disconnect status
853
+ * Warns of deprecation for the given event, if applicable.
905
854
  */
906
- disconnect(): Promise<boolean>;
855
+ private _warnOfDeprecation;
907
856
  /**
908
857
  * Equivalent to: ethereum.request('eth_requestAccounts')
858
+ *
909
859
  * @deprecated Use request({ method: 'eth_requestAccounts' }) instead.
910
- * @returns Promise resolving to array of addresses
860
+ * @returns A promise that resolves to an array of addresses.
911
861
  */
912
862
  enable(): Promise<string[]>;
863
+ setConnectedStatus({ connected, address }: {
864
+ connected: boolean;
865
+ address: string[];
866
+ }): void;
867
+ connect(): Promise<string[]>;
868
+ disconnect(): Promise<boolean>;
913
869
  /**
914
870
  * Submits an RPC request for the given method, with the given params.
915
- * @deprecated Use request() instead.
871
+ *
872
+ * @deprecated Use "request" instead.
916
873
  * @param method - The method to request.
917
874
  * @param params - Any params for the method.
918
- * @returns A Promise that resolves with the JSON-RPC response object for the request.
875
+ * @returns A Promise that resolves with the JSON-RPC response object for the
876
+ * request.
919
877
  */
920
878
  send<T>(method: string, params?: T[]): Promise<JsonRpcResponse<T>>;
921
879
  /**
922
880
  * Submits an RPC request per the given JSON-RPC request object.
923
- * @deprecated Use request() instead.
881
+ *
882
+ * @deprecated Use "request" instead.
924
883
  * @param payload - A JSON-RPC request object.
925
- * @param callback - An error-first callback that will receive the JSON-RPC response object.
884
+ * @param callback - An error-first callback that will receive the JSON-RPC
885
+ * response object.
926
886
  */
927
887
  send<T>(payload: JsonRpcRequest<unknown>, callback: (error: Error | null, result?: JsonRpcResponse<T>) => void): void;
928
888
  /**
929
889
  * Accepts a JSON-RPC request object, and synchronously returns the cached result
930
890
  * for the given method. Only supports 4 specific RPC methods.
931
- * @deprecated Use request() instead.
891
+ *
892
+ * @deprecated Use "request" instead.
932
893
  * @param payload - A JSON-RPC request object.
933
894
  * @returns A JSON-RPC response object.
934
895
  */
935
896
  send<T>(payload: SendSyncJsonRpcRequest): JsonRpcResponse<T>;
936
897
  /**
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
898
+ * Internal backwards compatibility method, used in send.
899
+ *
979
900
  * @deprecated
980
901
  */
981
- on(event: "data", listener: (payload: unknown) => void): this;
902
+ private _sendSync;
903
+ }
904
+
905
+ type SignInInput = {
906
+ domain?: string;
907
+ statement?: string;
908
+ version?: string;
909
+ nonce?: string;
910
+ chainId?: Cluster;
911
+ issuedAt?: string;
912
+ resources?: `https://${string}`[];
913
+ };
914
+ interface OriginTransaction {
915
+ from: string;
916
+ to: string;
917
+ amount: number;
918
+ tokenAddress?: string;
919
+ decimals?: number;
920
+ priorityFee?: number;
921
+ chainId?: Cluster;
922
+ }
923
+
924
+ interface StateProvider$1 {
925
+ accounts: any[] | null;
926
+ isConnected: boolean;
927
+ isUnlocked: boolean;
928
+ initialized: boolean;
929
+ isPermanentlyDisconnected: boolean;
930
+ }
931
+ declare class PhantomProvider extends EventEmitter {
932
+ chainType: ChainTypeEnum;
933
+ _isUnlocked: boolean;
934
+ name: string;
935
+ icon: string;
936
+ publicKey: PublicKey | null;
937
+ sendRequest: (chainType: string, data: any) => void;
938
+ onResponse: any;
939
+ events: {
940
+ connect: boolean;
941
+ disconnect: boolean;
942
+ accountChanged: boolean;
943
+ };
944
+ _state: StateProvider$1;
945
+ private _requestPromise;
946
+ constructor(productInfo: IProductInfo, { sendRequest, onResponse }: IConnectors);
947
+ initialize: () => Promise<void>;
948
+ subscribeWalletEventsCallback: ({ method, data }: {
949
+ method: string;
950
+ data: any;
951
+ }) => void;
982
952
  /**
983
- * Emitted when the network changes (deprecated).
984
- * @event
985
- * @deprecated
953
+ * Sending a message to the extension to receive will keep the service worker alive.
986
954
  */
987
- on(event: "networkChanged", listener: (networkId: string) => void): this;
955
+ private keepAlive;
956
+ on(eventName: string, listener: (...args: unknown[]) => void): this;
957
+ private _handleAccountsChanged;
958
+ _request: (data: any, responseAdaptor?: any) => Promise<any>;
959
+ request: ({ method, params }: {
960
+ method: string;
961
+ params: any;
962
+ }, responseAdaptor: any) => Promise<any>;
963
+ connect: (params?: {
964
+ onlyIfTrusted: boolean;
965
+ }) => Promise<any>;
966
+ disconnect: () => Promise<any>;
967
+ getAccount: () => Promise<any>;
968
+ signMessage: (message: Uint8Array, display: "utf8" | "hex") => Promise<any>;
969
+ signIn: (params?: SignInInput) => Promise<any>;
970
+ signTransaction: (tx: VersionedTransaction | Transaction) => Promise<any>;
971
+ signAllTransactions: (txs: (VersionedTransaction | Transaction)[]) => Promise<any>;
972
+ signAndSendTransaction: (tx: VersionedTransaction | Transaction) => Promise<any>;
973
+ signAndSendAllTransactions: (txs: (VersionedTransaction | Transaction)[]) => Promise<any>;
974
+ sendSolana: (tx: OriginTransaction) => Promise<any>;
975
+ sendToken: (tx: OriginTransaction) => Promise<any>;
976
+ }
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
+
989
+ interface StateProvider {
990
+ accounts: any[] | null;
991
+ isConnected: boolean;
992
+ isUnlocked: boolean;
993
+ initialized: boolean;
994
+ isPermanentlyDisconnected: boolean;
995
+ }
996
+ declare class TomoTronProvider extends EventEmitter implements ITomoTronProvider {
997
+ type: ChainTypeEnum.TRON;
998
+ _isUnlocked: boolean;
999
+ name: string;
1000
+ icon: string;
1001
+ ready: boolean;
1002
+ tronWeb: TronWeb$1;
1003
+ address: string;
1004
+ sendRequest: (chainType: string, data: any) => void;
1005
+ onResponse: any;
1006
+ events: {
1007
+ connect: boolean;
1008
+ disconnect: boolean;
1009
+ accountChanged: boolean;
1010
+ };
1011
+ _state: StateProvider;
1012
+ private _requestPromise;
1013
+ constructor(productInfo: IProductInfo, { sendRequest, onResponse }: IConnectors);
1014
+ switchChain?: ((chainId: string) => Promise<void>) | undefined;
1015
+ private _initTronWeb;
1016
+ initialize: () => Promise<void>;
1017
+ subscribeWalletEventsCallback: ({ method, data }: {
1018
+ method: string;
1019
+ data: any;
1020
+ }) => void;
1021
+ on(eventName: string, listener: (...args: unknown[]) => void): this;
1022
+ private _handleAccountsChanged;
1023
+ _request: (data: any, responseAdaptor?: any) => Promise<any>;
1024
+ request: ({ method, params }: {
1025
+ method: string;
1026
+ params: any;
1027
+ }, responseAdaptor?: any) => Promise<any>;
1028
+ connect: () => Promise<any>;
1029
+ disconnect: () => Promise<any>;
1030
+ signMessage: (message: string) => Promise<any>;
1031
+ signTransaction: (transaction: Transaction$1) => Promise<any>;
1032
+ sendRawTransaction: (transaction: Transaction$1) => Promise<any>;
1033
+ sendTransaction: (params: any) => Promise<any>;
1034
+ sendToken: (params: any) => Promise<any>;
988
1035
  }
989
1036
 
990
1037
  type WalletProvider = IDogecoinProvider | IEvmProvider;
991
1038
 
992
- export { BtcProvider, DogecoinProvider, EvmProvider, PhantomProvider as SolanaProvider, TomoTronProvider as TronProvider, type WalletProvider };
1039
+ export { BitcoinProvider, DogecoinProvider, EvmProvider, PhantomProvider as SolanaProvider, TomoTronProvider as TronProvider, type WalletProvider };