From ee21e26369c4761db46f67c37d608dfbb2a70f60 Mon Sep 17 00:00:00 2001 From: tcar121293 Date: Fri, 20 Sep 2024 15:41:17 +0200 Subject: [PATCH] fix: handle unknown error messages (#222) * handle unknown error messages; Signed-off-by: tcar * lint code; Signed-off-by: tcar --------- Signed-off-by: tcar --- src/indexer/utils/evm/index.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/indexer/utils/evm/index.ts b/src/indexer/utils/evm/index.ts index 36f04d12..93bc2efc 100644 --- a/src/indexer/utils/evm/index.ts +++ b/src/indexer/utils/evm/index.ts @@ -229,11 +229,19 @@ export async function getFee(provider: Provider, feeHandlerRouterAddress: string export function parseFailedHandlerExecution(log: Log, decodedLog: LogDescription, blockUnixTimestamp: number): DecodedFailedHandlerExecution { const originDomainID = decodedLog.args.originDomainID as number const errorData = decodedLog.args.lowLevelData as ArrayBuffer + let errMsg + + try { + errMsg = ethers.decodeBytes32String("0x" + Buffer.from(errorData.slice(-64)).toString()) + } catch (err) { + errMsg = "Unknown error type, raw data:" + errorData.toString() + } + return { domainId: originDomainID.toString(), depositNonce: Number(decodedLog.args.depositNonce as string), txHash: log.transactionHash, - message: ethers.decodeBytes32String("0x" + Buffer.from(errorData.slice(-64)).toString()), + message: errMsg, blockNumber: log.blockNumber, timestamp: blockUnixTimestamp, }