@zubari/sdk 0.3.2 → 0.3.4
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/README.md +7 -0
- package/dist/{WalletManager-CEjN-YBF.d.ts → WalletManager-CmiNyapl.d.ts} +1 -1
- package/dist/{WalletManager-bo35aHOJ.d.mts → WalletManager-DXt6vihp.d.mts} +1 -1
- package/dist/{index-DJnsirV5.d.mts → index-CRsZrlN0.d.mts} +3 -2
- package/dist/{index-BpjMiC3n.d.ts → index-VNzO49qu.d.ts} +3 -2
- package/dist/index.d.mts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +13 -248
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -248
- package/dist/index.mjs.map +1 -1
- package/dist/protocols/index.d.mts +5 -2
- package/dist/protocols/index.d.ts +5 -2
- package/dist/protocols/index.js +12 -7
- package/dist/protocols/index.js.map +1 -1
- package/dist/protocols/index.mjs +12 -7
- package/dist/protocols/index.mjs.map +1 -1
- package/dist/react/index.d.mts +2 -2
- package/dist/react/index.d.ts +2 -2
- package/dist/services/index.js.map +1 -1
- package/dist/services/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.map +1 -1
- package/dist/wallet/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -317,8 +317,15 @@ Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md)
|
|
|
317
317
|
|
|
318
318
|
MIT - see [LICENSE](LICENSE) for details.
|
|
319
319
|
|
|
320
|
+
## Architecture
|
|
321
|
+
|
|
322
|
+
For detailed architecture documentation including WDK integration, protocol design, and API patterns, see **[ARCHITECTURE.md](./ARCHITECTURE.md)**.
|
|
323
|
+
|
|
320
324
|
## Links
|
|
321
325
|
|
|
326
|
+
- [Architecture Documentation](./ARCHITECTURE.md)
|
|
322
327
|
- [GitHub Repository](https://github.com/zubaridev/Zubari-wallet)
|
|
323
328
|
- [Documentation](https://zubari-wallet-api.vercel.app/demo)
|
|
324
329
|
- [Tether WDK](https://docs.wallet.tether.io)
|
|
330
|
+
- [Zubari Frontend](../../../Zubari-frontend/ARCHITECTURE.md)
|
|
331
|
+
- [Zubari Backend](../../../Zubari-backend/backend/ARCHITECTURE.md)
|
|
@@ -6067,4 +6067,4 @@ declare class WalletManager {
|
|
|
6067
6067
|
}>;
|
|
6068
6068
|
}
|
|
6069
6069
|
|
|
6070
|
-
export { type ChainBalance as C, DERIVATION_PATHS as D, type MultiChainAddresses as M, NETWORKS as N, SUPPORTED_CHAINS as S, TESTNET_NETWORKS as T,
|
|
6070
|
+
export { type ChainBalance as C, DERIVATION_PATHS as D, type MultiChainAddresses as M, NETWORKS as N, SUPPORTED_CHAINS as S, TESTNET_NETWORKS as T, type WalletManagerConfig as W, type WalletState as a, WalletManager as b, getNetworkConfig as g };
|
|
@@ -6067,4 +6067,4 @@ declare class WalletManager {
|
|
|
6067
6067
|
}>;
|
|
6068
6068
|
}
|
|
6069
6069
|
|
|
6070
|
-
export { type ChainBalance as C, DERIVATION_PATHS as D, type MultiChainAddresses as M, NETWORKS as N, SUPPORTED_CHAINS as S, TESTNET_NETWORKS as T,
|
|
6070
|
+
export { type ChainBalance as C, DERIVATION_PATHS as D, type MultiChainAddresses as M, NETWORKS as N, SUPPORTED_CHAINS as S, TESTNET_NETWORKS as T, type WalletManagerConfig as W, type WalletState as a, WalletManager as b, getNetworkConfig as g };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Z as ZubariWalletConfig, a as NetworkType, A as Account, b as NetworkBalance, S as SendParams, c as TxResult } from './index-DF0Gf8NK.mjs';
|
|
2
|
-
import './WalletManager-
|
|
2
|
+
import './WalletManager-DXt6vihp.mjs';
|
|
3
3
|
|
|
4
4
|
interface ContractAddresses {
|
|
5
5
|
registry: string;
|
|
@@ -18,7 +18,8 @@ interface ContractAddresses {
|
|
|
18
18
|
declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
19
19
|
declare const ZUBARI_CONTRACTS: Record<'testnet' | 'mainnet', ContractAddresses>;
|
|
20
20
|
declare const PLATFORM_CONFIG: {
|
|
21
|
-
readonly
|
|
21
|
+
readonly platformFeeBps: 1000;
|
|
22
|
+
readonly tipFeeBps: 1000;
|
|
22
23
|
readonly maxRoyaltyBps: 1000;
|
|
23
24
|
readonly defaultSlippageBps: 50;
|
|
24
25
|
readonly voucherValiditySecs: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Z as ZubariWalletConfig, a as NetworkType, A as Account, b as NetworkBalance, S as SendParams, c as TxResult } from './index-DF0Gf8NK.js';
|
|
2
|
-
import './WalletManager-
|
|
2
|
+
import './WalletManager-CmiNyapl.js';
|
|
3
3
|
|
|
4
4
|
interface ContractAddresses {
|
|
5
5
|
registry: string;
|
|
@@ -18,7 +18,8 @@ interface ContractAddresses {
|
|
|
18
18
|
declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
19
19
|
declare const ZUBARI_CONTRACTS: Record<'testnet' | 'mainnet', ContractAddresses>;
|
|
20
20
|
declare const PLATFORM_CONFIG: {
|
|
21
|
-
readonly
|
|
21
|
+
readonly platformFeeBps: 1000;
|
|
22
|
+
readonly tipFeeBps: 1000;
|
|
22
23
|
readonly maxRoyaltyBps: 1000;
|
|
23
24
|
readonly defaultSlippageBps: 50;
|
|
24
25
|
readonly voucherValiditySecs: number;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
export { C as CURRENCY_ADDRESSES, N as NFT_VOUCHER_DOMAIN, c as NFT_VOUCHER_TYPES, P as PLATFORM_CONFIG, b as ZERO_ADDRESS, 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,
|
|
1
|
+
export { C as CURRENCY_ADDRESSES, N as NFT_VOUCHER_DOMAIN, c as NFT_VOUCHER_TYPES, P as PLATFORM_CONFIG, b as ZERO_ADDRESS, a as ZUBARI_CONTRACTS, Z as ZubariWallet, g as getContractAddresses } from './index-CRsZrlN0.mjs';
|
|
2
|
+
export { D as DERIVATION_PATHS, N as NETWORKS, T as TESTNET_NETWORKS, b as WalletManager, W as WalletManagerConfig, a as WalletState, g as getNetworkConfig } from './WalletManager-DXt6vihp.mjs';
|
|
3
3
|
export { M as MemoryStorageAdapter, S as SecureStorageAdapter, W as WebEncryptedStorageAdapter, c as createSecureStorage } from './SecureStorage-jO783AhC.mjs';
|
|
4
4
|
export { ZubariMarketProtocol, ZubariNFTProtocol, ZubariPayoutsProtocol, ZubariSubscriptionProtocol, ZubariTipsProtocol } from './protocols/index.mjs';
|
|
5
5
|
export { B as BrowserAddressDerivation, l as ChainAddress, m as ChainBalance, v as FeeEstimate, F as FeeRates, M as MultiChainAddresses, k as SupportedChain, S as SwapService, u as TransactionHistoryItem, s as TransactionParams, t as TransactionResult, p as TransactionService, w as TransactionServiceConfig, W as WdkApiClient, Z as ZubariWdkService, o as ZubariWdkServiceConfig, r as createTransactionService, i as createZubariWdkService, q as getTransactionService, g as getWdkApiClient, h as getZubariWdkService, j as isBrowser } from './TransactionService-DuMJmrG3.mjs';
|
|
6
6
|
export { A as Account, B as BuyParams, C as CreateVoucherParams, E as EarningsBreakdown, L as LazyMintVoucher, h as Listing, g as ListingParams, f as NFT, d as NFTAttribute, N as NFTCurrency, e as NFTMetadata, b as NetworkBalance, a as NetworkType, R as RevenueSplit, S as SendParams, n as Subscription, m as SubscriptionPlan, p as SwapParams, o as SwapQuote, l as Tip, i as TipData, j as TipResult, k as TipStats, T as TokenBalance, c as TxResult, W as WatermarkingData, r as ZubariError, q as ZubariErrorCode, Z as ZubariWalletConfig } from './index-DF0Gf8NK.mjs';
|
|
7
|
-
export { FeeEstimateResult, SendTransactionResult, UseWalletManagerOptions, UseWalletManagerReturn, useWalletManager } from './react/index.mjs';
|
|
8
7
|
import 'abitype';
|
|
9
8
|
import 'viem';
|
|
10
9
|
import 'ethers';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
export { C as CURRENCY_ADDRESSES, N as NFT_VOUCHER_DOMAIN, c as NFT_VOUCHER_TYPES, P as PLATFORM_CONFIG, b as ZERO_ADDRESS, 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,
|
|
1
|
+
export { C as CURRENCY_ADDRESSES, N as NFT_VOUCHER_DOMAIN, c as NFT_VOUCHER_TYPES, P as PLATFORM_CONFIG, b as ZERO_ADDRESS, a as ZUBARI_CONTRACTS, Z as ZubariWallet, g as getContractAddresses } from './index-VNzO49qu.js';
|
|
2
|
+
export { D as DERIVATION_PATHS, N as NETWORKS, T as TESTNET_NETWORKS, b as WalletManager, W as WalletManagerConfig, a as WalletState, g as getNetworkConfig } from './WalletManager-CmiNyapl.js';
|
|
3
3
|
export { M as MemoryStorageAdapter, S as SecureStorageAdapter, W as WebEncryptedStorageAdapter, c as createSecureStorage } from './SecureStorage-jO783AhC.js';
|
|
4
4
|
export { ZubariMarketProtocol, ZubariNFTProtocol, ZubariPayoutsProtocol, ZubariSubscriptionProtocol, ZubariTipsProtocol } from './protocols/index.js';
|
|
5
5
|
export { B as BrowserAddressDerivation, l as ChainAddress, m as ChainBalance, v as FeeEstimate, F as FeeRates, M as MultiChainAddresses, k as SupportedChain, S as SwapService, u as TransactionHistoryItem, s as TransactionParams, t as TransactionResult, p as TransactionService, w as TransactionServiceConfig, W as WdkApiClient, Z as ZubariWdkService, o as ZubariWdkServiceConfig, r as createTransactionService, i as createZubariWdkService, q as getTransactionService, g as getWdkApiClient, h as getZubariWdkService, j as isBrowser } from './TransactionService-DURp3bRL.js';
|
|
6
6
|
export { A as Account, B as BuyParams, C as CreateVoucherParams, E as EarningsBreakdown, L as LazyMintVoucher, h as Listing, g as ListingParams, f as NFT, d as NFTAttribute, N as NFTCurrency, e as NFTMetadata, b as NetworkBalance, a as NetworkType, R as RevenueSplit, S as SendParams, n as Subscription, m as SubscriptionPlan, p as SwapParams, o as SwapQuote, l as Tip, i as TipData, j as TipResult, k as TipStats, T as TokenBalance, c as TxResult, W as WatermarkingData, r as ZubariError, q as ZubariErrorCode, Z as ZubariWalletConfig } from './index-DF0Gf8NK.js';
|
|
7
|
-
export { FeeEstimateResult, SendTransactionResult, UseWalletManagerOptions, UseWalletManagerReturn, useWalletManager } from './react/index.js';
|
|
8
7
|
import 'abitype';
|
|
9
8
|
import 'viem';
|
|
10
9
|
import 'ethers';
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,6 @@ var sha256 = require('@noble/hashes/sha256');
|
|
|
9
9
|
var ripemd160 = require('@noble/hashes/ripemd160');
|
|
10
10
|
var viem = require('viem');
|
|
11
11
|
var chains = require('viem/chains');
|
|
12
|
-
var react = require('react');
|
|
13
12
|
|
|
14
13
|
var __defProp = Object.defineProperty;
|
|
15
14
|
var __export = (target, all) => {
|
|
@@ -184,8 +183,11 @@ var ZUBARI_CONTRACTS = {
|
|
|
184
183
|
}
|
|
185
184
|
};
|
|
186
185
|
var PLATFORM_CONFIG = {
|
|
187
|
-
// Platform fee in basis points (
|
|
188
|
-
|
|
186
|
+
// Platform fee in basis points (1000 = 10%)
|
|
187
|
+
// Zubari keeps 10%, Creator receives 90%
|
|
188
|
+
platformFeeBps: 1e3,
|
|
189
|
+
tipFeeBps: 1e3,
|
|
190
|
+
// Alias for backward compatibility
|
|
189
191
|
// Maximum royalty in basis points (1000 = 10%)
|
|
190
192
|
maxRoyaltyBps: 1e3,
|
|
191
193
|
// Default slippage tolerance for swaps (50 = 0.5%)
|
|
@@ -4422,10 +4424,11 @@ var ZubariMarketProtocol = class {
|
|
|
4422
4424
|
}
|
|
4423
4425
|
/**
|
|
4424
4426
|
* Calculate platform fee for a given price
|
|
4427
|
+
* Platform keeps 10%, Creator/Seller receives 90%
|
|
4425
4428
|
* @param price The sale price
|
|
4426
4429
|
*/
|
|
4427
4430
|
calculateFee(price) {
|
|
4428
|
-
const fee = price * BigInt(PLATFORM_CONFIG.
|
|
4431
|
+
const fee = price * BigInt(PLATFORM_CONFIG.platformFeeBps) / 10000n;
|
|
4429
4432
|
return {
|
|
4430
4433
|
fee,
|
|
4431
4434
|
sellerAmount: price - fee
|
|
@@ -5229,9 +5232,10 @@ var ZubariTipsProtocol = class {
|
|
|
5229
5232
|
/**
|
|
5230
5233
|
* Calculate platform fee for a given amount
|
|
5231
5234
|
* @param amount The tip amount
|
|
5232
|
-
* @param feeBps Fee in basis points (default:
|
|
5235
|
+
* @param feeBps Fee in basis points (default: 1000 = 10%)
|
|
5236
|
+
* Platform keeps 10%, Creator receives 90%
|
|
5233
5237
|
*/
|
|
5234
|
-
calculateFee(amount, feeBps =
|
|
5238
|
+
calculateFee(amount, feeBps = 1e3) {
|
|
5235
5239
|
const fee = amount * BigInt(feeBps) / 10000n;
|
|
5236
5240
|
return {
|
|
5237
5241
|
fee,
|
|
@@ -6440,9 +6444,10 @@ var ZubariSubscriptionProtocol = class {
|
|
|
6440
6444
|
/**
|
|
6441
6445
|
* Calculate platform fee for a given amount
|
|
6442
6446
|
* @param amount The amount
|
|
6443
|
-
* @param feeBps Fee in basis points
|
|
6447
|
+
* @param feeBps Fee in basis points (default: 1000 = 10%)
|
|
6448
|
+
* Platform keeps 10%, Creator receives 90%
|
|
6444
6449
|
*/
|
|
6445
|
-
calculateFee(amount, feeBps =
|
|
6450
|
+
calculateFee(amount, feeBps = 1e3) {
|
|
6446
6451
|
const fee = amount * BigInt(feeBps) / 10000n;
|
|
6447
6452
|
return {
|
|
6448
6453
|
fee,
|
|
@@ -7452,245 +7457,6 @@ var ZubariError = class extends Error {
|
|
|
7452
7457
|
this.name = "ZubariError";
|
|
7453
7458
|
}
|
|
7454
7459
|
};
|
|
7455
|
-
function useWalletManager(options = {}) {
|
|
7456
|
-
const { autoCheckWallet = true, ...config } = options;
|
|
7457
|
-
const manager = react.useMemo(() => new WalletManager(config), [
|
|
7458
|
-
config.network,
|
|
7459
|
-
config.rpcUrl
|
|
7460
|
-
]);
|
|
7461
|
-
const [state, setState] = react.useState({
|
|
7462
|
-
isInitialized: false,
|
|
7463
|
-
isLocked: true,
|
|
7464
|
-
address: null,
|
|
7465
|
-
balance: null
|
|
7466
|
-
});
|
|
7467
|
-
const [isLoading, setIsLoading] = react.useState(false);
|
|
7468
|
-
const [error, setError] = react.useState(null);
|
|
7469
|
-
const [selectedChain, setSelectedChainState] = react.useState("ethereum");
|
|
7470
|
-
const [chainBalances, setChainBalances] = react.useState([]);
|
|
7471
|
-
const updateState = react.useCallback(() => {
|
|
7472
|
-
setState(manager.getExtendedState());
|
|
7473
|
-
}, [manager]);
|
|
7474
|
-
react.useEffect(() => {
|
|
7475
|
-
if (autoCheckWallet) {
|
|
7476
|
-
manager.hasWallet().then((exists) => {
|
|
7477
|
-
if (exists) {
|
|
7478
|
-
setState((prev) => ({
|
|
7479
|
-
...prev,
|
|
7480
|
-
isInitialized: true,
|
|
7481
|
-
isLocked: true
|
|
7482
|
-
}));
|
|
7483
|
-
}
|
|
7484
|
-
});
|
|
7485
|
-
}
|
|
7486
|
-
}, [manager, autoCheckWallet]);
|
|
7487
|
-
const createWallet = react.useCallback(
|
|
7488
|
-
async (password) => {
|
|
7489
|
-
setIsLoading(true);
|
|
7490
|
-
setError(null);
|
|
7491
|
-
try {
|
|
7492
|
-
await manager.initializeStorage(password);
|
|
7493
|
-
const result = await manager.createWallet(password);
|
|
7494
|
-
try {
|
|
7495
|
-
await manager.deriveAllAddressesAsync();
|
|
7496
|
-
} catch {
|
|
7497
|
-
manager.deriveAllAddresses();
|
|
7498
|
-
}
|
|
7499
|
-
updateState();
|
|
7500
|
-
try {
|
|
7501
|
-
const balances = await manager.fetchAllBalances();
|
|
7502
|
-
setChainBalances(balances);
|
|
7503
|
-
} catch (err) {
|
|
7504
|
-
console.warn("Failed to fetch balances after create:", err);
|
|
7505
|
-
}
|
|
7506
|
-
return result;
|
|
7507
|
-
} catch (err) {
|
|
7508
|
-
const message = err instanceof Error ? err.message : "Failed to create wallet";
|
|
7509
|
-
setError(message);
|
|
7510
|
-
throw err;
|
|
7511
|
-
} finally {
|
|
7512
|
-
setIsLoading(false);
|
|
7513
|
-
}
|
|
7514
|
-
},
|
|
7515
|
-
[manager, updateState]
|
|
7516
|
-
);
|
|
7517
|
-
const importWallet = react.useCallback(
|
|
7518
|
-
async (seed, password) => {
|
|
7519
|
-
setIsLoading(true);
|
|
7520
|
-
setError(null);
|
|
7521
|
-
try {
|
|
7522
|
-
await manager.initializeStorage(password);
|
|
7523
|
-
await manager.importWallet(seed, password);
|
|
7524
|
-
try {
|
|
7525
|
-
await manager.deriveAllAddressesAsync();
|
|
7526
|
-
} catch {
|
|
7527
|
-
manager.deriveAllAddresses();
|
|
7528
|
-
}
|
|
7529
|
-
updateState();
|
|
7530
|
-
try {
|
|
7531
|
-
const balances = await manager.fetchAllBalances();
|
|
7532
|
-
setChainBalances(balances);
|
|
7533
|
-
} catch (err) {
|
|
7534
|
-
console.warn("Failed to fetch balances after import:", err);
|
|
7535
|
-
}
|
|
7536
|
-
} catch (err) {
|
|
7537
|
-
const message = err instanceof Error ? err.message : "Failed to import wallet";
|
|
7538
|
-
setError(message);
|
|
7539
|
-
throw err;
|
|
7540
|
-
} finally {
|
|
7541
|
-
setIsLoading(false);
|
|
7542
|
-
}
|
|
7543
|
-
},
|
|
7544
|
-
[manager, updateState]
|
|
7545
|
-
);
|
|
7546
|
-
const unlock = react.useCallback(
|
|
7547
|
-
async (password) => {
|
|
7548
|
-
setIsLoading(true);
|
|
7549
|
-
setError(null);
|
|
7550
|
-
try {
|
|
7551
|
-
await manager.initializeStorage(password);
|
|
7552
|
-
await manager.unlock(password);
|
|
7553
|
-
try {
|
|
7554
|
-
await manager.deriveAllAddressesAsync();
|
|
7555
|
-
} catch {
|
|
7556
|
-
manager.deriveAllAddresses();
|
|
7557
|
-
}
|
|
7558
|
-
updateState();
|
|
7559
|
-
try {
|
|
7560
|
-
const balances = await manager.fetchAllBalances();
|
|
7561
|
-
setChainBalances(balances);
|
|
7562
|
-
} catch (err) {
|
|
7563
|
-
console.warn("Failed to fetch balances after unlock:", err);
|
|
7564
|
-
}
|
|
7565
|
-
} catch (err) {
|
|
7566
|
-
const message = err instanceof Error ? err.message : "Invalid password";
|
|
7567
|
-
setError(message);
|
|
7568
|
-
throw err;
|
|
7569
|
-
} finally {
|
|
7570
|
-
setIsLoading(false);
|
|
7571
|
-
}
|
|
7572
|
-
},
|
|
7573
|
-
[manager, updateState]
|
|
7574
|
-
);
|
|
7575
|
-
const lock = react.useCallback(() => {
|
|
7576
|
-
manager.lock();
|
|
7577
|
-
setChainBalances([]);
|
|
7578
|
-
updateState();
|
|
7579
|
-
}, [manager, updateState]);
|
|
7580
|
-
const deleteWallet = react.useCallback(async () => {
|
|
7581
|
-
setIsLoading(true);
|
|
7582
|
-
setError(null);
|
|
7583
|
-
try {
|
|
7584
|
-
await manager.deleteWallet();
|
|
7585
|
-
setChainBalances([]);
|
|
7586
|
-
setState({
|
|
7587
|
-
isInitialized: false,
|
|
7588
|
-
isLocked: true,
|
|
7589
|
-
address: null,
|
|
7590
|
-
balance: null
|
|
7591
|
-
});
|
|
7592
|
-
} catch (err) {
|
|
7593
|
-
const message = err instanceof Error ? err.message : "Failed to delete wallet";
|
|
7594
|
-
setError(message);
|
|
7595
|
-
throw err;
|
|
7596
|
-
} finally {
|
|
7597
|
-
setIsLoading(false);
|
|
7598
|
-
}
|
|
7599
|
-
}, [manager]);
|
|
7600
|
-
const fetchBalance = react.useCallback(async () => {
|
|
7601
|
-
setIsLoading(true);
|
|
7602
|
-
try {
|
|
7603
|
-
const balance = await manager.fetchBalance();
|
|
7604
|
-
setState((prev) => ({ ...prev, balance }));
|
|
7605
|
-
return balance;
|
|
7606
|
-
} catch (err) {
|
|
7607
|
-
console.warn("Failed to fetch balance:", err);
|
|
7608
|
-
setState((prev) => ({ ...prev, balance: "0" }));
|
|
7609
|
-
return "0";
|
|
7610
|
-
} finally {
|
|
7611
|
-
setIsLoading(false);
|
|
7612
|
-
}
|
|
7613
|
-
}, [manager]);
|
|
7614
|
-
const fetchAllBalances = react.useCallback(async () => {
|
|
7615
|
-
setIsLoading(true);
|
|
7616
|
-
try {
|
|
7617
|
-
const balances = await manager.fetchAllBalances();
|
|
7618
|
-
setChainBalances(balances);
|
|
7619
|
-
return balances;
|
|
7620
|
-
} catch (err) {
|
|
7621
|
-
console.warn("Failed to fetch all balances:", err);
|
|
7622
|
-
return [];
|
|
7623
|
-
} finally {
|
|
7624
|
-
setIsLoading(false);
|
|
7625
|
-
}
|
|
7626
|
-
}, [manager]);
|
|
7627
|
-
const setSelectedChain = react.useCallback((chain) => {
|
|
7628
|
-
manager.setSelectedChain(chain);
|
|
7629
|
-
setSelectedChainState(chain);
|
|
7630
|
-
}, [manager]);
|
|
7631
|
-
const getAddressForChain = react.useCallback(
|
|
7632
|
-
(chain) => manager.getAddressForChain(chain),
|
|
7633
|
-
[manager]
|
|
7634
|
-
);
|
|
7635
|
-
const getAllAddresses = react.useCallback(
|
|
7636
|
-
() => manager.getAllAddresses(),
|
|
7637
|
-
[manager]
|
|
7638
|
-
);
|
|
7639
|
-
const hasWallet = react.useCallback(() => manager.hasWallet(), [manager]);
|
|
7640
|
-
const getSeed = react.useCallback(() => manager.getSeed(), [manager]);
|
|
7641
|
-
const sendTransaction = react.useCallback(
|
|
7642
|
-
async (chain, to, amount, token) => {
|
|
7643
|
-
setIsLoading(true);
|
|
7644
|
-
try {
|
|
7645
|
-
const result = await manager.sendTransaction(chain, to, amount, token);
|
|
7646
|
-
if (result.success) {
|
|
7647
|
-
try {
|
|
7648
|
-
const balances = await manager.fetchAllBalances();
|
|
7649
|
-
setChainBalances(balances);
|
|
7650
|
-
} catch (err) {
|
|
7651
|
-
console.warn("Failed to refresh balances after transaction:", err);
|
|
7652
|
-
}
|
|
7653
|
-
}
|
|
7654
|
-
return result;
|
|
7655
|
-
} finally {
|
|
7656
|
-
setIsLoading(false);
|
|
7657
|
-
}
|
|
7658
|
-
},
|
|
7659
|
-
[manager]
|
|
7660
|
-
);
|
|
7661
|
-
const estimateFee = react.useCallback(
|
|
7662
|
-
async (chain, to, amount, token) => {
|
|
7663
|
-
return manager.estimateFee(chain, to, amount, token);
|
|
7664
|
-
},
|
|
7665
|
-
[manager]
|
|
7666
|
-
);
|
|
7667
|
-
return {
|
|
7668
|
-
state,
|
|
7669
|
-
isLoading,
|
|
7670
|
-
error,
|
|
7671
|
-
createWallet,
|
|
7672
|
-
importWallet,
|
|
7673
|
-
unlock,
|
|
7674
|
-
lock,
|
|
7675
|
-
deleteWallet,
|
|
7676
|
-
fetchBalance,
|
|
7677
|
-
// Multi-chain
|
|
7678
|
-
selectedChain,
|
|
7679
|
-
setSelectedChain,
|
|
7680
|
-
chainBalances,
|
|
7681
|
-
fetchAllBalances,
|
|
7682
|
-
getAddressForChain,
|
|
7683
|
-
getAllAddresses,
|
|
7684
|
-
supportedChains: SUPPORTED_CHAINS,
|
|
7685
|
-
// Transaction Actions (Powered by Tether WDK)
|
|
7686
|
-
sendTransaction,
|
|
7687
|
-
estimateFee,
|
|
7688
|
-
// Utilities
|
|
7689
|
-
hasWallet,
|
|
7690
|
-
getSeed,
|
|
7691
|
-
manager
|
|
7692
|
-
};
|
|
7693
|
-
}
|
|
7694
7460
|
|
|
7695
7461
|
// src/utils/index.ts
|
|
7696
7462
|
function formatAddress(address, chars = 4) {
|
|
@@ -7752,6 +7518,5 @@ exports.getZubariWdkService = getZubariWdkService;
|
|
|
7752
7518
|
exports.isBrowser = isBrowser;
|
|
7753
7519
|
exports.isValidAddress = isValidAddress;
|
|
7754
7520
|
exports.normalizeAddress = normalizeAddress;
|
|
7755
|
-
exports.useWalletManager = useWalletManager;
|
|
7756
7521
|
//# sourceMappingURL=index.js.map
|
|
7757
7522
|
//# sourceMappingURL=index.js.map
|