Commit d2e39b36 authored by Max Alekseenko's avatar Max Alekseenko

remove get gas button from address page

parent 2faf4182
import { Grid, Box } from '@chakra-ui/react';
import React from 'react';
import * as addressMock from 'mocks/address/address';
import { test, expect, devices } from 'playwright/lib';
import AddressBalance from './AddressBalance';
const ICON_URL = 'https://localhost:3000/my-icon.png';
const eoaWithSmallBalance = {
...addressMock.eoa,
coin_balance: '500000000000000000', // 0.5 * 10^18
exchange_rate: '1', // 1 USD
};
test('base view', async({ render }) => {
const component = await render(
<Grid columnGap={ 8 } templateColumns={{ base: 'minmax(0, 1fr)', lg: 'auto minmax(0, 1fr)' }} overflow="hidden">
<AddressBalance data={ addressMock.eoa } isLoading={ false }/>
</Grid>,
);
await expect(component).toHaveScreenshot();
});
test('with get gas button internal +@dark-mode', async({ render, mockEnvs, mockAssetResponse }) => {
await mockEnvs([
[
'NEXT_PUBLIC_GAS_REFUEL_PROVIDER_CONFIG',
`{"name": "Need gas?", "dapp_id": "duck", "url_template": "https://duck.url/{chainId}", "logo": "${ ICON_URL }", "usd_threshold": 1}`,
],
]);
await mockAssetResponse(ICON_URL, './playwright/mocks/image_svg.svg');
const component = await render(
<Grid columnGap={ 8 } templateColumns={{ base: 'minmax(0, 1fr)', lg: 'auto minmax(0, 1fr)' }} overflow="hidden">
<AddressBalance data={ eoaWithSmallBalance } isLoading={ false }/>
</Grid>,
);
await expect(component).toHaveScreenshot();
});
test('with get gas button external', async({ render, mockEnvs, mockAssetResponse }) => {
await mockEnvs([
[
'NEXT_PUBLIC_GAS_REFUEL_PROVIDER_CONFIG',
`{"name": "Need gas?", "url_template": "https://duck.url/{chainId}", "logo": "${ ICON_URL }", "usd_threshold": 1}`,
],
]);
await mockAssetResponse(ICON_URL, './playwright/mocks/image_svg.svg');
const component = await render(
<Grid columnGap={ 8 } templateColumns={{ base: 'minmax(0, 1fr)', lg: 'auto minmax(0, 1fr)' }} overflow="hidden">
<AddressBalance data={ eoaWithSmallBalance } isLoading={ false }/>
</Grid>,
);
await expect(component).toHaveScreenshot();
});
test.describe('mobile', () => {
test.use({ viewport: devices['iPhone 13 Pro'].viewport });
test('base view', async({ render, mockEnvs, mockAssetResponse }) => {
await mockEnvs([
[
'NEXT_PUBLIC_GAS_REFUEL_PROVIDER_CONFIG',
`{"name": "Need gas?", "dapp_id": "duck", "url_template": "https://duck.url/{chainId}", "logo": "${ ICON_URL }", "usd_threshold": 1}`,
],
]);
await mockAssetResponse(ICON_URL, './playwright/mocks/image_svg.svg');
const component = await render(
<Box w="300px">
<Grid columnGap={ 8 } templateColumns={{ base: 'minmax(0, 1fr)', lg: 'auto minmax(0, 1fr)' }} overflow="hidden">
<AddressBalance data={ eoaWithSmallBalance } isLoading={ false }/>
</Grid>
</Box>,
);
await expect(component).toHaveScreenshot();
});
});
...@@ -6,7 +6,6 @@ import type { Address } from 'types/api/address'; ...@@ -6,7 +6,6 @@ import type { Address } from 'types/api/address';
import config from 'configs/app'; import config from 'configs/app';
import { getResourceKey } from 'lib/api/useApiQuery'; import { getResourceKey } from 'lib/api/useApiQuery';
import getCurrencyValue from 'lib/getCurrencyValue';
import useSocketChannel from 'lib/socket/useSocketChannel'; import useSocketChannel from 'lib/socket/useSocketChannel';
import useSocketMessage from 'lib/socket/useSocketMessage'; import useSocketMessage from 'lib/socket/useSocketMessage';
import { currencyUnits } from 'lib/units'; import { currencyUnits } from 'lib/units';
...@@ -14,10 +13,8 @@ import CurrencyValue from 'ui/shared/CurrencyValue'; ...@@ -14,10 +13,8 @@ import CurrencyValue from 'ui/shared/CurrencyValue';
import * as DetailsInfoItem from 'ui/shared/DetailsInfoItem'; import * as DetailsInfoItem from 'ui/shared/DetailsInfoItem';
import NativeTokenIcon from 'ui/shared/NativeTokenIcon'; import NativeTokenIcon from 'ui/shared/NativeTokenIcon';
import GetGasButton from './GetGasButton';
interface Props { interface Props {
data: Pick<Address, 'block_number_balance_updated_at' | 'coin_balance' | 'hash' | 'exchange_rate' | 'is_contract'>; data: Pick<Address, 'block_number_balance_updated_at' | 'coin_balance' | 'hash' | 'exchange_rate'>;
isLoading: boolean; isLoading: boolean;
} }
...@@ -68,14 +65,6 @@ const AddressBalance = ({ data, isLoading }: Props) => { ...@@ -68,14 +65,6 @@ const AddressBalance = ({ data, isLoading }: Props) => {
handler: handleNewCoinBalanceMessage, handler: handleNewCoinBalanceMessage,
}); });
const value = data.coin_balance || '0';
const exchangeRate = data.exchange_rate;
const decimals = String(config.chain.currency.decimals);
const accuracyUsd = 2;
const accuracy = 8;
const { usd: usdResult } = getCurrencyValue({ value, accuracy, accuracyUsd, exchangeRate, decimals });
return ( return (
<> <>
<DetailsInfoItem.Label <DetailsInfoItem.Label
...@@ -87,18 +76,15 @@ const AddressBalance = ({ data, isLoading }: Props) => { ...@@ -87,18 +76,15 @@ const AddressBalance = ({ data, isLoading }: Props) => {
<DetailsInfoItem.Value alignSelf="center" flexWrap="nowrap"> <DetailsInfoItem.Value alignSelf="center" flexWrap="nowrap">
<NativeTokenIcon boxSize={ 6 } mr={ 2 } isLoading={ isLoading }/> <NativeTokenIcon boxSize={ 6 } mr={ 2 } isLoading={ isLoading }/>
<CurrencyValue <CurrencyValue
value={ value } value={ data.coin_balance || '0' }
exchangeRate={ exchangeRate } exchangeRate={ data.exchange_rate }
decimals={ decimals } decimals={ String(config.chain.currency.decimals) }
currency={ currencyUnits.ether } currency={ currencyUnits.ether }
accuracyUsd={ accuracyUsd } accuracyUsd={ 2 }
accuracy={ accuracy } accuracy={ 8 }
flexWrap="wrap" flexWrap="wrap"
isLoading={ isLoading } isLoading={ isLoading }
/> />
{ !isLoading && (
<GetGasButton usdValue={ usdResult } isContract={ data?.is_contract }/>
) }
</DetailsInfoItem.Value> </DetailsInfoItem.Value>
</> </>
); );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment