@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.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { N as NetworkType } from '../index-DhluuR9H.mjs';
|
|
2
|
-
import { b as WalletManagerConfig, a as WalletState, C as ChainBalance, M as MultiChainAddresses, W as WalletManager } from '../WalletManager
|
|
3
|
-
export { S as SUPPORTED_CHAINS } from '../WalletManager
|
|
2
|
+
import { b as WalletManagerConfig, a as WalletState, C as ChainBalance, M as MultiChainAddresses, W as WalletManager } from '../WalletManager--UOBwXJp.mjs';
|
|
3
|
+
export { S as SUPPORTED_CHAINS } from '../WalletManager--UOBwXJp.mjs';
|
|
4
4
|
import 'abitype';
|
|
5
5
|
import 'viem';
|
|
6
6
|
import 'ethers';
|
|
@@ -16,6 +16,23 @@ import '../SecureStorage-jO783AhC.mjs';
|
|
|
16
16
|
interface UseWalletManagerOptions extends WalletManagerConfig {
|
|
17
17
|
autoCheckWallet?: boolean;
|
|
18
18
|
}
|
|
19
|
+
/** Transaction result from sendTransaction */
|
|
20
|
+
interface SendTransactionResult {
|
|
21
|
+
success: boolean;
|
|
22
|
+
txHash?: string;
|
|
23
|
+
from?: string;
|
|
24
|
+
to?: string;
|
|
25
|
+
amount?: string;
|
|
26
|
+
chain?: NetworkType;
|
|
27
|
+
error?: string;
|
|
28
|
+
}
|
|
29
|
+
/** Fee estimation result */
|
|
30
|
+
interface FeeEstimateResult {
|
|
31
|
+
success: boolean;
|
|
32
|
+
fee?: string;
|
|
33
|
+
feeUsd?: number;
|
|
34
|
+
error?: string;
|
|
35
|
+
}
|
|
19
36
|
interface UseWalletManagerReturn {
|
|
20
37
|
state: WalletState;
|
|
21
38
|
isLoading: boolean;
|
|
@@ -36,6 +53,8 @@ interface UseWalletManagerReturn {
|
|
|
36
53
|
getAddressForChain: (chain: NetworkType) => string | null;
|
|
37
54
|
getAllAddresses: () => Partial<MultiChainAddresses>;
|
|
38
55
|
supportedChains: NetworkType[];
|
|
56
|
+
sendTransaction: (chain: NetworkType, to: string, amount: string, token?: string) => Promise<SendTransactionResult>;
|
|
57
|
+
estimateFee: (chain: NetworkType, to: string, amount: string, token?: string) => Promise<FeeEstimateResult>;
|
|
39
58
|
hasWallet: () => Promise<boolean>;
|
|
40
59
|
getSeed: () => string | null;
|
|
41
60
|
manager: WalletManager;
|
|
@@ -45,4 +64,4 @@ interface UseWalletManagerReturn {
|
|
|
45
64
|
*/
|
|
46
65
|
declare function useWalletManager(options?: UseWalletManagerOptions): UseWalletManagerReturn;
|
|
47
66
|
|
|
48
|
-
export { ChainBalance, MultiChainAddresses, type UseWalletManagerOptions, type UseWalletManagerReturn, WalletState, useWalletManager };
|
|
67
|
+
export { ChainBalance, type FeeEstimateResult, MultiChainAddresses, type SendTransactionResult, type UseWalletManagerOptions, type UseWalletManagerReturn, WalletState, useWalletManager };
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { N as NetworkType } from '../index-DhluuR9H.js';
|
|
2
|
-
import { b as WalletManagerConfig, a as WalletState, C as ChainBalance, M as MultiChainAddresses, W as WalletManager } from '../WalletManager-
|
|
3
|
-
export { S as SUPPORTED_CHAINS } from '../WalletManager-
|
|
2
|
+
import { b as WalletManagerConfig, a as WalletState, C as ChainBalance, M as MultiChainAddresses, W as WalletManager } from '../WalletManager-DVq_PUZK.js';
|
|
3
|
+
export { S as SUPPORTED_CHAINS } from '../WalletManager-DVq_PUZK.js';
|
|
4
4
|
import 'abitype';
|
|
5
5
|
import 'viem';
|
|
6
6
|
import 'ethers';
|
|
@@ -16,6 +16,23 @@ import '../SecureStorage-jO783AhC.js';
|
|
|
16
16
|
interface UseWalletManagerOptions extends WalletManagerConfig {
|
|
17
17
|
autoCheckWallet?: boolean;
|
|
18
18
|
}
|
|
19
|
+
/** Transaction result from sendTransaction */
|
|
20
|
+
interface SendTransactionResult {
|
|
21
|
+
success: boolean;
|
|
22
|
+
txHash?: string;
|
|
23
|
+
from?: string;
|
|
24
|
+
to?: string;
|
|
25
|
+
amount?: string;
|
|
26
|
+
chain?: NetworkType;
|
|
27
|
+
error?: string;
|
|
28
|
+
}
|
|
29
|
+
/** Fee estimation result */
|
|
30
|
+
interface FeeEstimateResult {
|
|
31
|
+
success: boolean;
|
|
32
|
+
fee?: string;
|
|
33
|
+
feeUsd?: number;
|
|
34
|
+
error?: string;
|
|
35
|
+
}
|
|
19
36
|
interface UseWalletManagerReturn {
|
|
20
37
|
state: WalletState;
|
|
21
38
|
isLoading: boolean;
|
|
@@ -36,6 +53,8 @@ interface UseWalletManagerReturn {
|
|
|
36
53
|
getAddressForChain: (chain: NetworkType) => string | null;
|
|
37
54
|
getAllAddresses: () => Partial<MultiChainAddresses>;
|
|
38
55
|
supportedChains: NetworkType[];
|
|
56
|
+
sendTransaction: (chain: NetworkType, to: string, amount: string, token?: string) => Promise<SendTransactionResult>;
|
|
57
|
+
estimateFee: (chain: NetworkType, to: string, amount: string, token?: string) => Promise<FeeEstimateResult>;
|
|
39
58
|
hasWallet: () => Promise<boolean>;
|
|
40
59
|
getSeed: () => string | null;
|
|
41
60
|
manager: WalletManager;
|
|
@@ -45,4 +64,4 @@ interface UseWalletManagerReturn {
|
|
|
45
64
|
*/
|
|
46
65
|
declare function useWalletManager(options?: UseWalletManagerOptions): UseWalletManagerReturn;
|
|
47
66
|
|
|
48
|
-
export { ChainBalance, MultiChainAddresses, type UseWalletManagerOptions, type UseWalletManagerReturn, WalletState, useWalletManager };
|
|
67
|
+
export { ChainBalance, type FeeEstimateResult, MultiChainAddresses, type SendTransactionResult, type UseWalletManagerOptions, type UseWalletManagerReturn, WalletState, useWalletManager };
|
package/dist/react/index.js
CHANGED
|
@@ -1783,6 +1783,94 @@ var WalletManager = class _WalletManager {
|
|
|
1783
1783
|
selectedChain: this.selectedChain
|
|
1784
1784
|
};
|
|
1785
1785
|
}
|
|
1786
|
+
/**
|
|
1787
|
+
* Send a transaction using Tether WDK
|
|
1788
|
+
* Supports native tokens and USDT on all chains
|
|
1789
|
+
*
|
|
1790
|
+
* @param chain - Target blockchain (ethereum, bitcoin, ton, tron, solana, spark)
|
|
1791
|
+
* @param to - Recipient address
|
|
1792
|
+
* @param amount - Amount to send (in human-readable format)
|
|
1793
|
+
* @param token - Optional token symbol (e.g., 'USDT' for stablecoins)
|
|
1794
|
+
* @returns Transaction result with hash and status
|
|
1795
|
+
*/
|
|
1796
|
+
async sendTransaction(chain, to, amount, token) {
|
|
1797
|
+
if (!this.currentSeed) {
|
|
1798
|
+
return { success: false, error: "Wallet is locked" };
|
|
1799
|
+
}
|
|
1800
|
+
const fromAddress = this.getAddressForChain(chain);
|
|
1801
|
+
if (!fromAddress) {
|
|
1802
|
+
return { success: false, error: `No address for chain ${chain}` };
|
|
1803
|
+
}
|
|
1804
|
+
try {
|
|
1805
|
+
const response = await fetch(`${this.config.apiUrl}/api/wallets/wdk/send`, {
|
|
1806
|
+
method: "POST",
|
|
1807
|
+
headers: { "Content-Type": "application/json" },
|
|
1808
|
+
body: JSON.stringify({
|
|
1809
|
+
seed: this.currentSeed,
|
|
1810
|
+
chain,
|
|
1811
|
+
to,
|
|
1812
|
+
amount,
|
|
1813
|
+
token,
|
|
1814
|
+
network: this.config.network
|
|
1815
|
+
})
|
|
1816
|
+
});
|
|
1817
|
+
if (response.ok) {
|
|
1818
|
+
const data = await response.json();
|
|
1819
|
+
console.log(`Transaction sent on ${chain}:`, data);
|
|
1820
|
+
return {
|
|
1821
|
+
success: data.success,
|
|
1822
|
+
txHash: data.txHash,
|
|
1823
|
+
from: fromAddress,
|
|
1824
|
+
to,
|
|
1825
|
+
amount,
|
|
1826
|
+
chain
|
|
1827
|
+
};
|
|
1828
|
+
}
|
|
1829
|
+
const errorData = await response.json().catch(() => ({}));
|
|
1830
|
+
return {
|
|
1831
|
+
success: false,
|
|
1832
|
+
error: errorData.error || `HTTP ${response.status}`
|
|
1833
|
+
};
|
|
1834
|
+
} catch (error) {
|
|
1835
|
+
console.error(`Transaction failed on ${chain}:`, error);
|
|
1836
|
+
return {
|
|
1837
|
+
success: false,
|
|
1838
|
+
error: error instanceof Error ? error.message : "Transaction failed"
|
|
1839
|
+
};
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
/**
|
|
1843
|
+
* Estimate transaction fee using Tether WDK
|
|
1844
|
+
*/
|
|
1845
|
+
async estimateFee(chain, to, amount, token) {
|
|
1846
|
+
try {
|
|
1847
|
+
const response = await fetch(`${this.config.apiUrl}/api/wallets/wdk/estimate-fee`, {
|
|
1848
|
+
method: "POST",
|
|
1849
|
+
headers: { "Content-Type": "application/json" },
|
|
1850
|
+
body: JSON.stringify({
|
|
1851
|
+
chain,
|
|
1852
|
+
to,
|
|
1853
|
+
amount,
|
|
1854
|
+
token,
|
|
1855
|
+
network: this.config.network
|
|
1856
|
+
})
|
|
1857
|
+
});
|
|
1858
|
+
if (response.ok) {
|
|
1859
|
+
const data = await response.json();
|
|
1860
|
+
return {
|
|
1861
|
+
success: true,
|
|
1862
|
+
fee: data.fee,
|
|
1863
|
+
feeUsd: data.feeUsd
|
|
1864
|
+
};
|
|
1865
|
+
}
|
|
1866
|
+
return { success: false, error: "Failed to estimate fee" };
|
|
1867
|
+
} catch (error) {
|
|
1868
|
+
return {
|
|
1869
|
+
success: false,
|
|
1870
|
+
error: error instanceof Error ? error.message : "Fee estimation failed"
|
|
1871
|
+
};
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1786
1874
|
};
|
|
1787
1875
|
|
|
1788
1876
|
// src/react/useWalletManager.ts
|
|
@@ -1972,6 +2060,32 @@ function useWalletManager(options = {}) {
|
|
|
1972
2060
|
);
|
|
1973
2061
|
const hasWallet = react.useCallback(() => manager.hasWallet(), [manager]);
|
|
1974
2062
|
const getSeed = react.useCallback(() => manager.getSeed(), [manager]);
|
|
2063
|
+
const sendTransaction = react.useCallback(
|
|
2064
|
+
async (chain, to, amount, token) => {
|
|
2065
|
+
setIsLoading(true);
|
|
2066
|
+
try {
|
|
2067
|
+
const result = await manager.sendTransaction(chain, to, amount, token);
|
|
2068
|
+
if (result.success) {
|
|
2069
|
+
try {
|
|
2070
|
+
const balances = await manager.fetchAllBalances();
|
|
2071
|
+
setChainBalances(balances);
|
|
2072
|
+
} catch (err) {
|
|
2073
|
+
console.warn("Failed to refresh balances after transaction:", err);
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
2076
|
+
return result;
|
|
2077
|
+
} finally {
|
|
2078
|
+
setIsLoading(false);
|
|
2079
|
+
}
|
|
2080
|
+
},
|
|
2081
|
+
[manager]
|
|
2082
|
+
);
|
|
2083
|
+
const estimateFee = react.useCallback(
|
|
2084
|
+
async (chain, to, amount, token) => {
|
|
2085
|
+
return manager.estimateFee(chain, to, amount, token);
|
|
2086
|
+
},
|
|
2087
|
+
[manager]
|
|
2088
|
+
);
|
|
1975
2089
|
return {
|
|
1976
2090
|
state,
|
|
1977
2091
|
isLoading,
|
|
@@ -1990,6 +2104,9 @@ function useWalletManager(options = {}) {
|
|
|
1990
2104
|
getAddressForChain,
|
|
1991
2105
|
getAllAddresses,
|
|
1992
2106
|
supportedChains: SUPPORTED_CHAINS,
|
|
2107
|
+
// Transaction Actions (Powered by Tether WDK)
|
|
2108
|
+
sendTransaction,
|
|
2109
|
+
estimateFee,
|
|
1993
2110
|
// Utilities
|
|
1994
2111
|
hasWallet,
|
|
1995
2112
|
getSeed,
|