@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/index.mjs
CHANGED
|
@@ -2128,6 +2128,94 @@ var WalletManager = class _WalletManager {
|
|
|
2128
2128
|
selectedChain: this.selectedChain
|
|
2129
2129
|
};
|
|
2130
2130
|
}
|
|
2131
|
+
/**
|
|
2132
|
+
* Send a transaction using Tether WDK
|
|
2133
|
+
* Supports native tokens and USDT on all chains
|
|
2134
|
+
*
|
|
2135
|
+
* @param chain - Target blockchain (ethereum, bitcoin, ton, tron, solana, spark)
|
|
2136
|
+
* @param to - Recipient address
|
|
2137
|
+
* @param amount - Amount to send (in human-readable format)
|
|
2138
|
+
* @param token - Optional token symbol (e.g., 'USDT' for stablecoins)
|
|
2139
|
+
* @returns Transaction result with hash and status
|
|
2140
|
+
*/
|
|
2141
|
+
async sendTransaction(chain, to, amount, token) {
|
|
2142
|
+
if (!this.currentSeed) {
|
|
2143
|
+
return { success: false, error: "Wallet is locked" };
|
|
2144
|
+
}
|
|
2145
|
+
const fromAddress = this.getAddressForChain(chain);
|
|
2146
|
+
if (!fromAddress) {
|
|
2147
|
+
return { success: false, error: `No address for chain ${chain}` };
|
|
2148
|
+
}
|
|
2149
|
+
try {
|
|
2150
|
+
const response = await fetch(`${this.config.apiUrl}/api/wallets/wdk/send`, {
|
|
2151
|
+
method: "POST",
|
|
2152
|
+
headers: { "Content-Type": "application/json" },
|
|
2153
|
+
body: JSON.stringify({
|
|
2154
|
+
seed: this.currentSeed,
|
|
2155
|
+
chain,
|
|
2156
|
+
to,
|
|
2157
|
+
amount,
|
|
2158
|
+
token,
|
|
2159
|
+
network: this.config.network
|
|
2160
|
+
})
|
|
2161
|
+
});
|
|
2162
|
+
if (response.ok) {
|
|
2163
|
+
const data = await response.json();
|
|
2164
|
+
console.log(`Transaction sent on ${chain}:`, data);
|
|
2165
|
+
return {
|
|
2166
|
+
success: data.success,
|
|
2167
|
+
txHash: data.txHash,
|
|
2168
|
+
from: fromAddress,
|
|
2169
|
+
to,
|
|
2170
|
+
amount,
|
|
2171
|
+
chain
|
|
2172
|
+
};
|
|
2173
|
+
}
|
|
2174
|
+
const errorData = await response.json().catch(() => ({}));
|
|
2175
|
+
return {
|
|
2176
|
+
success: false,
|
|
2177
|
+
error: errorData.error || `HTTP ${response.status}`
|
|
2178
|
+
};
|
|
2179
|
+
} catch (error) {
|
|
2180
|
+
console.error(`Transaction failed on ${chain}:`, error);
|
|
2181
|
+
return {
|
|
2182
|
+
success: false,
|
|
2183
|
+
error: error instanceof Error ? error.message : "Transaction failed"
|
|
2184
|
+
};
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
2187
|
+
/**
|
|
2188
|
+
* Estimate transaction fee using Tether WDK
|
|
2189
|
+
*/
|
|
2190
|
+
async estimateFee(chain, to, amount, token) {
|
|
2191
|
+
try {
|
|
2192
|
+
const response = await fetch(`${this.config.apiUrl}/api/wallets/wdk/estimate-fee`, {
|
|
2193
|
+
method: "POST",
|
|
2194
|
+
headers: { "Content-Type": "application/json" },
|
|
2195
|
+
body: JSON.stringify({
|
|
2196
|
+
chain,
|
|
2197
|
+
to,
|
|
2198
|
+
amount,
|
|
2199
|
+
token,
|
|
2200
|
+
network: this.config.network
|
|
2201
|
+
})
|
|
2202
|
+
});
|
|
2203
|
+
if (response.ok) {
|
|
2204
|
+
const data = await response.json();
|
|
2205
|
+
return {
|
|
2206
|
+
success: true,
|
|
2207
|
+
fee: data.fee,
|
|
2208
|
+
feeUsd: data.feeUsd
|
|
2209
|
+
};
|
|
2210
|
+
}
|
|
2211
|
+
return { success: false, error: "Failed to estimate fee" };
|
|
2212
|
+
} catch (error) {
|
|
2213
|
+
return {
|
|
2214
|
+
success: false,
|
|
2215
|
+
error: error instanceof Error ? error.message : "Fee estimation failed"
|
|
2216
|
+
};
|
|
2217
|
+
}
|
|
2218
|
+
}
|
|
2131
2219
|
};
|
|
2132
2220
|
|
|
2133
2221
|
// src/protocols/NFTProtocol.ts
|
|
@@ -3235,6 +3323,32 @@ function useWalletManager(options = {}) {
|
|
|
3235
3323
|
);
|
|
3236
3324
|
const hasWallet = useCallback(() => manager.hasWallet(), [manager]);
|
|
3237
3325
|
const getSeed = useCallback(() => manager.getSeed(), [manager]);
|
|
3326
|
+
const sendTransaction = useCallback(
|
|
3327
|
+
async (chain, to, amount, token) => {
|
|
3328
|
+
setIsLoading(true);
|
|
3329
|
+
try {
|
|
3330
|
+
const result = await manager.sendTransaction(chain, to, amount, token);
|
|
3331
|
+
if (result.success) {
|
|
3332
|
+
try {
|
|
3333
|
+
const balances = await manager.fetchAllBalances();
|
|
3334
|
+
setChainBalances(balances);
|
|
3335
|
+
} catch (err) {
|
|
3336
|
+
console.warn("Failed to refresh balances after transaction:", err);
|
|
3337
|
+
}
|
|
3338
|
+
}
|
|
3339
|
+
return result;
|
|
3340
|
+
} finally {
|
|
3341
|
+
setIsLoading(false);
|
|
3342
|
+
}
|
|
3343
|
+
},
|
|
3344
|
+
[manager]
|
|
3345
|
+
);
|
|
3346
|
+
const estimateFee = useCallback(
|
|
3347
|
+
async (chain, to, amount, token) => {
|
|
3348
|
+
return manager.estimateFee(chain, to, amount, token);
|
|
3349
|
+
},
|
|
3350
|
+
[manager]
|
|
3351
|
+
);
|
|
3238
3352
|
return {
|
|
3239
3353
|
state,
|
|
3240
3354
|
isLoading,
|
|
@@ -3253,6 +3367,9 @@ function useWalletManager(options = {}) {
|
|
|
3253
3367
|
getAddressForChain,
|
|
3254
3368
|
getAllAddresses,
|
|
3255
3369
|
supportedChains: SUPPORTED_CHAINS,
|
|
3370
|
+
// Transaction Actions (Powered by Tether WDK)
|
|
3371
|
+
sendTransaction,
|
|
3372
|
+
estimateFee,
|
|
3256
3373
|
// Utilities
|
|
3257
3374
|
hasWallet,
|
|
3258
3375
|
getSeed,
|