Skip to content

Commit 9370668

Browse files
committed
refactor(rebalancer): use SealevelCoreAdapter.parseMessageDispatchLogs for Sealevel message ID extraction
Replaced inline regex duplication with the SDK's existing static method, keeping the parsing logic in a single source of truth.
1 parent 2585025 commit 9370668

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

typescript/rebalancer/src/core/InventoryRebalancer.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
type MultiProvider,
99
Token,
1010
ProviderType,
11+
SealevelCoreAdapter,
1112
TOKEN_COLLATERALIZED_STANDARDS,
1213
TokenAmount,
1314
type WarpTypedTransaction,
@@ -16,7 +17,12 @@ import {
1617
getSignerForChain,
1718
type TypedTransactionReceipt,
1819
} from '@hyperlane-xyz/sdk';
19-
import { ProtocolType, assert, isZeroishAddress } from '@hyperlane-xyz/utils';
20+
import {
21+
ProtocolType,
22+
assert,
23+
ensure0x,
24+
isZeroishAddress,
25+
} from '@hyperlane-xyz/utils';
2026

2127
import type { ExternalBridgeType } from '../config/types.js';
2228
import type {
@@ -1045,11 +1051,8 @@ export class InventoryRebalancer implements IInventoryRebalancer {
10451051
| string[]
10461052
| undefined;
10471053
if (!logs) return undefined;
1048-
const regex = /Dispatched message to (.*), ID (.*)/;
1049-
const dispatchLog = logs.find((log) => regex.test(log));
1050-
if (!dispatchLog) return undefined;
1051-
const [, _destination, messageId] = regex.exec(dispatchLog) ?? [];
1052-
return messageId ? `0x${messageId.replace(/^0x/, '')}` : undefined;
1054+
const parsed = SealevelCoreAdapter.parseMessageDispatchLogs(logs);
1055+
return parsed[0]?.messageId ? ensure0x(parsed[0].messageId) : undefined;
10531056
}
10541057

10551058
return undefined;

0 commit comments

Comments
 (0)