@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.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ethErrors, EthereumRpcError } from 'eth-rpc-errors';
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
|
+
import { ChainTypeEnum } from '@tomo-inc/wallet-utils';
|
|
3
4
|
import { JsonRpcEngine, createIdRemapMiddleware } from 'json-rpc-engine';
|
|
4
5
|
import { createStreamMiddleware } from 'json-rpc-middleware-stream';
|
|
5
6
|
import { toHex } from 'viem';
|
|
@@ -163,10 +164,10 @@ function isHexString(str) {
|
|
|
163
164
|
}
|
|
164
165
|
|
|
165
166
|
// src/btc/unisat.ts
|
|
166
|
-
var
|
|
167
|
-
var BtcProvider = class extends EventEmitter {
|
|
167
|
+
var BitcoinProvider = class extends EventEmitter {
|
|
168
168
|
constructor(productInfo, { sendRequest, onResponse }) {
|
|
169
169
|
super();
|
|
170
|
+
this.type = ChainTypeEnum.BITCOIN;
|
|
170
171
|
this._selectedAddress = null;
|
|
171
172
|
this._isConnected = false;
|
|
172
173
|
this._initialized = false;
|
|
@@ -209,13 +210,13 @@ var BtcProvider = class extends EventEmitter {
|
|
|
209
210
|
};
|
|
210
211
|
this.subscribeWalletEventsCallback = ({ method, data }) => {
|
|
211
212
|
if (method === "accountsChanged") {
|
|
212
|
-
const addresses = (data == null ? void 0 : data[
|
|
213
|
+
const addresses = (data == null ? void 0 : data[this.type]) || [];
|
|
213
214
|
const accounts = addresses.map(({ address }) => address);
|
|
214
215
|
this._handleAccountsChanged(accounts);
|
|
215
216
|
}
|
|
216
217
|
if (method === "chainChanged") {
|
|
217
218
|
const { chainId, type } = data;
|
|
218
|
-
if (type.indexOf(`${
|
|
219
|
+
if (type.indexOf(`${this.type}:`) === 0) {
|
|
219
220
|
this._handleChainChanged({ chainId, isConnected: true });
|
|
220
221
|
}
|
|
221
222
|
}
|
|
@@ -239,7 +240,7 @@ var BtcProvider = class extends EventEmitter {
|
|
|
239
240
|
throw ethErrors.rpc.invalidRequest();
|
|
240
241
|
}
|
|
241
242
|
const dappInfo = await getDappInfo();
|
|
242
|
-
this.sendRequest(
|
|
243
|
+
this.sendRequest(this.type, { method, params, dappInfo });
|
|
243
244
|
const connectFuns = {
|
|
244
245
|
getAccounts: true,
|
|
245
246
|
requestAccounts: true
|
|
@@ -308,7 +309,7 @@ var BtcProvider = class extends EventEmitter {
|
|
|
308
309
|
params: { txId }
|
|
309
310
|
});
|
|
310
311
|
};
|
|
311
|
-
this.signMessage = async (text, type) => {
|
|
312
|
+
this.signMessage = async (text, type = "ecdsa") => {
|
|
312
313
|
return this._request({
|
|
313
314
|
method: "signMessage",
|
|
314
315
|
params: {
|
|
@@ -397,6 +398,12 @@ var BtcProvider = class extends EventEmitter {
|
|
|
397
398
|
}
|
|
398
399
|
});
|
|
399
400
|
};
|
|
401
|
+
this.sendTransaction = async (params) => {
|
|
402
|
+
return this._request({
|
|
403
|
+
method: "sendTransaction",
|
|
404
|
+
params
|
|
405
|
+
});
|
|
406
|
+
};
|
|
400
407
|
this.name = productInfo.name;
|
|
401
408
|
this.rdns = productInfo.rdns;
|
|
402
409
|
this._handleAccountsChanged = this._handleAccountsChanged.bind(this);
|
|
@@ -430,10 +437,10 @@ var BtcProvider = class extends EventEmitter {
|
|
|
430
437
|
}
|
|
431
438
|
}
|
|
432
439
|
};
|
|
433
|
-
var chainType2 = "doge" /* DOGE */;
|
|
434
440
|
var DogecoinProvider = class extends EventEmitter {
|
|
435
441
|
constructor(productInfo, { sendRequest, onResponse }) {
|
|
436
442
|
super();
|
|
443
|
+
this.type = ChainTypeEnum.DOGECOIN;
|
|
437
444
|
this._selectedAddress = null;
|
|
438
445
|
this._network = null;
|
|
439
446
|
this._isConnected = false;
|
|
@@ -487,7 +494,7 @@ var DogecoinProvider = class extends EventEmitter {
|
|
|
487
494
|
throw ethErrors.rpc.invalidRequest();
|
|
488
495
|
}
|
|
489
496
|
const dappInfo = await getDappInfo();
|
|
490
|
-
this.sendRequest(
|
|
497
|
+
this.sendRequest(this.type, { method, params, dappInfo });
|
|
491
498
|
return this.onResponse({ method }).then((res) => {
|
|
492
499
|
const { data } = res || {};
|
|
493
500
|
return adapter ? adapter(data) : data;
|
|
@@ -809,7 +816,6 @@ var EMITTED_NOTIFICATIONS = [
|
|
|
809
816
|
];
|
|
810
817
|
|
|
811
818
|
// src/evm/metamask.ts
|
|
812
|
-
var chainType3 = "evm" /* EVM */;
|
|
813
819
|
var EvmProvider = class extends EventEmitter {
|
|
814
820
|
/**
|
|
815
821
|
* @param connectionStream - A Node.js duplex stream
|
|
@@ -833,15 +839,16 @@ var EvmProvider = class extends EventEmitter {
|
|
|
833
839
|
}
|
|
834
840
|
validateLoggerObject(logger);
|
|
835
841
|
super();
|
|
842
|
+
this.type = ChainTypeEnum.EVM;
|
|
836
843
|
this.subscribeWalletEventsCallback = ({ method, data }) => {
|
|
837
844
|
if (method === "accountsChanged") {
|
|
838
|
-
const addresses = (data == null ? void 0 : data[
|
|
845
|
+
const addresses = (data == null ? void 0 : data[this.type]) || [];
|
|
839
846
|
const accounts = addresses.map(({ address }) => address);
|
|
840
847
|
this._handleAccountsChanged(accounts, true);
|
|
841
848
|
}
|
|
842
849
|
if (method === "chainChanged") {
|
|
843
850
|
const { chainId, type } = data;
|
|
844
|
-
if (type.indexOf(`${
|
|
851
|
+
if (type.indexOf(`${this.type}:`) === 0) {
|
|
845
852
|
const chainIdHex = toHex(parseInt(chainId));
|
|
846
853
|
this._handleChainChanged({ chainId: chainIdHex, isConnected: true });
|
|
847
854
|
}
|
|
@@ -1011,7 +1018,7 @@ var EvmProvider = class extends EventEmitter {
|
|
|
1011
1018
|
};
|
|
1012
1019
|
const dappInfo = await getDappInfo();
|
|
1013
1020
|
args = __spreadValues(__spreadValues({}, args), { dappInfo });
|
|
1014
|
-
this.sendRequest(
|
|
1021
|
+
this.sendRequest(this.type, args);
|
|
1015
1022
|
return this.onResponse(args).then((res) => {
|
|
1016
1023
|
const { data, method: method2 } = res || {};
|
|
1017
1024
|
if (method2 === "_wallet_getProviderState") {
|
|
@@ -1430,10 +1437,10 @@ var hexToTx = (hexString) => {
|
|
|
1430
1437
|
};
|
|
1431
1438
|
|
|
1432
1439
|
// src/solana/phantom.ts
|
|
1433
|
-
var chainType4 = "sol" /* SOL */;
|
|
1434
1440
|
var PhantomProvider = class extends EventEmitter {
|
|
1435
1441
|
constructor(productInfo, { sendRequest, onResponse }) {
|
|
1436
1442
|
super();
|
|
1443
|
+
this.chainType = ChainTypeEnum.SOLANA;
|
|
1437
1444
|
this._isUnlocked = false;
|
|
1438
1445
|
this.name = "";
|
|
1439
1446
|
this.icon = "";
|
|
@@ -1478,7 +1485,7 @@ var PhantomProvider = class extends EventEmitter {
|
|
|
1478
1485
|
};
|
|
1479
1486
|
this.subscribeWalletEventsCallback = ({ method, data }) => {
|
|
1480
1487
|
if (method === "accountsChanged") {
|
|
1481
|
-
const accounts = data == null ? void 0 : data[
|
|
1488
|
+
const accounts = data == null ? void 0 : data[this.chainType];
|
|
1482
1489
|
this._handleAccountsChanged(accounts);
|
|
1483
1490
|
}
|
|
1484
1491
|
};
|
|
@@ -1500,7 +1507,7 @@ var PhantomProvider = class extends EventEmitter {
|
|
|
1500
1507
|
throw ethErrors.rpc.invalidRequest();
|
|
1501
1508
|
}
|
|
1502
1509
|
const dappInfo = await getDappInfo();
|
|
1503
|
-
this.sendRequest(
|
|
1510
|
+
this.sendRequest(this.chainType, __spreadProps(__spreadValues({}, data), { dappInfo }));
|
|
1504
1511
|
return this.onResponse(data).then((res) => {
|
|
1505
1512
|
let { data: data2 } = res || {};
|
|
1506
1513
|
if (data2 && data2.publicKey) {
|
|
@@ -1765,15 +1772,17 @@ Resources:`;
|
|
|
1765
1772
|
}
|
|
1766
1773
|
}
|
|
1767
1774
|
};
|
|
1768
|
-
var
|
|
1775
|
+
var _fullHost = "https://api.trongrid.io";
|
|
1769
1776
|
var TomoTronProvider = class extends EventEmitter {
|
|
1770
1777
|
constructor(productInfo, { sendRequest, onResponse }) {
|
|
1771
1778
|
super();
|
|
1779
|
+
this.type = ChainTypeEnum.TRON;
|
|
1772
1780
|
this._isUnlocked = false;
|
|
1773
1781
|
this.name = "";
|
|
1774
1782
|
this.icon = "";
|
|
1775
1783
|
this.ready = false;
|
|
1776
|
-
this.tronWeb =
|
|
1784
|
+
this.tronWeb = new TronWeb({ fullHost: _fullHost });
|
|
1785
|
+
this.address = "";
|
|
1777
1786
|
this.events = {
|
|
1778
1787
|
connect: true,
|
|
1779
1788
|
disconnect: true,
|
|
@@ -1789,9 +1798,9 @@ var TomoTronProvider = class extends EventEmitter {
|
|
|
1789
1798
|
// private _pushEventHandlers: PushEventHandlers;
|
|
1790
1799
|
this._requestPromise = new ReadyPromise(0);
|
|
1791
1800
|
this._initTronWeb = async (res) => {
|
|
1792
|
-
const { fullHost
|
|
1801
|
+
const { fullHost, address } = res || {};
|
|
1793
1802
|
this.tronWeb = new TronWeb({
|
|
1794
|
-
fullHost
|
|
1803
|
+
fullHost: fullHost || _fullHost
|
|
1795
1804
|
});
|
|
1796
1805
|
this.tronWeb.defaultAddress.base58 = address;
|
|
1797
1806
|
this.tronWeb.defaultAddress.hex = TronWeb.address.toHex(address);
|
|
@@ -1860,7 +1869,7 @@ var TomoTronProvider = class extends EventEmitter {
|
|
|
1860
1869
|
};
|
|
1861
1870
|
this.subscribeWalletEventsCallback = ({ method, data }) => {
|
|
1862
1871
|
if (method === "accountsChanged") {
|
|
1863
|
-
const accounts = data == null ? void 0 : data[
|
|
1872
|
+
const accounts = data == null ? void 0 : data[this.type];
|
|
1864
1873
|
this._handleAccountsChanged(accounts);
|
|
1865
1874
|
}
|
|
1866
1875
|
};
|
|
@@ -1869,7 +1878,7 @@ var TomoTronProvider = class extends EventEmitter {
|
|
|
1869
1878
|
throw ethErrors.rpc.invalidRequest();
|
|
1870
1879
|
}
|
|
1871
1880
|
const dappInfo = await getDappInfo();
|
|
1872
|
-
this.sendRequest(
|
|
1881
|
+
this.sendRequest(this.type, __spreadProps(__spreadValues({}, data), { dappInfo }));
|
|
1873
1882
|
return this.onResponse(data).then((res) => {
|
|
1874
1883
|
const { data: data2, method } = res || {};
|
|
1875
1884
|
if (method === "tron_requestAccounts") {
|
|
@@ -1998,7 +2007,7 @@ var TomoTronProvider = class extends EventEmitter {
|
|
|
1998
2007
|
});
|
|
1999
2008
|
this.on("disconnect", (result) => {
|
|
2000
2009
|
this._state.isConnected = false;
|
|
2001
|
-
this.tronWeb =
|
|
2010
|
+
this.tronWeb = new TronWeb({ fullHost: _fullHost });
|
|
2002
2011
|
window.postMessage(
|
|
2003
2012
|
{
|
|
2004
2013
|
message: {
|
|
@@ -2045,4 +2054,4 @@ var TomoTronProvider = class extends EventEmitter {
|
|
|
2045
2054
|
}
|
|
2046
2055
|
};
|
|
2047
2056
|
|
|
2048
|
-
export {
|
|
2057
|
+
export { BitcoinProvider, DogecoinProvider, EvmProvider, PhantomProvider as SolanaProvider, TomoTronProvider as TronProvider };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tomo-inc/inject-providers",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"author": "tomo.inc",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"json-rpc-middleware-stream": "^3.0.0",
|
|
26
26
|
"tronweb": "^6.0.3",
|
|
27
27
|
"viem": "^2.38.3",
|
|
28
|
-
"@tomo-inc/wallet-utils": "0.0.
|
|
28
|
+
"@tomo-inc/wallet-utils": "0.0.17"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^20.0.0",
|
package/src/btc/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BitcoinProvider } from "./unisat";
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { BitcoinProvider };
|
package/src/btc/types.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ChainTypes } from "types";
|
|
2
|
+
|
|
1
3
|
export enum TxType {
|
|
2
4
|
SIGN_TX,
|
|
3
5
|
SEND_BITCOIN,
|
|
@@ -14,7 +16,10 @@ export type Balance = {
|
|
|
14
16
|
total: number;
|
|
15
17
|
};
|
|
16
18
|
|
|
17
|
-
export type
|
|
19
|
+
export type SignMessageType = "ecdsa" | "bip322-simple";
|
|
20
|
+
|
|
21
|
+
export interface IBitcoinProvider {
|
|
22
|
+
type: ChainTypes.BITCOIN;
|
|
18
23
|
connect: () => Promise<any>;
|
|
19
24
|
disconnect: () => Promise<any>;
|
|
20
25
|
requestAccounts: () => Promise<any>;
|
|
@@ -22,7 +27,7 @@ export type IBtcProvider = {
|
|
|
22
27
|
getPublicKey: () => Promise<any>;
|
|
23
28
|
getBalance: () => Promise<any>;
|
|
24
29
|
getTransactionStatus: (params: { txId: string }) => Promise<any>;
|
|
25
|
-
signMessage: (
|
|
30
|
+
signMessage: (text: string, type: SignMessageType) => Promise<any>;
|
|
26
31
|
getNetwork: () => Promise<any>;
|
|
27
32
|
switchNetwork: (network: Network) => Promise<any>;
|
|
28
33
|
getChain: () => Promise<any>;
|
|
@@ -35,4 +40,4 @@ export type IBtcProvider = {
|
|
|
35
40
|
pushTx: (rawtx: string) => Promise<any>;
|
|
36
41
|
sendTransaction: (params: any) => Promise<any>;
|
|
37
42
|
sendBitcoin: (rawtx: string) => Promise<any>;
|
|
38
|
-
}
|
|
43
|
+
}
|
package/src/btc/unisat.ts
CHANGED
|
@@ -3,9 +3,7 @@ import { EventEmitter } from "events";
|
|
|
3
3
|
|
|
4
4
|
import { ChainTypes, IConnectors, IProductInfo } from "../types";
|
|
5
5
|
import { ReadyPromise, domReadyCall, getDappInfo } from "../utils/index";
|
|
6
|
-
import { Balance, ChainId, Network } from "./types";
|
|
7
|
-
|
|
8
|
-
const chainType = ChainTypes.BTC;
|
|
6
|
+
import { Balance, ChainId, IBitcoinProvider, Network, SignMessageType } from "./types";
|
|
9
7
|
|
|
10
8
|
interface StateProvider {
|
|
11
9
|
accounts: string[] | null;
|
|
@@ -15,7 +13,8 @@ interface StateProvider {
|
|
|
15
13
|
isPermanentlyDisconnected: boolean;
|
|
16
14
|
}
|
|
17
15
|
|
|
18
|
-
export class
|
|
16
|
+
export class BitcoinProvider extends EventEmitter implements IBitcoinProvider {
|
|
17
|
+
type: ChainTypes.BITCOIN = ChainTypes.BITCOIN;
|
|
19
18
|
_selectedAddress: string | null = null;
|
|
20
19
|
_isConnected = false;
|
|
21
20
|
_initialized = false;
|
|
@@ -80,14 +79,14 @@ export class BtcProvider extends EventEmitter {
|
|
|
80
79
|
|
|
81
80
|
subscribeWalletEventsCallback = ({ method, data }: { method: string; data: any }) => {
|
|
82
81
|
if (method === "accountsChanged") {
|
|
83
|
-
const addresses = data?.[
|
|
82
|
+
const addresses = data?.[this.type] || [];
|
|
84
83
|
// addresses = addresses.filter((item) => item.subType === "default");
|
|
85
84
|
const accounts = addresses.map(({ address }: { address: string }) => address);
|
|
86
85
|
this._handleAccountsChanged(accounts);
|
|
87
86
|
}
|
|
88
87
|
if (method === "chainChanged") {
|
|
89
88
|
const { chainId, type }: { chainId: string; type: string } = data;
|
|
90
|
-
if (type.indexOf(`${
|
|
89
|
+
if (type.indexOf(`${this.type}:`) === 0) {
|
|
91
90
|
this._handleChainChanged({ chainId, isConnected: true });
|
|
92
91
|
}
|
|
93
92
|
}
|
|
@@ -147,7 +146,7 @@ export class BtcProvider extends EventEmitter {
|
|
|
147
146
|
|
|
148
147
|
//api call -> ("0: dapp -> injector -> content");
|
|
149
148
|
const dappInfo = await getDappInfo();
|
|
150
|
-
this.sendRequest(
|
|
149
|
+
this.sendRequest(this.type, { method, params, dappInfo });
|
|
151
150
|
|
|
152
151
|
const connectFuns: Record<string, boolean> = {
|
|
153
152
|
getAccounts: true,
|
|
@@ -230,7 +229,7 @@ export class BtcProvider extends EventEmitter {
|
|
|
230
229
|
});
|
|
231
230
|
};
|
|
232
231
|
|
|
233
|
-
signMessage = async (text: string, type
|
|
232
|
+
signMessage = async (text: string, type: SignMessageType = "ecdsa"): Promise<string> => {
|
|
234
233
|
return this._request({
|
|
235
234
|
method: "signMessage",
|
|
236
235
|
params: {
|
|
@@ -329,4 +328,11 @@ export class BtcProvider extends EventEmitter {
|
|
|
329
328
|
},
|
|
330
329
|
});
|
|
331
330
|
};
|
|
331
|
+
|
|
332
|
+
sendTransaction = async (params: any) => {
|
|
333
|
+
return this._request({
|
|
334
|
+
method: "sendTransaction",
|
|
335
|
+
params,
|
|
336
|
+
});
|
|
337
|
+
};
|
|
332
338
|
}
|
package/src/dogecoin/dogecoin.ts
CHANGED
|
@@ -5,8 +5,7 @@ import { ReadyPromise, domReadyCall, getDappInfo } from "../utils/index";
|
|
|
5
5
|
import { TxType } from "./types";
|
|
6
6
|
|
|
7
7
|
import { ChainTypes, IConnectors, IProductInfo } from "../types";
|
|
8
|
-
|
|
9
|
-
const chainType = ChainTypes.DOGE;
|
|
8
|
+
import { IDogecoinProvider } from "./interface";
|
|
10
9
|
|
|
11
10
|
interface StateProvider {
|
|
12
11
|
accounts: string[] | null;
|
|
@@ -16,7 +15,8 @@ interface StateProvider {
|
|
|
16
15
|
isPermanentlyDisconnected: boolean;
|
|
17
16
|
}
|
|
18
17
|
|
|
19
|
-
export class DogecoinProvider extends EventEmitter {
|
|
18
|
+
export class DogecoinProvider extends EventEmitter implements IDogecoinProvider {
|
|
19
|
+
type: ChainTypes.DOGECOIN = ChainTypes.DOGECOIN;
|
|
20
20
|
_selectedAddress: string | null = null;
|
|
21
21
|
_network: string | null = null;
|
|
22
22
|
_isConnected = false;
|
|
@@ -94,7 +94,7 @@ export class DogecoinProvider extends EventEmitter {
|
|
|
94
94
|
|
|
95
95
|
//api call -> ("0: dapp -> injector -> content");
|
|
96
96
|
const dappInfo = await getDappInfo();
|
|
97
|
-
this.sendRequest(
|
|
97
|
+
this.sendRequest(this.type, { method, params, dappInfo });
|
|
98
98
|
|
|
99
99
|
//check result by method
|
|
100
100
|
return this.onResponse({ method }).then((res: any) => {
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import { EventEmitter } from "events";
|
|
2
|
+
import { ChainTypes } from "types";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* State interface for DogecoinProvider
|
|
6
|
+
*/
|
|
7
|
+
export interface IDogecoinProviderState {
|
|
8
|
+
accounts: string[] | null;
|
|
9
|
+
isConnected: boolean;
|
|
10
|
+
isUnlocked: boolean;
|
|
11
|
+
initialized: boolean;
|
|
12
|
+
isPermanentlyDisconnected: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Balance response interface
|
|
17
|
+
*/
|
|
18
|
+
export interface IDogecoinBalance {
|
|
19
|
+
confirmed: number;
|
|
20
|
+
unconfirmed: number;
|
|
21
|
+
total: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Transaction status response interface
|
|
26
|
+
*/
|
|
27
|
+
export interface ITransactionStatus {
|
|
28
|
+
status: string;
|
|
29
|
+
confirmations: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Signed message response interface
|
|
34
|
+
*/
|
|
35
|
+
export interface ISignedMessage {
|
|
36
|
+
signedMessage: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Decrypted message response interface
|
|
41
|
+
*/
|
|
42
|
+
export interface IDecryptedMessage {
|
|
43
|
+
decryptedMessage: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* PSBT request parameters interface
|
|
48
|
+
*/
|
|
49
|
+
export interface IRequestPsbtParams {
|
|
50
|
+
rawTx: string;
|
|
51
|
+
indexes?: [];
|
|
52
|
+
feeOnly?: boolean;
|
|
53
|
+
signOnly?: boolean;
|
|
54
|
+
partial?: boolean;
|
|
55
|
+
sighashType?: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* PSBT response interface
|
|
60
|
+
*/
|
|
61
|
+
export interface IPsbtResponse {
|
|
62
|
+
signedRawTx?: string;
|
|
63
|
+
txId?: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Send options interface
|
|
68
|
+
*/
|
|
69
|
+
export interface ISendOptions {
|
|
70
|
+
feeRate?: number;
|
|
71
|
+
memo?: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Connection status response interface
|
|
76
|
+
*/
|
|
77
|
+
export interface IConnectionStatus {
|
|
78
|
+
connected: boolean;
|
|
79
|
+
address: string;
|
|
80
|
+
selectedWalletAddress: string;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* DRC20 balance response interface
|
|
85
|
+
*/
|
|
86
|
+
export interface IDRC20Balance {
|
|
87
|
+
availableBalance: number;
|
|
88
|
+
transferableBalance: number;
|
|
89
|
+
ticker: string;
|
|
90
|
+
address: string;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Transferable DRC20 response interface
|
|
95
|
+
*/
|
|
96
|
+
export interface ITransferableDRC20 {
|
|
97
|
+
inscriptions: any[];
|
|
98
|
+
ticker: string;
|
|
99
|
+
address: string;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* DRC20 transaction response interface
|
|
104
|
+
*/
|
|
105
|
+
export interface IDRC20Transaction {
|
|
106
|
+
txId: string;
|
|
107
|
+
ticker: string;
|
|
108
|
+
amount: number;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Dunes balance response interface
|
|
113
|
+
*/
|
|
114
|
+
export interface IDunesBalance {
|
|
115
|
+
balance: number;
|
|
116
|
+
ticker: string;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Main interface for DogecoinProvider
|
|
121
|
+
* Extends EventEmitter to support event handling
|
|
122
|
+
*/
|
|
123
|
+
export interface IDogecoinProvider extends EventEmitter {
|
|
124
|
+
type: ChainTypes.DOGECOIN;
|
|
125
|
+
|
|
126
|
+
rdns: string;
|
|
127
|
+
name: string;
|
|
128
|
+
|
|
129
|
+
// Connection methods
|
|
130
|
+
/**
|
|
131
|
+
* Connect to the wallet
|
|
132
|
+
* @returns Promise resolving to connection result with address, approved, balance, publicKey
|
|
133
|
+
*/
|
|
134
|
+
connect(): Promise<any>;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Disconnect from the wallet
|
|
138
|
+
* @returns Promise resolving to disconnect result with disconnected status
|
|
139
|
+
*/
|
|
140
|
+
disconnect(): Promise<any>;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Get connection status
|
|
144
|
+
* @returns Promise resolving to connection status with connected, address, selectedWalletAddress
|
|
145
|
+
*/
|
|
146
|
+
getConnectionStatus(): Promise<IConnectionStatus>;
|
|
147
|
+
|
|
148
|
+
// Account methods
|
|
149
|
+
/**
|
|
150
|
+
* Request accounts from the wallet
|
|
151
|
+
* @returns Promise resolving to array of account addresses
|
|
152
|
+
*/
|
|
153
|
+
requestAccounts(): Promise<string[]>;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Get current accounts
|
|
157
|
+
* @returns Promise resolving to array of account addresses
|
|
158
|
+
*/
|
|
159
|
+
getAccounts(): Promise<string[]>;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Get public key
|
|
163
|
+
* @returns Promise resolving to public key string
|
|
164
|
+
*/
|
|
165
|
+
getPublicKey(): Promise<string>;
|
|
166
|
+
|
|
167
|
+
// Balance methods
|
|
168
|
+
/**
|
|
169
|
+
* Get balance
|
|
170
|
+
* @returns Promise resolving to balance object with confirmed, unconfirmed, and total
|
|
171
|
+
*/
|
|
172
|
+
getBalance(): Promise<IDogecoinBalance>;
|
|
173
|
+
|
|
174
|
+
// Transaction methods
|
|
175
|
+
/**
|
|
176
|
+
* Get transaction status
|
|
177
|
+
* @param params - Transaction status parameters
|
|
178
|
+
* @param params.txId - Transaction ID
|
|
179
|
+
* @returns Promise resolving to transaction status
|
|
180
|
+
*/
|
|
181
|
+
getTransactionStatus(params: { txId: string }): Promise<ITransactionStatus>;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Request a transaction
|
|
185
|
+
* @param params - Transaction parameters
|
|
186
|
+
* @param params.recipientAddress - Recipient address
|
|
187
|
+
* @param params.dogeAmount - Amount in DOGE
|
|
188
|
+
* @returns Promise resolving to transaction result with txId
|
|
189
|
+
*/
|
|
190
|
+
requestTransaction(params: { recipientAddress: string; dogeAmount: number }): Promise<{ txId: string }>;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Send DOGE
|
|
194
|
+
* @param toAddress - Recipient address
|
|
195
|
+
* @param satoshis - Amount in satoshis (optional)
|
|
196
|
+
* @param options - Send options (optional)
|
|
197
|
+
* @returns Promise resolving to transaction ID
|
|
198
|
+
*/
|
|
199
|
+
send(toAddress: string, satoshis?: number, options?: ISendOptions): Promise<string>;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Send DOGE (alias for send)
|
|
203
|
+
* @param toAddress - Recipient address
|
|
204
|
+
* @param satoshis - Amount in satoshis (optional)
|
|
205
|
+
* @param options - Send options (optional)
|
|
206
|
+
* @returns Promise resolving to transaction ID
|
|
207
|
+
*/
|
|
208
|
+
sendDogecoin(toAddress: string, satoshis?: number, options?: ISendOptions): Promise<string>;
|
|
209
|
+
|
|
210
|
+
// Message signing methods
|
|
211
|
+
/**
|
|
212
|
+
* Request signed message
|
|
213
|
+
* @param params - Sign message parameters
|
|
214
|
+
* @param params.message - Message to sign
|
|
215
|
+
* @param params.type - Message type (optional)
|
|
216
|
+
* @returns Promise resolving to signed message result
|
|
217
|
+
*/
|
|
218
|
+
requestSignedMessage(params: { message: string; type?: string }): Promise<ISignedMessage>;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Sign message
|
|
222
|
+
* @param message - Message to sign
|
|
223
|
+
* @param type - Message type (optional)
|
|
224
|
+
* @returns Promise resolving to signed message string
|
|
225
|
+
*/
|
|
226
|
+
signMessage(message: string, type?: string): Promise<string>;
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Request decrypted message
|
|
230
|
+
* @param params - Decrypt message parameters
|
|
231
|
+
* @param params.message - Message to decrypt
|
|
232
|
+
* @returns Promise resolving to decrypted message result
|
|
233
|
+
*/
|
|
234
|
+
requestDecryptedMessage(params: { message: string }): Promise<IDecryptedMessage>;
|
|
235
|
+
|
|
236
|
+
// PSBT methods
|
|
237
|
+
/**
|
|
238
|
+
* Request PSBT
|
|
239
|
+
* @param params - PSBT request parameters
|
|
240
|
+
* @returns Promise resolving to PSBT result with signedRawTx and/or txId
|
|
241
|
+
*/
|
|
242
|
+
requestPsbt(params: IRequestPsbtParams): Promise<IPsbtResponse>;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Sign PSBT
|
|
246
|
+
* @param psbtHex - PSBT hex string
|
|
247
|
+
* @param options - Sign options (optional)
|
|
248
|
+
* @returns Promise resolving to signed PSBT hex string
|
|
249
|
+
*/
|
|
250
|
+
signPsbt(psbtHex: string, options?: any): Promise<string>;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Sign multiple PSBTs
|
|
254
|
+
* @param psbtHexs - Array of PSBT hex strings
|
|
255
|
+
* @param options - Sign options (optional)
|
|
256
|
+
* @returns Promise resolving to signed PSBTs
|
|
257
|
+
*/
|
|
258
|
+
signPsbts(psbtHexs: string[], options?: any): Promise<any>;
|
|
259
|
+
|
|
260
|
+
// DRC20 methods
|
|
261
|
+
/**
|
|
262
|
+
* Get DRC20 balances
|
|
263
|
+
* @param address - Address to query
|
|
264
|
+
* @param ticker - Token ticker (optional)
|
|
265
|
+
* @returns Promise resolving to DRC20 balances
|
|
266
|
+
*/
|
|
267
|
+
getDRC20Balances(address: string, ticker?: string): Promise<any>;
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Get DRC20 balance
|
|
271
|
+
* @param params - Balance query parameters
|
|
272
|
+
* @param params.ticker - Token ticker (optional)
|
|
273
|
+
* @returns Promise resolving to DRC20 balance
|
|
274
|
+
*/
|
|
275
|
+
getDRC20Balance(params: { ticker?: string }): Promise<IDRC20Balance>;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Get transferable DRC20
|
|
279
|
+
* @param params - Transferable query parameters
|
|
280
|
+
* @param params.ticker - Token ticker (optional)
|
|
281
|
+
* @returns Promise resolving to transferable DRC20
|
|
282
|
+
*/
|
|
283
|
+
getTransferableDRC20(params: { ticker?: string }): Promise<ITransferableDRC20>;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Request available DRC20 transaction
|
|
287
|
+
* @param params - Transaction parameters
|
|
288
|
+
* @param params.ticker - Token ticker
|
|
289
|
+
* @param params.amount - Amount to transfer
|
|
290
|
+
* @returns Promise resolving to DRC20 transaction result
|
|
291
|
+
*/
|
|
292
|
+
requestAvailableDRC20Transaction(params: { ticker: string; amount: number }): Promise<IDRC20Transaction>;
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Request inscription transaction
|
|
296
|
+
* @param params - Inscription transaction parameters
|
|
297
|
+
* @param params.location - Inscription location
|
|
298
|
+
* @param params.recipientAddress - Recipient address
|
|
299
|
+
* @returns Promise resolving to transaction result with txId
|
|
300
|
+
*/
|
|
301
|
+
requestInscriptionTransaction(params: { location: string; recipientAddress: string }): Promise<{ txId: string }>;
|
|
302
|
+
|
|
303
|
+
// Dunes methods
|
|
304
|
+
/**
|
|
305
|
+
* Get Dunes balance
|
|
306
|
+
* @param params - Balance query parameters
|
|
307
|
+
* @param params.ticker - Token ticker
|
|
308
|
+
* @returns Promise resolving to Dunes balance
|
|
309
|
+
*/
|
|
310
|
+
getDunesBalance(params: { ticker: string }): Promise<IDunesBalance>;
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Request Dunes transaction
|
|
314
|
+
* @param params - Transaction parameters
|
|
315
|
+
* @param params.ticker - Token ticker
|
|
316
|
+
* @param params.amount - Amount to transfer
|
|
317
|
+
* @param params.recipientAddress - Recipient address
|
|
318
|
+
* @returns Promise resolving to transaction result
|
|
319
|
+
*/
|
|
320
|
+
requestDunesTransaction(params: { ticker: string; amount: number; recipientAddress: string }): Promise<any>;
|
|
321
|
+
|
|
322
|
+
// Generic request method
|
|
323
|
+
/**
|
|
324
|
+
* Generic request method
|
|
325
|
+
* @param params - Request parameters
|
|
326
|
+
* @param params.method - RPC method name
|
|
327
|
+
* @param params.params - Method parameters
|
|
328
|
+
* @returns Promise resolving to request result
|
|
329
|
+
*/
|
|
330
|
+
request(params: { method: string; params: any }): Promise<any>;
|
|
331
|
+
}
|