@rash2x/bridge-widget 0.7.0 → 0.7.1

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) {
@@ -3078,6 +3105,8 @@ const Details = () => {
3078
3105
  1,
3079
3106
  Math.round(bridgeData.quoteDetails?.etaSeconds / 60)
3080
3107
  )}m` : "—";
3108
+ const messageFeeDisplay = !quote ? "—" : fees.messageFeeAmount > 0 ? `${truncateToDecimals(fees.messageFeeAmount, 6)} ${fees.messageFeeSymbol}` : "—";
3109
+ const bridgeFeeDisplay = !quote ? "—" : fees.bridgeFeeAmount > 0 ? `${truncateToDecimals(fees.bridgeFeeAmount, 6)} ${fees.bridgeFeeSymbol}` : "—";
3081
3110
  const totalFeeDisplay = !quote ? "—" : formatUsd(fees.totalFeeUsd);
3082
3111
  const currentSlippageText = !quote ? "—" : formatPercentage(slippageBps);
3083
3112
  const routeText = getRouteDisplayName(quote?.route);
@@ -3119,6 +3148,24 @@ const Details = () => {
3119
3148
  value: currentSlippageText
3120
3149
  }
3121
3150
  ),
3151
+ /* @__PURE__ */ jsxRuntime.jsx(
3152
+ DetailsRow,
3153
+ {
3154
+ label: t2("transaction.messageFee"),
3155
+ tooltip: t2("transaction.messageFeeTooltip"),
3156
+ value: messageFeeDisplay,
3157
+ isLoading
3158
+ }
3159
+ ),
3160
+ /* @__PURE__ */ jsxRuntime.jsx(
3161
+ DetailsRow,
3162
+ {
3163
+ label: t2("transaction.bridgeFee"),
3164
+ tooltip: t2("transaction.bridgeFeeTooltip"),
3165
+ value: bridgeFeeDisplay,
3166
+ isLoading
3167
+ }
3168
+ ),
3122
3169
  /* @__PURE__ */ jsxRuntime.jsx(
3123
3170
  DetailsRow,
3124
3171
  {
@@ -25789,7 +25836,7 @@ class WalletConnectModal {
25789
25836
  }
25790
25837
  async initUi() {
25791
25838
  if (typeof window !== "undefined") {
25792
- await Promise.resolve().then(() => require("./index-jmefkuWp.cjs"));
25839
+ await Promise.resolve().then(() => require("./index-C7NE-Dmd.cjs"));
25793
25840
  const modal = document.createElement("wcm-modal");
25794
25841
  document.body.insertAdjacentElement("beforeend", modal);
25795
25842
  OptionsCtrl.setIsUiLoaded(true);
@@ -26635,4 +26682,4 @@ exports.useSettingsStore = useSettingsStore;
26635
26682
  exports.useSwapModel = useSwapModel;
26636
26683
  exports.useTokensStore = useTokensStore;
26637
26684
  exports.useTransactionStore = useTransactionStore;
26638
- //# sourceMappingURL=index-DwNmWmqq.cjs.map
26685
+ //# sourceMappingURL=index-CCfRExBc.cjs.map