feat: Add information to msg transaction cards (#104)

- Display duration in dest tx card per request from @Skunkchain 
- Display mailbox address in both tx cards
- Hide API docs page link which was disabled in #77 
- Fix missing type annotation
pull/105/head
J M Rossy 4 months ago committed by GitHub
parent 9fb83e538f
commit 230907367f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 14
      src/components/nav/Header.tsx
  2. 6
      src/features/messages/MessageDetails.tsx
  3. 27
      src/features/messages/cards/TransactionCard.tsx
  4. 2
      src/types.ts
  5. 6
      src/utils/time.ts

@ -62,9 +62,9 @@ export function Header({ pathName }: { pathName: string }) {
<a className={navLinkClass()} target="_blank" href={links.home} rel="noopener noreferrer"> <a className={navLinkClass()} target="_blank" href={links.home} rel="noopener noreferrer">
About About
</a> </a>
<Link href="/api-docs" className={navLinkClass('/api-docs')}> {/* <Link href="/api-docs" className={navLinkClass('/api-docs')}>
API API
</Link> </Link> */}
<a <a
className={navLinkClass()} className={navLinkClass()}
target="_blank" target="_blank"
@ -95,11 +95,11 @@ export function Header({ pathName }: { pathName: string }) {
Settings Settings
</MobileNavLink> </MobileNavLink>
), ),
(c: Fn) => ( // (c: Fn) => (
<MobileNavLink href="/api" closeDropdown={c} key="API"> // <MobileNavLink href="/api" closeDropdown={c} key="API">
API // API
</MobileNavLink> // </MobileNavLink>
), // ),
(c: Fn) => ( (c: Fn) => (
<MobileNavLink href={docLinks.home} closeDropdown={c} key="Docs"> <MobileNavLink href={docLinks.home} closeDropdown={c} key="Docs">
Docs Docs

@ -10,6 +10,7 @@ import CheckmarkIcon from '../../images/icons/checkmark-circle.svg';
import { useMultiProvider, useStore } from '../../store'; import { useMultiProvider, useStore } from '../../store';
import { Message, MessageStatus } from '../../types'; import { Message, MessageStatus } from '../../types';
import { logger } from '../../utils/logger'; import { logger } from '../../utils/logger';
import { getHumanReadableDuration } from '../../utils/time';
import { getChainDisplayName, isEvmChain } from '../chains/utils'; import { getChainDisplayName, isEvmChain } from '../chains/utils';
import { useMessageDeliveryStatus } from '../deliveryStatus/useMessageDeliveryStatus'; import { useMessageDeliveryStatus } from '../deliveryStatus/useMessageDeliveryStatus';
@ -84,6 +85,10 @@ export function MessageDetails({ messageId, message: messageFromUrlParams }: Pro
isPiMsg, isPiMsg,
} = message; } = message;
const duration = destination?.timestamp
? getHumanReadableDuration(destination.timestamp - origin.timestamp, 3)
: undefined;
const showTimeline = const showTimeline =
!isPiMsg && !isPiMsg &&
isEvmChain(multiProvider, originChainId) && isEvmChain(multiProvider, originChainId) &&
@ -120,6 +125,7 @@ export function MessageDetails({ messageId, message: messageFromUrlParams }: Pro
domainId={destinationDomainId} domainId={destinationDomainId}
status={status} status={status}
transaction={destination} transaction={destination}
duration={duration}
debugResult={debugResult} debugResult={debugResult}
isStatusFetching={isDeliveryStatusFetching} isStatusFetching={isDeliveryStatusFetching}
isPiMsg={isPiMsg} isPiMsg={isPiMsg}

@ -3,6 +3,7 @@ import Link from 'next/link';
import { PropsWithChildren, ReactNode, useState } from 'react'; import { PropsWithChildren, ReactNode, useState } from 'react';
import { MultiProvider } from '@hyperlane-xyz/sdk'; import { MultiProvider } from '@hyperlane-xyz/sdk';
import { isAddress, isZeroish } from '@hyperlane-xyz/utils';
import { Spinner } from '../../../components/animations/Spinner'; import { Spinner } from '../../../components/animations/Spinner';
import { ChainLogo } from '../../../components/icons/ChainLogo'; import { ChainLogo } from '../../../components/icons/ChainLogo';
@ -48,6 +49,7 @@ export function DestinationTransactionCard({
domainId, domainId,
status, status,
transaction, transaction,
duration,
debugResult, debugResult,
isStatusFetching, isStatusFetching,
isPiMsg, isPiMsg,
@ -57,6 +59,7 @@ export function DestinationTransactionCard({
domainId: DomainId; domainId: DomainId;
status: MessageStatus; status: MessageStatus;
transaction?: MessageTx; transaction?: MessageTx;
duration?: string;
debugResult?: MessageDebugResult; debugResult?: MessageDebugResult;
isStatusFetching: boolean; isStatusFetching: boolean;
isPiMsg?: boolean; isPiMsg?: boolean;
@ -74,6 +77,7 @@ export function DestinationTransactionCard({
transaction={transaction} transaction={transaction}
chainId={chainId} chainId={chainId}
domainId={domainId} domainId={domainId}
duration={duration}
blur={blur} blur={blur}
/> />
); );
@ -190,16 +194,18 @@ function TransactionDetails({
chainId, chainId,
domainId, domainId,
transaction, transaction,
duration,
blur, blur,
}: { }: {
chainId: ChainId; chainId: ChainId;
domainId: DomainId; domainId: DomainId;
transaction: MessageTx; transaction: MessageTx;
duration?: string;
blur: boolean; blur: boolean;
}) { }) {
const multiProvider = useMultiProvider(); const multiProvider = useMultiProvider();
const { hash, from, timestamp, blockNumber } = transaction; const { hash, from, timestamp, blockNumber, mailbox } = transaction;
const txExplorerLink = const txExplorerLink =
hash && !new BigNumber(hash).isZero() hash && !new BigNumber(hash).isZero()
@ -230,6 +236,16 @@ function TransactionDetails({
showCopy={true} showCopy={true}
blurValue={blur} blurValue={blur}
/> />
{mailbox && isAddress(mailbox) && !isZeroish(mailbox) && (
<KeyValueRow
label="Mailbox:"
labelWidth="w-16"
display={mailbox}
displayWidth="w-60 sm:w-64"
showCopy={true}
blurValue={blur}
/>
)}
{!!timestamp && ( {!!timestamp && (
<KeyValueRow <KeyValueRow
label="Time:" label="Time:"
@ -247,6 +263,15 @@ function TransactionDetails({
displayWidth="w-60 sm:w-64" displayWidth="w-60 sm:w-64"
blurValue={blur} blurValue={blur}
/> />
{duration && (
<KeyValueRow
label="Duration:"
labelWidth="w-16"
display={duration}
displayWidth="w-60 sm:w-64"
blurValue={blur}
/>
)}
{txExplorerLink && ( {txExplorerLink && (
<a <a
className={`block ${styles.textLink}`} className={`block ${styles.textLink}`}

@ -22,7 +22,7 @@ export interface MessageTx extends MessageTxStub {
nonce: number; nonce: number;
gasLimit: number; gasLimit: number;
gasPrice: number; gasPrice: number;
effectiveGasPrice; effectiveGasPrice: number;
gasUsed: number; gasUsed: number;
cumulativeGasUsed: number; cumulativeGasUsed: number;
maxFeePerGas: number; maxFeePerGas: number;

@ -37,14 +37,14 @@ export function getHumanReadableDuration(ms: number, minSec?: number) {
} }
if (seconds <= 60) { if (seconds <= 60) {
return `${seconds} sec`; return `${seconds} seconds`;
} }
const minutes = Math.floor(seconds / 60); const minutes = Math.floor(seconds / 60);
if (minutes < 60) { if (minutes < 60) {
return `${minutes} min`; return `${minutes} minutes`;
} }
const hours = Math.floor(minutes / 60); const hours = Math.floor(minutes / 60);
return `${hours} hr`; return `${hours} hours`;
} }
export function getDateTimeString(timestamp: number) { export function getDateTimeString(timestamp: number) {

Loading…
Cancel
Save