Skip to content

Commit

Permalink
Merge branch 'fe-1575' of https://github.com/blockscout/frontend into…
Browse files Browse the repository at this point in the history
… test-query-in-page
  • Loading branch information
ArminaAiren committed Feb 6, 2024
2 parents 5918a25 + acdf118 commit c2dc10c
Show file tree
Hide file tree
Showing 35 changed files with 139 additions and 52 deletions.
48 changes: 48 additions & 0 deletions configs/envs/.env.optimism_goerli
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Set of ENVs for zkevm (dev only)
# https://eth.blockscout.com/

# app configuration
NEXT_PUBLIC_APP_PROTOCOL=http
NEXT_PUBLIC_APP_HOST=localhost
NEXT_PUBLIC_APP_PORT=3000

# blockchain parameters
NEXT_PUBLIC_NETWORK_NAME='OP Goerli'
NEXT_PUBLIC_NETWORK_SHORT_NAME='OP Goerli'
NEXT_PUBLIC_NETWORK_ID=420
NEXT_PUBLIC_NETWORK_CURRENCY_NAME=Ether
NEXT_PUBLIC_NETWORK_CURRENCY_SYMBOL=ETH
NEXT_PUBLIC_NETWORK_CURRENCY_DECIMALS=18
NEXT_PUBLIC_NETWORK_VERIFICATION_TYPE=validation
NEXT_PUBLIC_NETWORK_RPC_URL=https://goerli.optimism.io

# api configuration
NEXT_PUBLIC_API_HOST=optimism-goerli.blockscout.com
NEXT_PUBLIC_API_PORT=80
NEXT_PUBLIC_API_PROTOCOL=http
NEXT_PUBLIC_API_BASE_PATH=/

# ui config
## homepage
NEXT_PUBLIC_HOMEPAGE_CHARTS=['daily_txs']
## sidebar
NEXT_PUBLIC_FEATURED_NETWORKS=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/featured-networks/polygon-mainnet.json
## footer
## misc
NEXT_PUBLIC_NETWORK_EXPLORERS=[{'title':'Etherscan','baseUrl':'https://etherscan.io/','paths':{'tx':'/tx','address':'/address','token':'/token','block':'/block'}}]
# app features
NEXT_PUBLIC_APP_INSTANCE=local
NEXT_PUBLIC_APP_ENV=development
NEXT_PUBLIC_GRAPHIQL_TRANSACTION=0xf7d4972356e6ae44ae948d0cf19ef2beaf0e574c180997e969a2837da15e349d
NEXT_PUBLIC_IS_ACCOUNT_SUPPORTED=true
# NEXT_PUBLIC_AUTH_URL=http://localhost:3000
NEXT_PUBLIC_API_WEBSOCKET_PROTOCOL=ws
NEXT_PUBLIC_LOGOUT_URL=https://blockscoutcom.us.auth0.com/v2/logout
NEXT_PUBLIC_STATS_API_HOST=https://stats-eth-main.k8s.blockscout.com
NEXT_PUBLIC_VISUALIZE_API_HOST=https://visualizer.services.blockscout.com
NEXT_PUBLIC_CONTRACT_INFO_API_HOST=https://contracts-info.services.blockscout.com
NEXT_PUBLIC_ADMIN_SERVICE_API_HOST=https://admin-rs.services.blockscout.com
# rollup
NEXT_PUBLIC_IS_OPTIMISTIC_L2_NETWORK=true
NEXT_PUBLIC_OPTIMISTIC_L2_WITHDRAWAL_URL=https://app.optimism.io/bridge/withdraw
NEXT_PUBLIC_L1_BASE_URL=https://eth-goerli.blockscout.com/
6 changes: 3 additions & 3 deletions lib/shortenString.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export default function shortenString(string: string | null) {
export default function shortenString(string: string | null, charNumber = 8) {
if (!string) {
return '';
}

if (string.length <= 7) {
if (string.length <= charNumber - 1) {
return string;
}

return string.slice(0, 4) + '...' + string.slice(-4);
return string.slice(0, charNumber - 4) + '...' + string.slice(-4);
}
2 changes: 1 addition & 1 deletion nextjs/nextjs-routes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ declare module "nextjs-routes" {
| StaticRoute<"/login">
| DynamicRoute<"/name-domains/[name]", { "name": string }>
| StaticRoute<"/name-domains">
| StaticRoute<"/output-roots">
| DynamicRoute<"/op/[hash]", { "hash": string }>
| StaticRoute<"/ops">
| StaticRoute<"/output-roots">
| StaticRoute<"/search-results">
| StaticRoute<"/stats">
| DynamicRoute<"/token/[hash]", { "hash": string }>
Expand Down
1 change: 1 addition & 0 deletions ui/address/tokens/ERC20TokensTableItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const ERC20TokensTableItem = ({
<AddressEntity
address={{ hash: token.address }}
isLoading={ isLoading }
truncation="constant"
noIcon
/>
<AddressAddToWallet token={ token } ml={ 4 } isLoading={ isLoading } opacity="0"/>
Expand Down
1 change: 1 addition & 0 deletions ui/addresses/AddressesListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const AddressesListItem = ({
isLoading={ isLoading }
fontWeight={ 700 }
mr={ 2 }
truncation="constant"
/>
<Skeleton isLoaded={ !isLoading } fontSize="sm" ml="auto" minW={ 6 } color="text_secondary">
<span>{ index }</span>
Expand Down
1 change: 1 addition & 0 deletions ui/blocks/BlocksListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const BlocksListItem = ({ data, isLoading, enableTimeIncrement }: Props) => {
<AddressEntity
address={ data.miner }
isLoading={ isLoading }
truncation="constant"
/>
</Flex>
) }
Expand Down
1 change: 1 addition & 0 deletions ui/blocks/BlocksTableItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const BlocksTableItem = ({ data, isLoading, enableTimeIncrement }: Props) => {
<AddressEntity
address={ data.miner }
isLoading={ isLoading }
truncation="constant"
/>
</Td>
) }
Expand Down
3 changes: 3 additions & 0 deletions ui/l2Deposits/DepositsListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const DepositsListItem = ({ item, isLoading }: Props) => {
hash={ item.l2_tx_hash }
fontSize="sm"
lineHeight={ 5 }
truncation="constant_long"
/>
</ListItemMobileGrid.Value>

Expand All @@ -59,6 +60,7 @@ const DepositsListItem = ({ item, isLoading }: Props) => {
hash={ item.l1_tx_hash }
fontSize="sm"
lineHeight={ 5 }
truncation="constant_long"
/>
</ListItemMobileGrid.Value>

Expand All @@ -68,6 +70,7 @@ const DepositsListItem = ({ item, isLoading }: Props) => {
address={{ hash: item.l1_tx_origin, name: '', is_contract: false, is_verified: false, implementation_name: '', ens_domain_name: null }}
isLoading={ isLoading }
noCopy
truncation="constant"
/>
</ListItemMobileGrid.Value>

Expand Down
7 changes: 5 additions & 2 deletions ui/l2Deposits/DepositsTableItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const WithdrawalsTableItem = ({ item, isLoading }: Props) => {
fontSize="sm"
lineHeight={ 5 }
fontWeight={ 600 }
noIcon
/>
</Td>
<Td verticalAlign="middle">
Expand All @@ -39,7 +40,8 @@ const WithdrawalsTableItem = ({ item, isLoading }: Props) => {
hash={ item.l2_tx_hash }
fontSize="sm"
lineHeight={ 5 }
truncation="constant"
truncation="constant_long"
noIcon
/>
</Td>
<Td verticalAlign="middle" pr={ 12 }>
Expand All @@ -49,7 +51,8 @@ const WithdrawalsTableItem = ({ item, isLoading }: Props) => {
<TxEntityL1
isLoading={ isLoading }
hash={ item.l1_tx_hash }
truncation="constant"
truncation="constant_long"
noIcon
fontSize="sm"
lineHeight={ 5 }
/>
Expand Down
9 changes: 5 additions & 4 deletions ui/l2OutputRoots/OutputRootsListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import dayjs from 'lib/date/dayjs';
import CopyToClipboard from 'ui/shared/CopyToClipboard';
import BlockEntityL2 from 'ui/shared/entities/block/BlockEntityL2';
import TxEntityL1 from 'ui/shared/entities/tx/TxEntityL1';
import HashStringShortenDynamic from 'ui/shared/HashStringShortenDynamic';
import HashStringShorten from 'ui/shared/HashStringShorten';
import ListItemMobileGrid from 'ui/shared/ListItemMobile/ListItemMobileGrid';

const feature = config.features.optimisticRollup;
Expand Down Expand Up @@ -55,14 +55,15 @@ const OutputRootsListItem = ({ item, isLoading }: Props) => {
hash={ item.l1_tx_hash }
fontSize="sm"
lineHeight={ 5 }
truncation="constant_long"
/>
</ListItemMobileGrid.Value>

<ListItemMobileGrid.Label isLoading={ isLoading }>Output root</ListItemMobileGrid.Label>
<ListItemMobileGrid.Value>
<Flex overflow="hidden" whiteSpace="nowrap" alignItems="center" w="100%" justifyContent="space-between">
<Skeleton isLoaded={ !isLoading } color="text_secondary" w="calc(100% - 24px)">
<HashStringShortenDynamic hash={ item.output_root }/>
<Flex overflow="hidden" whiteSpace="nowrap" alignItems="center" w="100%" justifyContent="start">
<Skeleton isLoaded={ !isLoading } color="text_secondary">
<HashStringShorten hash={ item.output_root } type="long"/>
</Skeleton>
<CopyToClipboard text={ item.output_root } isLoading={ isLoading }/>
</Flex>
Expand Down
2 changes: 1 addition & 1 deletion ui/l2OutputRoots/OutputRootsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const OutputRootsTable = ({ items, top, isLoading }: Props) => {
<Table variant="simple" size="sm" minW="900px">
<Thead top={ top }>
<Tr>
<Th width="140px">L2 output index</Th>
<Th width="160px">L2 output index</Th>
<Th width="20%">Age</Th>
<Th width="20%">L2 block #</Th>
<Th width="30%">L1 txn hash</Th>
Expand Down
11 changes: 7 additions & 4 deletions ui/l2OutputRoots/OutputRootsTableItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import dayjs from 'lib/date/dayjs';
import CopyToClipboard from 'ui/shared/CopyToClipboard';
import BlockEntityL2 from 'ui/shared/entities/block/BlockEntityL2';
import TxEntityL1 from 'ui/shared/entities/tx/TxEntityL1';
import HashStringShortenDynamic from 'ui/shared/HashStringShortenDynamic';
import HashStringShorten from 'ui/shared/HashStringShorten';

const feature = config.features.optimisticRollup;

Expand Down Expand Up @@ -36,6 +36,7 @@ const OutputRootsTableItem = ({ item, isLoading }: Props) => {
fontSize="sm"
lineHeight={ 5 }
fontWeight={ 600 }
noIcon
/>
</Td>
<Td verticalAlign="middle" pr={ 12 }>
Expand All @@ -44,12 +45,14 @@ const OutputRootsTableItem = ({ item, isLoading }: Props) => {
hash={ item.l1_tx_hash }
fontSize="sm"
lineHeight={ 5 }
noIcon
truncation="constant_long"
/>
</Td>
<Td verticalAlign="middle">
<Flex overflow="hidden" whiteSpace="nowrap" w="100%" alignItems="center">
<Skeleton isLoaded={ !isLoading } w="calc(100% - 36px)">
<HashStringShortenDynamic hash={ item.output_root }/>
<Flex overflow="hidden" w="100%" alignItems="center">
<Skeleton isLoaded={ !isLoading }>
<HashStringShorten hash={ item.output_root } type="long"/>
</Skeleton>
<CopyToClipboard text={ item.output_root } ml={ 2 } isLoading={ isLoading }/>
</Flex>
Expand Down
2 changes: 1 addition & 1 deletion ui/l2TxnBatches/TxnBatchesListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const TxnBatchesListItem = ({ item, isLoading }: Props) => {
hash={ hash }
fontSize="sm"
lineHeight={ 5 }
maxW="100%"
truncation="constant_long"
/>
)) }
</VStack>
Expand Down
4 changes: 3 additions & 1 deletion ui/l2TxnBatches/TxnBatchesTableItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const TxnBatchesTableItem = ({ item, isLoading }: Props) => {
fontSize="sm"
lineHeight={ 5 }
fontWeight={ 600 }
noIcon
/>
</Td>
<Td>
Expand Down Expand Up @@ -64,7 +65,8 @@ const TxnBatchesTableItem = ({ item, isLoading }: Props) => {
hash={ hash }
fontSize="sm"
lineHeight={ 5 }
maxW="100%"
truncation="constant_long"
noIcon
/>
)) }
</VStack>
Expand Down
1 change: 1 addition & 0 deletions ui/l2Withdrawals/WithdrawalsListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const WithdrawalsListItem = ({ item, isLoading }: Props) => {
<AddressEntity
address={ item.from }
isLoading={ isLoading }
truncation="constant"
/>
</ListItemMobileGrid.Value>
</>
Expand Down
6 changes: 4 additions & 2 deletions ui/l2Withdrawals/WithdrawalsTableItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ const WithdrawalsTableItem = ({ item, isLoading }: Props) => {
<TxEntity
isLoading={ isLoading }
hash={ item.l2_tx_hash }
truncation="constant"
fontSize="sm"
lineHeight={ 5 }
truncation="constant_long"
noIcon
/>
</Td>
<Td verticalAlign="middle" pr={ 12 }>
Expand All @@ -61,7 +62,8 @@ const WithdrawalsTableItem = ({ item, isLoading }: Props) => {
<TxEntityL1
isLoading={ isLoading }
hash={ item.l1_tx_hash }
truncation="constant"
truncation="constant_long"
noIcon
fontSize="sm"
lineHeight={ 5 }
/>
Expand Down
2 changes: 1 addition & 1 deletion ui/nameDomain/history/NameDomainHistoryListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const NameDomainHistoryListItem = ({ isLoading, transaction_hash: transactionHas
<>
<ListItemMobileGrid.Label isLoading={ isLoading }>From</ListItemMobileGrid.Label>
<ListItemMobileGrid.Value>
<AddressEntity address={ fromAddress } isLoading={ isLoading }/>
<AddressEntity address={ fromAddress } isLoading={ isLoading } truncation="constant"/>
</ListItemMobileGrid.Value>
</>
) }
Expand Down
2 changes: 1 addition & 1 deletion ui/nameDomain/history/NameDomainHistoryTableItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const NameDomainHistoryTableItem = ({ isLoading, transaction_hash: transactionHa
</Skeleton>
</Td>
<Td verticalAlign="middle">
{ fromAddress && <AddressEntity address={ fromAddress } isLoading={ isLoading }/> }
{ fromAddress && <AddressEntity address={ fromAddress } isLoading={ isLoading } truncation="constant"/> }
</Td>
<Td verticalAlign="middle">
{ action && <Tag colorScheme="gray" isLoading={ isLoading }>{ action }</Tag> }
Expand Down
2 changes: 1 addition & 1 deletion ui/shared/EntityTags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const EntityTags = ({ className, data, tagsBefore = [], tagsAfter = [], isLoadin
}
<Popover isOpen={ isOpen } onClose={ onClose } placement="bottom-start" isLazy>
<PopoverTrigger>
<Tag onClick={ onToggle }>+{ tags.length - 1 }</Tag>
<Tag isLoading={ isLoading }onClick={ onToggle }>+{ tags.length - 1 }</Tag>
</PopoverTrigger>
<PopoverContent w="240px">
<PopoverBody >
Expand Down
8 changes: 5 additions & 3 deletions ui/shared/HashStringShorten.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ import shortenString from 'lib/shortenString';
interface Props {
hash: string;
isTooltipDisabled?: boolean;
type?: 'long' | 'short';
as?: As;
}

const HashStringShorten = ({ hash, isTooltipDisabled, as = 'span' }: Props) => {
if (hash.length <= 8) {
const HashStringShorten = ({ hash, isTooltipDisabled, as = 'span', type }: Props) => {
const charNumber = type === 'long' ? 16 : 8;
if (hash.length <= charNumber) {
return <chakra.span as={ as }>{ hash }</chakra.span>;
}

return (
<Tooltip label={ hash } isDisabled={ isTooltipDisabled }>
<chakra.span as={ as }>{ shortenString(hash) }</chakra.span>
<chakra.span as={ as }>{ shortenString(hash, charNumber) }</chakra.span>
</Tooltip>
);
};
Expand Down
18 changes: 9 additions & 9 deletions ui/shared/address/AddressFromTo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface Props {
noIcon?: boolean;
}

const AddressFromTo = ({ from, to, current, mode: modeProp, className, isLoading, tokenHash = '', truncation, noIcon }: Props) => {
const AddressFromTo = ({ from, to, current, mode: modeProp, className, isLoading, tokenHash = '', noIcon }: Props) => {
const mode = useBreakpointValue(
{
base: (typeof modeProp === 'object' ? modeProp.base : modeProp),
Expand All @@ -52,8 +52,8 @@ const AddressFromTo = ({ from, to, current, mode: modeProp, className, isLoading
noCopy={ current === from.hash }
noIcon={ noIcon }
tokenHash={ tokenHash }
truncation={ truncation }
maxW={ truncation === 'constant' ? undefined : 'calc(100% - 28px)' }
truncation="constant"
maxW="calc(100% - 28px)"
w="min-content"
/>
</Flex>
Expand All @@ -65,8 +65,8 @@ const AddressFromTo = ({ from, to, current, mode: modeProp, className, isLoading
noCopy={ current === to.hash }
noIcon={ noIcon }
tokenHash={ tokenHash }
truncation={ truncation }
maxW={ truncation === 'constant' ? undefined : 'calc(100% - 28px)' }
truncation="constant"
maxW="calc(100% - 28px)"
w="min-content"
ml="28px"
/>
Expand All @@ -87,8 +87,8 @@ const AddressFromTo = ({ from, to, current, mode: modeProp, className, isLoading
noCopy={ isOutgoing }
noIcon={ noIcon }
tokenHash={ tokenHash }
truncation={ truncation }
maxW={ truncation === 'constant' ? undefined : `calc(50% - ${ iconSizeWithMargins / 2 }px)` }
truncation="constant"
maxW={ `calc(50% - ${ iconSizeWithMargins / 2 }px)` }
mr={ isOutgoing ? 4 : 2 }
/>
<AddressFromToIcon
Expand All @@ -103,8 +103,8 @@ const AddressFromTo = ({ from, to, current, mode: modeProp, className, isLoading
noCopy={ current === to.hash }
noIcon={ noIcon }
tokenHash={ tokenHash }
truncation={ truncation }
maxW={ truncation === 'constant' ? undefined : `calc(50% - ${ iconSizeWithMargins / 2 }px)` }
truncation="constant"
maxW={ `calc(50% - ${ iconSizeWithMargins / 2 }px)` }
ml={ 3 }
/>
) }
Expand Down
Loading

0 comments on commit c2dc10c

Please sign in to comment.