@zubari/sdk 0.1.11 → 0.1.12
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-DVq_PUZK.d.ts → WalletManager-DLN81Bpl.d.ts} +11 -17
- package/dist/{WalletManager--UOBwXJp.d.mts → WalletManager-DWLhos10.d.mts} +11 -17
- package/dist/{index-B19bUJSk.d.mts → index-BmBHZP3D.d.mts} +1 -1
- package/dist/{index-r6aRsMfN.d.ts → index-C47lb49r.d.ts} +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +55 -99
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +55 -99
- 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 +55 -99
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +55 -99
- package/dist/react/index.mjs.map +1 -1
- package/dist/services/index.d.mts +8 -2
- package/dist/services/index.d.ts +8 -2
- package/dist/services/index.js +20 -4
- package/dist/services/index.js.map +1 -1
- package/dist/services/index.mjs +20 -4
- package/dist/services/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 +55 -99
- package/dist/wallet/index.js.map +1 -1
- package/dist/wallet/index.mjs +55 -99
- package/dist/wallet/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/wallet/index.mjs
CHANGED
|
@@ -1118,7 +1118,10 @@ var ZubariWdkService = class {
|
|
|
1118
1118
|
return isValidSeed(seed);
|
|
1119
1119
|
}
|
|
1120
1120
|
/**
|
|
1121
|
-
* Derive address for a specific chain
|
|
1121
|
+
* Derive address for a specific chain using WDK API
|
|
1122
|
+
*
|
|
1123
|
+
* For Ethereum, falls back to local derivation if API fails.
|
|
1124
|
+
* For other chains, WDK API is required - no placeholder fallback.
|
|
1122
1125
|
*/
|
|
1123
1126
|
async deriveAddress(seed, chain) {
|
|
1124
1127
|
await this.initialize();
|
|
@@ -1134,6 +1137,9 @@ var ZubariWdkService = class {
|
|
|
1134
1137
|
}
|
|
1135
1138
|
} catch (error) {
|
|
1136
1139
|
console.warn(`API address derivation failed for ${chain}:`, error);
|
|
1140
|
+
if (chain === "ethereum") {
|
|
1141
|
+
return this.deriveBrowserAddress(seed, chain);
|
|
1142
|
+
}
|
|
1137
1143
|
}
|
|
1138
1144
|
if (this.useNativeWdk && this.nativeWdkService) {
|
|
1139
1145
|
try {
|
|
@@ -1144,10 +1150,18 @@ var ZubariWdkService = class {
|
|
|
1144
1150
|
console.warn(`Native WDK address derivation failed for ${chain}:`, error);
|
|
1145
1151
|
}
|
|
1146
1152
|
}
|
|
1147
|
-
|
|
1153
|
+
if (chain === "ethereum") {
|
|
1154
|
+
return this.deriveBrowserAddress(seed, chain);
|
|
1155
|
+
}
|
|
1156
|
+
throw new Error(
|
|
1157
|
+
`WDK API required for ${chain} address derivation. Ensure the backend is running.`
|
|
1158
|
+
);
|
|
1148
1159
|
}
|
|
1149
1160
|
/**
|
|
1150
|
-
* Derive addresses for all supported chains
|
|
1161
|
+
* Derive addresses for all supported chains using WDK API
|
|
1162
|
+
*
|
|
1163
|
+
* Uses the backend WDK API for real cryptographically valid addresses.
|
|
1164
|
+
* No placeholder fallback - WDK API is required for multi-chain addresses.
|
|
1151
1165
|
*/
|
|
1152
1166
|
async deriveAllAddresses(seed) {
|
|
1153
1167
|
await this.initialize();
|
|
@@ -1175,7 +1189,9 @@ var ZubariWdkService = class {
|
|
|
1175
1189
|
console.warn("Native WDK multi-chain derivation failed:", error);
|
|
1176
1190
|
}
|
|
1177
1191
|
}
|
|
1178
|
-
|
|
1192
|
+
throw new Error(
|
|
1193
|
+
"WDK API required for multi-chain address derivation. Ensure the backend is running."
|
|
1194
|
+
);
|
|
1179
1195
|
}
|
|
1180
1196
|
/**
|
|
1181
1197
|
* Get balances for all chains
|
|
@@ -1657,106 +1673,51 @@ var WalletManager = class _WalletManager {
|
|
|
1657
1673
|
* Uses the unified WDK service which:
|
|
1658
1674
|
* - In browser: Calls the backend API (which has Tether WDK)
|
|
1659
1675
|
* - In Node.js: Uses native WDK
|
|
1660
|
-
* - Falls back to browser-compatible derivation if needed
|
|
1661
|
-
*/
|
|
1662
|
-
static async deriveAddressForChainAsync(seed, chain, network = "testnet", apiUrl) {
|
|
1663
|
-
try {
|
|
1664
|
-
const wdkService = getZubariWdkService({ network, apiUrl });
|
|
1665
|
-
const result = await wdkService.deriveAddress(seed, chain);
|
|
1666
|
-
return result.address;
|
|
1667
|
-
} catch (error) {
|
|
1668
|
-
console.warn(`WDK service failed for ${chain}, using local derivation:`, error);
|
|
1669
|
-
}
|
|
1670
|
-
return _WalletManager.deriveAddressForChain(seed, chain);
|
|
1671
|
-
}
|
|
1672
|
-
/**
|
|
1673
|
-
* Format address for non-WDK chains (fallback)
|
|
1674
1676
|
*
|
|
1675
|
-
*
|
|
1676
|
-
* For real blockchain interaction, use the WDK API via deriveAddressForChainAsync().
|
|
1677
|
-
* These addresses should NOT be used for receiving funds without verification.
|
|
1677
|
+
* No fallback to placeholder addresses - WDK API is required for real addresses.
|
|
1678
1678
|
*/
|
|
1679
|
-
static
|
|
1679
|
+
static async deriveAddressForChainAsync(seed, chain, network = "testnet", apiUrl) {
|
|
1680
1680
|
if (chain === "ethereum") {
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
for (let i = 0; i < 38; i++) {
|
|
1689
|
-
const idx = parseInt(addressBytes.charAt(i % 40) || "0", 16) % btcChars.length;
|
|
1690
|
-
btcAddr += btcChars[idx];
|
|
1691
|
-
}
|
|
1692
|
-
return btcAddr;
|
|
1693
|
-
}
|
|
1694
|
-
case "ton": {
|
|
1695
|
-
const base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
1696
|
-
let tonAddr = "EQ";
|
|
1697
|
-
for (let i = 0; i < 46; i++) {
|
|
1698
|
-
const idx = parseInt(addressBytes.charAt(i % 40) || "0", 16) * 4 % base64Chars.length;
|
|
1699
|
-
tonAddr += base64Chars[idx];
|
|
1700
|
-
}
|
|
1701
|
-
return tonAddr;
|
|
1702
|
-
}
|
|
1703
|
-
case "tron": {
|
|
1704
|
-
const base58Chars = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
1705
|
-
let tronAddr = "T";
|
|
1706
|
-
for (let i = 0; i < 33; i++) {
|
|
1707
|
-
const idx = parseInt(addressBytes.charAt(i % 40) || "0", 16) * 3 % base58Chars.length;
|
|
1708
|
-
tronAddr += base58Chars[idx];
|
|
1709
|
-
}
|
|
1710
|
-
return tronAddr;
|
|
1711
|
-
}
|
|
1712
|
-
case "solana": {
|
|
1713
|
-
const base58Chars = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
1714
|
-
let solAddr = "";
|
|
1715
|
-
for (let i = 0; i < 44; i++) {
|
|
1716
|
-
const idx = parseInt(addressBytes.charAt(i % 40) || "0", 16) * 3 % base58Chars.length;
|
|
1717
|
-
solAddr += base58Chars[idx];
|
|
1718
|
-
}
|
|
1719
|
-
return solAddr;
|
|
1720
|
-
}
|
|
1721
|
-
case "spark": {
|
|
1722
|
-
const bech32Chars = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
|
|
1723
|
-
let sparkAddr = "sp1q";
|
|
1724
|
-
for (let i = 0; i < 58; i++) {
|
|
1725
|
-
const idx = parseInt(addressBytes.charAt(i % 40) || "0", 16) % bech32Chars.length;
|
|
1726
|
-
sparkAddr += bech32Chars[idx];
|
|
1727
|
-
}
|
|
1728
|
-
return sparkAddr;
|
|
1681
|
+
try {
|
|
1682
|
+
const wdkService2 = getZubariWdkService({ network, apiUrl });
|
|
1683
|
+
const result2 = await wdkService2.deriveAddress(seed, chain);
|
|
1684
|
+
return result2.address;
|
|
1685
|
+
} catch (error) {
|
|
1686
|
+
console.warn("WDK service failed for Ethereum, using local derivation:", error);
|
|
1687
|
+
return _WalletManager.deriveAddressForChain(seed, "ethereum");
|
|
1729
1688
|
}
|
|
1730
|
-
default:
|
|
1731
|
-
return address;
|
|
1732
1689
|
}
|
|
1690
|
+
const wdkService = getZubariWdkService({ network, apiUrl });
|
|
1691
|
+
const result = await wdkService.deriveAddress(seed, chain);
|
|
1692
|
+
return result.address;
|
|
1733
1693
|
}
|
|
1734
1694
|
/**
|
|
1735
|
-
* Derive address for a specific chain (sync version
|
|
1736
|
-
*
|
|
1695
|
+
* Derive address for a specific chain (sync version)
|
|
1696
|
+
* Only supports Ethereum - for other chains use deriveAddressForChainAsync with WDK API
|
|
1737
1697
|
*
|
|
1738
|
-
*
|
|
1739
|
-
* deterministic but not cryptographically valid. Use WDK API for real addresses.
|
|
1698
|
+
* @throws Error for non-Ethereum chains - use WDK API instead
|
|
1740
1699
|
*/
|
|
1741
1700
|
static deriveAddressForChain(seed, chain) {
|
|
1742
|
-
const ethPath = DERIVATION_PATHS["ethereum"];
|
|
1743
|
-
const ethNode = HDNodeWallet.fromPhrase(seed, void 0, `${ethPath}/0`);
|
|
1744
1701
|
if (chain === "ethereum") {
|
|
1702
|
+
const ethPath = DERIVATION_PATHS["ethereum"];
|
|
1703
|
+
const ethNode = HDNodeWallet.fromPhrase(seed, void 0, `${ethPath}/0`);
|
|
1745
1704
|
return ethNode.address;
|
|
1746
1705
|
}
|
|
1747
|
-
|
|
1706
|
+
throw new Error(
|
|
1707
|
+
`Sync derivation not supported for ${chain}. Use deriveAddressForChainAsync() with WDK API.`
|
|
1708
|
+
);
|
|
1748
1709
|
}
|
|
1749
1710
|
/**
|
|
1750
1711
|
* Derive addresses for all enabled chains (sync version)
|
|
1712
|
+
* Only derives Ethereum address synchronously - use deriveAllAddressesAsync for all chains
|
|
1751
1713
|
*/
|
|
1752
1714
|
deriveAllAddresses() {
|
|
1753
1715
|
if (!this.currentSeed) {
|
|
1754
1716
|
throw new Error("Wallet is locked");
|
|
1755
1717
|
}
|
|
1756
|
-
const addresses = {
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
}
|
|
1718
|
+
const addresses = {
|
|
1719
|
+
ethereum: _WalletManager.deriveAddressForChain(this.currentSeed, "ethereum")
|
|
1720
|
+
};
|
|
1760
1721
|
this.derivedAddresses = addresses;
|
|
1761
1722
|
return addresses;
|
|
1762
1723
|
}
|
|
@@ -1817,11 +1778,11 @@ var WalletManager = class _WalletManager {
|
|
|
1817
1778
|
}
|
|
1818
1779
|
/**
|
|
1819
1780
|
* Derive addresses for all enabled chains using Tether WDK
|
|
1820
|
-
* The unified WDK service handles all fallback strategies automatically:
|
|
1821
|
-
* - Browser: API backend -> Browser derivation
|
|
1822
|
-
* - Node.js: Native WDK -> API backend -> Browser derivation
|
|
1823
1781
|
*
|
|
1824
|
-
*
|
|
1782
|
+
* Uses the WDK API backend for real cryptographically valid addresses.
|
|
1783
|
+
* First tries to load from storage to avoid losing previously derived addresses.
|
|
1784
|
+
*
|
|
1785
|
+
* @throws Error if WDK API is unavailable and no cached addresses exist
|
|
1825
1786
|
*/
|
|
1826
1787
|
async deriveAllAddressesAsync() {
|
|
1827
1788
|
if (!this.currentSeed) {
|
|
@@ -1838,26 +1799,21 @@ var WalletManager = class _WalletManager {
|
|
|
1838
1799
|
console.log("Stored addresses do not match current seed, re-deriving...");
|
|
1839
1800
|
}
|
|
1840
1801
|
}
|
|
1841
|
-
|
|
1842
|
-
return await this.deriveAllAddressesWithWdk();
|
|
1843
|
-
} catch (error) {
|
|
1844
|
-
console.error("All derivation strategies failed:", error);
|
|
1845
|
-
const ethAddress = _WalletManager.deriveAddress(this.currentSeed);
|
|
1846
|
-
this.derivedAddresses = { ethereum: ethAddress };
|
|
1847
|
-
return this.derivedAddresses;
|
|
1848
|
-
}
|
|
1802
|
+
return await this.deriveAllAddressesWithWdk();
|
|
1849
1803
|
}
|
|
1850
1804
|
/**
|
|
1851
1805
|
* Get address for a specific chain
|
|
1806
|
+
* Returns cached address or null - use deriveAllAddressesAsync to derive addresses
|
|
1852
1807
|
*/
|
|
1853
1808
|
getAddressForChain(chain) {
|
|
1854
|
-
if (
|
|
1855
|
-
return this.derivedAddresses[chain]
|
|
1809
|
+
if (this.derivedAddresses[chain]) {
|
|
1810
|
+
return this.derivedAddresses[chain];
|
|
1856
1811
|
}
|
|
1857
|
-
if (
|
|
1812
|
+
if (chain === "ethereum" && this.currentSeed) {
|
|
1858
1813
|
this.derivedAddresses[chain] = _WalletManager.deriveAddressForChain(this.currentSeed, chain);
|
|
1814
|
+
return this.derivedAddresses[chain];
|
|
1859
1815
|
}
|
|
1860
|
-
return
|
|
1816
|
+
return null;
|
|
1861
1817
|
}
|
|
1862
1818
|
/**
|
|
1863
1819
|
* Get all derived addresses
|