@zubari/sdk 0.1.9 → 0.1.11
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-zKc_xew_.d.mts → WalletManager--UOBwXJp.d.mts} +39 -0
- package/dist/{WalletManager-YnFArqAt.d.ts → WalletManager-DVq_PUZK.d.ts} +39 -0
- package/dist/{index-DXTHGOnP.d.mts → index-B19bUJSk.d.mts} +1 -1
- package/dist/{index-CLssrNf2.d.ts → index-r6aRsMfN.d.ts} +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +162 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +162 -1
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.d.mts +22 -3
- package/dist/react/index.d.ts +22 -3
- package/dist/react/index.js +162 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +162 -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 +133 -1
- package/dist/wallet/index.js.map +1 -1
- package/dist/wallet/index.mjs +133 -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
|
/**
|
|
@@ -6023,6 +6034,34 @@ declare class WalletManager {
|
|
|
6023
6034
|
* Get extended wallet state with multi-chain info
|
|
6024
6035
|
*/
|
|
6025
6036
|
getExtendedState(): WalletState;
|
|
6037
|
+
/**
|
|
6038
|
+
* Send a transaction using Tether WDK
|
|
6039
|
+
* Supports native tokens and USDT on all chains
|
|
6040
|
+
*
|
|
6041
|
+
* @param chain - Target blockchain (ethereum, bitcoin, ton, tron, solana, spark)
|
|
6042
|
+
* @param to - Recipient address
|
|
6043
|
+
* @param amount - Amount to send (in human-readable format)
|
|
6044
|
+
* @param token - Optional token symbol (e.g., 'USDT' for stablecoins)
|
|
6045
|
+
* @returns Transaction result with hash and status
|
|
6046
|
+
*/
|
|
6047
|
+
sendTransaction(chain: NetworkType, to: string, amount: string, token?: string): Promise<{
|
|
6048
|
+
success: boolean;
|
|
6049
|
+
txHash?: string;
|
|
6050
|
+
from?: string;
|
|
6051
|
+
to?: string;
|
|
6052
|
+
amount?: string;
|
|
6053
|
+
chain?: NetworkType;
|
|
6054
|
+
error?: string;
|
|
6055
|
+
}>;
|
|
6056
|
+
/**
|
|
6057
|
+
* Estimate transaction fee using Tether WDK
|
|
6058
|
+
*/
|
|
6059
|
+
estimateFee(chain: NetworkType, to: string, amount: string, token?: string): Promise<{
|
|
6060
|
+
success: boolean;
|
|
6061
|
+
fee?: string;
|
|
6062
|
+
feeUsd?: number;
|
|
6063
|
+
error?: string;
|
|
6064
|
+
}>;
|
|
6026
6065
|
}
|
|
6027
6066
|
|
|
6028
6067
|
export { type ChainBalance as C, DERIVATION_PATHS as D, type MultiChainAddresses as M, NETWORKS as N, SUPPORTED_CHAINS as S, TESTNET_NETWORKS as T, WalletManager as W, type WalletState as a, type WalletManagerConfig as b, getNetworkConfig as g };
|
|
@@ -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
|
/**
|
|
@@ -6023,6 +6034,34 @@ declare class WalletManager {
|
|
|
6023
6034
|
* Get extended wallet state with multi-chain info
|
|
6024
6035
|
*/
|
|
6025
6036
|
getExtendedState(): WalletState;
|
|
6037
|
+
/**
|
|
6038
|
+
* Send a transaction using Tether WDK
|
|
6039
|
+
* Supports native tokens and USDT on all chains
|
|
6040
|
+
*
|
|
6041
|
+
* @param chain - Target blockchain (ethereum, bitcoin, ton, tron, solana, spark)
|
|
6042
|
+
* @param to - Recipient address
|
|
6043
|
+
* @param amount - Amount to send (in human-readable format)
|
|
6044
|
+
* @param token - Optional token symbol (e.g., 'USDT' for stablecoins)
|
|
6045
|
+
* @returns Transaction result with hash and status
|
|
6046
|
+
*/
|
|
6047
|
+
sendTransaction(chain: NetworkType, to: string, amount: string, token?: string): Promise<{
|
|
6048
|
+
success: boolean;
|
|
6049
|
+
txHash?: string;
|
|
6050
|
+
from?: string;
|
|
6051
|
+
to?: string;
|
|
6052
|
+
amount?: string;
|
|
6053
|
+
chain?: NetworkType;
|
|
6054
|
+
error?: string;
|
|
6055
|
+
}>;
|
|
6056
|
+
/**
|
|
6057
|
+
* Estimate transaction fee using Tether WDK
|
|
6058
|
+
*/
|
|
6059
|
+
estimateFee(chain: NetworkType, to: string, amount: string, token?: string): Promise<{
|
|
6060
|
+
success: boolean;
|
|
6061
|
+
fee?: string;
|
|
6062
|
+
feeUsd?: number;
|
|
6063
|
+
error?: string;
|
|
6064
|
+
}>;
|
|
6026
6065
|
}
|
|
6027
6066
|
|
|
6028
6067
|
export { type ChainBalance as C, DERIVATION_PATHS as D, type MultiChainAddresses as M, NETWORKS as N, SUPPORTED_CHAINS as S, TESTNET_NETWORKS as T, WalletManager as W, type WalletState as a, type WalletManagerConfig as b, getNetworkConfig as g };
|
|
@@ -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--UOBwXJp.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-DVq_PUZK.js';
|
|
3
3
|
|
|
4
4
|
interface ContractAddresses {
|
|
5
5
|
registry: string;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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-B19bUJSk.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--UOBwXJp.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';
|
|
6
6
|
export { A as Account, E as EarningsBreakdown, L as LazyMintVoucher, e as ListingParams, d as NFT, c as NFTMetadata, a as NetworkBalance, N as NetworkType, R as RevenueSplit, S as SendParams, j as Subscription, i as SubscriptionPlan, l as SwapParams, k as SwapQuote, f as TipData, g as TipResult, h as TipStats, T as TokenBalance, b as TxResult, n as ZubariError, m as ZubariErrorCode, Z as ZubariWalletConfig } from './index-DhluuR9H.mjs';
|
|
7
|
-
export { UseWalletManagerOptions, UseWalletManagerReturn, useWalletManager } from './react/index.mjs';
|
|
7
|
+
export { FeeEstimateResult, SendTransactionResult, UseWalletManagerOptions, UseWalletManagerReturn, useWalletManager } from './react/index.mjs';
|
|
8
8
|
import 'abitype';
|
|
9
9
|
import 'viem';
|
|
10
10
|
import 'ethers';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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-r6aRsMfN.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-DVq_PUZK.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';
|
|
6
6
|
export { A as Account, E as EarningsBreakdown, L as LazyMintVoucher, e as ListingParams, d as NFT, c as NFTMetadata, a as NetworkBalance, N as NetworkType, R as RevenueSplit, S as SendParams, j as Subscription, i as SubscriptionPlan, l as SwapParams, k as SwapQuote, f as TipData, g as TipResult, h as TipStats, T as TokenBalance, b as TxResult, n as ZubariError, m as ZubariErrorCode, Z as ZubariWalletConfig } from './index-DhluuR9H.js';
|
|
7
|
-
export { UseWalletManagerOptions, UseWalletManagerReturn, useWalletManager } from './react/index.js';
|
|
7
|
+
export { FeeEstimateResult, SendTransactionResult, UseWalletManagerOptions, UseWalletManagerReturn, useWalletManager } from './react/index.js';
|
|
8
8
|
import 'abitype';
|
|
9
9
|
import 'viem';
|
|
10
10
|
import 'ethers';
|
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) {
|
|
@@ -2086,6 +2130,94 @@ var WalletManager = class _WalletManager {
|
|
|
2086
2130
|
selectedChain: this.selectedChain
|
|
2087
2131
|
};
|
|
2088
2132
|
}
|
|
2133
|
+
/**
|
|
2134
|
+
* Send a transaction using Tether WDK
|
|
2135
|
+
* Supports native tokens and USDT on all chains
|
|
2136
|
+
*
|
|
2137
|
+
* @param chain - Target blockchain (ethereum, bitcoin, ton, tron, solana, spark)
|
|
2138
|
+
* @param to - Recipient address
|
|
2139
|
+
* @param amount - Amount to send (in human-readable format)
|
|
2140
|
+
* @param token - Optional token symbol (e.g., 'USDT' for stablecoins)
|
|
2141
|
+
* @returns Transaction result with hash and status
|
|
2142
|
+
*/
|
|
2143
|
+
async sendTransaction(chain, to, amount, token) {
|
|
2144
|
+
if (!this.currentSeed) {
|
|
2145
|
+
return { success: false, error: "Wallet is locked" };
|
|
2146
|
+
}
|
|
2147
|
+
const fromAddress = this.getAddressForChain(chain);
|
|
2148
|
+
if (!fromAddress) {
|
|
2149
|
+
return { success: false, error: `No address for chain ${chain}` };
|
|
2150
|
+
}
|
|
2151
|
+
try {
|
|
2152
|
+
const response = await fetch(`${this.config.apiUrl}/api/wallets/wdk/send`, {
|
|
2153
|
+
method: "POST",
|
|
2154
|
+
headers: { "Content-Type": "application/json" },
|
|
2155
|
+
body: JSON.stringify({
|
|
2156
|
+
seed: this.currentSeed,
|
|
2157
|
+
chain,
|
|
2158
|
+
to,
|
|
2159
|
+
amount,
|
|
2160
|
+
token,
|
|
2161
|
+
network: this.config.network
|
|
2162
|
+
})
|
|
2163
|
+
});
|
|
2164
|
+
if (response.ok) {
|
|
2165
|
+
const data = await response.json();
|
|
2166
|
+
console.log(`Transaction sent on ${chain}:`, data);
|
|
2167
|
+
return {
|
|
2168
|
+
success: data.success,
|
|
2169
|
+
txHash: data.txHash,
|
|
2170
|
+
from: fromAddress,
|
|
2171
|
+
to,
|
|
2172
|
+
amount,
|
|
2173
|
+
chain
|
|
2174
|
+
};
|
|
2175
|
+
}
|
|
2176
|
+
const errorData = await response.json().catch(() => ({}));
|
|
2177
|
+
return {
|
|
2178
|
+
success: false,
|
|
2179
|
+
error: errorData.error || `HTTP ${response.status}`
|
|
2180
|
+
};
|
|
2181
|
+
} catch (error) {
|
|
2182
|
+
console.error(`Transaction failed on ${chain}:`, error);
|
|
2183
|
+
return {
|
|
2184
|
+
success: false,
|
|
2185
|
+
error: error instanceof Error ? error.message : "Transaction failed"
|
|
2186
|
+
};
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
/**
|
|
2190
|
+
* Estimate transaction fee using Tether WDK
|
|
2191
|
+
*/
|
|
2192
|
+
async estimateFee(chain, to, amount, token) {
|
|
2193
|
+
try {
|
|
2194
|
+
const response = await fetch(`${this.config.apiUrl}/api/wallets/wdk/estimate-fee`, {
|
|
2195
|
+
method: "POST",
|
|
2196
|
+
headers: { "Content-Type": "application/json" },
|
|
2197
|
+
body: JSON.stringify({
|
|
2198
|
+
chain,
|
|
2199
|
+
to,
|
|
2200
|
+
amount,
|
|
2201
|
+
token,
|
|
2202
|
+
network: this.config.network
|
|
2203
|
+
})
|
|
2204
|
+
});
|
|
2205
|
+
if (response.ok) {
|
|
2206
|
+
const data = await response.json();
|
|
2207
|
+
return {
|
|
2208
|
+
success: true,
|
|
2209
|
+
fee: data.fee,
|
|
2210
|
+
feeUsd: data.feeUsd
|
|
2211
|
+
};
|
|
2212
|
+
}
|
|
2213
|
+
return { success: false, error: "Failed to estimate fee" };
|
|
2214
|
+
} catch (error) {
|
|
2215
|
+
return {
|
|
2216
|
+
success: false,
|
|
2217
|
+
error: error instanceof Error ? error.message : "Fee estimation failed"
|
|
2218
|
+
};
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2089
2221
|
};
|
|
2090
2222
|
|
|
2091
2223
|
// src/protocols/NFTProtocol.ts
|
|
@@ -3193,6 +3325,32 @@ function useWalletManager(options = {}) {
|
|
|
3193
3325
|
);
|
|
3194
3326
|
const hasWallet = react.useCallback(() => manager.hasWallet(), [manager]);
|
|
3195
3327
|
const getSeed = react.useCallback(() => manager.getSeed(), [manager]);
|
|
3328
|
+
const sendTransaction = react.useCallback(
|
|
3329
|
+
async (chain, to, amount, token) => {
|
|
3330
|
+
setIsLoading(true);
|
|
3331
|
+
try {
|
|
3332
|
+
const result = await manager.sendTransaction(chain, to, amount, token);
|
|
3333
|
+
if (result.success) {
|
|
3334
|
+
try {
|
|
3335
|
+
const balances = await manager.fetchAllBalances();
|
|
3336
|
+
setChainBalances(balances);
|
|
3337
|
+
} catch (err) {
|
|
3338
|
+
console.warn("Failed to refresh balances after transaction:", err);
|
|
3339
|
+
}
|
|
3340
|
+
}
|
|
3341
|
+
return result;
|
|
3342
|
+
} finally {
|
|
3343
|
+
setIsLoading(false);
|
|
3344
|
+
}
|
|
3345
|
+
},
|
|
3346
|
+
[manager]
|
|
3347
|
+
);
|
|
3348
|
+
const estimateFee = react.useCallback(
|
|
3349
|
+
async (chain, to, amount, token) => {
|
|
3350
|
+
return manager.estimateFee(chain, to, amount, token);
|
|
3351
|
+
},
|
|
3352
|
+
[manager]
|
|
3353
|
+
);
|
|
3196
3354
|
return {
|
|
3197
3355
|
state,
|
|
3198
3356
|
isLoading,
|
|
@@ -3211,6 +3369,9 @@ function useWalletManager(options = {}) {
|
|
|
3211
3369
|
getAddressForChain,
|
|
3212
3370
|
getAllAddresses,
|
|
3213
3371
|
supportedChains: SUPPORTED_CHAINS,
|
|
3372
|
+
// Transaction Actions (Powered by Tether WDK)
|
|
3373
|
+
sendTransaction,
|
|
3374
|
+
estimateFee,
|
|
3214
3375
|
// Utilities
|
|
3215
3376
|
hasWallet,
|
|
3216
3377
|
getSeed,
|