From aa02978347cb349f06ca2e3ad049563737de95ba Mon Sep 17 00:00:00 2001 From: Andrea Rampin Date: Sun, 28 Jan 2024 20:37:17 +1100 Subject: [PATCH] fix: WT-2080 - Bridge should be an option for Passport users (#1394) --- .../src/views/top-up/TopUpView.cy.tsx | 31 +--------- .../src/views/top-up/TopUpView.tsx | 11 +--- .../components/BalanceItem/BalanceItem.cy.tsx | 59 +------------------ .../components/BalanceItem/BalanceItem.tsx | 3 +- 4 files changed, 6 insertions(+), 98 deletions(-) diff --git a/packages/checkout/widgets-lib/src/views/top-up/TopUpView.cy.tsx b/packages/checkout/widgets-lib/src/views/top-up/TopUpView.cy.tsx index d950f7171c..99ac9db106 100644 --- a/packages/checkout/widgets-lib/src/views/top-up/TopUpView.cy.tsx +++ b/packages/checkout/widgets-lib/src/views/top-up/TopUpView.cy.tsx @@ -7,7 +7,7 @@ import { } from '@imtbl/checkout-sdk'; import { Environment } from '@imtbl/config'; import { BigNumber } from 'ethers'; -import { ExternalProvider, Web3Provider } from '@ethersproject/providers'; +import { Web3Provider } from '@ethersproject/providers'; import { UserJourney } from 'context/analytics-provider/SegmentAnalyticsProvider'; import { CustomAnalyticsProvider } from 'context/analytics-provider/CustomAnalyticsProvider'; import { ViewContextTestComponent } from 'context/view-context/test-components/ViewContextTestComponent'; @@ -124,35 +124,6 @@ describe('Top Up View', () => { cySmartGet('menu-item-bridge').should('not.exist'); }); - it('should hide bridge option when provider is Passport', () => { - mount( - - - - {}} - /> - - - , - ); - cySmartGet('menu-item-onramp').should('exist'); - cySmartGet('menu-item-swap').should('exist'); - cySmartGet('menu-item-bridge').should('not.exist'); - }); - it('should call close function when close button clicked', () => { const closeFunction = cy.stub().as('closeFunction'); mount( diff --git a/packages/checkout/widgets-lib/src/views/top-up/TopUpView.tsx b/packages/checkout/widgets-lib/src/views/top-up/TopUpView.tsx index f94baba80c..a9ccfca6d2 100644 --- a/packages/checkout/widgets-lib/src/views/top-up/TopUpView.tsx +++ b/packages/checkout/widgets-lib/src/views/top-up/TopUpView.tsx @@ -28,7 +28,6 @@ import { getOnRampFeeEstimation, } from '../../lib/feeEstimation'; import { CryptoFiatActions, CryptoFiatContext } from '../../context/crypto-fiat-context/CryptoFiatContext'; -import { isPassportProvider } from '../../lib/providerUtils'; import { OnRampWidgetViews } from '../../context/view-context/OnRampViewContextTypes'; import { EventTargetContext } from '../../context/event-target-context/EventTargetContext'; import { TopUpMenuItem } from './TopUpMenuItem'; @@ -52,7 +51,8 @@ interface TopUpViewProps { export function TopUpView({ widgetEvent, checkout, - provider, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + provider, // Keep this for future use showOnrampOption, showSwapOption, showBridgeOption, @@ -65,9 +65,6 @@ export function TopUpView({ const { t } = useTranslation(); const { userJourney } = analytics; - // const { header, topUpOptions } = text.views[SharedViews.TOP_UP_VIEW]; - // const { onramp, swap, bridge } = topUpOptions; - const { viewDispatch } = useContext(ViewContext); const { cryptoFiatState, cryptoFiatDispatch } = useContext(CryptoFiatContext); @@ -82,8 +79,6 @@ export function TopUpView({ const { page, track } = useAnalytics(); - const isPassport = isPassportProvider(provider); - useEffect(() => { page({ userJourney, @@ -263,7 +258,7 @@ export function TopUpView({ `${t('views.TOP_UP_VIEW.topUpOptions.bridge.subcaption')} ≈ $${bridgeFeesInFiat} ${fiatSymbol.toUpperCase()}`, ), isAvailable: true, - isEnabled: showBridgeOption && !isPassport, + isEnabled: showBridgeOption, }, ]; diff --git a/packages/checkout/widgets-lib/src/widgets/wallet/components/BalanceItem/BalanceItem.cy.tsx b/packages/checkout/widgets-lib/src/widgets/wallet/components/BalanceItem/BalanceItem.cy.tsx index 7cbf139b58..c25cd3a921 100644 --- a/packages/checkout/widgets-lib/src/widgets/wallet/components/BalanceItem/BalanceItem.cy.tsx +++ b/packages/checkout/widgets-lib/src/widgets/wallet/components/BalanceItem/BalanceItem.cy.tsx @@ -10,7 +10,7 @@ import { } from '@imtbl/checkout-sdk'; import { cy } from 'local-cypress'; import { Environment } from '@imtbl/config'; -import { ExternalProvider, Web3Provider } from '@ethersproject/providers'; +import { Web3Provider } from '@ethersproject/providers'; import { BigNumber } from 'ethers'; import { BalanceInfo } from 'widgets/wallet/functions/tokenBalances'; import { WalletState } from '../../context/WalletContext'; @@ -440,63 +440,6 @@ describe('BalanceItem', () => { cySmartGet('balance-item-move-option').should('have.text', 'Move IMX'); }); - it('should NOT show the move option when provider is Passport', () => { - cy.stub(Checkout.prototype, 'getTokenAllowList') - .as('tokenAllowListStub') - .resolves({ - tokens: [ - { - name: 'tIMX', - symbol: 'tIMX', - decimals: 18, - address: NATIVE, - }, - ], - }); - const testWalletState = { - ...baseWalletState, - network: { - chainId: ChainId.IMTBL_ZKEVM_TESTNET, - name: ChainName.IMTBL_ZKEVM_TESTNET, - nativeCurrency: { - name: 'IMX', - symbol: 'IMX', - decimals: 18, - }, - isSupported: true, - }, - tokenBalances: testTokenBalances, - supportedTopUps: { - isOnRampEnabled: true, - isSwapEnabled: true, - isBridgeEnabled: true, - }, - }; - - mount( - - - {}} - /> - - , - ); - cySmartGet('token-menu').should('exist'); - cySmartGet('token-menu').click(); - cySmartGet('balance-item-add-option').should('be.visible'); - cySmartGet('balance-item-swap-option').should('be.visible'); - cySmartGet('balance-item-move-option').should('not.be.visible'); - }); - it('should NOT show menu options for the token when all top ups are disabled', () => { const testWalletState = { ...baseWalletState, diff --git a/packages/checkout/widgets-lib/src/widgets/wallet/components/BalanceItem/BalanceItem.tsx b/packages/checkout/widgets-lib/src/widgets/wallet/components/BalanceItem/BalanceItem.tsx index fd45feed6a..f28afd7b68 100644 --- a/packages/checkout/widgets-lib/src/widgets/wallet/components/BalanceItem/BalanceItem.tsx +++ b/packages/checkout/widgets-lib/src/widgets/wallet/components/BalanceItem/BalanceItem.tsx @@ -62,8 +62,7 @@ export function BalanceItem({ const enableMoveCoin = (network.chainId === getL1ChainId(checkout.config) || network.chainId === getL2ChainId(checkout.config)) - && (supportedTopUps?.isBridgeEnabled ?? true) - && !isPassport; + && (supportedTopUps?.isBridgeEnabled ?? true); setIsBridgeEnabled(enableMoveCoin); const enableSwapCoin = network.chainId === getL2ChainId(checkout.config)