@rango-dev/widget-embedded 0.62.2-next.1 → 0.62.2-next.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.62.2-next.1",
3
+ "version": "0.62.2-next.2",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -65,4 +65,4 @@
65
65
  "publishConfig": {
66
66
  "access": "public"
67
67
  }
68
- }
68
+ }
@@ -362,7 +362,6 @@ export function Quote(props: QuoteProps) {
362
362
  quote={quote}
363
363
  fullExpandedMode
364
364
  time={totalTime}
365
- fee={totalFee}
366
365
  feeWarning={feeWarning}
367
366
  timeWarning={timeWarning}
368
367
  showModalFee={showModalFee}
@@ -415,7 +414,6 @@ export function Quote(props: QuoteProps) {
415
414
  <QuoteCostDetails
416
415
  quote={quote}
417
416
  time={totalTime}
418
- fee={totalFee}
419
417
  feeWarning={feeWarning}
420
418
  timeWarning={timeWarning}
421
419
  showModalFee={showModalFee}
@@ -1,6 +1,5 @@
1
1
  import type { QuoteError, QuoteWarning, SelectedQuote } from '../../types';
2
2
  import type { Step } from '@rango-dev/ui';
3
- import type BigNumber from 'bignumber.js';
4
3
  import type { ReactNode } from 'react';
5
4
 
6
5
  export type QuoteProps = {
@@ -46,7 +45,6 @@ export type QuoteTriggerImagesProps = {
46
45
  export type QuoteCostDetailsProps = {
47
46
  quote: SelectedQuote | null;
48
47
  steps: number;
49
- fee: BigNumber;
50
48
  time: string;
51
49
  feeWarning?: boolean;
52
50
  timeWarning?: boolean;
@@ -1,6 +1,5 @@
1
1
  import type { QuoteCostDetailsProps } from './Quote.types';
2
2
  import type { NameOfFees } from '../../constants/quote';
3
- import type BigNumber from 'bignumber.js';
4
3
 
5
4
  import { i18n } from '@lingui/core';
6
5
  import {
@@ -12,6 +11,7 @@ import {
12
11
  QuoteCost,
13
12
  Typography,
14
13
  } from '@rango-dev/ui';
14
+ import BigNumber from 'bignumber.js';
15
15
  import React, { useState } from 'react';
16
16
 
17
17
  import { getFeeLabel } from '../../constants/quote';
@@ -62,7 +62,6 @@ export function QuoteCostDetails(props: QuoteCostDetailsProps) {
62
62
  const {
63
63
  steps,
64
64
  quote,
65
- fee,
66
65
  time,
67
66
  feeWarning,
68
67
  timeWarning,
@@ -73,8 +72,20 @@ export function QuoteCostDetails(props: QuoteCostDetailsProps) {
73
72
  const container = fullExpandedMode ? getExpanded() : getContainer();
74
73
 
75
74
  const feesGroup = getFeesGroup(swaps);
75
+
76
+ /*
77
+ * The "Total Payable Fee" must reflect only the fees the user actually pays
78
+ * (feesGroup.payable). We sum the USD value of every payable fee group and use
79
+ * it for both the collapsed summary and the itemized rows in the modal, so the
80
+ * two never disagree.
81
+ */
82
+ const totalPayableFee = Object.values(feesGroup.payable).reduce(
83
+ (acc: BigNumber, fees) => acc.plus(getTotalFeesInUsd(fees)),
84
+ new BigNumber(0)
85
+ );
86
+
76
87
  const roundedFee = numberToString(
77
- fee,
88
+ totalPayableFee,
78
89
  GAS_FEE_MIN_DECIMALS,
79
90
  GAS_FEE_MAX_DECIMALS
80
91
  );
@@ -181,7 +192,7 @@ export function QuoteCostDetails(props: QuoteCostDetailsProps) {
181
192
  <Typography variant="label" size="medium">
182
193
  $
183
194
  {numberToString(
184
- fee,
195
+ totalPayableFee,
185
196
  USD_VALUE_MIN_DECIMALS,
186
197
  USD_VALUE_MAX_DECIMALS
187
198
  )}