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