@rash2x/bridge-widget 0.7.0 → 0.7.2

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.
@@ -2380,9 +2380,19 @@ function getRouteDisplayName(route) {
2380
2380
  return route.split(/[/\-_]/).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
2381
2381
  }
2382
2382
  function computeFeeBreakdownUsd(quote, srcToken, tokens, chains) {
2383
- const empty = { messageFeeUsd: 0, bridgeFeeUsd: 0, totalFeeUsd: 0 };
2383
+ const empty = {
2384
+ messageFeeAmount: 0,
2385
+ messageFeeSymbol: "",
2386
+ messageFeeUsd: 0,
2387
+ bridgeFeeAmount: 0,
2388
+ bridgeFeeSymbol: "",
2389
+ bridgeFeeUsd: 0,
2390
+ totalFeeUsd: 0
2391
+ };
2384
2392
  if (!quote || !srcToken) return empty;
2385
2393
  let messageFeeUsd = 0;
2394
+ let messageFeeAmount = 0;
2395
+ let messageFeeSymbol = "";
2386
2396
  const messageFees = quote.fees.filter((f4) => f4.type === "message");
2387
2397
  for (const f4 of messageFees) {
2388
2398
  const { decimals, priceUsd } = lookupTokenMeta(
@@ -2392,19 +2402,36 @@ function computeFeeBreakdownUsd(quote, srcToken, tokens, chains) {
2392
2402
  f4.token
2393
2403
  );
2394
2404
  const human = fromLD(f4.amount || "0", decimals);
2405
+ messageFeeAmount += human;
2395
2406
  messageFeeUsd += human * (priceUsd ?? 0);
2407
+ if (!messageFeeSymbol) {
2408
+ const chain2 = chains?.find((c2) => c2.chainKey === f4.chainKey);
2409
+ const token = tokens?.find(
2410
+ (t2) => t2.chainKey === f4.chainKey && t2.address.toLowerCase() === f4.token.toLowerCase()
2411
+ );
2412
+ messageFeeSymbol = token?.symbol?.toUpperCase() ?? chain2?.nativeCurrency?.symbol?.toUpperCase() ?? "";
2413
+ }
2396
2414
  }
2415
+ let bridgeFeeAmount = 0;
2397
2416
  let bridgeFeeUsd = 0;
2398
- if (srcToken.price?.usd) {
2399
- const srcHuman = fromLD(quote.srcAmount, srcToken.decimals);
2400
- const dstHuman = fromLD(quote.dstAmount, srcToken.decimals);
2401
- const diff = srcHuman - dstHuman;
2402
- if (diff > 0) {
2403
- bridgeFeeUsd = diff * srcToken.price.usd;
2404
- }
2417
+ const bridgeFeeSymbol = srcToken.symbol?.toUpperCase() ?? "";
2418
+ const srcHuman = fromLD(quote.srcAmount, srcToken.decimals);
2419
+ const dstHuman = fromLD(quote.dstAmount, srcToken.decimals);
2420
+ const diff = srcHuman - dstHuman;
2421
+ if (diff > 0) {
2422
+ bridgeFeeAmount = diff;
2423
+ bridgeFeeUsd = (srcToken.price?.usd ?? 0) * diff;
2405
2424
  }
2406
2425
  const totalFeeUsd = messageFeeUsd + bridgeFeeUsd;
2407
- return { messageFeeUsd, bridgeFeeUsd, totalFeeUsd };
2426
+ return {
2427
+ messageFeeAmount,
2428
+ messageFeeSymbol,
2429
+ messageFeeUsd,
2430
+ bridgeFeeAmount,
2431
+ bridgeFeeSymbol,
2432
+ bridgeFeeUsd,
2433
+ totalFeeUsd
2434
+ };
2408
2435
  }
2409
2436
  async function addNetworkFeesToQuote(quote, chainRegistry, chains) {
2410
2437
  if (!quote || !chains) {
@@ -25789,7 +25816,7 @@ class WalletConnectModal {
25789
25816
  }
25790
25817
  async initUi() {
25791
25818
  if (typeof window !== "undefined") {
25792
- await Promise.resolve().then(() => require("./index-jmefkuWp.cjs"));
25819
+ await Promise.resolve().then(() => require("./index-Cm_DEiyS.cjs"));
25793
25820
  const modal = document.createElement("wcm-modal");
25794
25821
  document.body.insertAdjacentElement("beforeend", modal);
25795
25822
  OptionsCtrl.setIsUiLoaded(true);
@@ -26635,4 +26662,4 @@ exports.useSettingsStore = useSettingsStore;
26635
26662
  exports.useSwapModel = useSwapModel;
26636
26663
  exports.useTokensStore = useTokensStore;
26637
26664
  exports.useTransactionStore = useTransactionStore;
26638
- //# sourceMappingURL=index-DwNmWmqq.cjs.map
26665
+ //# sourceMappingURL=index-CxHwwPJD.cjs.map