Skip to content

Commit

Permalink
fix: tryGetChainName instead of hard crashing (#137)
Browse files Browse the repository at this point in the history
use tryGetChainName instead of hard crashing for unknown domains

tested locally


![image](https://github.com/user-attachments/assets/7b6e6de5-c023-4644-af02-e8ccb5a00e0e)
  • Loading branch information
paulbalaji authored Nov 7, 2024
1 parent b8e0d31 commit b7e8e1d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/features/deliveryStatus/fetchDeliveryStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ export async function fetchDeliveryStatus(
overrideChainMetadata: ChainMap<Partial<ChainMetadata>>,
message: Message,
): Promise<MessageDeliveryStatusResponse> {
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(
Expand Down
4 changes: 2 additions & 2 deletions src/features/messages/MessageDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<>
Expand Down
4 changes: 2 additions & 2 deletions src/features/messages/MessageTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<>
Expand Down

0 comments on commit b7e8e1d

Please sign in to comment.