From e46657c1ed0aa74557058a7d1816c35ab80702dc Mon Sep 17 00:00:00 2001
From: Mikhala <122326421+imx-mikhala@users.noreply.github.com>
Date: Thu, 20 Jul 2023 08:45:58 +0800
Subject: [PATCH] WT-1358 Show need ETH for gas drawer from wallet view
NO-CHANGELOG (#577)
---
.../checkout/widgets-lib/src/lib/constants.ts | 1 +
.../components/BalanceItem/BalanceItem.cy.tsx | 51 +-----
.../components/BalanceItem/BalanceItem.tsx | 11 +-
.../TokenBalanceList/TokenBalanceList.tsx | 13 +-
.../wallet/views/WalletBalances.cy.tsx | 155 +++++++++++++++++-
.../widgets/wallet/views/WalletBalances.tsx | 80 ++++++++-
6 files changed, 254 insertions(+), 57 deletions(-)
diff --git a/packages/checkout/widgets-lib/src/lib/constants.ts b/packages/checkout/widgets-lib/src/lib/constants.ts
index c28ecda87e..99060ead9b 100644
--- a/packages/checkout/widgets-lib/src/lib/constants.ts
+++ b/packages/checkout/widgets-lib/src/lib/constants.ts
@@ -7,6 +7,7 @@ export const DEFAULT_TOKEN_DECIMALS = 18;
export const DEFAULT_TOKEN_FORMATTING_DECIMALS = 6;
export const DEFAULT_GT_ONE_TOKEN_FORMATTING_DECIMALS = 2;
export const IMX_TOKEN_SYMBOL = 'IMX';
+export const ETH_TOKEN_SYMBOL = 'ETH';
/**
* Checkout Widget default env
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 d15328c00f..836c950f73 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
@@ -33,14 +33,13 @@ describe('BalanceItem', () => {
beforeEach(() => {
cy.stub(orchestrationEvents, 'sendRequestSwapEvent').as('requestSwapEventStub');
- cy.stub(orchestrationEvents, 'sendRequestBridgeEvent').as('requestBridgeEventStub');
cy.stub(orchestrationEvents, 'sendRequestOnrampEvent').as('requestOnrampEventStub');
});
it('should show balance details', () => {
mount(
-
+ {}} />
,
);
@@ -76,7 +75,7 @@ describe('BalanceItem', () => {
mount(
-
+ {}} />
,
);
@@ -106,7 +105,7 @@ describe('BalanceItem', () => {
mount(
-
+ {}} />
,
);
@@ -142,7 +141,7 @@ describe('BalanceItem', () => {
mount(
-
+ {}} />
,
);
@@ -177,7 +176,7 @@ describe('BalanceItem', () => {
mount(
-
+ {}} />
,
);
cySmartGet('token-menu').should('exist');
@@ -199,7 +198,7 @@ describe('BalanceItem', () => {
};
mount(
-
+ {}} />
,
);
@@ -233,7 +232,7 @@ describe('BalanceItem', () => {
it('should emit sendRequestSwapEvent when swap menu button is clicked', () => {
mount(
-
+ {}} />
,
);
@@ -251,7 +250,7 @@ describe('BalanceItem', () => {
it('should emit sendRequestOnrampEvent when add menu button is clicked', () => {
mount(
-
+ {}} />
,
);
@@ -269,39 +268,5 @@ describe('BalanceItem', () => {
},
);
});
-
- it('should emit sendRequestBridgeEvent when move menu button is clicked', () => {
- testWalletState = {
- ...testWalletState,
- network: {
- chainId: ChainId.SEPOLIA,
- name: 'Immutable zkEVM Testnet',
- nativeCurrency: {
- name: 'ETH',
- symbol: 'ETH',
- decimals: 18,
- },
- isSupported: true,
- },
- };
- mount(
-
-
- ,
- );
-
- cySmartGet('token-menu').should('exist');
- cySmartGet('token-menu').click();
- cySmartGet('balance-item-move-option').click();
- cySmartGet('@requestBridgeEventStub').should('have.been.called');
- cySmartGet('@requestBridgeEventStub').should(
- 'have.been.calledWith',
- IMTBLWidgetEvents.IMTBL_WALLET_WIDGET_EVENT,
- {
- tokenAddress: '',
- amount: '',
- },
- );
- });
});
});
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 cb1d0acfd7..a91f4ddb41 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
@@ -25,10 +25,10 @@ import { formatZeroAmount, tokenValueFormat } from '../../../../lib/utils';
export interface BalanceItemProps {
balanceInfo: BalanceInfo;
+ bridgeToL2OnClick: (address?: string) => void;
}
-export function BalanceItem(props: BalanceItemProps) {
- const { balanceInfo } = props;
+export function BalanceItem({ balanceInfo, bridgeToL2OnClick }: BalanceItemProps) {
const fiatAmount = `≈ USD $${formatZeroAmount(balanceInfo.fiatAmount)}`;
const { walletState } = useContext(WalletContext);
const { supportedTopUps, network, checkout } = walletState;
@@ -104,12 +104,7 @@ export function BalanceItem(props: BalanceItemProps) {
)}
+ setShowNotEnoughGasDrawer(false)}
+ walletAddress={walletAddress}
+ showAdjustAmount={false}
+ />
);