From b7e8e1dcd339f458ad4c6b4901efd5169a301ec4 Mon Sep 17 00:00:00 2001 From: Paul Balaji <10051819+paulbalaji@users.noreply.github.com> Date: Thu, 7 Nov 2024 16:22:59 +0000 Subject: [PATCH] fix: tryGetChainName instead of hard crashing (#137) use tryGetChainName instead of hard crashing for unknown domains tested locally ![image](https://github.com/user-attachments/assets/7b6e6de5-c023-4644-af02-e8ccb5a00e0e) --- src/features/deliveryStatus/fetchDeliveryStatus.ts | 6 +++++- src/features/messages/MessageDetails.tsx | 4 ++-- src/features/messages/MessageTable.tsx | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/features/deliveryStatus/fetchDeliveryStatus.ts b/src/features/deliveryStatus/fetchDeliveryStatus.ts index 42e3081..ca6a994 100644 --- a/src/features/deliveryStatus/fetchDeliveryStatus.ts +++ b/src/features/deliveryStatus/fetchDeliveryStatus.ts @@ -25,7 +25,11 @@ export async function fetchDeliveryStatus( overrideChainMetadata: ChainMap>, message: Message, ): Promise { - const destName = multiProvider.getChainName(message.destinationDomainId); + const destName = multiProvider.tryGetChainName(message.destinationDomainId); + if (!destName) + throw new Error( + `Cannot check delivery status, no chain name provided for domain ${message.destinationDomainId}`, + ); const destMailboxAddr = await getMailboxAddress(destName, overrideChainMetadata, registry); if (!destMailboxAddr) throw new Error( diff --git a/src/features/messages/MessageDetails.tsx b/src/features/messages/MessageDetails.tsx index af98d45..0113e9f 100644 --- a/src/features/messages/MessageDetails.tsx +++ b/src/features/messages/MessageDetails.tsx @@ -88,8 +88,8 @@ export function MessageDetails({ messageId, message: messageFromUrlParams }: Pro // Banner color setter useDynamicBannerColor(isFetching, status, isMessageFound, isError || isPiError); - const originChainName = multiProvider.getChainName(originDomainId); - const destinationChainName = multiProvider.getChainName(destinationDomainId); + const originChainName = multiProvider.tryGetChainName(originDomainId) || 'Unknown'; + const destinationChainName = multiProvider.tryGetChainName(destinationDomainId) || 'Unknown'; return ( <> diff --git a/src/features/messages/MessageTable.tsx b/src/features/messages/MessageTable.tsx index a307d15..e4afc59 100644 --- a/src/features/messages/MessageTable.tsx +++ b/src/features/messages/MessageTable.tsx @@ -67,8 +67,8 @@ export function MessageSummaryRow({ message, mp }: { message: MessageStub; mp: M const base64 = message.isPiMsg ? serializeMessage(message) : undefined; - const originChainName = mp.getChainName(originDomainId); - const destinationChainName = mp.getChainName(destinationDomainId); + const originChainName = mp.tryGetChainName(originDomainId) || 'Unknown'; + const destinationChainName = mp.tryGetChainName(destinationDomainId) || 'Unknown'; return ( <>