@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
|
@@ -5977,13 +5977,24 @@ declare class WalletManager {
|
|
|
5977
5977
|
* In browser: Uses the backend API (which has Tether WDK)
|
|
5978
5978
|
* In Node.js: Uses native WDK directly
|
|
5979
5979
|
* Returns REAL cryptographically valid addresses for all chains.
|
|
5980
|
+
* Addresses are persisted to storage for future use.
|
|
5980
5981
|
*/
|
|
5981
5982
|
deriveAllAddressesWithWdk(): Promise<Partial<MultiChainAddresses>>;
|
|
5983
|
+
/**
|
|
5984
|
+
* Save derived addresses to storage
|
|
5985
|
+
*/
|
|
5986
|
+
private saveAddressesToStorage;
|
|
5987
|
+
/**
|
|
5988
|
+
* Load derived addresses from storage
|
|
5989
|
+
*/
|
|
5990
|
+
private loadAddressesFromStorage;
|
|
5982
5991
|
/**
|
|
5983
5992
|
* Derive addresses for all enabled chains using Tether WDK
|
|
5984
5993
|
* The unified WDK service handles all fallback strategies automatically:
|
|
5985
5994
|
* - Browser: API backend -> Browser derivation
|
|
5986
5995
|
* - Node.js: Native WDK -> API backend -> Browser derivation
|
|
5996
|
+
*
|
|
5997
|
+
* First tries to load from storage to avoid losing real WDK-derived addresses.
|
|
5987
5998
|
*/
|
|
5988
5999
|
deriveAllAddressesAsync(): Promise<Partial<MultiChainAddresses>>;
|
|
5989
6000
|
/**
|
|
@@ -5977,13 +5977,24 @@ declare class WalletManager {
|
|
|
5977
5977
|
* In browser: Uses the backend API (which has Tether WDK)
|
|
5978
5978
|
* In Node.js: Uses native WDK directly
|
|
5979
5979
|
* Returns REAL cryptographically valid addresses for all chains.
|
|
5980
|
+
* Addresses are persisted to storage for future use.
|
|
5980
5981
|
*/
|
|
5981
5982
|
deriveAllAddressesWithWdk(): Promise<Partial<MultiChainAddresses>>;
|
|
5983
|
+
/**
|
|
5984
|
+
* Save derived addresses to storage
|
|
5985
|
+
*/
|
|
5986
|
+
private saveAddressesToStorage;
|
|
5987
|
+
/**
|
|
5988
|
+
* Load derived addresses from storage
|
|
5989
|
+
*/
|
|
5990
|
+
private loadAddressesFromStorage;
|
|
5982
5991
|
/**
|
|
5983
5992
|
* Derive addresses for all enabled chains using Tether WDK
|
|
5984
5993
|
* The unified WDK service handles all fallback strategies automatically:
|
|
5985
5994
|
* - Browser: API backend -> Browser derivation
|
|
5986
5995
|
* - Node.js: Native WDK -> API backend -> Browser derivation
|
|
5996
|
+
*
|
|
5997
|
+
* First tries to load from storage to avoid losing real WDK-derived addresses.
|
|
5987
5998
|
*/
|
|
5988
5999
|
deriveAllAddressesAsync(): Promise<Partial<MultiChainAddresses>>;
|
|
5989
6000
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Z as ZubariWalletConfig, N as NetworkType, A as Account, a as NetworkBalance, S as SendParams, b as TxResult } from './index-DhluuR9H.mjs';
|
|
2
|
-
import './WalletManager-
|
|
2
|
+
import './WalletManager-UG6taF_0.mjs';
|
|
3
3
|
|
|
4
4
|
interface ContractAddresses {
|
|
5
5
|
registry: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Z as ZubariWalletConfig, N as NetworkType, A as Account, a as NetworkBalance, S as SendParams, b as TxResult } from './index-DhluuR9H.js';
|
|
2
|
-
import './WalletManager-
|
|
2
|
+
import './WalletManager-CkGhJZDo.js';
|
|
3
3
|
|
|
4
4
|
interface ContractAddresses {
|
|
5
5
|
registry: string;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { P as PLATFORM_CONFIG, a as ZUBARI_CONTRACTS, Z as ZubariWallet, g as getContractAddresses } from './index-
|
|
2
|
-
export { D as DERIVATION_PATHS, N as NETWORKS, T as TESTNET_NETWORKS, W as WalletManager, b as WalletManagerConfig, a as WalletState, g as getNetworkConfig } from './WalletManager-
|
|
1
|
+
export { P as PLATFORM_CONFIG, a as ZUBARI_CONTRACTS, Z as ZubariWallet, g as getContractAddresses } from './index-DS2d6LVD.mjs';
|
|
2
|
+
export { D as DERIVATION_PATHS, N as NETWORKS, T as TESTNET_NETWORKS, W as WalletManager, b as WalletManagerConfig, a as WalletState, g as getNetworkConfig } from './WalletManager-UG6taF_0.mjs';
|
|
3
3
|
export { M as MemoryStorageAdapter, S as SecureStorageAdapter, W as WebEncryptedStorageAdapter, c as createSecureStorage } from './SecureStorage-jO783AhC.mjs';
|
|
4
4
|
export { ZubariNFTProtocol, ZubariPayoutsProtocol, ZubariSubscriptionProtocol, ZubariTipsProtocol } from './protocols/index.mjs';
|
|
5
5
|
export { BrowserAddressDerivation, ChainAddress, ChainBalance, FeeEstimate, FeeRates, MultiChainAddresses, SupportedChain, SwapService, TransactionHistoryItem, TransactionParams, TransactionResult, TransactionService, TransactionServiceConfig, WdkApiClient, ZubariWdkService, ZubariWdkServiceConfig, createTransactionService, createZubariWdkService, getTransactionService, getWdkApiClient, getZubariWdkService, isBrowser } from './services/index.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { P as PLATFORM_CONFIG, a as ZUBARI_CONTRACTS, Z as ZubariWallet, g as getContractAddresses } from './index-
|
|
2
|
-
export { D as DERIVATION_PATHS, N as NETWORKS, T as TESTNET_NETWORKS, W as WalletManager, b as WalletManagerConfig, a as WalletState, g as getNetworkConfig } from './WalletManager-
|
|
1
|
+
export { P as PLATFORM_CONFIG, a as ZUBARI_CONTRACTS, Z as ZubariWallet, g as getContractAddresses } from './index-Dk_dYBbp.js';
|
|
2
|
+
export { D as DERIVATION_PATHS, N as NETWORKS, T as TESTNET_NETWORKS, W as WalletManager, b as WalletManagerConfig, a as WalletState, g as getNetworkConfig } from './WalletManager-CkGhJZDo.js';
|
|
3
3
|
export { M as MemoryStorageAdapter, S as SecureStorageAdapter, W as WebEncryptedStorageAdapter, c as createSecureStorage } from './SecureStorage-jO783AhC.js';
|
|
4
4
|
export { ZubariNFTProtocol, ZubariPayoutsProtocol, ZubariSubscriptionProtocol, ZubariTipsProtocol } from './protocols/index.js';
|
|
5
5
|
export { BrowserAddressDerivation, ChainAddress, ChainBalance, FeeEstimate, FeeRates, MultiChainAddresses, SupportedChain, SwapService, TransactionHistoryItem, TransactionParams, TransactionResult, TransactionService, TransactionServiceConfig, WdkApiClient, ZubariWdkService, ZubariWdkServiceConfig, createTransactionService, createZubariWdkService, getTransactionService, getWdkApiClient, getZubariWdkService, isBrowser } from './services/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1460,7 +1460,8 @@ async function getPriceForChain(chain) {
|
|
|
1460
1460
|
}
|
|
1461
1461
|
var STORAGE_KEYS = {
|
|
1462
1462
|
ENCRYPTED_SEED: "encrypted_seed",
|
|
1463
|
-
ACTIVE_WALLET: "active_wallet"
|
|
1463
|
+
ACTIVE_WALLET: "active_wallet",
|
|
1464
|
+
DERIVED_ADDRESSES: "derived_addresses"
|
|
1464
1465
|
};
|
|
1465
1466
|
var SUPPORTED_CHAINS = ["ethereum", "bitcoin", "ton", "tron", "solana", "spark"];
|
|
1466
1467
|
var WalletManager = class _WalletManager {
|
|
@@ -1601,6 +1602,7 @@ var WalletManager = class _WalletManager {
|
|
|
1601
1602
|
*/
|
|
1602
1603
|
async deleteWallet() {
|
|
1603
1604
|
await this.storage.removeItem(STORAGE_KEYS.ENCRYPTED_SEED);
|
|
1605
|
+
await this.storage.removeItem(STORAGE_KEYS.DERIVED_ADDRESSES);
|
|
1604
1606
|
this.currentSeed = null;
|
|
1605
1607
|
this.derivedAddress = null;
|
|
1606
1608
|
this.derivedAddresses = {};
|
|
@@ -1814,6 +1816,7 @@ var WalletManager = class _WalletManager {
|
|
|
1814
1816
|
* In browser: Uses the backend API (which has Tether WDK)
|
|
1815
1817
|
* In Node.js: Uses native WDK directly
|
|
1816
1818
|
* Returns REAL cryptographically valid addresses for all chains.
|
|
1819
|
+
* Addresses are persisted to storage for future use.
|
|
1817
1820
|
*/
|
|
1818
1821
|
async deriveAllAddressesWithWdk() {
|
|
1819
1822
|
if (!this.currentSeed) {
|
|
@@ -1829,22 +1832,63 @@ var WalletManager = class _WalletManager {
|
|
|
1829
1832
|
}
|
|
1830
1833
|
}
|
|
1831
1834
|
this.derivedAddresses = addresses;
|
|
1835
|
+
await this.saveAddressesToStorage(addresses);
|
|
1832
1836
|
return addresses;
|
|
1833
1837
|
} catch (error) {
|
|
1834
1838
|
console.error("WDK derivation failed:", error);
|
|
1835
1839
|
throw error;
|
|
1836
1840
|
}
|
|
1837
1841
|
}
|
|
1842
|
+
/**
|
|
1843
|
+
* Save derived addresses to storage
|
|
1844
|
+
*/
|
|
1845
|
+
async saveAddressesToStorage(addresses) {
|
|
1846
|
+
try {
|
|
1847
|
+
await this.storage.setItem(STORAGE_KEYS.DERIVED_ADDRESSES, JSON.stringify(addresses));
|
|
1848
|
+
console.log("Saved derived addresses to storage:", Object.keys(addresses));
|
|
1849
|
+
} catch (error) {
|
|
1850
|
+
console.warn("Failed to save addresses to storage:", error);
|
|
1851
|
+
}
|
|
1852
|
+
}
|
|
1853
|
+
/**
|
|
1854
|
+
* Load derived addresses from storage
|
|
1855
|
+
*/
|
|
1856
|
+
async loadAddressesFromStorage() {
|
|
1857
|
+
try {
|
|
1858
|
+
const stored = await this.storage.getItem(STORAGE_KEYS.DERIVED_ADDRESSES);
|
|
1859
|
+
if (stored) {
|
|
1860
|
+
const addresses = JSON.parse(stored);
|
|
1861
|
+
console.log("Loaded derived addresses from storage:", Object.keys(addresses));
|
|
1862
|
+
return addresses;
|
|
1863
|
+
}
|
|
1864
|
+
} catch (error) {
|
|
1865
|
+
console.warn("Failed to load addresses from storage:", error);
|
|
1866
|
+
}
|
|
1867
|
+
return null;
|
|
1868
|
+
}
|
|
1838
1869
|
/**
|
|
1839
1870
|
* Derive addresses for all enabled chains using Tether WDK
|
|
1840
1871
|
* The unified WDK service handles all fallback strategies automatically:
|
|
1841
1872
|
* - Browser: API backend -> Browser derivation
|
|
1842
1873
|
* - Node.js: Native WDK -> API backend -> Browser derivation
|
|
1874
|
+
*
|
|
1875
|
+
* First tries to load from storage to avoid losing real WDK-derived addresses.
|
|
1843
1876
|
*/
|
|
1844
1877
|
async deriveAllAddressesAsync() {
|
|
1845
1878
|
if (!this.currentSeed) {
|
|
1846
1879
|
throw new Error("Wallet is locked");
|
|
1847
1880
|
}
|
|
1881
|
+
const storedAddresses = await this.loadAddressesFromStorage();
|
|
1882
|
+
if (storedAddresses && Object.keys(storedAddresses).length > 1) {
|
|
1883
|
+
const expectedEthAddress = _WalletManager.deriveAddress(this.currentSeed);
|
|
1884
|
+
if (storedAddresses.ethereum === expectedEthAddress) {
|
|
1885
|
+
console.log("Using addresses from storage (verified by Ethereum address)");
|
|
1886
|
+
this.derivedAddresses = storedAddresses;
|
|
1887
|
+
return storedAddresses;
|
|
1888
|
+
} else {
|
|
1889
|
+
console.log("Stored addresses do not match current seed, re-deriving...");
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1848
1892
|
try {
|
|
1849
1893
|
return await this.deriveAllAddressesWithWdk();
|
|
1850
1894
|
} catch (error) {
|
|
@@ -3052,6 +3096,12 @@ function useWalletManager(options = {}) {
|
|
|
3052
3096
|
manager.deriveAllAddresses();
|
|
3053
3097
|
}
|
|
3054
3098
|
updateState();
|
|
3099
|
+
try {
|
|
3100
|
+
const balances = await manager.fetchAllBalances();
|
|
3101
|
+
setChainBalances(balances);
|
|
3102
|
+
} catch (err) {
|
|
3103
|
+
console.warn("Failed to fetch balances after create:", err);
|
|
3104
|
+
}
|
|
3055
3105
|
return result;
|
|
3056
3106
|
} catch (err) {
|
|
3057
3107
|
const message = err instanceof Error ? err.message : "Failed to create wallet";
|
|
@@ -3076,6 +3126,12 @@ function useWalletManager(options = {}) {
|
|
|
3076
3126
|
manager.deriveAllAddresses();
|
|
3077
3127
|
}
|
|
3078
3128
|
updateState();
|
|
3129
|
+
try {
|
|
3130
|
+
const balances = await manager.fetchAllBalances();
|
|
3131
|
+
setChainBalances(balances);
|
|
3132
|
+
} catch (err) {
|
|
3133
|
+
console.warn("Failed to fetch balances after import:", err);
|
|
3134
|
+
}
|
|
3079
3135
|
} catch (err) {
|
|
3080
3136
|
const message = err instanceof Error ? err.message : "Failed to import wallet";
|
|
3081
3137
|
setError(message);
|
|
@@ -3099,6 +3155,12 @@ function useWalletManager(options = {}) {
|
|
|
3099
3155
|
manager.deriveAllAddresses();
|
|
3100
3156
|
}
|
|
3101
3157
|
updateState();
|
|
3158
|
+
try {
|
|
3159
|
+
const balances = await manager.fetchAllBalances();
|
|
3160
|
+
setChainBalances(balances);
|
|
3161
|
+
} catch (err) {
|
|
3162
|
+
console.warn("Failed to fetch balances after unlock:", err);
|
|
3163
|
+
}
|
|
3102
3164
|
} catch (err) {
|
|
3103
3165
|
const message = err instanceof Error ? err.message : "Invalid password";
|
|
3104
3166
|
setError(message);
|