@rash2x/bridge-widget 0.1.3 → 0.1.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/dist/evaa-bridge.cjs +52 -64
- package/dist/evaa-bridge.cjs.map +1 -1
- package/dist/evaa-bridge.mjs +52 -64
- package/dist/evaa-bridge.mjs.map +1 -1
- package/package.json +1 -1
package/dist/evaa-bridge.cjs
CHANGED
|
@@ -1531,8 +1531,12 @@ function useBalances(chainKey, address) {
|
|
|
1531
1531
|
[balanceBySymbol]
|
|
1532
1532
|
);
|
|
1533
1533
|
const isLoading = query.isLoading || query.isFetching;
|
|
1534
|
+
const balances = require$$0.useMemo(
|
|
1535
|
+
() => query.data || {},
|
|
1536
|
+
[query.data]
|
|
1537
|
+
);
|
|
1534
1538
|
return {
|
|
1535
|
-
balances
|
|
1539
|
+
balances,
|
|
1536
1540
|
getBalance,
|
|
1537
1541
|
isLoading,
|
|
1538
1542
|
query
|
|
@@ -3763,7 +3767,9 @@ function useBridgeTransaction() {
|
|
|
3763
3767
|
function useGasEstimate(amountNum) {
|
|
3764
3768
|
const { fromChain } = useChainsStore();
|
|
3765
3769
|
const { selectedAssetSymbol, tokens } = useTokensStore();
|
|
3766
|
-
const
|
|
3770
|
+
const getSourceGasReserveHuman = useSettingsStore(
|
|
3771
|
+
(state) => state.getSourceGasReserveHuman
|
|
3772
|
+
);
|
|
3767
3773
|
const { srcAddress } = useAddresses();
|
|
3768
3774
|
const { balances, isLoading: balancesLoading } = useBalances(
|
|
3769
3775
|
fromChain?.chainKey,
|
|
@@ -3771,59 +3777,44 @@ function useGasEstimate(amountNum) {
|
|
|
3771
3777
|
);
|
|
3772
3778
|
const { chainRegistry } = useChainStrategies();
|
|
3773
3779
|
const balancesKnown = !balancesLoading;
|
|
3774
|
-
const
|
|
3775
|
-
null
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
}
|
|
3813
|
-
}
|
|
3814
|
-
estimateGas();
|
|
3815
|
-
return () => {
|
|
3816
|
-
cancelled = true;
|
|
3817
|
-
};
|
|
3818
|
-
}, [
|
|
3819
|
-
fromChain,
|
|
3820
|
-
selectedAssetSymbol,
|
|
3821
|
-
tokens,
|
|
3822
|
-
amountNum,
|
|
3823
|
-
balances,
|
|
3824
|
-
chainRegistry,
|
|
3825
|
-
getSourceGasReserveHuman
|
|
3826
|
-
]);
|
|
3780
|
+
const strategy = require$$0.useMemo(() => {
|
|
3781
|
+
if (!fromChain) return null;
|
|
3782
|
+
return chainRegistry.getStrategy(fromChain.chainKey);
|
|
3783
|
+
}, [fromChain, chainRegistry]);
|
|
3784
|
+
const { data: gasRequirement } = reactQuery.useQuery({
|
|
3785
|
+
queryKey: [
|
|
3786
|
+
"gas-estimate",
|
|
3787
|
+
fromChain?.chainKey,
|
|
3788
|
+
selectedAssetSymbol,
|
|
3789
|
+
amountNum,
|
|
3790
|
+
balances
|
|
3791
|
+
],
|
|
3792
|
+
queryFn: async () => {
|
|
3793
|
+
if (!fromChain || !strategy) {
|
|
3794
|
+
return null;
|
|
3795
|
+
}
|
|
3796
|
+
const selectedToken = tokens?.find(
|
|
3797
|
+
(t) => t.symbol.toUpperCase() === selectedAssetSymbol?.toUpperCase()
|
|
3798
|
+
) || null;
|
|
3799
|
+
const nativeTokenSymbol = fromChain.nativeCurrency?.symbol ?? "";
|
|
3800
|
+
const nativeDecimals = fromChain.nativeCurrency?.decimals || 18;
|
|
3801
|
+
const reserveFallback = getSourceGasReserveHuman(fromChain.chainKey);
|
|
3802
|
+
const result = await strategy.estimateGasRequirement({
|
|
3803
|
+
selectedToken,
|
|
3804
|
+
nativeTokenSymbol,
|
|
3805
|
+
amount: amountNum,
|
|
3806
|
+
balances,
|
|
3807
|
+
nativeDecimals,
|
|
3808
|
+
reserveFallback
|
|
3809
|
+
});
|
|
3810
|
+
return result;
|
|
3811
|
+
},
|
|
3812
|
+
enabled: !!fromChain && !!strategy,
|
|
3813
|
+
staleTime: 3e4,
|
|
3814
|
+
gcTime: 5 * 6e4,
|
|
3815
|
+
refetchOnWindowFocus: false,
|
|
3816
|
+
retry: 1
|
|
3817
|
+
});
|
|
3827
3818
|
return {
|
|
3828
3819
|
nativeSym: gasRequirement?.nativeSym || "",
|
|
3829
3820
|
nativeBalance: gasRequirement?.nativeBalance || 0,
|
|
@@ -6528,7 +6519,6 @@ class EvmChainStrategy {
|
|
|
6528
6519
|
this.provider = new ethers.BrowserProvider(config.walletClient.transport);
|
|
6529
6520
|
}
|
|
6530
6521
|
}
|
|
6531
|
-
// ========== Identity ==========
|
|
6532
6522
|
canHandle(chainKey) {
|
|
6533
6523
|
const key = chainKey.toLowerCase();
|
|
6534
6524
|
return key !== "ton" && key !== "tron";
|
|
@@ -6539,7 +6529,6 @@ class EvmChainStrategy {
|
|
|
6539
6529
|
getName() {
|
|
6540
6530
|
return "EVM Chain Strategy";
|
|
6541
6531
|
}
|
|
6542
|
-
// ========== Wallet Management ==========
|
|
6543
6532
|
async connect() {
|
|
6544
6533
|
}
|
|
6545
6534
|
async disconnect() {
|
|
@@ -6563,7 +6552,6 @@ class EvmChainStrategy {
|
|
|
6563
6552
|
getConnectLabel(t) {
|
|
6564
6553
|
return t("wallets.connectEvmWallet");
|
|
6565
6554
|
}
|
|
6566
|
-
// ========== Balance & Validation ==========
|
|
6567
6555
|
async getBalances(address, tokens) {
|
|
6568
6556
|
return await getEvmBalances(address, tokens);
|
|
6569
6557
|
}
|
|
@@ -6571,7 +6559,6 @@ class EvmChainStrategy {
|
|
|
6571
6559
|
if (!address) return false;
|
|
6572
6560
|
return /^0x[0-9a-fA-F]{40}$/.test(address);
|
|
6573
6561
|
}
|
|
6574
|
-
// ========== Gas Estimation ==========
|
|
6575
6562
|
async estimateGasRequirement(params) {
|
|
6576
6563
|
const provider = this.provider;
|
|
6577
6564
|
const {
|
|
@@ -6618,7 +6605,6 @@ class EvmChainStrategy {
|
|
|
6618
6605
|
isNativeSelected
|
|
6619
6606
|
};
|
|
6620
6607
|
}
|
|
6621
|
-
// ========== Transaction Execution ==========
|
|
6622
6608
|
validateSteps(steps) {
|
|
6623
6609
|
if (!steps || steps.length === 0) {
|
|
6624
6610
|
throw new InvalidStepsError("evm", "No transaction steps provided");
|
|
@@ -6721,7 +6707,6 @@ class EvmChainStrategy {
|
|
|
6721
6707
|
};
|
|
6722
6708
|
}
|
|
6723
6709
|
}
|
|
6724
|
-
// ========== Private Helper Methods ==========
|
|
6725
6710
|
async executeTransaction(step) {
|
|
6726
6711
|
const provider = this.provider;
|
|
6727
6712
|
const signer = await provider?.getSigner();
|
|
@@ -7576,9 +7561,12 @@ function ChainStrategyProvider({
|
|
|
7576
7561
|
() => new ChainStrategyRegistry([evmStrategy, tonStrategy, tronStrategy]),
|
|
7577
7562
|
[evmStrategy, tonStrategy, tronStrategy]
|
|
7578
7563
|
);
|
|
7579
|
-
const value =
|
|
7580
|
-
|
|
7581
|
-
|
|
7564
|
+
const value = require$$0.useMemo(
|
|
7565
|
+
() => ({
|
|
7566
|
+
chainRegistry
|
|
7567
|
+
}),
|
|
7568
|
+
[chainRegistry]
|
|
7569
|
+
);
|
|
7582
7570
|
return /* @__PURE__ */ jsxRuntime.jsx(ChainStrategyContext.Provider, { value, children });
|
|
7583
7571
|
}
|
|
7584
7572
|
const EvaaBridgeWithProviders = (props) => {
|