Commit 43d1dc85 authored by tom's avatar tom

remove ERC1155 batches

parent 5c9556ca
...@@ -85,7 +85,7 @@ export const erc721: TokenTransfer = { ...@@ -85,7 +85,7 @@ export const erc721: TokenTransfer = {
method: 'updateSmartAsset', method: 'updateSmartAsset',
}; };
export const erc1155: TokenTransfer = { export const erc1155A: TokenTransfer = {
from: { from: {
hash: '0x0000000000000000000000000000000000000000', hash: '0x0000000000000000000000000000000000000000',
implementation_name: null, implementation_name: null,
...@@ -128,26 +128,44 @@ export const erc1155: TokenTransfer = { ...@@ -128,26 +128,44 @@ export const erc1155: TokenTransfer = {
log_index: '1', log_index: '1',
}; };
export const erc1155multiple: TokenTransfer = { export const erc1155B: TokenTransfer = {
...erc1155, ...erc1155A,
token: { token: {
...erc1155.token, ...erc1155A.token,
name: 'SastanaNFT', name: 'SastanaNFT',
symbol: 'ipfs://QmUpFUfVKDCWeZQk5pvDFUxnpQP9N6eLSHhNUy49T1JVtY', symbol: 'ipfs://QmUpFUfVKDCWeZQk5pvDFUxnpQP9N6eLSHhNUy49T1JVtY',
}, },
total: [ total: { token_id: '12345678', value: '100000000000000000000', decimals: null },
{ token_id: '12345678', value: '100000000000000000000', decimals: null }, };
{ token_id: '483200961027732618117991942553110860267520', value: '200000000000000000000', decimals: null },
{ token_id: '456', value: '42', decimals: null }, export const erc1155C: TokenTransfer = {
], ...erc1155A,
token: {
...erc1155A.token,
name: 'SastanaNFT',
symbol: 'ipfs://QmUpFUfVKDCWeZQk5pvDFUxnpQP9N6eLSHhNUy49T1JVtY',
},
total: { token_id: '483200961027732618117991942553110860267520', value: '200000000000000000000', decimals: null },
};
export const erc1155D: TokenTransfer = {
...erc1155A,
token: {
...erc1155A.token,
name: 'SastanaNFT',
symbol: 'ipfs://QmUpFUfVKDCWeZQk5pvDFUxnpQP9N6eLSHhNUy49T1JVtY',
},
total: { token_id: '456', value: '42', decimals: null },
}; };
export const mixTokens: TokenTransferResponse = { export const mixTokens: TokenTransferResponse = {
items: [ items: [
erc20, erc20,
erc721, erc721,
erc1155, erc1155A,
erc1155multiple, erc1155B,
erc1155C,
erc1155D,
], ],
next_page_params: null, next_page_params: null,
}; };
...@@ -100,8 +100,10 @@ export const withTokenTransfer: Transaction = { ...@@ -100,8 +100,10 @@ export const withTokenTransfer: Transaction = {
token_transfers: [ token_transfers: [
tokenTransferMock.erc20, tokenTransferMock.erc20,
tokenTransferMock.erc721, tokenTransferMock.erc721,
tokenTransferMock.erc1155, tokenTransferMock.erc1155A,
tokenTransferMock.erc1155multiple, tokenTransferMock.erc1155B,
tokenTransferMock.erc1155C,
tokenTransferMock.erc1155D,
], ],
tx_types: [ tx_types: [
'token_transfer', 'token_transfer',
......
...@@ -27,7 +27,7 @@ export type TokenTransfer = ( ...@@ -27,7 +27,7 @@ export type TokenTransfer = (
} | } |
{ {
token: TokenInfoGeneric<'ERC-1155'>; token: TokenInfoGeneric<'ERC-1155'>;
total: Erc1155TotalPayload | Array<Erc1155TotalPayload>; total: Erc1155TotalPayload;
} }
) & TokenTransferBase ) & TokenTransferBase
......
...@@ -2,7 +2,7 @@ import { Box } from '@chakra-ui/react'; ...@@ -2,7 +2,7 @@ import { Box } from '@chakra-ui/react';
import { test, expect } from '@playwright/experimental-ct-react'; import { test, expect } from '@playwright/experimental-ct-react';
import React from 'react'; import React from 'react';
import { erc1155 } from 'mocks/tokens/tokenTransfer'; import { erc1155A } from 'mocks/tokens/tokenTransfer';
import TestApp from 'playwright/TestApp'; import TestApp from 'playwright/TestApp';
import buildApiUrl from 'playwright/utils/buildApiUrl'; import buildApiUrl from 'playwright/utils/buildApiUrl';
...@@ -20,7 +20,7 @@ const hooksConfig = { ...@@ -20,7 +20,7 @@ const hooksConfig = {
test('with token filter and pagination +@mobile', async({ mount, page }) => { test('with token filter and pagination +@mobile', async({ mount, page }) => {
await page.route(API_URL, (route) => route.fulfill({ await page.route(API_URL, (route) => route.fulfill({
status: 200, status: 200,
body: JSON.stringify({ items: [ erc1155 ], next_page_params: { block_number: 1 } }), body: JSON.stringify({ items: [ erc1155A ], next_page_params: { block_number: 1 } }),
})); }));
const component = await mount( const component = await mount(
...@@ -37,7 +37,7 @@ test('with token filter and pagination +@mobile', async({ mount, page }) => { ...@@ -37,7 +37,7 @@ test('with token filter and pagination +@mobile', async({ mount, page }) => {
test('with token filter and no pagination +@mobile', async({ mount, page }) => { test('with token filter and no pagination +@mobile', async({ mount, page }) => {
await page.route(API_URL, (route) => route.fulfill({ await page.route(API_URL, (route) => route.fulfill({
status: 200, status: 200,
body: JSON.stringify({ items: [ erc1155 ] }), body: JSON.stringify({ items: [ erc1155A ] }),
})); }));
const component = await mount( const component = await mount(
......
...@@ -26,7 +26,6 @@ import HashStringShorten from 'ui/shared/HashStringShorten'; ...@@ -26,7 +26,6 @@ import HashStringShorten from 'ui/shared/HashStringShorten';
import Pagination from 'ui/shared/Pagination'; import Pagination from 'ui/shared/Pagination';
import SocketNewItemsNotice from 'ui/shared/SocketNewItemsNotice'; import SocketNewItemsNotice from 'ui/shared/SocketNewItemsNotice';
import TokenLogo from 'ui/shared/TokenLogo'; import TokenLogo from 'ui/shared/TokenLogo';
import { flattenTotal } from 'ui/shared/TokenTransfer/helpers';
import TokenTransferFilter from 'ui/shared/TokenTransfer/TokenTransferFilter'; import TokenTransferFilter from 'ui/shared/TokenTransfer/TokenTransferFilter';
import TokenTransferList from 'ui/shared/TokenTransfer/TokenTransferList'; import TokenTransferList from 'ui/shared/TokenTransfer/TokenTransferList';
import TokenTransferTable from 'ui/shared/TokenTransfer/TokenTransferTable'; import TokenTransferTable from 'ui/shared/TokenTransfer/TokenTransferTable';
...@@ -161,12 +160,11 @@ const AddressTokenTransfers = ({ scrollRef }: {scrollRef?: React.RefObject<HTMLD ...@@ -161,12 +160,11 @@ const AddressTokenTransfers = ({ scrollRef }: {scrollRef?: React.RefObject<HTMLD
const numActiveFilters = (filters.type?.length || 0) + (filters.filter ? 1 : 0); const numActiveFilters = (filters.type?.length || 0) + (filters.filter ? 1 : 0);
const isActionBarHidden = !tokenFilter && !numActiveFilters && !data?.items.length && !currentAddress; const isActionBarHidden = !tokenFilter && !numActiveFilters && !data?.items.length && !currentAddress;
const items = data?.items?.reduce(flattenTotal, []); const content = data?.items ? (
const content = items ? (
<> <>
<Hide below="lg" ssr={ false }> <Hide below="lg" ssr={ false }>
<TokenTransferTable <TokenTransferTable
data={ items } data={ data?.items }
baseAddress={ currentAddress } baseAddress={ currentAddress }
showTxInfo showTxInfo
top={ isActionBarHidden ? 0 : 80 } top={ isActionBarHidden ? 0 : 80 }
...@@ -187,7 +185,7 @@ const AddressTokenTransfers = ({ scrollRef }: {scrollRef?: React.RefObject<HTMLD ...@@ -187,7 +185,7 @@ const AddressTokenTransfers = ({ scrollRef }: {scrollRef?: React.RefObject<HTMLD
/> />
) } ) }
<TokenTransferList <TokenTransferList
data={ items } data={ data?.items }
baseAddress={ currentAddress } baseAddress={ currentAddress }
showTxInfo showTxInfo
enableTimeIncrement enableTimeIncrement
......
...@@ -5,11 +5,8 @@ import React from 'react'; ...@@ -5,11 +5,8 @@ import React from 'react';
import * as tokenTransferMock from 'mocks/tokens/tokenTransfer'; import * as tokenTransferMock from 'mocks/tokens/tokenTransfer';
import TestApp from 'playwright/TestApp'; import TestApp from 'playwright/TestApp';
import { flattenTotal } from './helpers';
import TokenTransferList from './TokenTransferList'; import TokenTransferList from './TokenTransferList';
const flattenData = tokenTransferMock.mixTokens.items.reduce(flattenTotal, []);
test.use({ viewport: devices['iPhone 13 Pro'].viewport }); test.use({ viewport: devices['iPhone 13 Pro'].viewport });
test('without tx info', async({ mount }) => { test('without tx info', async({ mount }) => {
...@@ -17,7 +14,7 @@ test('without tx info', async({ mount }) => { ...@@ -17,7 +14,7 @@ test('without tx info', async({ mount }) => {
<TestApp> <TestApp>
<Box h={{ base: '134px', lg: 6 }}/> <Box h={{ base: '134px', lg: 6 }}/>
<TokenTransferList <TokenTransferList
data={ flattenData } data={ tokenTransferMock.mixTokens.items }
showTxInfo={ false } showTxInfo={ false }
/> />
</TestApp>, </TestApp>,
...@@ -31,7 +28,7 @@ test('with tx info', async({ mount }) => { ...@@ -31,7 +28,7 @@ test('with tx info', async({ mount }) => {
<TestApp> <TestApp>
<Box h={{ base: '134px', lg: 6 }}/> <Box h={{ base: '134px', lg: 6 }}/>
<TokenTransferList <TokenTransferList
data={ flattenData } data={ tokenTransferMock.mixTokens.items }
showTxInfo={ true } showTxInfo={ true }
/> />
</TestApp>, </TestApp>,
......
...@@ -5,17 +5,14 @@ import React from 'react'; ...@@ -5,17 +5,14 @@ import React from 'react';
import * as tokenTransferMock from 'mocks/tokens/tokenTransfer'; import * as tokenTransferMock from 'mocks/tokens/tokenTransfer';
import TestApp from 'playwright/TestApp'; import TestApp from 'playwright/TestApp';
import { flattenTotal } from './helpers';
import TokenTransferTable from './TokenTransferTable'; import TokenTransferTable from './TokenTransferTable';
const flattenData = tokenTransferMock.mixTokens.items.reduce(flattenTotal, []);
test('without tx info', async({ mount }) => { test('without tx info', async({ mount }) => {
const component = await mount( const component = await mount(
<TestApp> <TestApp>
<Box h={{ base: '134px', lg: 6 }}/> <Box h={{ base: '134px', lg: 6 }}/>
<TokenTransferTable <TokenTransferTable
data={ flattenData } data={ tokenTransferMock.mixTokens.items }
top={ 0 } top={ 0 }
showTxInfo={ false } showTxInfo={ false }
/> />
...@@ -30,7 +27,7 @@ test('with tx info', async({ mount }) => { ...@@ -30,7 +27,7 @@ test('with tx info', async({ mount }) => {
<TestApp> <TestApp>
<Box h={{ base: '134px', lg: 6 }}/> <Box h={{ base: '134px', lg: 6 }}/>
<TokenTransferTable <TokenTransferTable
data={ flattenData } data={ tokenTransferMock.mixTokens.items }
top={ 0 } top={ 0 }
showTxInfo={ true } showTxInfo={ true }
/> />
......
import type { TokenTransfer } from 'types/api/tokenTransfer'; import type { TokenTransfer } from 'types/api/tokenTransfer';
export const flattenTotal = (result: Array<TokenTransfer>, item: TokenTransfer): Array<TokenTransfer> => {
if (Array.isArray(item.total)) {
item.total.forEach((total) => {
result.push({ ...item, total });
});
} else {
result.push(item);
}
return result;
};
export const getTokenTransferTypeText = (type: TokenTransfer['type']) => { export const getTokenTransferTypeText = (type: TokenTransfer['type']) => {
switch (type) { switch (type) {
case 'token_minting': case 'token_minting':
......
...@@ -64,7 +64,12 @@ test('erc1155 +@mobile', async({ mount }) => { ...@@ -64,7 +64,12 @@ test('erc1155 +@mobile', async({ mount }) => {
// @ts-ignore: // @ts-ignore:
transfersQuery={{ transfersQuery={{
data: { data: {
items: [ tokenTransferMock.erc1155, tokenTransferMock.erc1155multiple ], items: [
tokenTransferMock.erc1155A,
tokenTransferMock.erc1155B,
tokenTransferMock.erc1155C,
tokenTransferMock.erc1155D,
],
next_page_params: null, next_page_params: null,
}, },
isPaginationVisible: true, isPaginationVisible: true,
......
...@@ -15,7 +15,6 @@ import DataListDisplay from 'ui/shared/DataListDisplay'; ...@@ -15,7 +15,6 @@ import DataListDisplay from 'ui/shared/DataListDisplay';
import Pagination from 'ui/shared/Pagination'; import Pagination from 'ui/shared/Pagination';
import type { Props as PaginationProps } from 'ui/shared/Pagination'; import type { Props as PaginationProps } from 'ui/shared/Pagination';
import SocketNewItemsNotice from 'ui/shared/SocketNewItemsNotice'; import SocketNewItemsNotice from 'ui/shared/SocketNewItemsNotice';
import { flattenTotal } from 'ui/shared/TokenTransfer/helpers';
import TokenTransferList from 'ui/token/TokenTransfer/TokenTransferList'; import TokenTransferList from 'ui/token/TokenTransfer/TokenTransferList';
import TokenTransferTable from 'ui/token/TokenTransfer/TokenTransferTable'; import TokenTransferTable from 'ui/token/TokenTransfer/TokenTransferTable';
...@@ -59,14 +58,12 @@ const TokenTransfer = ({ transfersQuery, tokenId }: Props) => { ...@@ -59,14 +58,12 @@ const TokenTransfer = ({ transfersQuery, tokenId }: Props) => {
handler: handleNewTransfersMessage, handler: handleNewTransfersMessage,
}); });
const items = data?.items?.reduce(flattenTotal, []); const content = data?.items ? (
const content = items ? (
<> <>
<Hide below="lg" ssr={ false }> <Hide below="lg" ssr={ false }>
<TokenTransferTable <TokenTransferTable
data={ items } data={ data?.items }
top={ isPaginationVisible ? 80 : 0 } top={ isPaginationVisible ? 80 : 0 }
showSocketInfo={ pagination.page === 1 } showSocketInfo={ pagination.page === 1 }
socketInfoAlert={ socketAlert } socketInfoAlert={ socketAlert }
...@@ -84,7 +81,7 @@ const TokenTransfer = ({ transfersQuery, tokenId }: Props) => { ...@@ -84,7 +81,7 @@ const TokenTransfer = ({ transfersQuery, tokenId }: Props) => {
borderBottomRadius={ 0 } borderBottomRadius={ 0 }
/> />
) } ) }
<TokenTransferList data={ items } tokenId={ tokenId }/> <TokenTransferList data={ data?.items } tokenId={ tokenId }/>
</Show> </Show>
</> </>
) : null; ) : null;
......
...@@ -13,7 +13,6 @@ import ActionBar from 'ui/shared/ActionBar'; ...@@ -13,7 +13,6 @@ import ActionBar from 'ui/shared/ActionBar';
import DataFetchAlert from 'ui/shared/DataFetchAlert'; import DataFetchAlert from 'ui/shared/DataFetchAlert';
import DataListDisplay from 'ui/shared/DataListDisplay'; import DataListDisplay from 'ui/shared/DataListDisplay';
import Pagination from 'ui/shared/Pagination'; import Pagination from 'ui/shared/Pagination';
import { flattenTotal } from 'ui/shared/TokenTransfer/helpers';
import TokenTransferFilter from 'ui/shared/TokenTransfer/TokenTransferFilter'; import TokenTransferFilter from 'ui/shared/TokenTransfer/TokenTransferFilter';
import TokenTransferList from 'ui/shared/TokenTransfer/TokenTransferList'; import TokenTransferList from 'ui/shared/TokenTransfer/TokenTransferList';
import TokenTransferTable from 'ui/shared/TokenTransfer/TokenTransferTable'; import TokenTransferTable from 'ui/shared/TokenTransfer/TokenTransferTable';
...@@ -55,15 +54,13 @@ const TxTokenTransfer = () => { ...@@ -55,15 +54,13 @@ const TxTokenTransfer = () => {
const numActiveFilters = typeFilter.length; const numActiveFilters = typeFilter.length;
const isActionBarHidden = !numActiveFilters && !tokenTransferQuery.data?.items.length; const isActionBarHidden = !numActiveFilters && !tokenTransferQuery.data?.items.length;
const items = tokenTransferQuery.data?.items?.reduce(flattenTotal, []); const content = tokenTransferQuery.data?.items ? (
const content = items ? (
<> <>
<Hide below="lg" ssr={ false }> <Hide below="lg" ssr={ false }>
<TokenTransferTable data={ items } top={ isActionBarHidden ? 0 : 80 }/> <TokenTransferTable data={ tokenTransferQuery.data?.items } top={ isActionBarHidden ? 0 : 80 }/>
</Hide> </Hide>
<Show below="lg" ssr={ false }> <Show below="lg" ssr={ false }>
<TokenTransferList data={ items }/> <TokenTransferList data={ tokenTransferQuery.data?.items }/>
</Show> </Show>
</> </>
) : null; ) : null;
......
...@@ -7,7 +7,6 @@ import type { TokenTransfer } from 'types/api/tokenTransfer'; ...@@ -7,7 +7,6 @@ import type { TokenTransfer } from 'types/api/tokenTransfer';
import tokenIcon from 'icons/token.svg'; import tokenIcon from 'icons/token.svg';
import DetailsInfoItem from 'ui/shared/DetailsInfoItem'; import DetailsInfoItem from 'ui/shared/DetailsInfoItem';
import LinkInternal from 'ui/shared/LinkInternal'; import LinkInternal from 'ui/shared/LinkInternal';
import { flattenTotal } from 'ui/shared/TokenTransfer/helpers';
import TxDetailsTokenTransfer from './TxDetailsTokenTransfer'; import TxDetailsTokenTransfer from './TxDetailsTokenTransfer';
...@@ -27,10 +26,9 @@ const VISIBLE_ITEMS_NUM = 3; ...@@ -27,10 +26,9 @@ const VISIBLE_ITEMS_NUM = 3;
const TxDetailsTokenTransfers = ({ data, txHash }: Props) => { const TxDetailsTokenTransfers = ({ data, txHash }: Props) => {
const viewAllUrl = route({ pathname: '/tx/[hash]', query: { hash: txHash, tab: 'token_transfers' } }); const viewAllUrl = route({ pathname: '/tx/[hash]', query: { hash: txHash, tab: 'token_transfers' } });
const formattedData = data.reduce(flattenTotal, []);
const transferGroups = TOKEN_TRANSFERS_TYPES.map((group) => ({ const transferGroups = TOKEN_TRANSFERS_TYPES.map((group) => ({
...group, ...group,
items: formattedData?.filter((token) => token.type === group.type) || [], items: data?.filter((token) => token.type === group.type) || [],
})); }));
const showViewAllLink = transferGroups.some(({ items }) => items.length > VISIBLE_ITEMS_NUM); const showViewAllLink = transferGroups.some(({ items }) => items.length > VISIBLE_ITEMS_NUM);
......
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