Fix Mailbox address fetching

pull/53/head
Nam Chu Hoai 1 year ago
parent a649e33efe
commit 6fdca9bc22
  1. 13
      src/features/chains/utils.ts
  2. 3
      src/features/debugger/debugMessage.ts
  3. 3
      src/features/deliveryStatus/fetchDeliveryStatus.ts

@ -1,12 +1,23 @@
import { type MultiProvider, chainIdToMetadata } from '@hyperlane-xyz/sdk';
import {
ChainMap,
type MultiProvider,
chainIdToMetadata,
hyperlaneContractAddresses,
} from '@hyperlane-xyz/sdk';
import { toTitleCase } from '@hyperlane-xyz/utils';
import { Environment } from '../../consts/environments';
import { ChainConfig } from './chainConfig';
export function getChainName(mp: MultiProvider, chainId?: number) {
return mp.tryGetChainName(chainId || 0) || undefined;
}
export function getMailboxAddress(customChainConfigs: ChainMap<ChainConfig>, chainName: string) {
return customChainConfigs[chainName]?.mailbox ?? hyperlaneContractAddresses[chainName]?.mailbox;
}
export function getChainDisplayName(
mp: MultiProvider,
chainOrDomainId?: ChainId | DomainId,

@ -23,6 +23,7 @@ import { MAILBOX_VERSION } from '../../consts/environments';
import { Message } from '../../types';
import { logger } from '../../utils/logger';
import type { ChainConfig } from '../chains/chainConfig';
import { getMailboxAddress } from '../chains/utils';
import { isIcaMessage, tryDecodeIcaBody, tryFetchIcaAddress } from '../messages/ica';
import { GasPayment, IsmModuleTypes, MessageDebugResult, MessageDebugStatus } from './types';
@ -68,7 +69,7 @@ export async function debugMessage(
const recipInvalid = await isInvalidRecipient(destProvider, recipient);
if (recipInvalid) return recipInvalid;
const destMailbox = customChainConfigs[destName]?.mailbox;
const destMailbox = getMailboxAddress(customChainConfigs, destName);
if (!destMailbox)
throw new Error(`Cannot debug message, no mailbox address provided for chain ${destName}`);

@ -7,6 +7,7 @@ import { Message, MessageStatus } from '../../types';
import { logger } from '../../utils/logger';
import { toDecimalNumber } from '../../utils/number';
import type { ChainConfig } from '../chains/chainConfig';
import { getMailboxAddress } from '../chains/utils';
import { debugMessage } from '../debugger/debugMessage';
import { MessageDebugStatus } from '../debugger/types';
@ -23,7 +24,7 @@ export async function fetchDeliveryStatus(
message: Message,
): Promise<MessageDeliveryStatusResponse> {
const destName = multiProvider.getChainName(message.destinationChainId);
const destMailboxAddr = customChainConfigs[destName]?.mailbox;
const destMailboxAddr = getMailboxAddress(customChainConfigs, destName);
if (!destMailboxAddr)
throw new Error(
`Cannot check delivery status, no mailbox address provided for chain ${destName}`,

Loading…
Cancel
Save