@rash2x/bridge-widget 0.6.86 → 0.6.87
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 +1 -1
- package/dist/evaa-bridge.mjs +1 -1
- package/dist/{index-FgCGs20h.js → index-pqf2Zph9.js} +127 -386
- package/dist/index-pqf2Zph9.js.map +1 -0
- package/dist/{index-C4Q8SlY6.js → index-tUykJWk6.js} +2 -2
- package/dist/{index-C4Q8SlY6.js.map → index-tUykJWk6.js.map} +1 -1
- package/dist/{index-BSBhFRpe.cjs → index-uXNjFbDF.cjs} +2 -2
- package/dist/{index-BSBhFRpe.cjs.map → index-uXNjFbDF.cjs.map} +1 -1
- package/dist/{index-qUQoBkSH.cjs → index-y4iIYAAQ.cjs} +126 -385
- package/dist/index-y4iIYAAQ.cjs.map +1 -0
- package/dist/index.d.ts +2 -14
- package/package.json +1 -1
- package/dist/index-FgCGs20h.js.map +0 -1
- package/dist/index-qUQoBkSH.cjs.map +0 -1
package/dist/evaa-bridge.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const index = require("./index-
|
|
3
|
+
const index = require("./index-y4iIYAAQ.cjs");
|
|
4
4
|
exports.DEFAULT_SLIPPAGE_BPS = index.DEFAULT_SLIPPAGE_BPS;
|
|
5
5
|
exports.EvaaBridge = index.EvaaBridge;
|
|
6
6
|
exports.RoutePriority = index.RoutePriority;
|
package/dist/evaa-bridge.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { L, d, f, e, D, Q, H, z, W, U, w, s, v, r, p, q, G, Z, a5, $, a2, x, A, y, a0, B, _, a3, a4, S, a1, P, I, V, Y, a6, a7, J, K, X, F, N, t, o, i, u, l, m, j, n, h, k } from "./index-
|
|
1
|
+
import { L, d, f, e, D, Q, H, z, W, U, w, s, v, r, p, q, G, Z, a5, $, a2, x, A, y, a0, B, _, a3, a4, S, a1, P, I, V, Y, a6, a7, J, K, X, F, N, t, o, i, u, l, m, j, n, h, k } from "./index-pqf2Zph9.js";
|
|
2
2
|
export {
|
|
3
3
|
L as DEFAULT_SLIPPAGE_BPS,
|
|
4
4
|
d as EvaaBridge,
|
|
@@ -25,7 +25,7 @@ import { Alert, AlertDescription } from "@/components/ui/alert";
|
|
|
25
25
|
import { toast, Toaster } from "sonner";
|
|
26
26
|
import { Badge } from "@/components/ui/badge";
|
|
27
27
|
import { DialogDescription as DialogDescription$1 } from "@radix-ui/react-dialog";
|
|
28
|
-
import { isAddress, formatUnits, parseAbi
|
|
28
|
+
import { isAddress, formatUnits, parseAbi } from "viem";
|
|
29
29
|
import { TonClient, Address as Address$1, beginCell } from "@ton/ton";
|
|
30
30
|
import { TronLinkAdapterName } from "@tronweb3/tronwallet-adapters";
|
|
31
31
|
import { TronWeb } from "tronweb";
|
|
@@ -1132,7 +1132,13 @@ function useBridgeQuote() {
|
|
|
1132
1132
|
const { assetMatrix, selectedAssetSymbol } = useTokensStore();
|
|
1133
1133
|
const { fromChain, toChain, chains } = useChainsStore();
|
|
1134
1134
|
const { srcAddress, dstAddress } = useAddresses();
|
|
1135
|
-
const {
|
|
1135
|
+
const {
|
|
1136
|
+
slippageBps,
|
|
1137
|
+
routePriority,
|
|
1138
|
+
gasPreset,
|
|
1139
|
+
getDstNativeAmount,
|
|
1140
|
+
getSlippageDecimal
|
|
1141
|
+
} = useSettingsStore();
|
|
1136
1142
|
const {
|
|
1137
1143
|
inputAmount,
|
|
1138
1144
|
refetchTrigger,
|
|
@@ -3598,7 +3604,7 @@ function useBridgeTransaction() {
|
|
|
3598
3604
|
const { quote } = useBridgeQuoteStore();
|
|
3599
3605
|
const { chainRegistry } = useChainStrategies();
|
|
3600
3606
|
const { srcAddress, dstAddress } = useAddresses();
|
|
3601
|
-
const { assetMatrix, selectedAssetSymbol
|
|
3607
|
+
const { assetMatrix, selectedAssetSymbol } = useTokensStore();
|
|
3602
3608
|
const { chains } = useChainsStore();
|
|
3603
3609
|
const txStore = useTransactionStore();
|
|
3604
3610
|
const gas = useGasEstimate();
|
|
@@ -3742,27 +3748,6 @@ function useBridgeTransaction() {
|
|
|
3742
3748
|
if (lzResult.dstTxHash) {
|
|
3743
3749
|
txStore.setDstHash(lzResult.dstTxHash);
|
|
3744
3750
|
}
|
|
3745
|
-
if (strategy.getSourceCost) {
|
|
3746
|
-
const srcChain2 = chains?.find(
|
|
3747
|
-
(c2) => c2.chainKey === quote.srcChainKey
|
|
3748
|
-
);
|
|
3749
|
-
const feeSymbol = srcChain2?.nativeCurrency?.symbol || "";
|
|
3750
|
-
const { priceUsd } = findNativeMeta(allTokens, srcChain2);
|
|
3751
|
-
const hashForSourceCost = quote.srcChainKey === "ton" ? messageHash : hashForLayerZero;
|
|
3752
|
-
try {
|
|
3753
|
-
const sourceCost = await strategy.getSourceCost(hashForSourceCost);
|
|
3754
|
-
if (sourceCost?.totalNative !== void 0 && isFinite(sourceCost.totalNative)) {
|
|
3755
|
-
const feeUsd = priceUsd && priceUsd > 0 ? sourceCost.totalNative * priceUsd : void 0;
|
|
3756
|
-
txStore.updateLayerZeroTotalFee(
|
|
3757
|
-
sourceCost.totalNative,
|
|
3758
|
-
feeSymbol,
|
|
3759
|
-
feeUsd
|
|
3760
|
-
);
|
|
3761
|
-
}
|
|
3762
|
-
} catch (error) {
|
|
3763
|
-
console.warn("Failed to compute source cost:", error);
|
|
3764
|
-
}
|
|
3765
|
-
}
|
|
3766
3751
|
callbacks?.onSwapSuccess?.(successData);
|
|
3767
3752
|
txStore.updateStatus("completed");
|
|
3768
3753
|
} else {
|
|
@@ -4513,9 +4498,6 @@ const SuccessStep = ({
|
|
|
4513
4498
|
const srcTxHash = current?.tonTransactionHash || current?.srcTxHash;
|
|
4514
4499
|
const srcChainKey = current?.quote?.srcChainKey;
|
|
4515
4500
|
const quote = current?.quote;
|
|
4516
|
-
const layerZeroTotalFeeValue = metadata?.layerZeroTotalFeeValue;
|
|
4517
|
-
const layerZeroTotalFeeSymbol = metadata?.layerZeroTotalFeeSymbol;
|
|
4518
|
-
const layerZeroTotalFeeUsd = metadata?.layerZeroTotalFeeUsd;
|
|
4519
4501
|
const estimatedFee = useMemo(() => {
|
|
4520
4502
|
if (!quote?.fees || !srcChainKey || !chains) return null;
|
|
4521
4503
|
const srcChain = chains.find((c2) => c2.chainKey === srcChainKey);
|
|
@@ -4542,98 +4524,81 @@ const SuccessStep = ({
|
|
|
4542
4524
|
}
|
|
4543
4525
|
return estimatedFee;
|
|
4544
4526
|
}, [metadata?.actualFeeValue, metadata?.actualFeeSymbol, estimatedFee]);
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
{
|
|
4598
|
-
className: "w-[18px] h-[18px] rounded-full",
|
|
4599
|
-
chainKey: metadata.srcChainName
|
|
4600
|
-
}
|
|
4601
|
-
)
|
|
4527
|
+
return /* @__PURE__ */ jsxs(
|
|
4528
|
+
DialogContent,
|
|
4529
|
+
{
|
|
4530
|
+
closeButtonClassName: "!absolute",
|
|
4531
|
+
showCloseButton: true,
|
|
4532
|
+
className,
|
|
4533
|
+
children: [
|
|
4534
|
+
icon,
|
|
4535
|
+
/* @__PURE__ */ jsx(DialogHeader, { className: "z-10 relative p-0", children: /* @__PURE__ */ jsx(DialogTitle, { className: "text-[28px] text-center", children: t2("transaction.success") }) }),
|
|
4536
|
+
/* @__PURE__ */ jsxs("div", { className: "w-full space-y-2 mt-5 relative z-10 pb-14", children: [
|
|
4537
|
+
metadata?.srcAmountHuman && /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center", children: [
|
|
4538
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: t2("transaction.bridged") }),
|
|
4539
|
+
/* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1 font-medium", children: [
|
|
4540
|
+
formatBalance(metadata.srcAmountHuman, 2),
|
|
4541
|
+
" ",
|
|
4542
|
+
metadata?.srcTokenSymbol,
|
|
4543
|
+
/* @__PURE__ */ jsx(
|
|
4544
|
+
TokenSymbol,
|
|
4545
|
+
{
|
|
4546
|
+
className: "w-[18px] h-[18px]",
|
|
4547
|
+
symbol: metadata?.srcTokenSymbol
|
|
4548
|
+
}
|
|
4549
|
+
)
|
|
4550
|
+
] })
|
|
4551
|
+
] }),
|
|
4552
|
+
metadata?.srcChainName && metadata?.dstChainName && /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center", children: [
|
|
4553
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: t2("transaction.transferTitle") }),
|
|
4554
|
+
/* @__PURE__ */ jsxs("span", { className: "font-medium flex gap-1 items-center", children: [
|
|
4555
|
+
/* @__PURE__ */ jsxs("span", { className: "inline-flex gap-1 items-center", children: [
|
|
4556
|
+
metadata.srcChainName,
|
|
4557
|
+
" ",
|
|
4558
|
+
/* @__PURE__ */ jsx(
|
|
4559
|
+
NetworkSymbol,
|
|
4560
|
+
{
|
|
4561
|
+
className: "w-[18px] h-[18px] rounded-full",
|
|
4562
|
+
chainKey: metadata.srcChainName
|
|
4563
|
+
}
|
|
4564
|
+
)
|
|
4565
|
+
] }),
|
|
4566
|
+
/* @__PURE__ */ jsx(ArrowRight, { className: "text-muted-foreground/50 size-4" }),
|
|
4567
|
+
/* @__PURE__ */ jsxs("span", { className: "inline-flex gap-1 items-center", children: [
|
|
4568
|
+
metadata.dstChainName,
|
|
4569
|
+
" ",
|
|
4570
|
+
/* @__PURE__ */ jsx(
|
|
4571
|
+
NetworkSymbol,
|
|
4572
|
+
{
|
|
4573
|
+
className: "w-[18px] h-[18px] rounded-full",
|
|
4574
|
+
chainKey: metadata.dstChainName
|
|
4575
|
+
}
|
|
4576
|
+
)
|
|
4577
|
+
] })
|
|
4578
|
+
] })
|
|
4602
4579
|
] }),
|
|
4603
|
-
/* @__PURE__ */
|
|
4604
|
-
|
|
4605
|
-
metadata.dstChainName,
|
|
4606
|
-
" ",
|
|
4580
|
+
srcTxHash && /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center", children: [
|
|
4581
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: t2("transaction.hash") }),
|
|
4607
4582
|
/* @__PURE__ */ jsx(
|
|
4608
|
-
|
|
4583
|
+
"a",
|
|
4609
4584
|
{
|
|
4610
|
-
|
|
4611
|
-
|
|
4585
|
+
href: `https://layerzeroscan.com/tx/${srcTxHash}`,
|
|
4586
|
+
target: "_blank",
|
|
4587
|
+
rel: "noopener noreferrer",
|
|
4588
|
+
className: "font-medium cursor-pointer inline-flex items-center gap-1 underline hover:no-underline",
|
|
4589
|
+
children: formatHash(srcTxHash)
|
|
4612
4590
|
}
|
|
4613
4591
|
)
|
|
4592
|
+
] }),
|
|
4593
|
+
finalFee && /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center", children: [
|
|
4594
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: t2("transaction.finalFee") }),
|
|
4595
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", children: `${formatBalance(finalFee.value, 6)} ${finalFee.symbol}` })
|
|
4614
4596
|
] })
|
|
4615
|
-
] })
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
"a",
|
|
4621
|
-
{
|
|
4622
|
-
href: `https://layerzeroscan.com/tx/${srcTxHash}`,
|
|
4623
|
-
target: "_blank",
|
|
4624
|
-
rel: "noopener noreferrer",
|
|
4625
|
-
className: "font-medium cursor-pointer inline-flex items-center gap-1 underline hover:no-underline",
|
|
4626
|
-
children: formatHash(srcTxHash)
|
|
4627
|
-
}
|
|
4628
|
-
)
|
|
4629
|
-
] }),
|
|
4630
|
-
totalFee && /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center", children: [
|
|
4631
|
-
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: totalFee.label }),
|
|
4632
|
-
/* @__PURE__ */ jsx("span", { className: "font-medium", children: totalFee.display })
|
|
4633
|
-
] })
|
|
4634
|
-
] }),
|
|
4635
|
-
/* @__PURE__ */ jsx(DialogFooter, { className: "w-full pt-10", children: /* @__PURE__ */ jsx(Button, { onClick: reset, className: "w-full", children: t2("transaction.done") }) })
|
|
4636
|
-
] });
|
|
4597
|
+
] }),
|
|
4598
|
+
/* @__PURE__ */ jsx(DialogFooter, { className: "w-full pt-10", children: /* @__PURE__ */ jsx(Button, { onClick: reset, className: "w-full", children: t2("transaction.done") }) })
|
|
4599
|
+
]
|
|
4600
|
+
}
|
|
4601
|
+
);
|
|
4637
4602
|
};
|
|
4638
4603
|
const useCountdown = (initialSeconds) => {
|
|
4639
4604
|
const [time2, setTime] = useState(initialSeconds);
|
|
@@ -5227,35 +5192,6 @@ class EvmChainStrategy {
|
|
|
5227
5192
|
throw new InvalidStepsError("evm", "Missing transaction data in steps");
|
|
5228
5193
|
}
|
|
5229
5194
|
}
|
|
5230
|
-
async getSourceCost(txHash) {
|
|
5231
|
-
if (!this.publicClient) {
|
|
5232
|
-
return null;
|
|
5233
|
-
}
|
|
5234
|
-
try {
|
|
5235
|
-
const hash = txHash.startsWith("0x") ? txHash : `0x${txHash}`;
|
|
5236
|
-
const [receipt, tx] = await Promise.all([
|
|
5237
|
-
this.publicClient.getTransactionReceipt({ hash }),
|
|
5238
|
-
this.publicClient.getTransaction({ hash })
|
|
5239
|
-
]);
|
|
5240
|
-
if (!receipt || !tx) return null;
|
|
5241
|
-
const gasUsed = receipt.gasUsed ?? 0n;
|
|
5242
|
-
const gasPrice = receipt.effectiveGasPrice ?? tx.gasPrice ?? 0n;
|
|
5243
|
-
const gasFeeWei = gasUsed * gasPrice;
|
|
5244
|
-
const txValueWei = tx.value ?? 0n;
|
|
5245
|
-
const totalWei = gasFeeWei + txValueWei;
|
|
5246
|
-
const sourceCost = {
|
|
5247
|
-
totalNative: Number(formatUnits(totalWei, 18)),
|
|
5248
|
-
breakdown: {
|
|
5249
|
-
gasFee: Number(formatUnits(gasFeeWei, 18)),
|
|
5250
|
-
layerZeroFee: Number(formatUnits(txValueWei, 18))
|
|
5251
|
-
}
|
|
5252
|
-
};
|
|
5253
|
-
return sourceCost;
|
|
5254
|
-
} catch (error) {
|
|
5255
|
-
console.warn("Failed to compute EVM source cost:", error);
|
|
5256
|
-
return null;
|
|
5257
|
-
}
|
|
5258
|
-
}
|
|
5259
5195
|
async estimateNetworkFee(steps) {
|
|
5260
5196
|
if (!this.walletClient) {
|
|
5261
5197
|
return 0;
|
|
@@ -5444,61 +5380,6 @@ class EvmChainStrategy {
|
|
|
5444
5380
|
throw toChainStrategyError(error, "evm", "approve");
|
|
5445
5381
|
}
|
|
5446
5382
|
}
|
|
5447
|
-
async checkAllowance(tokenAddress, spenderAddress, amount) {
|
|
5448
|
-
try {
|
|
5449
|
-
const publicClient = this.publicClient;
|
|
5450
|
-
if (!publicClient) {
|
|
5451
|
-
return false;
|
|
5452
|
-
}
|
|
5453
|
-
const allowance = await publicClient.readContract({
|
|
5454
|
-
address: tokenAddress,
|
|
5455
|
-
abi: ERC20_ABI,
|
|
5456
|
-
functionName: "allowance",
|
|
5457
|
-
args: [
|
|
5458
|
-
this.config.evmAddress,
|
|
5459
|
-
spenderAddress
|
|
5460
|
-
]
|
|
5461
|
-
});
|
|
5462
|
-
const decimals = await publicClient.readContract({
|
|
5463
|
-
address: tokenAddress,
|
|
5464
|
-
abi: ERC20_ABI,
|
|
5465
|
-
functionName: "decimals"
|
|
5466
|
-
});
|
|
5467
|
-
const requiredAmount = parseUnits(amount, decimals);
|
|
5468
|
-
return allowance >= requiredAmount;
|
|
5469
|
-
} catch (error) {
|
|
5470
|
-
console.error("Error checking allowance:", error);
|
|
5471
|
-
return false;
|
|
5472
|
-
}
|
|
5473
|
-
}
|
|
5474
|
-
/**
|
|
5475
|
-
* Check if a block has reached finality status (optional, for critical transactions)
|
|
5476
|
-
* This is more stringent than confirmations and protects against long-range reorgs
|
|
5477
|
-
*
|
|
5478
|
-
* Usage: Call this method after waitForCompletion if you need additional security
|
|
5479
|
-
* for high-value transactions. The method checks if the block has been marked as
|
|
5480
|
-
* "finalized" by the Ethereum consensus layer (2/3 of validators).
|
|
5481
|
-
*
|
|
5482
|
-
* @param blockNumber - The block number to check for finality
|
|
5483
|
-
* @returns true if the block is finalized, false otherwise
|
|
5484
|
-
*/
|
|
5485
|
-
async checkFinality(blockNumber) {
|
|
5486
|
-
try {
|
|
5487
|
-
const publicClient = this.publicClient;
|
|
5488
|
-
if (!publicClient) {
|
|
5489
|
-
return false;
|
|
5490
|
-
}
|
|
5491
|
-
const finalizedBlock = await publicClient.getBlock({
|
|
5492
|
-
blockTag: "finalized"
|
|
5493
|
-
});
|
|
5494
|
-
if (!finalizedBlock) {
|
|
5495
|
-
return false;
|
|
5496
|
-
}
|
|
5497
|
-
return blockNumber <= finalizedBlock.number;
|
|
5498
|
-
} catch {
|
|
5499
|
-
return false;
|
|
5500
|
-
}
|
|
5501
|
-
}
|
|
5502
5383
|
}
|
|
5503
5384
|
class TonChainStrategy {
|
|
5504
5385
|
constructor(config) {
|
|
@@ -5692,85 +5573,6 @@ class TonChainStrategy {
|
|
|
5692
5573
|
};
|
|
5693
5574
|
return beginCell$1().store(storeMessage(normalizedMessage, { forceRef: true })).endCell().hash();
|
|
5694
5575
|
}
|
|
5695
|
-
toBigInt(value) {
|
|
5696
|
-
if (typeof value === "bigint") return value;
|
|
5697
|
-
if (typeof value === "number" && Number.isFinite(value)) {
|
|
5698
|
-
return BigInt(Math.trunc(value));
|
|
5699
|
-
}
|
|
5700
|
-
if (typeof value === "object" && value !== null && "coins" in value) {
|
|
5701
|
-
return this.toBigInt(value.coins);
|
|
5702
|
-
}
|
|
5703
|
-
if (typeof value === "string" && value.trim() !== "") {
|
|
5704
|
-
try {
|
|
5705
|
-
return BigInt(value);
|
|
5706
|
-
} catch {
|
|
5707
|
-
return null;
|
|
5708
|
-
}
|
|
5709
|
-
}
|
|
5710
|
-
return null;
|
|
5711
|
-
}
|
|
5712
|
-
getOutMessages(tx) {
|
|
5713
|
-
const candidate = tx.outMessages;
|
|
5714
|
-
if (!candidate) return [];
|
|
5715
|
-
if (Array.isArray(candidate)) return candidate;
|
|
5716
|
-
if (typeof candidate === "object" && candidate !== null && "values" in candidate && typeof candidate.values === "function") {
|
|
5717
|
-
const values = candidate.values();
|
|
5718
|
-
if (Array.isArray(values)) {
|
|
5719
|
-
return [...values];
|
|
5720
|
-
}
|
|
5721
|
-
if (values && typeof values === "object" && Symbol.iterator in values) {
|
|
5722
|
-
return Array.from(values);
|
|
5723
|
-
}
|
|
5724
|
-
}
|
|
5725
|
-
if (candidate instanceof Map) return Array.from(candidate.values());
|
|
5726
|
-
return [];
|
|
5727
|
-
}
|
|
5728
|
-
getMessageValue(message) {
|
|
5729
|
-
const info = message.info;
|
|
5730
|
-
const value = info?.value;
|
|
5731
|
-
if (!value) return null;
|
|
5732
|
-
if (typeof value === "object" && value !== null && "coins" in value) {
|
|
5733
|
-
return this.toBigInt(value.coins);
|
|
5734
|
-
}
|
|
5735
|
-
return this.toBigInt(value);
|
|
5736
|
-
}
|
|
5737
|
-
getTotalOutMessageValue(tx) {
|
|
5738
|
-
const outMessages = this.getOutMessages(tx);
|
|
5739
|
-
if (!outMessages.length) return 0n;
|
|
5740
|
-
let total = 0n;
|
|
5741
|
-
for (const message of outMessages) {
|
|
5742
|
-
const value = this.getMessageValue(message);
|
|
5743
|
-
if (value) {
|
|
5744
|
-
total += value;
|
|
5745
|
-
}
|
|
5746
|
-
}
|
|
5747
|
-
return total;
|
|
5748
|
-
}
|
|
5749
|
-
async getSourceCost(messageHash) {
|
|
5750
|
-
const timeoutMs = 3e4;
|
|
5751
|
-
const result = await this.checkTonTransaction(messageHash, timeoutMs);
|
|
5752
|
-
if (!result.confirmed) {
|
|
5753
|
-
console.warn("Transaction not found for source cost calculation");
|
|
5754
|
-
return null;
|
|
5755
|
-
}
|
|
5756
|
-
const totalFees = result.totalFees ?? 0n;
|
|
5757
|
-
const outValue = result.outValue ?? 0n;
|
|
5758
|
-
const totalNanotons = totalFees + outValue;
|
|
5759
|
-
const toTon = (value) => Number(value) / 1e9;
|
|
5760
|
-
const sourceCost = {
|
|
5761
|
-
totalNative: toTon(totalNanotons),
|
|
5762
|
-
breakdown: {
|
|
5763
|
-
gasFee: toTon(totalFees),
|
|
5764
|
-
layerZeroFee: toTon(outValue)
|
|
5765
|
-
}
|
|
5766
|
-
};
|
|
5767
|
-
console.log("TON source cost:", {
|
|
5768
|
-
gasFee: `${sourceCost.breakdown.gasFee} TON`,
|
|
5769
|
-
layerZeroFee: `${sourceCost.breakdown.layerZeroFee} TON`,
|
|
5770
|
-
total: `${sourceCost.totalNative} TON`
|
|
5771
|
-
});
|
|
5772
|
-
return sourceCost;
|
|
5773
|
-
}
|
|
5774
5576
|
async estimateNetworkFee() {
|
|
5775
5577
|
const fee = Number(TON_CONFIG.estimatedNetworkFee);
|
|
5776
5578
|
if (!Number.isFinite(fee) || fee <= 0) {
|
|
@@ -5778,69 +5580,6 @@ class TonChainStrategy {
|
|
|
5778
5580
|
}
|
|
5779
5581
|
return fee / 1e9;
|
|
5780
5582
|
}
|
|
5781
|
-
async checkTonTransaction(hashOrBoc, timeoutMs = 36e4) {
|
|
5782
|
-
const deadline = Date.now() + timeoutMs;
|
|
5783
|
-
const client = getTonClient(this.config.tonClient, this.config.tonApiKey);
|
|
5784
|
-
try {
|
|
5785
|
-
let targetMessageHash;
|
|
5786
|
-
let accountAddress;
|
|
5787
|
-
try {
|
|
5788
|
-
const inMessage = loadMessage(Cell.fromBase64(hashOrBoc).beginParse());
|
|
5789
|
-
if (inMessage.info.type !== "external-in") {
|
|
5790
|
-
return { confirmed: false };
|
|
5791
|
-
}
|
|
5792
|
-
accountAddress = inMessage.info.dest;
|
|
5793
|
-
targetMessageHash = this.getNormalizedExtMessageHash(inMessage);
|
|
5794
|
-
} catch {
|
|
5795
|
-
targetMessageHash = Buffer.from(hashOrBoc, "hex");
|
|
5796
|
-
if (!this.config.tonAddress) {
|
|
5797
|
-
return { confirmed: false };
|
|
5798
|
-
}
|
|
5799
|
-
accountAddress = Address.parse(this.config.tonAddress);
|
|
5800
|
-
}
|
|
5801
|
-
while (Date.now() < deadline) {
|
|
5802
|
-
try {
|
|
5803
|
-
const transactions = await client.getTransactions(accountAddress, {
|
|
5804
|
-
limit: 20,
|
|
5805
|
-
// Check last 20 transactions
|
|
5806
|
-
archival: true
|
|
5807
|
-
});
|
|
5808
|
-
for (const tx of transactions) {
|
|
5809
|
-
if (tx.inMessage?.info.type === "external-in") {
|
|
5810
|
-
try {
|
|
5811
|
-
const txInMessageHash = this.getNormalizedExtMessageHash(
|
|
5812
|
-
tx.inMessage
|
|
5813
|
-
);
|
|
5814
|
-
if (txInMessageHash.equals(targetMessageHash)) {
|
|
5815
|
-
const totalFees = this.toBigInt(tx.totalFees) ?? this.toBigInt(
|
|
5816
|
-
tx.total_fees
|
|
5817
|
-
) ?? 0n;
|
|
5818
|
-
const outValue = this.getTotalOutMessageValue(tx);
|
|
5819
|
-
const feeInTon = Number(totalFees) / 1e9;
|
|
5820
|
-
const transactionHash = tx.hash().toString("hex");
|
|
5821
|
-
return {
|
|
5822
|
-
confirmed: true,
|
|
5823
|
-
fee: feeInTon.toString(),
|
|
5824
|
-
totalFees,
|
|
5825
|
-
outValue,
|
|
5826
|
-
transactionHash
|
|
5827
|
-
};
|
|
5828
|
-
}
|
|
5829
|
-
} catch {
|
|
5830
|
-
continue;
|
|
5831
|
-
}
|
|
5832
|
-
}
|
|
5833
|
-
}
|
|
5834
|
-
await new Promise((r2) => setTimeout(r2, TON_CONFIG.pollingInterval));
|
|
5835
|
-
} catch {
|
|
5836
|
-
await new Promise((r2) => setTimeout(r2, TON_CONFIG.pollingInterval));
|
|
5837
|
-
}
|
|
5838
|
-
}
|
|
5839
|
-
return { confirmed: false };
|
|
5840
|
-
} catch {
|
|
5841
|
-
return { confirmed: false };
|
|
5842
|
-
}
|
|
5843
|
-
}
|
|
5844
5583
|
}
|
|
5845
5584
|
const DEFAULT_TRON_NODE = "https://api.trongrid.io";
|
|
5846
5585
|
class TronChainStrategy {
|
|
@@ -5929,6 +5668,11 @@ class TronChainStrategy {
|
|
|
5929
5668
|
}
|
|
5930
5669
|
return null;
|
|
5931
5670
|
}
|
|
5671
|
+
getPreferredProvider() {
|
|
5672
|
+
const provider = this.getActiveConnector()?.provider;
|
|
5673
|
+
if (!provider) return null;
|
|
5674
|
+
return this.resolveProvider(provider);
|
|
5675
|
+
}
|
|
5932
5676
|
getConnectorState(provider) {
|
|
5933
5677
|
if (provider === "walletconnect") {
|
|
5934
5678
|
const walletConnect = this.config.walletConnect;
|
|
@@ -5973,7 +5717,8 @@ class TronChainStrategy {
|
|
|
5973
5717
|
return t2("wallets.connectTronWallet");
|
|
5974
5718
|
}
|
|
5975
5719
|
async getBalances(address, tokens) {
|
|
5976
|
-
const
|
|
5720
|
+
const preferredProvider = this.getPreferredProvider();
|
|
5721
|
+
const tronWeb = this.getClient(preferredProvider);
|
|
5977
5722
|
if (!tronWeb) return {};
|
|
5978
5723
|
return await getTronBalances(tronWeb, address, tokens);
|
|
5979
5724
|
}
|
|
@@ -5995,42 +5740,6 @@ class TronChainStrategy {
|
|
|
5995
5740
|
throw new InvalidTransactionDataError("tron", "Missing transaction data");
|
|
5996
5741
|
}
|
|
5997
5742
|
}
|
|
5998
|
-
async getSourceCost(txHash) {
|
|
5999
|
-
const tronWeb = this.getClient();
|
|
6000
|
-
if (!tronWeb) {
|
|
6001
|
-
console.warn("No TronWeb client available for source cost query");
|
|
6002
|
-
return null;
|
|
6003
|
-
}
|
|
6004
|
-
try {
|
|
6005
|
-
const [info, tx] = await Promise.all([
|
|
6006
|
-
tronWeb.trx.getTransactionInfo(txHash),
|
|
6007
|
-
tronWeb.trx.getTransaction(txHash)
|
|
6008
|
-
]);
|
|
6009
|
-
const feeSun = info?.fee ?? 0;
|
|
6010
|
-
const paramValue = tx?.raw_data?.contract?.[0]?.parameter?.value ?? {};
|
|
6011
|
-
const callValueRaw = paramValue["call_value"] ?? paramValue["callValue"] ?? paramValue["amount"] ?? 0;
|
|
6012
|
-
const callValueSun = typeof callValueRaw === "string" ? Number(callValueRaw) : typeof callValueRaw === "number" ? callValueRaw : 0;
|
|
6013
|
-
const feeTrx = feeSun / 1e6;
|
|
6014
|
-
const lzFeeTrx = callValueSun / 1e6;
|
|
6015
|
-
const totalTrx = (feeSun + callValueSun) / 1e6;
|
|
6016
|
-
const sourceCost = {
|
|
6017
|
-
totalNative: totalTrx,
|
|
6018
|
-
breakdown: {
|
|
6019
|
-
gasFee: feeTrx,
|
|
6020
|
-
layerZeroFee: lzFeeTrx
|
|
6021
|
-
}
|
|
6022
|
-
};
|
|
6023
|
-
console.log("TRON source cost:", {
|
|
6024
|
-
gasFee: `${sourceCost.breakdown.gasFee} TRX`,
|
|
6025
|
-
layerZeroFee: `${sourceCost.breakdown.layerZeroFee} TRX`,
|
|
6026
|
-
total: `${sourceCost.totalNative} TRX`
|
|
6027
|
-
});
|
|
6028
|
-
return sourceCost;
|
|
6029
|
-
} catch (error) {
|
|
6030
|
-
console.warn("Failed to compute TRON source cost:", error);
|
|
6031
|
-
return null;
|
|
6032
|
-
}
|
|
6033
|
-
}
|
|
6034
5743
|
async estimateNetworkFee() {
|
|
6035
5744
|
const fee = Number(TRON_CONFIG.estimatedNetworkFee);
|
|
6036
5745
|
if (!Number.isFinite(fee) || fee <= 0) {
|
|
@@ -6039,14 +5748,27 @@ class TronChainStrategy {
|
|
|
6039
5748
|
return fee / 1e6;
|
|
6040
5749
|
}
|
|
6041
5750
|
async executeSteps(steps, _context, onStepComplete) {
|
|
6042
|
-
const tronWeb = this.getClient();
|
|
6043
|
-
if (!tronWeb) {
|
|
6044
|
-
throw new ProviderNotAvailableError("tron");
|
|
6045
|
-
}
|
|
6046
5751
|
const connector = this.getActiveConnector();
|
|
5752
|
+
console.log("TRON executeSteps", {
|
|
5753
|
+
provider: connector?.provider ?? null,
|
|
5754
|
+
connected: connector?.connected ?? false,
|
|
5755
|
+
address: connector?.address ?? null
|
|
5756
|
+
});
|
|
6047
5757
|
if (!connector?.connected || !connector.address) {
|
|
6048
5758
|
throw new WalletNotConnectedError("tron");
|
|
6049
5759
|
}
|
|
5760
|
+
const resolvedProvider = this.resolveProvider(connector.provider);
|
|
5761
|
+
const tronWeb = this.getClient(resolvedProvider);
|
|
5762
|
+
console.log("TRON executeSteps client", {
|
|
5763
|
+
resolvedProvider,
|
|
5764
|
+
hasClient: !!tronWeb
|
|
5765
|
+
});
|
|
5766
|
+
if (!tronWeb) {
|
|
5767
|
+
throw new ProviderNotAvailableError(
|
|
5768
|
+
"tron",
|
|
5769
|
+
connector.provider === "walletconnect" ? "TRON API key is required for WalletConnect" : void 0
|
|
5770
|
+
);
|
|
5771
|
+
}
|
|
6050
5772
|
this.validateSteps(steps);
|
|
6051
5773
|
const fromB58 = connector.address;
|
|
6052
5774
|
this.ensureDefaultAddress(tronWeb, fromB58);
|
|
@@ -6135,11 +5857,17 @@ class TronChainStrategy {
|
|
|
6135
5857
|
}
|
|
6136
5858
|
return { hash: lastTxId, chainKey: "tron" };
|
|
6137
5859
|
}
|
|
6138
|
-
getClient() {
|
|
6139
|
-
if (
|
|
5860
|
+
getClient(preferProvider) {
|
|
5861
|
+
if (preferProvider === "walletconnect") {
|
|
5862
|
+
return this.getFallbackClient();
|
|
5863
|
+
}
|
|
5864
|
+
if (typeof window !== "undefined" && window.tronWeb && this.isTronLinkInstalled()) {
|
|
6140
5865
|
this.applyTronApiKey(window.tronWeb);
|
|
6141
5866
|
return window.tronWeb;
|
|
6142
5867
|
}
|
|
5868
|
+
return this.getFallbackClient();
|
|
5869
|
+
}
|
|
5870
|
+
getFallbackClient() {
|
|
6143
5871
|
if (!this.fallbackClient) {
|
|
6144
5872
|
this.fallbackClient = this.createFallbackClient();
|
|
6145
5873
|
}
|
|
@@ -6197,7 +5925,17 @@ class TronChainStrategy {
|
|
|
6197
5925
|
return false;
|
|
6198
5926
|
}
|
|
6199
5927
|
const win = window;
|
|
6200
|
-
|
|
5928
|
+
if (!win.tronWeb) {
|
|
5929
|
+
return false;
|
|
5930
|
+
}
|
|
5931
|
+
const tronLink = win.tronWeb;
|
|
5932
|
+
if (typeof tronLink.isTronLink === "boolean") {
|
|
5933
|
+
return tronLink.isTronLink;
|
|
5934
|
+
}
|
|
5935
|
+
if (typeof tronLink.ready === "boolean") {
|
|
5936
|
+
return tronLink.ready;
|
|
5937
|
+
}
|
|
5938
|
+
return true;
|
|
6201
5939
|
}
|
|
6202
5940
|
ensureDefaultAddress(tronWeb, address) {
|
|
6203
5941
|
if (!address) return;
|
|
@@ -6511,7 +6249,7 @@ class TronChainStrategy {
|
|
|
6511
6249
|
*/
|
|
6512
6250
|
async checkSolidified(txHash) {
|
|
6513
6251
|
try {
|
|
6514
|
-
const tronWeb = this.getClient();
|
|
6252
|
+
const tronWeb = this.getClient(this.getPreferredProvider());
|
|
6515
6253
|
if (!tronWeb) {
|
|
6516
6254
|
return false;
|
|
6517
6255
|
}
|
|
@@ -25991,7 +25729,7 @@ class WalletConnectModal {
|
|
|
25991
25729
|
}
|
|
25992
25730
|
async initUi() {
|
|
25993
25731
|
if (typeof window !== "undefined") {
|
|
25994
|
-
await import("./index-
|
|
25732
|
+
await import("./index-tUykJWk6.js");
|
|
25995
25733
|
const modal = document.createElement("wcm-modal");
|
|
25996
25734
|
document.body.insertAdjacentElement("beforeend", modal);
|
|
25997
25735
|
OptionsCtrl.setIsUiLoaded(true);
|
|
@@ -26437,6 +26175,9 @@ const EvaaBridgeWithProviders = (props) => {
|
|
|
26437
26175
|
const { disconnect: evmDisconnect } = useDisconnect();
|
|
26438
26176
|
const { data: walletClient } = useWalletClient();
|
|
26439
26177
|
const publicClient = usePublicClient();
|
|
26178
|
+
console.log("tonApiKey", props.tonApiKey);
|
|
26179
|
+
console.log("tronApiKey", props.tronApiKey);
|
|
26180
|
+
console.log("walletConnectProjectId", props.walletConnectProjectId);
|
|
26440
26181
|
const {
|
|
26441
26182
|
address: tronAddress,
|
|
26442
26183
|
connected: tronConnected,
|
|
@@ -26743,4 +26484,4 @@ export {
|
|
|
26743
26484
|
getQuoteFees as y,
|
|
26744
26485
|
calculateMinReceived as z
|
|
26745
26486
|
};
|
|
26746
|
-
//# sourceMappingURL=index-
|
|
26487
|
+
//# sourceMappingURL=index-pqf2Zph9.js.map
|