@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/react/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { N as NetworkType } from '../index-DhluuR9H.mjs';
|
|
2
|
-
import { b as WalletManagerConfig, a as WalletState, C as ChainBalance, M as MultiChainAddresses, W as WalletManager } from '../WalletManager-
|
|
3
|
-
export { S as SUPPORTED_CHAINS } from '../WalletManager-
|
|
2
|
+
import { b as WalletManagerConfig, a as WalletState, C as ChainBalance, M as MultiChainAddresses, W as WalletManager } from '../WalletManager-UG6taF_0.mjs';
|
|
3
|
+
export { S as SUPPORTED_CHAINS } from '../WalletManager-UG6taF_0.mjs';
|
|
4
4
|
import 'abitype';
|
|
5
5
|
import 'viem';
|
|
6
6
|
import 'ethers';
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { N as NetworkType } from '../index-DhluuR9H.js';
|
|
2
|
-
import { b as WalletManagerConfig, a as WalletState, C as ChainBalance, M as MultiChainAddresses, W as WalletManager } from '../WalletManager-
|
|
3
|
-
export { S as SUPPORTED_CHAINS } from '../WalletManager-
|
|
2
|
+
import { b as WalletManagerConfig, a as WalletState, C as ChainBalance, M as MultiChainAddresses, W as WalletManager } from '../WalletManager-CkGhJZDo.js';
|
|
3
|
+
export { S as SUPPORTED_CHAINS } from '../WalletManager-CkGhJZDo.js';
|
|
4
4
|
import 'abitype';
|
|
5
5
|
import 'viem';
|
|
6
6
|
import 'ethers';
|
package/dist/react/index.js
CHANGED
|
@@ -1113,7 +1113,8 @@ async function getPriceForChain(chain) {
|
|
|
1113
1113
|
}
|
|
1114
1114
|
var STORAGE_KEYS = {
|
|
1115
1115
|
ENCRYPTED_SEED: "encrypted_seed",
|
|
1116
|
-
ACTIVE_WALLET: "active_wallet"
|
|
1116
|
+
ACTIVE_WALLET: "active_wallet",
|
|
1117
|
+
DERIVED_ADDRESSES: "derived_addresses"
|
|
1117
1118
|
};
|
|
1118
1119
|
var SUPPORTED_CHAINS = ["ethereum", "bitcoin", "ton", "tron", "solana", "spark"];
|
|
1119
1120
|
var WalletManager = class _WalletManager {
|
|
@@ -1254,6 +1255,7 @@ var WalletManager = class _WalletManager {
|
|
|
1254
1255
|
*/
|
|
1255
1256
|
async deleteWallet() {
|
|
1256
1257
|
await this.storage.removeItem(STORAGE_KEYS.ENCRYPTED_SEED);
|
|
1258
|
+
await this.storage.removeItem(STORAGE_KEYS.DERIVED_ADDRESSES);
|
|
1257
1259
|
this.currentSeed = null;
|
|
1258
1260
|
this.derivedAddress = null;
|
|
1259
1261
|
this.derivedAddresses = {};
|
|
@@ -1467,6 +1469,7 @@ var WalletManager = class _WalletManager {
|
|
|
1467
1469
|
* In browser: Uses the backend API (which has Tether WDK)
|
|
1468
1470
|
* In Node.js: Uses native WDK directly
|
|
1469
1471
|
* Returns REAL cryptographically valid addresses for all chains.
|
|
1472
|
+
* Addresses are persisted to storage for future use.
|
|
1470
1473
|
*/
|
|
1471
1474
|
async deriveAllAddressesWithWdk() {
|
|
1472
1475
|
if (!this.currentSeed) {
|
|
@@ -1482,22 +1485,63 @@ var WalletManager = class _WalletManager {
|
|
|
1482
1485
|
}
|
|
1483
1486
|
}
|
|
1484
1487
|
this.derivedAddresses = addresses;
|
|
1488
|
+
await this.saveAddressesToStorage(addresses);
|
|
1485
1489
|
return addresses;
|
|
1486
1490
|
} catch (error) {
|
|
1487
1491
|
console.error("WDK derivation failed:", error);
|
|
1488
1492
|
throw error;
|
|
1489
1493
|
}
|
|
1490
1494
|
}
|
|
1495
|
+
/**
|
|
1496
|
+
* Save derived addresses to storage
|
|
1497
|
+
*/
|
|
1498
|
+
async saveAddressesToStorage(addresses) {
|
|
1499
|
+
try {
|
|
1500
|
+
await this.storage.setItem(STORAGE_KEYS.DERIVED_ADDRESSES, JSON.stringify(addresses));
|
|
1501
|
+
console.log("Saved derived addresses to storage:", Object.keys(addresses));
|
|
1502
|
+
} catch (error) {
|
|
1503
|
+
console.warn("Failed to save addresses to storage:", error);
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
/**
|
|
1507
|
+
* Load derived addresses from storage
|
|
1508
|
+
*/
|
|
1509
|
+
async loadAddressesFromStorage() {
|
|
1510
|
+
try {
|
|
1511
|
+
const stored = await this.storage.getItem(STORAGE_KEYS.DERIVED_ADDRESSES);
|
|
1512
|
+
if (stored) {
|
|
1513
|
+
const addresses = JSON.parse(stored);
|
|
1514
|
+
console.log("Loaded derived addresses from storage:", Object.keys(addresses));
|
|
1515
|
+
return addresses;
|
|
1516
|
+
}
|
|
1517
|
+
} catch (error) {
|
|
1518
|
+
console.warn("Failed to load addresses from storage:", error);
|
|
1519
|
+
}
|
|
1520
|
+
return null;
|
|
1521
|
+
}
|
|
1491
1522
|
/**
|
|
1492
1523
|
* Derive addresses for all enabled chains using Tether WDK
|
|
1493
1524
|
* The unified WDK service handles all fallback strategies automatically:
|
|
1494
1525
|
* - Browser: API backend -> Browser derivation
|
|
1495
1526
|
* - Node.js: Native WDK -> API backend -> Browser derivation
|
|
1527
|
+
*
|
|
1528
|
+
* First tries to load from storage to avoid losing real WDK-derived addresses.
|
|
1496
1529
|
*/
|
|
1497
1530
|
async deriveAllAddressesAsync() {
|
|
1498
1531
|
if (!this.currentSeed) {
|
|
1499
1532
|
throw new Error("Wallet is locked");
|
|
1500
1533
|
}
|
|
1534
|
+
const storedAddresses = await this.loadAddressesFromStorage();
|
|
1535
|
+
if (storedAddresses && Object.keys(storedAddresses).length > 1) {
|
|
1536
|
+
const expectedEthAddress = _WalletManager.deriveAddress(this.currentSeed);
|
|
1537
|
+
if (storedAddresses.ethereum === expectedEthAddress) {
|
|
1538
|
+
console.log("Using addresses from storage (verified by Ethereum address)");
|
|
1539
|
+
this.derivedAddresses = storedAddresses;
|
|
1540
|
+
return storedAddresses;
|
|
1541
|
+
} else {
|
|
1542
|
+
console.log("Stored addresses do not match current seed, re-deriving...");
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1501
1545
|
try {
|
|
1502
1546
|
return await this.deriveAllAddressesWithWdk();
|
|
1503
1547
|
} catch (error) {
|