@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.
@@ -2379,9 +2379,19 @@ function getRouteDisplayName(route) {
2379
2379
  return route.split(/[/\-_]/).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
2380
2380
  }
2381
2381
  function computeFeeBreakdownUsd(quote, srcToken, tokens, chains) {
2382
- const empty = { messageFeeUsd: 0, bridgeFeeUsd: 0, totalFeeUsd: 0 };
2382
+ const empty = {
2383
+ messageFeeAmount: 0,
2384
+ messageFeeSymbol: "",
2385
+ messageFeeUsd: 0,
2386
+ bridgeFeeAmount: 0,
2387
+ bridgeFeeSymbol: "",
2388
+ bridgeFeeUsd: 0,
2389
+ totalFeeUsd: 0
2390
+ };
2383
2391
  if (!quote || !srcToken) return empty;
2384
2392
  let messageFeeUsd = 0;
2393
+ let messageFeeAmount = 0;
2394
+ let messageFeeSymbol = "";
2385
2395
  const messageFees = quote.fees.filter((f4) => f4.type === "message");
2386
2396
  for (const f4 of messageFees) {
2387
2397
  const { decimals, priceUsd } = lookupTokenMeta(
@@ -2391,19 +2401,36 @@ function computeFeeBreakdownUsd(quote, srcToken, tokens, chains) {
2391
2401
  f4.token
2392
2402
  );
2393
2403
  const human = fromLD(f4.amount || "0", decimals);
2404
+ messageFeeAmount += human;
2394
2405
  messageFeeUsd += human * (priceUsd ?? 0);
2406
+ if (!messageFeeSymbol) {
2407
+ const chain2 = chains?.find((c2) => c2.chainKey === f4.chainKey);
2408
+ const token = tokens?.find(
2409
+ (t2) => t2.chainKey === f4.chainKey && t2.address.toLowerCase() === f4.token.toLowerCase()
2410
+ );
2411
+ messageFeeSymbol = token?.symbol?.toUpperCase() ?? chain2?.nativeCurrency?.symbol?.toUpperCase() ?? "";
2412
+ }
2395
2413
  }
2414
+ let bridgeFeeAmount = 0;
2396
2415
  let bridgeFeeUsd = 0;
2397
- if (srcToken.price?.usd) {
2398
- const srcHuman = fromLD(quote.srcAmount, srcToken.decimals);
2399
- const dstHuman = fromLD(quote.dstAmount, srcToken.decimals);
2400
- const diff = srcHuman - dstHuman;
2401
- if (diff > 0) {
2402
- bridgeFeeUsd = diff * srcToken.price.usd;
2403
- }
2416
+ const bridgeFeeSymbol = srcToken.symbol?.toUpperCase() ?? "";
2417
+ const srcHuman = fromLD(quote.srcAmount, srcToken.decimals);
2418
+ const dstHuman = fromLD(quote.dstAmount, srcToken.decimals);
2419
+ const diff = srcHuman - dstHuman;
2420
+ if (diff > 0) {
2421
+ bridgeFeeAmount = diff;
2422
+ bridgeFeeUsd = (srcToken.price?.usd ?? 0) * diff;
2404
2423
  }
2405
2424
  const totalFeeUsd = messageFeeUsd + bridgeFeeUsd;
2406
- return { messageFeeUsd, bridgeFeeUsd, totalFeeUsd };
2425
+ return {
2426
+ messageFeeAmount,
2427
+ messageFeeSymbol,
2428
+ messageFeeUsd,
2429
+ bridgeFeeAmount,
2430
+ bridgeFeeSymbol,
2431
+ bridgeFeeUsd,
2432
+ totalFeeUsd
2433
+ };
2407
2434
  }
2408
2435
  async function addNetworkFeesToQuote(quote, chainRegistry, chains) {
2409
2436
  if (!quote || !chains) {
@@ -3077,6 +3104,8 @@ const Details = () => {
3077
3104
  1,
3078
3105
  Math.round(bridgeData.quoteDetails?.etaSeconds / 60)
3079
3106
  )}m` : "—";
3107
+ const messageFeeDisplay = !quote ? "—" : fees.messageFeeAmount > 0 ? `${truncateToDecimals(fees.messageFeeAmount, 6)} ${fees.messageFeeSymbol}` : "—";
3108
+ const bridgeFeeDisplay = !quote ? "—" : fees.bridgeFeeAmount > 0 ? `${truncateToDecimals(fees.bridgeFeeAmount, 6)} ${fees.bridgeFeeSymbol}` : "—";
3080
3109
  const totalFeeDisplay = !quote ? "—" : formatUsd(fees.totalFeeUsd);
3081
3110
  const currentSlippageText = !quote ? "—" : formatPercentage(slippageBps);
3082
3111
  const routeText = getRouteDisplayName(quote?.route);
@@ -3118,6 +3147,24 @@ const Details = () => {
3118
3147
  value: currentSlippageText
3119
3148
  }
3120
3149
  ),
3150
+ /* @__PURE__ */ jsx(
3151
+ DetailsRow,
3152
+ {
3153
+ label: t2("transaction.messageFee"),
3154
+ tooltip: t2("transaction.messageFeeTooltip"),
3155
+ value: messageFeeDisplay,
3156
+ isLoading
3157
+ }
3158
+ ),
3159
+ /* @__PURE__ */ jsx(
3160
+ DetailsRow,
3161
+ {
3162
+ label: t2("transaction.bridgeFee"),
3163
+ tooltip: t2("transaction.bridgeFeeTooltip"),
3164
+ value: bridgeFeeDisplay,
3165
+ isLoading
3166
+ }
3167
+ ),
3121
3168
  /* @__PURE__ */ jsx(
3122
3169
  DetailsRow,
3123
3170
  {
@@ -25788,7 +25835,7 @@ class WalletConnectModal {
25788
25835
  }
25789
25836
  async initUi() {
25790
25837
  if (typeof window !== "undefined") {
25791
- await import("./index-CbOaxQWE.js");
25838
+ await import("./index-Fzl5CHpO.js");
25792
25839
  const modal = document.createElement("wcm-modal");
25793
25840
  document.body.insertAdjacentElement("beforeend", modal);
25794
25841
  OptionsCtrl.setIsUiLoaded(true);
@@ -26636,4 +26683,4 @@ export {
26636
26683
  calculateMinReceived as y,
26637
26684
  getQuoteDetails as z
26638
26685
  };
26639
- //# sourceMappingURL=index-D_iIDai5.js.map
26686
+ //# sourceMappingURL=index-DMIMGpk_.js.map