@tomo-inc/inject-providers 0.0.3 → 0.0.5
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.cjs +1995 -0
- package/dist/index.d.cts +518 -0
- package/dist/index.d.ts +518 -0
- package/dist/index.js +1985 -0
- package/package.json +3 -3
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,518 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
import { JsonRpcRequest, JsonRpcResponse } from 'json-rpc-engine';
|
|
3
|
+
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';
|
|
6
|
+
|
|
7
|
+
interface IProductInfo {
|
|
8
|
+
name: string;
|
|
9
|
+
rdns: string;
|
|
10
|
+
icon: string;
|
|
11
|
+
}
|
|
12
|
+
interface IConnectors {
|
|
13
|
+
sendRequest: (chainType: string, data: any) => void;
|
|
14
|
+
onResponse: (data: any) => void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type Network = "livenet" | "testnet";
|
|
18
|
+
type ChainId = "BITCOIN_MAINNET" | "BITCOIN_TESTNET" | "FRACTAL_BITCOIN_MAINNET";
|
|
19
|
+
type Balance = {
|
|
20
|
+
confirmed: number;
|
|
21
|
+
unconfirmed: number;
|
|
22
|
+
total: number;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
interface StateProvider$3 {
|
|
26
|
+
accounts: string[] | null;
|
|
27
|
+
isConnected: boolean;
|
|
28
|
+
isUnlocked: boolean;
|
|
29
|
+
initialized: boolean;
|
|
30
|
+
isPermanentlyDisconnected: boolean;
|
|
31
|
+
}
|
|
32
|
+
declare class BtcProvider extends EventEmitter {
|
|
33
|
+
_selectedAddress: string | null;
|
|
34
|
+
_isConnected: boolean;
|
|
35
|
+
_initialized: boolean;
|
|
36
|
+
_isUnlocked: boolean;
|
|
37
|
+
rdns: string;
|
|
38
|
+
name: string;
|
|
39
|
+
chainId: string;
|
|
40
|
+
sendRequest: (chainType: string, data: any) => void;
|
|
41
|
+
onResponse: any;
|
|
42
|
+
_state: StateProvider$3;
|
|
43
|
+
private _requestPromise;
|
|
44
|
+
constructor(productInfo: IProductInfo, { sendRequest, onResponse }: IConnectors);
|
|
45
|
+
initialize: () => Promise<void>;
|
|
46
|
+
subscribeWalletEventsCallback: ({ method, data }: {
|
|
47
|
+
method: string;
|
|
48
|
+
data: any;
|
|
49
|
+
}) => void;
|
|
50
|
+
/**
|
|
51
|
+
* Sending a message to the extension to receive will keep the service worker alive.
|
|
52
|
+
*/
|
|
53
|
+
private keepAlive;
|
|
54
|
+
private _handleChainChanged;
|
|
55
|
+
private _handleAccountsChanged;
|
|
56
|
+
_request: ({ method, params }: {
|
|
57
|
+
method: string;
|
|
58
|
+
params?: any;
|
|
59
|
+
}, adapter?: any) => Promise<any>;
|
|
60
|
+
request: ({ method, params }: {
|
|
61
|
+
method: string;
|
|
62
|
+
params: any;
|
|
63
|
+
}) => Promise<any>;
|
|
64
|
+
connect: () => Promise<any>;
|
|
65
|
+
disconnect: () => Promise<any>;
|
|
66
|
+
requestAccounts: () => Promise<string[]>;
|
|
67
|
+
getAccounts: () => Promise<string[]>;
|
|
68
|
+
getPublicKey: () => Promise<any>;
|
|
69
|
+
getBalance: () => Promise<Balance>;
|
|
70
|
+
getTransactionStatus: ({ txId }: {
|
|
71
|
+
txId: string;
|
|
72
|
+
}) => Promise<any>;
|
|
73
|
+
signMessage: (text: string, type?: "ecdsa" | "bip322-simple") => Promise<string>;
|
|
74
|
+
getNetwork: () => Promise<any>;
|
|
75
|
+
switchNetwork: (network: Network) => Promise<any>;
|
|
76
|
+
getChain: () => Promise<any>;
|
|
77
|
+
switchChain: (chainId: ChainId) => Promise<any>;
|
|
78
|
+
signPsbt: (psbtHex: string, options?: any) => Promise<string>;
|
|
79
|
+
signPsbts: (psbtHexs: string[], options?: any[]) => Promise<string[]>;
|
|
80
|
+
pushPsbt: (psbtHex: string) => Promise<string>;
|
|
81
|
+
sendBitcoin: (toAddress: string, satoshis?: number, options?: {
|
|
82
|
+
feeRate: number;
|
|
83
|
+
}) => Promise<string>;
|
|
84
|
+
signTx: (rawtx: string) => Promise<any>;
|
|
85
|
+
pushTx: (rawtx: string) => Promise<string>;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
interface StateProvider$2 {
|
|
89
|
+
accounts: string[] | null;
|
|
90
|
+
isConnected: boolean;
|
|
91
|
+
isUnlocked: boolean;
|
|
92
|
+
initialized: boolean;
|
|
93
|
+
isPermanentlyDisconnected: boolean;
|
|
94
|
+
}
|
|
95
|
+
declare class DogecoinProvider extends EventEmitter {
|
|
96
|
+
_selectedAddress: string | null;
|
|
97
|
+
_network: string | null;
|
|
98
|
+
_isConnected: boolean;
|
|
99
|
+
_initialized: boolean;
|
|
100
|
+
_isUnlocked: boolean;
|
|
101
|
+
rdns: string;
|
|
102
|
+
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
|
+
/**
|
|
110
|
+
* Sending a message to the extension to receive will keep the service worker alive.
|
|
111
|
+
*/
|
|
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
|
+
getBalance: () => Promise<any>;
|
|
123
|
+
disconnect: () => Promise<any>;
|
|
124
|
+
getConnectionStatus: () => Promise<any>;
|
|
125
|
+
requestTransaction: ({ recipientAddress, dogeAmount }: {
|
|
126
|
+
recipientAddress: string;
|
|
127
|
+
dogeAmount: number;
|
|
128
|
+
}) => Promise<any>;
|
|
129
|
+
getTransactionStatus: ({ txId }: {
|
|
130
|
+
txId: string;
|
|
131
|
+
}) => Promise<any>;
|
|
132
|
+
requestSignedMessage: ({ message, type }: {
|
|
133
|
+
message: string;
|
|
134
|
+
type?: string;
|
|
135
|
+
}) => Promise<any>;
|
|
136
|
+
requestDecryptedMessage: ({ message }: {
|
|
137
|
+
message: string;
|
|
138
|
+
}) => Promise<any>;
|
|
139
|
+
getDRC20Balances: (address: string, ticker?: string) => Promise<any>;
|
|
140
|
+
getDRC20Balance: ({ ticker }: {
|
|
141
|
+
ticker?: string;
|
|
142
|
+
}) => Promise<any>;
|
|
143
|
+
getTransferableDRC20: ({ ticker }: {
|
|
144
|
+
ticker?: string;
|
|
145
|
+
}) => Promise<any>;
|
|
146
|
+
requestAvailableDRC20Transaction: ({ ticker, amount }: {
|
|
147
|
+
ticker: string;
|
|
148
|
+
amount: number;
|
|
149
|
+
}) => Promise<any>;
|
|
150
|
+
requestInscriptionTransaction: ({ location, recipientAddress, }: {
|
|
151
|
+
location: string;
|
|
152
|
+
recipientAddress: string;
|
|
153
|
+
}) => Promise<any>;
|
|
154
|
+
requestPsbt: ({ rawTx, indexes, feeOnly, signOnly, partial, sighashType, }: {
|
|
155
|
+
rawTx: string;
|
|
156
|
+
indexes?: [];
|
|
157
|
+
feeOnly?: boolean;
|
|
158
|
+
signOnly?: boolean;
|
|
159
|
+
partial?: boolean;
|
|
160
|
+
sighashType?: string;
|
|
161
|
+
}) => Promise<any>;
|
|
162
|
+
getDunesBalance: (params: {
|
|
163
|
+
ticker: string;
|
|
164
|
+
}) => Promise<any>;
|
|
165
|
+
requestDunesTransaction: ({ ticker, amount, recipientAddress, }: {
|
|
166
|
+
ticker: string;
|
|
167
|
+
amount: number;
|
|
168
|
+
recipientAddress: string;
|
|
169
|
+
}) => Promise<any>;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
type Maybe<T> = Partial<T> | null | undefined;
|
|
173
|
+
type ConsoleLike = Pick<Console, "log" | "warn" | "error" | "debug" | "info" | "trace">;
|
|
174
|
+
|
|
175
|
+
interface InpageProviderOptions {
|
|
176
|
+
/**
|
|
177
|
+
* The logging API to use.
|
|
178
|
+
*/
|
|
179
|
+
logger?: ConsoleLike;
|
|
180
|
+
jsonRpcStreamName?: any;
|
|
181
|
+
/**
|
|
182
|
+
* The maximum number of event listeners.
|
|
183
|
+
*/
|
|
184
|
+
maxEventListeners?: number;
|
|
185
|
+
/**
|
|
186
|
+
* Whether the provider should send page metadata.
|
|
187
|
+
*/
|
|
188
|
+
shouldSendMetadata?: boolean;
|
|
189
|
+
sendRequest: (chainType: string, data: any) => void;
|
|
190
|
+
onResponse: any;
|
|
191
|
+
}
|
|
192
|
+
interface RequestArguments {
|
|
193
|
+
/** The RPC method to request. */
|
|
194
|
+
method: string;
|
|
195
|
+
/** The params of the RPC method, if any. */
|
|
196
|
+
params?: unknown[] | Record<string, unknown>;
|
|
197
|
+
}
|
|
198
|
+
interface SendSyncJsonRpcRequest extends JsonRpcRequest<unknown> {
|
|
199
|
+
method: "eth_accounts" | "eth_coinbase" | "eth_uninstallFilter" | "net_version";
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
declare class EvmProvider extends EventEmitter {
|
|
203
|
+
private readonly _log;
|
|
204
|
+
private _state;
|
|
205
|
+
private _rpcEngine;
|
|
206
|
+
sendRequest: (chainType: string, data: any) => void;
|
|
207
|
+
onResponse: any;
|
|
208
|
+
/**
|
|
209
|
+
* The chain ID of the currently connected Ethereum chain.
|
|
210
|
+
* See [chainId.network]{@link https://chainid.network} for more information.
|
|
211
|
+
*/
|
|
212
|
+
chainId: string | null;
|
|
213
|
+
/**
|
|
214
|
+
* The network ID of the currently connected Ethereum chain.
|
|
215
|
+
*/
|
|
216
|
+
networkVersion: string | null;
|
|
217
|
+
/**
|
|
218
|
+
* The user's currently selected Ethereum address.
|
|
219
|
+
* If null, is either locked or the user has not permitted any
|
|
220
|
+
* addresses to be viewed.
|
|
221
|
+
*/
|
|
222
|
+
selectedAddress: string | null;
|
|
223
|
+
/**
|
|
224
|
+
* Indicating that this provider is a provider.
|
|
225
|
+
*/
|
|
226
|
+
name: string;
|
|
227
|
+
icon: string;
|
|
228
|
+
/**
|
|
229
|
+
* @param connectionStream - A Node.js duplex stream
|
|
230
|
+
* @param options - An options bag
|
|
231
|
+
* @param options.jsonRpcStreamName - The name of the internal JSON-RPC stream.
|
|
232
|
+
* @param options.logger - The logging API to use. Default: console
|
|
233
|
+
* @param options.maxEventListeners - The maximum number of event
|
|
234
|
+
* listeners. Default: 100
|
|
235
|
+
* @param options.shouldSendMetadata - Whether the provider should
|
|
236
|
+
* send page metadata. Default: true
|
|
237
|
+
*/
|
|
238
|
+
constructor(productInfo: IProductInfo, { logger, maxEventListeners, shouldSendMetadata, sendRequest, onResponse, }: InpageProviderOptions);
|
|
239
|
+
/**
|
|
240
|
+
* Returns whether the provider can process RPC requests.
|
|
241
|
+
*/
|
|
242
|
+
isConnected(): boolean;
|
|
243
|
+
/**
|
|
244
|
+
* Submits an RPC request for the given method, with the given params.
|
|
245
|
+
* Resolves with the result of the method call, or rejects on error.
|
|
246
|
+
*
|
|
247
|
+
* @param args - The RPC request arguments.
|
|
248
|
+
* @param args.method - The RPC method name.
|
|
249
|
+
* @param args.params - The parameters for the RPC method.
|
|
250
|
+
* @returns A Promise that resolves with the result of the RPC method,
|
|
251
|
+
* or rejects if an error is encountered.
|
|
252
|
+
*/
|
|
253
|
+
request<T>(args: RequestArguments): Promise<Maybe<T>>;
|
|
254
|
+
/**
|
|
255
|
+
* Submits an RPC request per the given JSON-RPC request object.
|
|
256
|
+
*
|
|
257
|
+
* @param payload - The RPC request object.
|
|
258
|
+
* @param cb - The callback function.
|
|
259
|
+
*/
|
|
260
|
+
sendAsync(payload: JsonRpcRequest<unknown>, callback: (error: Error | null, result?: JsonRpcResponse<unknown>) => void): void;
|
|
261
|
+
/**
|
|
262
|
+
* We override the following event methods so that we can warn consumers
|
|
263
|
+
* about deprecated events:
|
|
264
|
+
* addListener, on, once, prependListener, prependOnceListener
|
|
265
|
+
*/
|
|
266
|
+
addListener(eventName: string, listener: (...args: unknown[]) => void): this;
|
|
267
|
+
on(eventName: string, listener: (...args: unknown[]) => void): this;
|
|
268
|
+
once(eventName: string, listener: (...args: unknown[]) => void): this;
|
|
269
|
+
prependListener(eventName: string, listener: (...args: unknown[]) => void): this;
|
|
270
|
+
prependOnceListener(eventName: string, listener: (...args: unknown[]) => void): this;
|
|
271
|
+
/**
|
|
272
|
+
* Constructor helper.
|
|
273
|
+
* Populates initial state by calling 'getProviderState' and emits
|
|
274
|
+
* necessary events.
|
|
275
|
+
*/
|
|
276
|
+
private _initializeState;
|
|
277
|
+
private subscribeWalletEventsCallback;
|
|
278
|
+
private keepAlive;
|
|
279
|
+
/**
|
|
280
|
+
* Internal RPC method. Forwards requests to background via the RPC engine.
|
|
281
|
+
* Also remap ids inbound and outbound.
|
|
282
|
+
*
|
|
283
|
+
* @param payload - The RPC request object.
|
|
284
|
+
* @param callback - The consumer's callback.
|
|
285
|
+
*/
|
|
286
|
+
private _rpcRequest;
|
|
287
|
+
/**
|
|
288
|
+
* When the provider becomes connected, updates internal state and emits
|
|
289
|
+
* required events. Idempotent.
|
|
290
|
+
*
|
|
291
|
+
* @param chainId - The ID of the newly connected chain.
|
|
292
|
+
* @emits InpageProvider#connect
|
|
293
|
+
*/
|
|
294
|
+
private _handleConnect;
|
|
295
|
+
/**
|
|
296
|
+
* When the provider becomes disconnected, updates internal state and emits
|
|
297
|
+
* required events. Idempotent with respect to the isRecoverable parameter.
|
|
298
|
+
*
|
|
299
|
+
* Error codes per the CloseEvent status codes as required by EIP-1193:
|
|
300
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent#Status_codes
|
|
301
|
+
*
|
|
302
|
+
* @param isRecoverable - Whether the disconnection is recoverable.
|
|
303
|
+
* @param errorMessage - A custom error message.
|
|
304
|
+
* @emits InpageProvider#disconnect
|
|
305
|
+
*/
|
|
306
|
+
private _handleDisconnect;
|
|
307
|
+
/**
|
|
308
|
+
* Called when connection is lost to critical streams.
|
|
309
|
+
*
|
|
310
|
+
* @emits InpageProvider#disconnect
|
|
311
|
+
*/
|
|
312
|
+
private _handleStreamDisconnect;
|
|
313
|
+
/**
|
|
314
|
+
* Upon receipt of a new chainId and networkVersion, emits corresponding
|
|
315
|
+
* events and sets relevant public state.
|
|
316
|
+
* Does nothing if neither the chainId nor the networkVersion are different
|
|
317
|
+
* from existing values.
|
|
318
|
+
*
|
|
319
|
+
* @emits InpageProvider#chainChanged
|
|
320
|
+
* @param networkInfo - An object with network info.
|
|
321
|
+
* @param networkInfo.chainId - The latest chain ID.
|
|
322
|
+
* @param networkInfo.networkVersion - The latest network ID.
|
|
323
|
+
*/
|
|
324
|
+
private _handleChainChanged;
|
|
325
|
+
/**
|
|
326
|
+
* Called when accounts may have changed. Diffs the new accounts value with
|
|
327
|
+
* the current one, updates all state as necessary, and emits the
|
|
328
|
+
* accountsChanged event.
|
|
329
|
+
*
|
|
330
|
+
* @param accounts - The new accounts value.
|
|
331
|
+
* @param isEthAccounts - Whether the accounts value was returned by
|
|
332
|
+
* a call to eth_accounts.
|
|
333
|
+
*/
|
|
334
|
+
private _handleAccountsChanged;
|
|
335
|
+
/**
|
|
336
|
+
* Upon receipt of a new isUnlocked state, sets relevant public state.
|
|
337
|
+
* Calls the accounts changed handler with the received accounts, or an empty
|
|
338
|
+
* array.
|
|
339
|
+
*
|
|
340
|
+
* Does nothing if the received value is equal to the existing value.
|
|
341
|
+
* There are no lock/unlock events.
|
|
342
|
+
*
|
|
343
|
+
* @param opts - Options bag.
|
|
344
|
+
* @param opts.accounts - The exposed accounts, if any.
|
|
345
|
+
* @param opts.isUnlocked - The latest isUnlocked value.
|
|
346
|
+
*/
|
|
347
|
+
private _handleUnlockStateChanged;
|
|
348
|
+
/**
|
|
349
|
+
* Warns of deprecation for the given event, if applicable.
|
|
350
|
+
*/
|
|
351
|
+
private _warnOfDeprecation;
|
|
352
|
+
/**
|
|
353
|
+
* Equivalent to: ethereum.request('eth_requestAccounts')
|
|
354
|
+
*
|
|
355
|
+
* @deprecated Use request({ method: 'eth_requestAccounts' }) instead.
|
|
356
|
+
* @returns A promise that resolves to an array of addresses.
|
|
357
|
+
*/
|
|
358
|
+
enable(): Promise<string[]>;
|
|
359
|
+
setConnectedStatus({ connected, address }: {
|
|
360
|
+
connected: boolean;
|
|
361
|
+
address: string[];
|
|
362
|
+
}): void;
|
|
363
|
+
connect(): Promise<string[]>;
|
|
364
|
+
disconnect(): Promise<boolean>;
|
|
365
|
+
/**
|
|
366
|
+
* Submits an RPC request for the given method, with the given params.
|
|
367
|
+
*
|
|
368
|
+
* @deprecated Use "request" instead.
|
|
369
|
+
* @param method - The method to request.
|
|
370
|
+
* @param params - Any params for the method.
|
|
371
|
+
* @returns A Promise that resolves with the JSON-RPC response object for the
|
|
372
|
+
* request.
|
|
373
|
+
*/
|
|
374
|
+
send<T>(method: string, params?: T[]): Promise<JsonRpcResponse<T>>;
|
|
375
|
+
/**
|
|
376
|
+
* Submits an RPC request per the given JSON-RPC request object.
|
|
377
|
+
*
|
|
378
|
+
* @deprecated Use "request" instead.
|
|
379
|
+
* @param payload - A JSON-RPC request object.
|
|
380
|
+
* @param callback - An error-first callback that will receive the JSON-RPC
|
|
381
|
+
* response object.
|
|
382
|
+
*/
|
|
383
|
+
send<T>(payload: JsonRpcRequest<unknown>, callback: (error: Error | null, result?: JsonRpcResponse<T>) => void): void;
|
|
384
|
+
/**
|
|
385
|
+
* Accepts a JSON-RPC request object, and synchronously returns the cached result
|
|
386
|
+
* for the given method. Only supports 4 specific RPC methods.
|
|
387
|
+
*
|
|
388
|
+
* @deprecated Use "request" instead.
|
|
389
|
+
* @param payload - A JSON-RPC request object.
|
|
390
|
+
* @returns A JSON-RPC response object.
|
|
391
|
+
*/
|
|
392
|
+
send<T>(payload: SendSyncJsonRpcRequest): JsonRpcResponse<T>;
|
|
393
|
+
/**
|
|
394
|
+
* Internal backwards compatibility method, used in send.
|
|
395
|
+
*
|
|
396
|
+
* @deprecated
|
|
397
|
+
*/
|
|
398
|
+
private _sendSync;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
type SignInInput = {
|
|
402
|
+
domain?: string;
|
|
403
|
+
statement?: string;
|
|
404
|
+
version?: string;
|
|
405
|
+
nonce?: string;
|
|
406
|
+
chainId?: Cluster;
|
|
407
|
+
issuedAt?: string;
|
|
408
|
+
resources?: `https://${string}`[];
|
|
409
|
+
};
|
|
410
|
+
interface OriginTransaction {
|
|
411
|
+
from: string;
|
|
412
|
+
to: string;
|
|
413
|
+
amount: number;
|
|
414
|
+
tokenAddress?: string;
|
|
415
|
+
decimals?: number;
|
|
416
|
+
priorityFee?: number;
|
|
417
|
+
chainId?: Cluster;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
interface StateProvider$1 {
|
|
421
|
+
accounts: any[] | null;
|
|
422
|
+
isConnected: boolean;
|
|
423
|
+
isUnlocked: boolean;
|
|
424
|
+
initialized: boolean;
|
|
425
|
+
isPermanentlyDisconnected: boolean;
|
|
426
|
+
}
|
|
427
|
+
declare class PhantomProvider extends EventEmitter {
|
|
428
|
+
_isUnlocked: boolean;
|
|
429
|
+
name: string;
|
|
430
|
+
icon: string;
|
|
431
|
+
publicKey: PublicKey | null;
|
|
432
|
+
sendRequest: (chainType: string, data: any) => void;
|
|
433
|
+
onResponse: any;
|
|
434
|
+
events: {
|
|
435
|
+
connect: boolean;
|
|
436
|
+
disconnect: boolean;
|
|
437
|
+
accountChanged: boolean;
|
|
438
|
+
};
|
|
439
|
+
_state: StateProvider$1;
|
|
440
|
+
private _requestPromise;
|
|
441
|
+
constructor(productInfo: IProductInfo, { sendRequest, onResponse }: IConnectors);
|
|
442
|
+
initialize: () => Promise<void>;
|
|
443
|
+
subscribeWalletEventsCallback: ({ method, data }: {
|
|
444
|
+
method: string;
|
|
445
|
+
data: any;
|
|
446
|
+
}) => void;
|
|
447
|
+
/**
|
|
448
|
+
* Sending a message to the extension to receive will keep the service worker alive.
|
|
449
|
+
*/
|
|
450
|
+
private keepAlive;
|
|
451
|
+
on(eventName: string, listener: (...args: unknown[]) => void): this;
|
|
452
|
+
private _handleAccountsChanged;
|
|
453
|
+
_request: (data: any, responseAdaptor?: any) => Promise<any>;
|
|
454
|
+
request: ({ method, params }: {
|
|
455
|
+
method: string;
|
|
456
|
+
params: any;
|
|
457
|
+
}, responseAdaptor: any) => Promise<any>;
|
|
458
|
+
connect: (params?: {
|
|
459
|
+
onlyIfTrusted: boolean;
|
|
460
|
+
}) => Promise<any>;
|
|
461
|
+
disconnect: () => Promise<any>;
|
|
462
|
+
getAccount: () => Promise<any>;
|
|
463
|
+
signMessage: (message: Uint8Array, display: "utf8" | "hex") => Promise<any>;
|
|
464
|
+
signIn: (params?: SignInInput) => Promise<any>;
|
|
465
|
+
signTransaction: (tx: VersionedTransaction | Transaction) => Promise<any>;
|
|
466
|
+
signAllTransactions: (txs: (VersionedTransaction | Transaction)[]) => Promise<any>;
|
|
467
|
+
signAndSendTransaction: (tx: VersionedTransaction | Transaction) => Promise<any>;
|
|
468
|
+
signAndSendAllTransactions: (txs: (VersionedTransaction | Transaction)[]) => Promise<any>;
|
|
469
|
+
sendSolana: (tx: OriginTransaction) => Promise<any>;
|
|
470
|
+
sendToken: (tx: OriginTransaction) => Promise<any>;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
interface StateProvider {
|
|
474
|
+
accounts: any[] | null;
|
|
475
|
+
isConnected: boolean;
|
|
476
|
+
isUnlocked: boolean;
|
|
477
|
+
initialized: boolean;
|
|
478
|
+
isPermanentlyDisconnected: boolean;
|
|
479
|
+
}
|
|
480
|
+
declare class TomoTronProvider extends EventEmitter {
|
|
481
|
+
_isUnlocked: boolean;
|
|
482
|
+
name: string;
|
|
483
|
+
icon: string;
|
|
484
|
+
ready: boolean;
|
|
485
|
+
tronWeb: TronWeb | null;
|
|
486
|
+
sendRequest: (chainType: string, data: any) => void;
|
|
487
|
+
onResponse: any;
|
|
488
|
+
events: {
|
|
489
|
+
connect: boolean;
|
|
490
|
+
disconnect: boolean;
|
|
491
|
+
accountChanged: boolean;
|
|
492
|
+
};
|
|
493
|
+
_state: StateProvider;
|
|
494
|
+
private _requestPromise;
|
|
495
|
+
constructor(productInfo: IProductInfo, { sendRequest, onResponse }: IConnectors);
|
|
496
|
+
private _initTronWeb;
|
|
497
|
+
initialize: () => Promise<void>;
|
|
498
|
+
subscribeWalletEventsCallback: ({ method, data }: {
|
|
499
|
+
method: string;
|
|
500
|
+
data: any;
|
|
501
|
+
}) => void;
|
|
502
|
+
on(eventName: string, listener: (...args: unknown[]) => void): this;
|
|
503
|
+
private _handleAccountsChanged;
|
|
504
|
+
_request: (data: any, responseAdaptor?: any) => Promise<any>;
|
|
505
|
+
request: ({ method, params }: {
|
|
506
|
+
method: string;
|
|
507
|
+
params: any;
|
|
508
|
+
}, responseAdaptor?: any) => Promise<any>;
|
|
509
|
+
connect: () => Promise<any>;
|
|
510
|
+
disconnect: () => Promise<any>;
|
|
511
|
+
signMessage: (message: string) => Promise<any>;
|
|
512
|
+
signTransaction: (transaction: Transaction$1) => Promise<any>;
|
|
513
|
+
sendRawTransaction: (transaction: Transaction$1) => Promise<any>;
|
|
514
|
+
sendTransaction: (params: any) => Promise<any>;
|
|
515
|
+
sendToken: (params: any) => Promise<any>;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
export { BtcProvider, DogecoinProvider, EvmProvider, PhantomProvider as SolanaProvider, TomoTronProvider as TronProvider };
|