Skip to content

Commit

Permalink
Merge branch 'hirosystems:main' into fix/receipt-time
Browse files Browse the repository at this point in the history
  • Loading branch information
dragnoir authored Jul 26, 2023
2 parents bbd19a3 + 79efb8d commit 59dbfca
Show file tree
Hide file tree
Showing 16 changed files with 93 additions and 40 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [1.110.4](https://github.com/hirosystems/explorer/compare/v1.110.3...v1.110.4) (2023-07-13)


### Bug Fixes

* search bar crash ([57defa1](https://github.com/hirosystems/explorer/commit/57defa1e42230c28f80b67c3382c6342b4579354))

## [1.110.3](https://github.com/hirosystems/explorer/compare/v1.110.2...v1.110.3) (2023-07-06)


Expand Down
43 changes: 38 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/app/components/BlockList/MicroblockListItem.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { toRelativeTime } from '@/common/utils';
import { MicroblockLink } from '@/components/links';
import { MicroBlockLink } from '@/components/links';
import { Circle, Flex, Icon, Stack } from '@/ui/components';
import { Caption, Text, Title } from '@/ui/typography';
import { useColorMode } from '@chakra-ui/react';
Expand Down Expand Up @@ -28,7 +28,7 @@ export const MicroblockListItem: React.FC<{
</Circle>
<Stack spacing="8px" as="span" minWidth={0}>
<Flex alignItems="center" minWidth={0}>
<MicroblockLink hash={hash}>
<MicroBlockLink hash={hash}>
<Title
display="block"
fontSize={'14px'}
Expand All @@ -45,7 +45,7 @@ export const MicroblockListItem: React.FC<{
>
{hash}
</Title>
</MicroblockLink>
</MicroBlockLink>
</Flex>
<Caption display="block">Microblock</Caption>
</Stack>
Expand Down
2 changes: 1 addition & 1 deletion src/app/microblock/[hash]/tx-lists/MicroblockTxsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const MicroblockTxsList: FC<MicroblockTxsListProps> = memo(({ microblockH
leftContent={{
title: (
<Title fontWeight="500" display="block" fontSize="15px">
<TxLink txid={txId}>{truncateMiddle(txId)}</TxLink>
<TxLink txId={txId}>{truncateMiddle(txId)}</TxLink>
</Title>
),
subtitle: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const ContractInfo: FC<ContractInfoProps> = ({ contract: { contract_id, abi } })
return (
<Section
topRight={() => (
<TxLink txid={contract_id}>
<TxLink txId={contract_id}>
<Flex
as="a"
target="_blank"
Expand Down
2 changes: 1 addition & 1 deletion src/app/txid/[txid]/Cards/ContractDetailsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const ContractDetailsCard: React.FC<{ contractId: string }> = ({ contract
</Flex>
</Stack>
<Grid borderTopWidth="1px" placeItems="center" py="16px">
<TxLink txid={contractId}>
<TxLink txId={contractId}>
<Flex
as="a"
target="_blank"
Expand Down
4 changes: 2 additions & 2 deletions src/app/txid/[txid]/TxDetails/ContractName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const ContractName: FC<{
<KeyValueHorizontal
label={'Contract'}
value={
<TxLink txid={tx.contract_call.contract_id}>
<TxLink txId={tx.contract_call.contract_id}>
<TextLink as="a">
<Value>{tx.contract_call.contract_id}</Value>
</TextLink>
Expand All @@ -40,7 +40,7 @@ export const ContractName: FC<{
<KeyValueHorizontal
label={'Contract'}
value={
<TxLink txid={tx.smart_contract.contract_id}>
<TxLink txId={tx.smart_contract.contract_id}>
<TextLink as="a">
<Value>{tx.smart_contract.contract_id}</Value>
</TextLink>
Expand Down
2 changes: 1 addition & 1 deletion src/components/balances/token-asset-list-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const TokenAssetListItem: React.FC<TokenAssetListItemProps> = ({
? ftMetadata?.symbol || getTicker(asset).toUpperCase()
: getTicker(asset).toUpperCase()}
</Caption>
<TxLink txid={`${address}.${contract}`}>
<TxLink txId={`${address}.${contract}`}>
<Caption
target="_blank"
_hover={{
Expand Down
2 changes: 1 addition & 1 deletion src/components/contract-source.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const ContractSource: React.FC<
topRight={
sourceTx
? () => (
<TxLink txid={sourceTx}>
<TxLink txId={sourceTx}>
<Badge
as="a"
_hover={{ bg: '#eee', cursor: 'pointer' }}
Expand Down
2 changes: 1 addition & 1 deletion src/components/function-summary/value.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export const FunctionSummaryClarityValue = ({
if (isContract) {
return (
<Flex width="100%" flexGrow={1} justifyContent="space-between" {...rest}>
<TxLink txid={principal}>
<TxLink txId={principal}>
<TextLink as="a">{principal}</TextLink>
</TxLink>
<Caption>{getPrettyClarityValueType(arg.type)}</Caption>
Expand Down
40 changes: 24 additions & 16 deletions src/components/links.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,30 @@ export const ExplorerLink = forwardRef<LinkProps, 'a'>(({ href, ...rest }, ref)
return <Link ref={ref} legacyBehavior href={buildUrl(href, network)} passHref {...rest} />;
});

export const TxLink: React.FC<{ txid: string }> = React.memo(({ txid, ...rest }) => {
return <ExplorerLink href={`/txid/${encodeURIComponent(txid)}`} {...rest} />;
});
export const TxLink = forwardRef<Partial<LinkProps> & { txId: string }, 'a'>(
({ txId, ...rest }, ref) => {
return <ExplorerLink ref={ref} href={`/txid/${encodeURIComponent(txId)}`} {...rest} />;
}
);

export const MicroblockLink: React.FC<{ hash: string }> = React.memo(({ hash, ...rest }) => {
return <ExplorerLink href={`/microblock/${encodeURIComponent(hash)}`} {...rest} />;
});
export const MicroBlockLink = forwardRef<Partial<LinkProps> & { hash: string }, 'a'>(
({ hash, ...rest }, ref) => {
return <ExplorerLink ref={ref} href={`/microblock/${encodeURIComponent(hash)}`} {...rest} />;
}
);

export const BlockLink: React.FC<{ hash: string }> = React.memo(({ hash, ...rest }) => {
return <ExplorerLink href={`/block/${encodeURIComponent(hash)}`} {...rest} />;
});
export const BlockLink = forwardRef<Partial<LinkProps> & { hash: string }, 'a'>(
({ hash, ...rest }, ref) => {
return <ExplorerLink ref={ref} href={`/block/${encodeURIComponent(hash)}`} {...rest} />;
}
);

export const AddressLink: React.FC<{ principal: string }> = React.memo(({ principal, ...rest }) => {
return principal.includes('.') ? (
<TxLink txid={principal} {...rest} />
) : (
<ExplorerLink href={`/address/${encodeURIComponent(principal)}`} {...rest} />
);
});
export const AddressLink = forwardRef<Partial<LinkProps> & { principal: string }, 'a'>(
({ principal, ...rest }, ref) => {
return principal.includes('.') ? (
<TxLink ref={ref} txId={principal} {...rest} />
) : (
<ExplorerLink ref={ref} href={`/address/${encodeURIComponent(principal)}`} {...rest} />
);
}
);
4 changes: 2 additions & 2 deletions src/components/stacking.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const StackingPercentage = ({ balances, address }: any) => {
~{blocksUntilUnlocked.toLocaleString(undefined, { maximumFractionDigits: 2 })}{' '}
blocks remaining
</Caption>
<TxLink txid={balances?.stx?.lock_tx_id}>
<TxLink txId={balances?.stx?.lock_tx_id}>
<TextLink target="_blank" color={'brand'} fontSize={0}>
View Stacking transaction
</TextLink>
Expand All @@ -83,7 +83,7 @@ export const StackingPercentage = ({ balances, address }: any) => {
<Title mb="12px" fontSize={2} fontWeight={500} color={'textTitle'}>
Completed at #{unlockBlock}
</Title>
<TxLink txid={balances?.stx?.lock_tx_id}>
<TxLink txId={balances?.stx?.lock_tx_id}>
<TextLink target="_blank" color={'brand'} fontSize={0}>
View Stacking transaction
</TextLink>
Expand Down
4 changes: 2 additions & 2 deletions src/components/transaction-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ const Item: React.FC<
{ tx: MempoolTransaction | Transaction; isLast?: boolean; principal?: string } & BoxProps
> = React.memo(({ tx, principal, ...rest }) => {
return (
<Flex>
<TxLink txid={tx.tx_id} {...rest}>
<Flex {...rest}>
<TxLink txId={tx.tx_id}>
<Box as="a" position="absolute" size="100%" />
</TxLink>
<TxItem as="span" tx={tx} principal={principal} key={tx.tx_id} />
Expand Down
2 changes: 1 addition & 1 deletion src/features/search/items/address-result-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const AddressResultItem: React.FC<AddressResultItemProps> = ({ result })
const { data: stxBalance } = useQuery(
['stx-balance', principal],
() => accountsApi.getAccountStxBalance({ principal }) as Promise<AddressStxBalanceResponse>,
{ staleTime: 3 * 60 * 1000 }
{ staleTime: 3 * 60 * 1000, suspense: false }
);
const colorMode = useColorMode().colorMode;
return (
Expand Down
10 changes: 7 additions & 3 deletions src/features/search/items/result-item-wrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { Flex, FlexProps } from '@/ui/components';
import React, { FC } from 'react';
import { forwardRef } from '@chakra-ui/react';
import Link, { LinkProps } from 'next/link';
import { useGlobalContext } from '@/common/context/useAppContext';
import { buildUrl } from '@/app/common/utils/buildUrl';

export const ResultItemWrapper: FC<FlexProps> = ({ children, ...rest }) => (
<Flex>
export const ResultItemWrapper = forwardRef<FlexProps, 'div'>(({ children, ...rest }, ref) => (
<Flex ref={ref}>
<Flex
as={'a'}
p="24px"
Expand All @@ -17,4 +21,4 @@ export const ResultItemWrapper: FC<FlexProps> = ({ children, ...rest }) => (
</Flex>
</Flex>
</Flex>
);
));
1 change: 1 addition & 0 deletions src/features/search/use-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export const useSearchQuery = (id: string) => {
retry: false,
refetchOnWindowFocus: false,
staleTime: 1 * 60 * 1000,
suspense: false,
}
);
};
Expand Down

0 comments on commit 59dbfca

Please sign in to comment.