|
|
@ -2,12 +2,10 @@ import type { TransactionReceipt } from '@ethersproject/providers'; |
|
|
|
import { input } from '@inquirer/prompts'; |
|
|
|
import { input } from '@inquirer/prompts'; |
|
|
|
|
|
|
|
|
|
|
|
import { ChainName, HyperlaneCore, HyperlaneRelayer } from '@hyperlane-xyz/sdk'; |
|
|
|
import { ChainName, HyperlaneCore, HyperlaneRelayer } from '@hyperlane-xyz/sdk'; |
|
|
|
import { assert, parseWarpRouteMessage } from '@hyperlane-xyz/utils'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { WriteCommandContext } from '../context/types.js'; |
|
|
|
import { WriteCommandContext } from '../context/types.js'; |
|
|
|
import { log, logBlue, logGray, logGreen, logRed } from '../logger.js'; |
|
|
|
import { log, logBlue, logGreen, logRed } from '../logger.js'; |
|
|
|
import { runSingleChainSelectionStep } from '../utils/chains.js'; |
|
|
|
import { runSingleChainSelectionStep } from '../utils/chains.js'; |
|
|
|
import { stubMerkleTreeConfig } from '../utils/relay.js'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export async function checkMessageStatus({ |
|
|
|
export async function checkMessageStatus({ |
|
|
|
context, |
|
|
|
context, |
|
|
@ -31,15 +29,9 @@ export async function checkMessageStatus({ |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!messageId) { |
|
|
|
const coreAddresses = await context.registry.getAddresses(); |
|
|
|
messageId = await input({ |
|
|
|
|
|
|
|
message: 'Please specify the message id', |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const chainAddresses = await context.registry.getAddresses(); |
|
|
|
|
|
|
|
const core = HyperlaneCore.fromAddressesMap( |
|
|
|
const core = HyperlaneCore.fromAddressesMap( |
|
|
|
chainAddresses, |
|
|
|
coreAddresses, |
|
|
|
context.multiProvider, |
|
|
|
context.multiProvider, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
@ -50,6 +42,9 @@ export async function checkMessageStatus({ |
|
|
|
.getProvider(origin) |
|
|
|
.getProvider(origin) |
|
|
|
.getTransactionReceipt(dispatchTx); |
|
|
|
.getTransactionReceipt(dispatchTx); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
messageId ??= await input({ |
|
|
|
|
|
|
|
message: 'Please specify the message id', |
|
|
|
|
|
|
|
}); |
|
|
|
try { |
|
|
|
try { |
|
|
|
dispatchedReceipt = await core.getDispatchTx(origin, messageId); |
|
|
|
dispatchedReceipt = await core.getDispatchTx(origin, messageId); |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
@ -64,44 +59,24 @@ export async function checkMessageStatus({ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const messages = core.getDispatchedMessages(dispatchedReceipt!); |
|
|
|
const messages = core.getDispatchedMessages(dispatchedReceipt); |
|
|
|
const match = messages.find((m) => m.id === messageId); |
|
|
|
|
|
|
|
assert(match, `Message ${messageId} not found in dispatch tx ${dispatchTx}`); |
|
|
|
|
|
|
|
const message = match; |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
const { amount, recipient } = parseWarpRouteMessage(message.parsed.body); |
|
|
|
|
|
|
|
logGray(`Warping ${amount} to ${recipient}`); |
|
|
|
|
|
|
|
// eslint-disable-next-line no-empty
|
|
|
|
|
|
|
|
} catch {} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let deliveredTx: TransactionReceipt; |
|
|
|
let undelivered = []; |
|
|
|
|
|
|
|
for (const message of messages) { |
|
|
|
log(`Checking status of message ${messageId} on ${destination}`); |
|
|
|
log( |
|
|
|
const delivered = await core.isDelivered(message); |
|
|
|
`Checking status of message ${message.id} on ${message.parsed.destinationChain}`, |
|
|
|
if (delivered) { |
|
|
|
); |
|
|
|
logGreen(`Message ${messageId} was delivered`); |
|
|
|
const delivered = await core.isDelivered(message); |
|
|
|
deliveredTx = await core.getProcessedReceipt(message); |
|
|
|
if (delivered) { |
|
|
|
} else { |
|
|
|
logGreen(`Message ${message.id} was delivered`); |
|
|
|
logBlue(`Message ${messageId} was not yet delivered`); |
|
|
|
} else { |
|
|
|
|
|
|
|
logBlue(`Message ${message.id} was not yet delivered`); |
|
|
|
if (!selfRelay) { |
|
|
|
undelivered.push(message); |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (selfRelay) { |
|
|
|
const relayer = new HyperlaneRelayer({ core }); |
|
|
|
const relayer = new HyperlaneRelayer({ core }); |
|
|
|
|
|
|
|
await relayer.relayAll(dispatchedReceipt, undelivered); |
|
|
|
const hookAddress = await core.getSenderHookAddress(message); |
|
|
|
|
|
|
|
const merkleAddress = chainAddresses[origin].merkleTreeHook; |
|
|
|
|
|
|
|
stubMerkleTreeConfig(relayer, origin, hookAddress, merkleAddress); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
deliveredTx = await relayer.relayMessage(dispatchedReceipt); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
logGreen( |
|
|
|
|
|
|
|
`Message ${messageId} delivered in ${ |
|
|
|
|
|
|
|
context.multiProvider.tryGetExplorerTxUrl(message.parsed.destination, { |
|
|
|
|
|
|
|
hash: deliveredTx.transactionHash, |
|
|
|
|
|
|
|
}) ?? deliveredTx.transactionHash |
|
|
|
|
|
|
|
}`,
|
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|