From 230907367f0df944a26868f2450ba5b75cd1dd3c Mon Sep 17 00:00:00 2001 From: J M Rossy Date: Fri, 16 Aug 2024 17:11:20 +0100 Subject: [PATCH] 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 --- src/components/nav/Header.tsx | 14 +++++----- src/features/messages/MessageDetails.tsx | 6 +++++ .../messages/cards/TransactionCard.tsx | 27 ++++++++++++++++++- src/types.ts | 2 +- src/utils/time.ts | 6 ++--- 5 files changed, 43 insertions(+), 12 deletions(-) diff --git a/src/components/nav/Header.tsx b/src/components/nav/Header.tsx index 57d2d33..136a080 100644 --- a/src/components/nav/Header.tsx +++ b/src/components/nav/Header.tsx @@ -62,9 +62,9 @@ export function Header({ pathName }: { pathName: string }) { About - + {/* API - + */} ), - (c: Fn) => ( - - API - - ), + // (c: Fn) => ( + // + // API + // + // ), (c: Fn) => ( Docs diff --git a/src/features/messages/MessageDetails.tsx b/src/features/messages/MessageDetails.tsx index fb5d319..b5abc7b 100644 --- a/src/features/messages/MessageDetails.tsx +++ b/src/features/messages/MessageDetails.tsx @@ -10,6 +10,7 @@ import CheckmarkIcon from '../../images/icons/checkmark-circle.svg'; import { useMultiProvider, useStore } from '../../store'; import { Message, MessageStatus } from '../../types'; import { logger } from '../../utils/logger'; +import { getHumanReadableDuration } from '../../utils/time'; import { getChainDisplayName, isEvmChain } from '../chains/utils'; import { useMessageDeliveryStatus } from '../deliveryStatus/useMessageDeliveryStatus'; @@ -84,6 +85,10 @@ export function MessageDetails({ messageId, message: messageFromUrlParams }: Pro isPiMsg, } = message; + const duration = destination?.timestamp + ? getHumanReadableDuration(destination.timestamp - origin.timestamp, 3) + : undefined; + const showTimeline = !isPiMsg && isEvmChain(multiProvider, originChainId) && @@ -120,6 +125,7 @@ export function MessageDetails({ messageId, message: messageFromUrlParams }: Pro domainId={destinationDomainId} status={status} transaction={destination} + duration={duration} debugResult={debugResult} isStatusFetching={isDeliveryStatusFetching} isPiMsg={isPiMsg} diff --git a/src/features/messages/cards/TransactionCard.tsx b/src/features/messages/cards/TransactionCard.tsx index dc7b619..e174a84 100644 --- a/src/features/messages/cards/TransactionCard.tsx +++ b/src/features/messages/cards/TransactionCard.tsx @@ -3,6 +3,7 @@ import Link from 'next/link'; import { PropsWithChildren, ReactNode, useState } from 'react'; import { MultiProvider } from '@hyperlane-xyz/sdk'; +import { isAddress, isZeroish } from '@hyperlane-xyz/utils'; import { Spinner } from '../../../components/animations/Spinner'; import { ChainLogo } from '../../../components/icons/ChainLogo'; @@ -48,6 +49,7 @@ export function DestinationTransactionCard({ domainId, status, transaction, + duration, debugResult, isStatusFetching, isPiMsg, @@ -57,6 +59,7 @@ export function DestinationTransactionCard({ domainId: DomainId; status: MessageStatus; transaction?: MessageTx; + duration?: string; debugResult?: MessageDebugResult; isStatusFetching: boolean; isPiMsg?: boolean; @@ -74,6 +77,7 @@ export function DestinationTransactionCard({ transaction={transaction} chainId={chainId} domainId={domainId} + duration={duration} blur={blur} /> ); @@ -190,16 +194,18 @@ function TransactionDetails({ chainId, domainId, transaction, + duration, blur, }: { chainId: ChainId; domainId: DomainId; transaction: MessageTx; + duration?: string; blur: boolean; }) { const multiProvider = useMultiProvider(); - const { hash, from, timestamp, blockNumber } = transaction; + const { hash, from, timestamp, blockNumber, mailbox } = transaction; const txExplorerLink = hash && !new BigNumber(hash).isZero() @@ -230,6 +236,16 @@ function TransactionDetails({ showCopy={true} blurValue={blur} /> + {mailbox && isAddress(mailbox) && !isZeroish(mailbox) && ( + + )} {!!timestamp && ( + {duration && ( + + )} {txExplorerLink && (