Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WT-1798] Skip fetching fees estimates on top-up view #1001

Merged
merged 9 commits into from
Oct 17, 2023
13 changes: 11 additions & 2 deletions packages/checkout/widgets-lib/src/lib/feeEstimation.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import {
GasEstimateBridgeToL2Result, GasEstimateSwapResult, OnRampProviderFees, TokenInfo,
GasEstimateBridgeToL2Result,
GasEstimateSwapResult,
OnRampProviderFees,
TokenInfo,
} from '@imtbl/checkout-sdk';
import { BigNumber, ethers } from 'ethers';
import { IMX_TOKEN_SYMBOL } from './constants';

const convertFeeToFiat = (
fee: BigNumber | undefined,
Expand All @@ -12,7 +16,12 @@ const convertFeeToFiat = (

if (fee && token) {
const formattedAmount = ethers.utils.formatUnits(fee, token.decimals);
const gasFeeTokenConversion = conversions.get(token.symbol.toLocaleLowerCase());
const tokenSymbol = token.symbol.toLocaleLowerCase() === 'timx'
? IMX_TOKEN_SYMBOL
: token.symbol;
const gasFeeTokenConversion = conversions.get(
tokenSymbol.toLocaleLowerCase(),
);
Comment on lines +19 to +24
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this check because swap fees is always -.-- in dev/sandbox env due to symbol being tIMX instead of IMX

Copy link
Contributor

@imx-mikhala imx-mikhala Oct 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we instead go token.address === IMX_ADDRESS_ZKEVM instead of token.symbol.toLocaleLowerCase() === 'timx' since symbol isnt unique identifier and the address should still be the 0x..1010 one

if (gasFeeTokenConversion) {
const parsedAmount = parseFloat(formattedAmount);
if (Number.isNaN(parsedAmount)) return feeAmountInFiat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ import { ReactNode } from 'react';

export interface TopUpMenuItemProps {
testId: string;
icon: 'Wallet' | 'Coins' | 'Minting',
icon: 'Wallet' | 'Coins' | 'Minting';
heading: string;
caption: string,
subcaption: string,
disabledCaption: string,
onClick: () => void,
renderFeeFunction: (fees: string, feesLoading: boolean) => ReactNode,
isDisabled :boolean
caption: string;
subcaption: string;
onClick: () => void;
renderFeeFunction: (fees: string, feesLoading: boolean) => ReactNode;
isDisabled: boolean;
}

export function TopUpMenuItem({
testId, icon, heading, caption, subcaption, disabledCaption, onClick, renderFeeFunction, isDisabled,
testId, icon, heading, caption, subcaption, onClick, renderFeeFunction, isDisabled,
}: TopUpMenuItemProps) {
return (
<Box testId="top-up-view" sx={{ paddingY: '1px' }}>
Expand All @@ -33,7 +32,7 @@ export function TopUpMenuItem({
</MenuItem.Label>
<MenuItem.IntentIcon />
<MenuItem.Caption testId={`menu-item-caption-${testId}`}>
{isDisabled ? disabledCaption : caption}
{caption}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the prop disabledCaption.
This is now handled in Top-up view to decide what text to show as caption

<br />
{isDisabled ? '' : subcaption}
{' '}
Expand Down
Loading