@zubari/sdk 0.1.10 → 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-UG6taF_0.d.mts → WalletManager--UOBwXJp.d.mts} +28 -0
- package/dist/{WalletManager-CkGhJZDo.d.ts → WalletManager-DVq_PUZK.d.ts} +28 -0
- package/dist/{index-DS2d6LVD.d.mts → index-B19bUJSk.d.mts} +1 -1
- package/dist/{index-Dk_dYBbp.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 +117 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +117 -0
- 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 +117 -0
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +117 -0
- 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 +88 -0
- package/dist/wallet/index.js.map +1 -1
- package/dist/wallet/index.mjs +88 -0
- package/dist/wallet/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react/index.mjs
CHANGED
|
@@ -1781,6 +1781,94 @@ var WalletManager = class _WalletManager {
|
|
|
1781
1781
|
selectedChain: this.selectedChain
|
|
1782
1782
|
};
|
|
1783
1783
|
}
|
|
1784
|
+
/**
|
|
1785
|
+
* Send a transaction using Tether WDK
|
|
1786
|
+
* Supports native tokens and USDT on all chains
|
|
1787
|
+
*
|
|
1788
|
+
* @param chain - Target blockchain (ethereum, bitcoin, ton, tron, solana, spark)
|
|
1789
|
+
* @param to - Recipient address
|
|
1790
|
+
* @param amount - Amount to send (in human-readable format)
|
|
1791
|
+
* @param token - Optional token symbol (e.g., 'USDT' for stablecoins)
|
|
1792
|
+
* @returns Transaction result with hash and status
|
|
1793
|
+
*/
|
|
1794
|
+
async sendTransaction(chain, to, amount, token) {
|
|
1795
|
+
if (!this.currentSeed) {
|
|
1796
|
+
return { success: false, error: "Wallet is locked" };
|
|
1797
|
+
}
|
|
1798
|
+
const fromAddress = this.getAddressForChain(chain);
|
|
1799
|
+
if (!fromAddress) {
|
|
1800
|
+
return { success: false, error: `No address for chain ${chain}` };
|
|
1801
|
+
}
|
|
1802
|
+
try {
|
|
1803
|
+
const response = await fetch(`${this.config.apiUrl}/api/wallets/wdk/send`, {
|
|
1804
|
+
method: "POST",
|
|
1805
|
+
headers: { "Content-Type": "application/json" },
|
|
1806
|
+
body: JSON.stringify({
|
|
1807
|
+
seed: this.currentSeed,
|
|
1808
|
+
chain,
|
|
1809
|
+
to,
|
|
1810
|
+
amount,
|
|
1811
|
+
token,
|
|
1812
|
+
network: this.config.network
|
|
1813
|
+
})
|
|
1814
|
+
});
|
|
1815
|
+
if (response.ok) {
|
|
1816
|
+
const data = await response.json();
|
|
1817
|
+
console.log(`Transaction sent on ${chain}:`, data);
|
|
1818
|
+
return {
|
|
1819
|
+
success: data.success,
|
|
1820
|
+
txHash: data.txHash,
|
|
1821
|
+
from: fromAddress,
|
|
1822
|
+
to,
|
|
1823
|
+
amount,
|
|
1824
|
+
chain
|
|
1825
|
+
};
|
|
1826
|
+
}
|
|
1827
|
+
const errorData = await response.json().catch(() => ({}));
|
|
1828
|
+
return {
|
|
1829
|
+
success: false,
|
|
1830
|
+
error: errorData.error || `HTTP ${response.status}`
|
|
1831
|
+
};
|
|
1832
|
+
} catch (error) {
|
|
1833
|
+
console.error(`Transaction failed on ${chain}:`, error);
|
|
1834
|
+
return {
|
|
1835
|
+
success: false,
|
|
1836
|
+
error: error instanceof Error ? error.message : "Transaction failed"
|
|
1837
|
+
};
|
|
1838
|
+
}
|
|
1839
|
+
}
|
|
1840
|
+
/**
|
|
1841
|
+
* Estimate transaction fee using Tether WDK
|
|
1842
|
+
*/
|
|
1843
|
+
async estimateFee(chain, to, amount, token) {
|
|
1844
|
+
try {
|
|
1845
|
+
const response = await fetch(`${this.config.apiUrl}/api/wallets/wdk/estimate-fee`, {
|
|
1846
|
+
method: "POST",
|
|
1847
|
+
headers: { "Content-Type": "application/json" },
|
|
1848
|
+
body: JSON.stringify({
|
|
1849
|
+
chain,
|
|
1850
|
+
to,
|
|
1851
|
+
amount,
|
|
1852
|
+
token,
|
|
1853
|
+
network: this.config.network
|
|
1854
|
+
})
|
|
1855
|
+
});
|
|
1856
|
+
if (response.ok) {
|
|
1857
|
+
const data = await response.json();
|
|
1858
|
+
return {
|
|
1859
|
+
success: true,
|
|
1860
|
+
fee: data.fee,
|
|
1861
|
+
feeUsd: data.feeUsd
|
|
1862
|
+
};
|
|
1863
|
+
}
|
|
1864
|
+
return { success: false, error: "Failed to estimate fee" };
|
|
1865
|
+
} catch (error) {
|
|
1866
|
+
return {
|
|
1867
|
+
success: false,
|
|
1868
|
+
error: error instanceof Error ? error.message : "Fee estimation failed"
|
|
1869
|
+
};
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1784
1872
|
};
|
|
1785
1873
|
|
|
1786
1874
|
// src/react/useWalletManager.ts
|
|
@@ -1970,6 +2058,32 @@ function useWalletManager(options = {}) {
|
|
|
1970
2058
|
);
|
|
1971
2059
|
const hasWallet = useCallback(() => manager.hasWallet(), [manager]);
|
|
1972
2060
|
const getSeed = useCallback(() => manager.getSeed(), [manager]);
|
|
2061
|
+
const sendTransaction = useCallback(
|
|
2062
|
+
async (chain, to, amount, token) => {
|
|
2063
|
+
setIsLoading(true);
|
|
2064
|
+
try {
|
|
2065
|
+
const result = await manager.sendTransaction(chain, to, amount, token);
|
|
2066
|
+
if (result.success) {
|
|
2067
|
+
try {
|
|
2068
|
+
const balances = await manager.fetchAllBalances();
|
|
2069
|
+
setChainBalances(balances);
|
|
2070
|
+
} catch (err) {
|
|
2071
|
+
console.warn("Failed to refresh balances after transaction:", err);
|
|
2072
|
+
}
|
|
2073
|
+
}
|
|
2074
|
+
return result;
|
|
2075
|
+
} finally {
|
|
2076
|
+
setIsLoading(false);
|
|
2077
|
+
}
|
|
2078
|
+
},
|
|
2079
|
+
[manager]
|
|
2080
|
+
);
|
|
2081
|
+
const estimateFee = useCallback(
|
|
2082
|
+
async (chain, to, amount, token) => {
|
|
2083
|
+
return manager.estimateFee(chain, to, amount, token);
|
|
2084
|
+
},
|
|
2085
|
+
[manager]
|
|
2086
|
+
);
|
|
1973
2087
|
return {
|
|
1974
2088
|
state,
|
|
1975
2089
|
isLoading,
|
|
@@ -1988,6 +2102,9 @@ function useWalletManager(options = {}) {
|
|
|
1988
2102
|
getAddressForChain,
|
|
1989
2103
|
getAllAddresses,
|
|
1990
2104
|
supportedChains: SUPPORTED_CHAINS,
|
|
2105
|
+
// Transaction Actions (Powered by Tether WDK)
|
|
2106
|
+
sendTransaction,
|
|
2107
|
+
estimateFee,
|
|
1991
2108
|
// Utilities
|
|
1992
2109
|
hasWallet,
|
|
1993
2110
|
getSeed,
|