Files
tom goriunovandGitHub e6e83ee4e7 Add cross-chain transaction tracking and visualization (#3227)
* envs and feature setup

* home page layout

* cross-chain txs page

* cross-chain transfers page

* cross-chain transfers on tx page

* cross-chain messages on tx page

* cross-chain tx page

* cross-chain tx details token transfers

* stats and counters for lists

* migrate to new API version

* add swagger

* mobile lists

* placeholder views on address page

* tests

* fix adaptive tabs initial state when there is only one tab in the list

* tweaks

* bug fixes

* fix tests

* update screenshots

* migrate to new api version

* add chain label tooltip, copy button to txs in lists and same address highlight

* list views on address page

* fix tests

* fix links to current address in the list views

* update tooltips

* update tables layout

* review fixes

* fix spelling

* update screenshots

* update screenshot
2026-02-19 15:14:32 +01:00

110 lines
2.4 KiB
TypeScript

import { chakra } from '@chakra-ui/react';
import React from 'react';
import { route } from 'nextjs/routes';
import * as EntityBase from 'ui/shared/entities/base/components';
import getChainTooltipText from 'ui/shared/externalChains/getChainTooltipText';
import { distributeEntityProps } from '../base/utils';
type LinkProps = EntityBase.LinkBaseProps & Pick<EntityProps, 'id'>;
const Link = chakra((props: LinkProps) => {
const defaultHref = route(
{ pathname: '/cross-chain-tx/[id]', query: { id: props.id } },
{ chain: props.chain, external: props.external },
);
return (
<EntityBase.Link
{ ...props }
href={ props.href ?? defaultHref }
>
{ props.children }
</EntityBase.Link>
);
});
type IconProps = EntityBase.IconBaseProps;
const Icon = ({ noIcon, ...props }: IconProps) => {
// by default, we don't show the icon
if (noIcon !== false) {
return null;
}
const hint = (() => {
if ('hint' in props) {
return props.hint;
}
if (props.chain && props.shield !== false) {
return getChainTooltipText(props.chain, 'Cross-chain transaction on ');
}
})();
return (
<EntityBase.Icon
name="interop"
{ ...props }
shield={ props.shield ?? (props.chain ? { src: props.chain.logo } : undefined) }
hint={ hint }
/>
);
};
type ContentProps = Omit<EntityBase.ContentBaseProps, 'text'> & Pick<EntityProps, 'id'>;
const Content = chakra((props: ContentProps) => {
return (
<EntityBase.Content
truncation="constant"
{ ...props }
text={ props.id }
/>
);
});
type CopyProps = Omit<EntityBase.CopyBaseProps, 'text'> & Pick<EntityProps, 'id'>;
const Copy = (props: CopyProps) => {
return (
<EntityBase.Copy
{ ...props }
text={ props.id }
noCopy={ props.noCopy }
/>
);
};
const Container = EntityBase.Container;
export interface EntityProps extends EntityBase.EntityBaseProps {
id: string;
}
const CrossChainMessageEntity = (props: EntityProps) => {
const partsProps = distributeEntityProps(props);
const content = <Content { ...partsProps.content }/>;
return (
<Container { ...partsProps.container }>
<Icon { ...partsProps.icon }/>
{ props.noLink ? content : <Link { ...partsProps.link }>{ content }</Link> }
<Copy { ...partsProps.copy }/>
</Container>
);
};
export default React.memo(chakra(CrossChainMessageEntity));
export {
Container,
Link,
Icon,
Content,
Copy,
};