@zubari/sdk 0.1.9 → 0.1.10
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/{WalletManager-YnFArqAt.d.ts → WalletManager-CkGhJZDo.d.ts} +11 -0
- package/dist/{WalletManager-zKc_xew_.d.mts → WalletManager-UG6taF_0.d.mts} +11 -0
- package/dist/{index-DXTHGOnP.d.mts → index-DS2d6LVD.d.mts} +1 -1
- package/dist/{index-CLssrNf2.d.ts → index-Dk_dYBbp.d.ts} +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +45 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -1
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.d.mts +2 -2
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +45 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +45 -1
- package/dist/react/index.mjs.map +1 -1
- package/dist/wallet/index.d.mts +2 -2
- package/dist/wallet/index.d.ts +2 -2
- package/dist/wallet/index.js +45 -1
- package/dist/wallet/index.js.map +1 -1
- package/dist/wallet/index.mjs +45 -1
- package/dist/wallet/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/wallet/index.mjs
CHANGED
|
@@ -1409,7 +1409,8 @@ async function getPriceForChain(chain) {
|
|
|
1409
1409
|
}
|
|
1410
1410
|
var STORAGE_KEYS = {
|
|
1411
1411
|
ENCRYPTED_SEED: "encrypted_seed",
|
|
1412
|
-
ACTIVE_WALLET: "active_wallet"
|
|
1412
|
+
ACTIVE_WALLET: "active_wallet",
|
|
1413
|
+
DERIVED_ADDRESSES: "derived_addresses"
|
|
1413
1414
|
};
|
|
1414
1415
|
var SUPPORTED_CHAINS = ["ethereum", "bitcoin", "ton", "tron", "solana", "spark"];
|
|
1415
1416
|
var WalletManager = class _WalletManager {
|
|
@@ -1550,6 +1551,7 @@ var WalletManager = class _WalletManager {
|
|
|
1550
1551
|
*/
|
|
1551
1552
|
async deleteWallet() {
|
|
1552
1553
|
await this.storage.removeItem(STORAGE_KEYS.ENCRYPTED_SEED);
|
|
1554
|
+
await this.storage.removeItem(STORAGE_KEYS.DERIVED_ADDRESSES);
|
|
1553
1555
|
this.currentSeed = null;
|
|
1554
1556
|
this.derivedAddress = null;
|
|
1555
1557
|
this.derivedAddresses = {};
|
|
@@ -1763,6 +1765,7 @@ var WalletManager = class _WalletManager {
|
|
|
1763
1765
|
* In browser: Uses the backend API (which has Tether WDK)
|
|
1764
1766
|
* In Node.js: Uses native WDK directly
|
|
1765
1767
|
* Returns REAL cryptographically valid addresses for all chains.
|
|
1768
|
+
* Addresses are persisted to storage for future use.
|
|
1766
1769
|
*/
|
|
1767
1770
|
async deriveAllAddressesWithWdk() {
|
|
1768
1771
|
if (!this.currentSeed) {
|
|
@@ -1778,22 +1781,63 @@ var WalletManager = class _WalletManager {
|
|
|
1778
1781
|
}
|
|
1779
1782
|
}
|
|
1780
1783
|
this.derivedAddresses = addresses;
|
|
1784
|
+
await this.saveAddressesToStorage(addresses);
|
|
1781
1785
|
return addresses;
|
|
1782
1786
|
} catch (error) {
|
|
1783
1787
|
console.error("WDK derivation failed:", error);
|
|
1784
1788
|
throw error;
|
|
1785
1789
|
}
|
|
1786
1790
|
}
|
|
1791
|
+
/**
|
|
1792
|
+
* Save derived addresses to storage
|
|
1793
|
+
*/
|
|
1794
|
+
async saveAddressesToStorage(addresses) {
|
|
1795
|
+
try {
|
|
1796
|
+
await this.storage.setItem(STORAGE_KEYS.DERIVED_ADDRESSES, JSON.stringify(addresses));
|
|
1797
|
+
console.log("Saved derived addresses to storage:", Object.keys(addresses));
|
|
1798
|
+
} catch (error) {
|
|
1799
|
+
console.warn("Failed to save addresses to storage:", error);
|
|
1800
|
+
}
|
|
1801
|
+
}
|
|
1802
|
+
/**
|
|
1803
|
+
* Load derived addresses from storage
|
|
1804
|
+
*/
|
|
1805
|
+
async loadAddressesFromStorage() {
|
|
1806
|
+
try {
|
|
1807
|
+
const stored = await this.storage.getItem(STORAGE_KEYS.DERIVED_ADDRESSES);
|
|
1808
|
+
if (stored) {
|
|
1809
|
+
const addresses = JSON.parse(stored);
|
|
1810
|
+
console.log("Loaded derived addresses from storage:", Object.keys(addresses));
|
|
1811
|
+
return addresses;
|
|
1812
|
+
}
|
|
1813
|
+
} catch (error) {
|
|
1814
|
+
console.warn("Failed to load addresses from storage:", error);
|
|
1815
|
+
}
|
|
1816
|
+
return null;
|
|
1817
|
+
}
|
|
1787
1818
|
/**
|
|
1788
1819
|
* Derive addresses for all enabled chains using Tether WDK
|
|
1789
1820
|
* The unified WDK service handles all fallback strategies automatically:
|
|
1790
1821
|
* - Browser: API backend -> Browser derivation
|
|
1791
1822
|
* - Node.js: Native WDK -> API backend -> Browser derivation
|
|
1823
|
+
*
|
|
1824
|
+
* First tries to load from storage to avoid losing real WDK-derived addresses.
|
|
1792
1825
|
*/
|
|
1793
1826
|
async deriveAllAddressesAsync() {
|
|
1794
1827
|
if (!this.currentSeed) {
|
|
1795
1828
|
throw new Error("Wallet is locked");
|
|
1796
1829
|
}
|
|
1830
|
+
const storedAddresses = await this.loadAddressesFromStorage();
|
|
1831
|
+
if (storedAddresses && Object.keys(storedAddresses).length > 1) {
|
|
1832
|
+
const expectedEthAddress = _WalletManager.deriveAddress(this.currentSeed);
|
|
1833
|
+
if (storedAddresses.ethereum === expectedEthAddress) {
|
|
1834
|
+
console.log("Using addresses from storage (verified by Ethereum address)");
|
|
1835
|
+
this.derivedAddresses = storedAddresses;
|
|
1836
|
+
return storedAddresses;
|
|
1837
|
+
} else {
|
|
1838
|
+
console.log("Stored addresses do not match current seed, re-deriving...");
|
|
1839
|
+
}
|
|
1840
|
+
}
|
|
1797
1841
|
try {
|
|
1798
1842
|
return await this.deriveAllAddressesWithWdk();
|
|
1799
1843
|
} catch (error) {
|