@enclave-hq/wallet-sdk 1.1.2 → 1.1.4
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.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +143 -55
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +143 -55
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.d.mts +2 -1
- package/dist/react/index.d.ts +2 -1
- package/dist/react/index.js +164 -53
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +164 -53
- package/dist/react/index.mjs.map +1 -1
- package/package.json +1 -2
package/dist/index.mjs
CHANGED
|
@@ -360,7 +360,7 @@ var CHAIN_INFO = {
|
|
|
360
360
|
"https://data-seed-prebsc-1-s3.binance.org:8545",
|
|
361
361
|
"https://data-seed-prebsc-2-s3.binance.org:8545",
|
|
362
362
|
"https://data-seed-prebsc-1-s1.binance.org:8545"
|
|
363
|
-
//
|
|
363
|
+
// Original main node as last fallback
|
|
364
364
|
],
|
|
365
365
|
blockExplorerUrls: ["https://testnet.bscscan.com"]
|
|
366
366
|
},
|
|
@@ -535,7 +535,7 @@ var MetaMaskAdapter = class extends BrowserWalletAdapter {
|
|
|
535
535
|
};
|
|
536
536
|
}
|
|
537
537
|
/**
|
|
538
|
-
*
|
|
538
|
+
* Connect wallet
|
|
539
539
|
*/
|
|
540
540
|
async connect(chainId) {
|
|
541
541
|
await this.ensureAvailable();
|
|
@@ -1498,7 +1498,7 @@ var AdapterRegistry = class {
|
|
|
1498
1498
|
this.registerDefaultAdapters();
|
|
1499
1499
|
}
|
|
1500
1500
|
/**
|
|
1501
|
-
*
|
|
1501
|
+
* Register default adapters
|
|
1502
1502
|
*/
|
|
1503
1503
|
registerDefaultAdapters() {
|
|
1504
1504
|
this.register("metamask" /* METAMASK */, () => new MetaMaskAdapter());
|
|
@@ -1506,13 +1506,13 @@ var AdapterRegistry = class {
|
|
|
1506
1506
|
this.register("tronlink" /* TRONLINK */, () => new TronLinkAdapter());
|
|
1507
1507
|
}
|
|
1508
1508
|
/**
|
|
1509
|
-
*
|
|
1509
|
+
* Register adapter
|
|
1510
1510
|
*/
|
|
1511
1511
|
register(type, factory) {
|
|
1512
1512
|
this.adapters.set(type, factory);
|
|
1513
1513
|
}
|
|
1514
1514
|
/**
|
|
1515
|
-
*
|
|
1515
|
+
* Get adapter
|
|
1516
1516
|
*/
|
|
1517
1517
|
getAdapter(type) {
|
|
1518
1518
|
const factory = this.adapters.get(type);
|
|
@@ -1522,13 +1522,13 @@ var AdapterRegistry = class {
|
|
|
1522
1522
|
return factory();
|
|
1523
1523
|
}
|
|
1524
1524
|
/**
|
|
1525
|
-
*
|
|
1525
|
+
* Check if adapter is registered
|
|
1526
1526
|
*/
|
|
1527
1527
|
has(type) {
|
|
1528
1528
|
return this.adapters.has(type);
|
|
1529
1529
|
}
|
|
1530
1530
|
/**
|
|
1531
|
-
*
|
|
1531
|
+
* Get all registered adapter types
|
|
1532
1532
|
*/
|
|
1533
1533
|
getRegisteredTypes() {
|
|
1534
1534
|
return Array.from(this.adapters.keys());
|
|
@@ -1552,9 +1552,9 @@ var AdapterRegistry = class {
|
|
|
1552
1552
|
var WalletManager = class extends TypedEventEmitter {
|
|
1553
1553
|
constructor(config = {}) {
|
|
1554
1554
|
super();
|
|
1555
|
-
//
|
|
1555
|
+
// Primary wallet
|
|
1556
1556
|
this.primaryWallet = null;
|
|
1557
|
-
//
|
|
1557
|
+
// Connected wallet pool
|
|
1558
1558
|
this.connectedWallets = /* @__PURE__ */ new Map();
|
|
1559
1559
|
this.config = {
|
|
1560
1560
|
enableStorage: config.enableStorage ?? true,
|
|
@@ -1564,13 +1564,10 @@ var WalletManager = class extends TypedEventEmitter {
|
|
|
1564
1564
|
walletConnectProjectId: config.walletConnectProjectId ?? ""
|
|
1565
1565
|
};
|
|
1566
1566
|
this.registry = new AdapterRegistry();
|
|
1567
|
-
if (this.config.enableStorage) {
|
|
1568
|
-
this.restoreFromStorage();
|
|
1569
|
-
}
|
|
1570
1567
|
}
|
|
1571
|
-
// =====
|
|
1568
|
+
// ===== Connection Management =====
|
|
1572
1569
|
/**
|
|
1573
|
-
*
|
|
1570
|
+
* Connect primary wallet
|
|
1574
1571
|
*/
|
|
1575
1572
|
async connect(type, chainId) {
|
|
1576
1573
|
const adapter = this.registry.getAdapter(type);
|
|
@@ -1591,7 +1588,7 @@ var WalletManager = class extends TypedEventEmitter {
|
|
|
1591
1588
|
return account;
|
|
1592
1589
|
}
|
|
1593
1590
|
/**
|
|
1594
|
-
*
|
|
1591
|
+
* Connect additional wallet (without changing primary wallet)
|
|
1595
1592
|
*/
|
|
1596
1593
|
async connectAdditional(type, chainId) {
|
|
1597
1594
|
const adapter = this.registry.getAdapter(type);
|
|
@@ -1611,7 +1608,7 @@ var WalletManager = class extends TypedEventEmitter {
|
|
|
1611
1608
|
return account;
|
|
1612
1609
|
}
|
|
1613
1610
|
/**
|
|
1614
|
-
*
|
|
1611
|
+
* Connect with private key (for development/testing only)
|
|
1615
1612
|
*/
|
|
1616
1613
|
async connectWithPrivateKey(privateKey, chainId) {
|
|
1617
1614
|
const adapter = new EVMPrivateKeyAdapter();
|
|
@@ -1623,7 +1620,7 @@ var WalletManager = class extends TypedEventEmitter {
|
|
|
1623
1620
|
return account;
|
|
1624
1621
|
}
|
|
1625
1622
|
/**
|
|
1626
|
-
*
|
|
1623
|
+
* Disconnect primary wallet
|
|
1627
1624
|
*/
|
|
1628
1625
|
async disconnect() {
|
|
1629
1626
|
if (!this.primaryWallet) {
|
|
@@ -1640,7 +1637,7 @@ var WalletManager = class extends TypedEventEmitter {
|
|
|
1640
1637
|
this.emit("disconnected");
|
|
1641
1638
|
}
|
|
1642
1639
|
/**
|
|
1643
|
-
*
|
|
1640
|
+
* Disconnect all wallets
|
|
1644
1641
|
*/
|
|
1645
1642
|
async disconnectAll() {
|
|
1646
1643
|
const wallets = Array.from(this.connectedWallets.values());
|
|
@@ -1655,9 +1652,9 @@ var WalletManager = class extends TypedEventEmitter {
|
|
|
1655
1652
|
}
|
|
1656
1653
|
this.emit("disconnected");
|
|
1657
1654
|
}
|
|
1658
|
-
// =====
|
|
1655
|
+
// ===== Primary Wallet Management =====
|
|
1659
1656
|
/**
|
|
1660
|
-
*
|
|
1657
|
+
* Switch primary wallet
|
|
1661
1658
|
*/
|
|
1662
1659
|
async switchPrimaryWallet(chainType) {
|
|
1663
1660
|
const adapter = this.connectedWallets.get(chainType);
|
|
@@ -1677,13 +1674,13 @@ var WalletManager = class extends TypedEventEmitter {
|
|
|
1677
1674
|
return adapter.currentAccount;
|
|
1678
1675
|
}
|
|
1679
1676
|
/**
|
|
1680
|
-
*
|
|
1677
|
+
* Get primary wallet account
|
|
1681
1678
|
*/
|
|
1682
1679
|
getPrimaryAccount() {
|
|
1683
1680
|
return this.primaryWallet?.currentAccount || null;
|
|
1684
1681
|
}
|
|
1685
1682
|
/**
|
|
1686
|
-
*
|
|
1683
|
+
* Get all connected wallets
|
|
1687
1684
|
*/
|
|
1688
1685
|
getConnectedWallets() {
|
|
1689
1686
|
return Array.from(this.connectedWallets.values()).map((adapter) => ({
|
|
@@ -1696,14 +1693,14 @@ var WalletManager = class extends TypedEventEmitter {
|
|
|
1696
1693
|
}));
|
|
1697
1694
|
}
|
|
1698
1695
|
/**
|
|
1699
|
-
*
|
|
1696
|
+
* Get wallet by chain type
|
|
1700
1697
|
*/
|
|
1701
1698
|
getWalletByChainType(chainType) {
|
|
1702
1699
|
return this.connectedWallets.get(chainType) || null;
|
|
1703
1700
|
}
|
|
1704
|
-
// =====
|
|
1701
|
+
// ===== Signing =====
|
|
1705
1702
|
/**
|
|
1706
|
-
*
|
|
1703
|
+
* Sign message with primary wallet
|
|
1707
1704
|
*/
|
|
1708
1705
|
async signMessage(message) {
|
|
1709
1706
|
if (!this.primaryWallet) {
|
|
@@ -1712,7 +1709,7 @@ var WalletManager = class extends TypedEventEmitter {
|
|
|
1712
1709
|
return this.primaryWallet.signMessage(message);
|
|
1713
1710
|
}
|
|
1714
1711
|
/**
|
|
1715
|
-
*
|
|
1712
|
+
* Sign message with wallet of specified chain type
|
|
1716
1713
|
*/
|
|
1717
1714
|
async signMessageWithChainType(message, chainType) {
|
|
1718
1715
|
if (!chainType) {
|
|
@@ -1725,7 +1722,7 @@ var WalletManager = class extends TypedEventEmitter {
|
|
|
1725
1722
|
return adapter.signMessage(message);
|
|
1726
1723
|
}
|
|
1727
1724
|
/**
|
|
1728
|
-
*
|
|
1725
|
+
* Sign TypedData (EVM only)
|
|
1729
1726
|
*/
|
|
1730
1727
|
async signTypedData(typedData, chainType) {
|
|
1731
1728
|
const adapter = chainType ? this.connectedWallets.get(chainType) : this.primaryWallet;
|
|
@@ -1738,7 +1735,7 @@ var WalletManager = class extends TypedEventEmitter {
|
|
|
1738
1735
|
return adapter.signTypedData(typedData);
|
|
1739
1736
|
}
|
|
1740
1737
|
/**
|
|
1741
|
-
*
|
|
1738
|
+
* Sign transaction (with primary wallet)
|
|
1742
1739
|
*/
|
|
1743
1740
|
async signTransaction(transaction) {
|
|
1744
1741
|
if (!this.primaryWallet) {
|
|
@@ -1750,7 +1747,7 @@ var WalletManager = class extends TypedEventEmitter {
|
|
|
1750
1747
|
return this.primaryWallet.signTransaction(transaction);
|
|
1751
1748
|
}
|
|
1752
1749
|
/**
|
|
1753
|
-
*
|
|
1750
|
+
* Sign transaction with wallet of specified chain type
|
|
1754
1751
|
*/
|
|
1755
1752
|
async signTransactionWithChainType(transaction, chainType) {
|
|
1756
1753
|
if (!chainType) {
|
|
@@ -1765,9 +1762,9 @@ var WalletManager = class extends TypedEventEmitter {
|
|
|
1765
1762
|
}
|
|
1766
1763
|
return adapter.signTransaction(transaction);
|
|
1767
1764
|
}
|
|
1768
|
-
// =====
|
|
1765
|
+
// ===== Chain Switching =====
|
|
1769
1766
|
/**
|
|
1770
|
-
*
|
|
1767
|
+
* Request chain switch (EVM only)
|
|
1771
1768
|
*/
|
|
1772
1769
|
async requestSwitchChain(chainId, options) {
|
|
1773
1770
|
if (!this.primaryWallet) {
|
|
@@ -1788,9 +1785,9 @@ var WalletManager = class extends TypedEventEmitter {
|
|
|
1788
1785
|
throw error;
|
|
1789
1786
|
}
|
|
1790
1787
|
}
|
|
1791
|
-
// =====
|
|
1788
|
+
// ===== Contract Calls =====
|
|
1792
1789
|
/**
|
|
1793
|
-
*
|
|
1790
|
+
* Read contract
|
|
1794
1791
|
*/
|
|
1795
1792
|
async readContract(address, abi, functionName, args, chainType) {
|
|
1796
1793
|
const adapter = chainType ? this.connectedWallets.get(chainType) : this.primaryWallet;
|
|
@@ -1803,7 +1800,7 @@ var WalletManager = class extends TypedEventEmitter {
|
|
|
1803
1800
|
return adapter.readContract({ address, abi, functionName, args });
|
|
1804
1801
|
}
|
|
1805
1802
|
/**
|
|
1806
|
-
*
|
|
1803
|
+
* Write contract
|
|
1807
1804
|
*/
|
|
1808
1805
|
async writeContract(address, abi, functionName, args, options, chainType) {
|
|
1809
1806
|
const adapter = chainType ? this.connectedWallets.get(chainType) : this.primaryWallet;
|
|
@@ -1822,7 +1819,7 @@ var WalletManager = class extends TypedEventEmitter {
|
|
|
1822
1819
|
});
|
|
1823
1820
|
}
|
|
1824
1821
|
/**
|
|
1825
|
-
*
|
|
1822
|
+
* Estimate gas
|
|
1826
1823
|
*/
|
|
1827
1824
|
async estimateGas(address, abi, functionName, args, chainType) {
|
|
1828
1825
|
const adapter = chainType ? this.connectedWallets.get(chainType) : this.primaryWallet;
|
|
@@ -1835,7 +1832,7 @@ var WalletManager = class extends TypedEventEmitter {
|
|
|
1835
1832
|
return adapter.estimateGas({ address, abi, functionName, args });
|
|
1836
1833
|
}
|
|
1837
1834
|
/**
|
|
1838
|
-
*
|
|
1835
|
+
* Wait for transaction confirmation
|
|
1839
1836
|
*/
|
|
1840
1837
|
async waitForTransaction(txHash, confirmations, chainType) {
|
|
1841
1838
|
const adapter = chainType ? this.connectedWallets.get(chainType) : this.primaryWallet;
|
|
@@ -1847,9 +1844,9 @@ var WalletManager = class extends TypedEventEmitter {
|
|
|
1847
1844
|
}
|
|
1848
1845
|
return adapter.waitForTransaction(txHash, confirmations);
|
|
1849
1846
|
}
|
|
1850
|
-
// ===== Provider
|
|
1847
|
+
// ===== Provider Access =====
|
|
1851
1848
|
/**
|
|
1852
|
-
*
|
|
1849
|
+
* Get primary wallet Provider
|
|
1853
1850
|
*/
|
|
1854
1851
|
getProvider() {
|
|
1855
1852
|
if (!this.primaryWallet) {
|
|
@@ -1858,7 +1855,7 @@ var WalletManager = class extends TypedEventEmitter {
|
|
|
1858
1855
|
return this.primaryWallet.getProvider();
|
|
1859
1856
|
}
|
|
1860
1857
|
/**
|
|
1861
|
-
*
|
|
1858
|
+
* Get Provider by chain type
|
|
1862
1859
|
*/
|
|
1863
1860
|
getProviderByChainType(chainType) {
|
|
1864
1861
|
const adapter = this.connectedWallets.get(chainType);
|
|
@@ -1867,21 +1864,21 @@ var WalletManager = class extends TypedEventEmitter {
|
|
|
1867
1864
|
}
|
|
1868
1865
|
return adapter.getProvider();
|
|
1869
1866
|
}
|
|
1870
|
-
// =====
|
|
1867
|
+
// ===== Private Methods =====
|
|
1871
1868
|
/**
|
|
1872
|
-
*
|
|
1869
|
+
* Set primary wallet
|
|
1873
1870
|
*/
|
|
1874
1871
|
setPrimaryWallet(adapter) {
|
|
1875
1872
|
this.primaryWallet = adapter;
|
|
1876
1873
|
}
|
|
1877
1874
|
/**
|
|
1878
|
-
*
|
|
1875
|
+
* Check if wallet supports chain switching
|
|
1879
1876
|
*/
|
|
1880
1877
|
canSwitchChain(adapter) {
|
|
1881
1878
|
return !!adapter.switchChain;
|
|
1882
1879
|
}
|
|
1883
1880
|
/**
|
|
1884
|
-
*
|
|
1881
|
+
* Setup adapter event listeners
|
|
1885
1882
|
*/
|
|
1886
1883
|
setupAdapterListeners(adapter, isPrimary) {
|
|
1887
1884
|
adapter.on("accountChanged", (account) => {
|
|
@@ -1922,15 +1919,15 @@ var WalletManager = class extends TypedEventEmitter {
|
|
|
1922
1919
|
});
|
|
1923
1920
|
}
|
|
1924
1921
|
/**
|
|
1925
|
-
*
|
|
1922
|
+
* Remove adapter event listeners
|
|
1926
1923
|
*/
|
|
1927
1924
|
removeAdapterListeners(adapter) {
|
|
1928
1925
|
if (!adapter) return;
|
|
1929
1926
|
adapter.removeAllListeners();
|
|
1930
1927
|
}
|
|
1931
|
-
// =====
|
|
1928
|
+
// ===== Storage =====
|
|
1932
1929
|
/**
|
|
1933
|
-
*
|
|
1930
|
+
* Save to storage
|
|
1934
1931
|
*/
|
|
1935
1932
|
saveToStorage() {
|
|
1936
1933
|
if (typeof window === "undefined" || !this.config.enableStorage) {
|
|
@@ -1938,6 +1935,8 @@ var WalletManager = class extends TypedEventEmitter {
|
|
|
1938
1935
|
}
|
|
1939
1936
|
const data = {
|
|
1940
1937
|
current: this.primaryWallet?.currentAccount?.universalAddress || null,
|
|
1938
|
+
primaryWalletType: this.primaryWallet?.type,
|
|
1939
|
+
primaryChainId: this.primaryWallet?.currentAccount?.chainId,
|
|
1941
1940
|
history: this.getHistoryRecords()
|
|
1942
1941
|
};
|
|
1943
1942
|
try {
|
|
@@ -1950,12 +1949,101 @@ var WalletManager = class extends TypedEventEmitter {
|
|
|
1950
1949
|
}
|
|
1951
1950
|
}
|
|
1952
1951
|
/**
|
|
1953
|
-
*
|
|
1952
|
+
* Restore from storage
|
|
1953
|
+
* Returns a Promise that can be used for auto-reconnection
|
|
1954
1954
|
*/
|
|
1955
|
-
restoreFromStorage() {
|
|
1955
|
+
async restoreFromStorage() {
|
|
1956
|
+
if (typeof window === "undefined" || !this.config.enableStorage) {
|
|
1957
|
+
return null;
|
|
1958
|
+
}
|
|
1959
|
+
try {
|
|
1960
|
+
const stored = localStorage.getItem(`${this.config.storagePrefix}data`);
|
|
1961
|
+
if (!stored) {
|
|
1962
|
+
console.debug("[WalletManager] No stored wallet data found");
|
|
1963
|
+
return null;
|
|
1964
|
+
}
|
|
1965
|
+
const data = JSON.parse(stored);
|
|
1966
|
+
console.debug("[WalletManager] Restoring from storage:", data);
|
|
1967
|
+
if (!data.primaryWalletType || !data.current) {
|
|
1968
|
+
console.debug("[WalletManager] Missing primary wallet info in storage");
|
|
1969
|
+
return null;
|
|
1970
|
+
}
|
|
1971
|
+
const adapter = this.registry.getAdapter(data.primaryWalletType);
|
|
1972
|
+
if (!adapter) {
|
|
1973
|
+
console.debug("[WalletManager] Adapter not found for type:", data.primaryWalletType);
|
|
1974
|
+
return null;
|
|
1975
|
+
}
|
|
1976
|
+
const isAvailable = await adapter.isAvailable();
|
|
1977
|
+
if (!isAvailable) {
|
|
1978
|
+
console.debug("[WalletManager] Wallet not available:", data.primaryWalletType);
|
|
1979
|
+
return null;
|
|
1980
|
+
}
|
|
1981
|
+
console.debug("[WalletManager] Wallet is available, attempting restoration");
|
|
1982
|
+
if (adapter.chainType === ChainType.EVM && data.primaryWalletType === "metamask" /* METAMASK */) {
|
|
1983
|
+
try {
|
|
1984
|
+
const provider = typeof window !== "undefined" ? window.ethereum : null;
|
|
1985
|
+
if (provider) {
|
|
1986
|
+
const accounts = await provider.request({
|
|
1987
|
+
method: "eth_accounts"
|
|
1988
|
+
});
|
|
1989
|
+
console.debug("[WalletManager] Checking authorized accounts:", accounts);
|
|
1990
|
+
if (accounts && accounts.length > 0) {
|
|
1991
|
+
const savedAddress = data.current.split(":")[1];
|
|
1992
|
+
const currentAddress = accounts[0].toLowerCase();
|
|
1993
|
+
console.debug("[WalletManager] Comparing addresses - saved:", savedAddress, "current:", currentAddress);
|
|
1994
|
+
if (currentAddress === savedAddress.toLowerCase()) {
|
|
1995
|
+
console.debug("[WalletManager] Address matches, attempting connect (should be silent if already authorized)");
|
|
1996
|
+
try {
|
|
1997
|
+
const account2 = await adapter.connect(data.primaryChainId);
|
|
1998
|
+
this.setPrimaryWallet(adapter);
|
|
1999
|
+
this.connectedWallets.set(adapter.chainType, adapter);
|
|
2000
|
+
this.setupAdapterListeners(adapter, true);
|
|
2001
|
+
this.emit("accountChanged", account2);
|
|
2002
|
+
console.debug("[WalletManager] Connect successful");
|
|
2003
|
+
return account2;
|
|
2004
|
+
} catch (connectError) {
|
|
2005
|
+
console.debug("[WalletManager] Connect failed (might be user rejection):", connectError?.message);
|
|
2006
|
+
return null;
|
|
2007
|
+
}
|
|
2008
|
+
} else {
|
|
2009
|
+
console.debug("[WalletManager] Address mismatch, will try normal connect");
|
|
2010
|
+
}
|
|
2011
|
+
} else {
|
|
2012
|
+
console.debug("[WalletManager] No authorized accounts found");
|
|
2013
|
+
}
|
|
2014
|
+
}
|
|
2015
|
+
} catch (silentError) {
|
|
2016
|
+
console.debug("Silent connection failed, trying normal connection:", silentError);
|
|
2017
|
+
}
|
|
2018
|
+
}
|
|
2019
|
+
if (adapter.chainType === ChainType.TRON && data.primaryWalletType === "tronlink" /* TRONLINK */) {
|
|
2020
|
+
try {
|
|
2021
|
+
const tronWeb = adapter.getTronWeb?.();
|
|
2022
|
+
if (tronWeb && tronWeb.defaultAddress?.base58) {
|
|
2023
|
+
const account2 = await adapter.connect(data.primaryChainId);
|
|
2024
|
+
this.setPrimaryWallet(adapter);
|
|
2025
|
+
this.connectedWallets.set(adapter.chainType, adapter);
|
|
2026
|
+
this.setupAdapterListeners(adapter, true);
|
|
2027
|
+
this.emit("accountChanged", account2);
|
|
2028
|
+
return account2;
|
|
2029
|
+
}
|
|
2030
|
+
} catch (silentError) {
|
|
2031
|
+
console.debug("Silent TronLink connection failed:", silentError);
|
|
2032
|
+
}
|
|
2033
|
+
}
|
|
2034
|
+
const account = await adapter.connect(data.primaryChainId);
|
|
2035
|
+
this.setPrimaryWallet(adapter);
|
|
2036
|
+
this.connectedWallets.set(adapter.chainType, adapter);
|
|
2037
|
+
this.setupAdapterListeners(adapter, true);
|
|
2038
|
+
this.emit("accountChanged", account);
|
|
2039
|
+
return account;
|
|
2040
|
+
} catch (error) {
|
|
2041
|
+
console.debug("Failed to restore wallet from storage:", error);
|
|
2042
|
+
return null;
|
|
2043
|
+
}
|
|
1956
2044
|
}
|
|
1957
2045
|
/**
|
|
1958
|
-
*
|
|
2046
|
+
* Clear storage
|
|
1959
2047
|
*/
|
|
1960
2048
|
clearStorage() {
|
|
1961
2049
|
if (typeof window === "undefined") {
|
|
@@ -1968,7 +2056,7 @@ var WalletManager = class extends TypedEventEmitter {
|
|
|
1968
2056
|
}
|
|
1969
2057
|
}
|
|
1970
2058
|
/**
|
|
1971
|
-
*
|
|
2059
|
+
* Get history records
|
|
1972
2060
|
*/
|
|
1973
2061
|
getHistoryRecords() {
|
|
1974
2062
|
const records = [];
|
|
@@ -2171,12 +2259,12 @@ function getTronWallets() {
|
|
|
2171
2259
|
// src/detection/detector.ts
|
|
2172
2260
|
var WalletDetector = class {
|
|
2173
2261
|
/**
|
|
2174
|
-
*
|
|
2262
|
+
* Detect all wallet availability
|
|
2175
2263
|
*/
|
|
2176
2264
|
async detectAllWallets() {
|
|
2177
2265
|
const walletTypes = Object.values(WalletType).filter(
|
|
2178
2266
|
(type) => type !== "private-key" /* PRIVATE_KEY */
|
|
2179
|
-
//
|
|
2267
|
+
// Private key wallet does not need detection
|
|
2180
2268
|
);
|
|
2181
2269
|
const results = await Promise.all(
|
|
2182
2270
|
walletTypes.map((type) => this.detectWallet(type))
|
|
@@ -2184,7 +2272,7 @@ var WalletDetector = class {
|
|
|
2184
2272
|
return results;
|
|
2185
2273
|
}
|
|
2186
2274
|
/**
|
|
2187
|
-
*
|
|
2275
|
+
* Detect specific wallet
|
|
2188
2276
|
*/
|
|
2189
2277
|
async detectWallet(walletType) {
|
|
2190
2278
|
const metadata = SUPPORTED_WALLETS[walletType];
|
|
@@ -2192,7 +2280,7 @@ var WalletDetector = class {
|
|
|
2192
2280
|
return {
|
|
2193
2281
|
walletType,
|
|
2194
2282
|
chainType: ChainType.EVM,
|
|
2195
|
-
//
|
|
2283
|
+
// Default
|
|
2196
2284
|
isAvailable: false,
|
|
2197
2285
|
detected: false
|
|
2198
2286
|
};
|
|
@@ -2207,7 +2295,7 @@ var WalletDetector = class {
|
|
|
2207
2295
|
};
|
|
2208
2296
|
}
|
|
2209
2297
|
/**
|
|
2210
|
-
*
|
|
2298
|
+
* Determine if wallet is available
|
|
2211
2299
|
*/
|
|
2212
2300
|
async isWalletAvailable(walletType) {
|
|
2213
2301
|
if (typeof window === "undefined") {
|