@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.
@@ -2079,6 +2079,94 @@ var WalletManager = class _WalletManager {
2079
2079
  selectedChain: this.selectedChain
2080
2080
  };
2081
2081
  }
2082
+ /**
2083
+ * Send a transaction using Tether WDK
2084
+ * Supports native tokens and USDT on all chains
2085
+ *
2086
+ * @param chain - Target blockchain (ethereum, bitcoin, ton, tron, solana, spark)
2087
+ * @param to - Recipient address
2088
+ * @param amount - Amount to send (in human-readable format)
2089
+ * @param token - Optional token symbol (e.g., 'USDT' for stablecoins)
2090
+ * @returns Transaction result with hash and status
2091
+ */
2092
+ async sendTransaction(chain, to, amount, token) {
2093
+ if (!this.currentSeed) {
2094
+ return { success: false, error: "Wallet is locked" };
2095
+ }
2096
+ const fromAddress = this.getAddressForChain(chain);
2097
+ if (!fromAddress) {
2098
+ return { success: false, error: `No address for chain ${chain}` };
2099
+ }
2100
+ try {
2101
+ const response = await fetch(`${this.config.apiUrl}/api/wallets/wdk/send`, {
2102
+ method: "POST",
2103
+ headers: { "Content-Type": "application/json" },
2104
+ body: JSON.stringify({
2105
+ seed: this.currentSeed,
2106
+ chain,
2107
+ to,
2108
+ amount,
2109
+ token,
2110
+ network: this.config.network
2111
+ })
2112
+ });
2113
+ if (response.ok) {
2114
+ const data = await response.json();
2115
+ console.log(`Transaction sent on ${chain}:`, data);
2116
+ return {
2117
+ success: data.success,
2118
+ txHash: data.txHash,
2119
+ from: fromAddress,
2120
+ to,
2121
+ amount,
2122
+ chain
2123
+ };
2124
+ }
2125
+ const errorData = await response.json().catch(() => ({}));
2126
+ return {
2127
+ success: false,
2128
+ error: errorData.error || `HTTP ${response.status}`
2129
+ };
2130
+ } catch (error) {
2131
+ console.error(`Transaction failed on ${chain}:`, error);
2132
+ return {
2133
+ success: false,
2134
+ error: error instanceof Error ? error.message : "Transaction failed"
2135
+ };
2136
+ }
2137
+ }
2138
+ /**
2139
+ * Estimate transaction fee using Tether WDK
2140
+ */
2141
+ async estimateFee(chain, to, amount, token) {
2142
+ try {
2143
+ const response = await fetch(`${this.config.apiUrl}/api/wallets/wdk/estimate-fee`, {
2144
+ method: "POST",
2145
+ headers: { "Content-Type": "application/json" },
2146
+ body: JSON.stringify({
2147
+ chain,
2148
+ to,
2149
+ amount,
2150
+ token,
2151
+ network: this.config.network
2152
+ })
2153
+ });
2154
+ if (response.ok) {
2155
+ const data = await response.json();
2156
+ return {
2157
+ success: true,
2158
+ fee: data.fee,
2159
+ feeUsd: data.feeUsd
2160
+ };
2161
+ }
2162
+ return { success: false, error: "Failed to estimate fee" };
2163
+ } catch (error) {
2164
+ return {
2165
+ success: false,
2166
+ error: error instanceof Error ? error.message : "Fee estimation failed"
2167
+ };
2168
+ }
2169
+ }
2082
2170
  };
2083
2171
 
2084
2172
  export { SUPPORTED_CHAINS, WalletManager, ZubariWallet };