Skip to content

Commit

Permalink
Adjust whitelist matching
Browse files Browse the repository at this point in the history
  • Loading branch information
yorhodes committed Nov 7, 2024
1 parent e181013 commit 3e85984
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
11 changes: 7 additions & 4 deletions typescript/sdk/src/core/HyperlaneCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,16 @@ export class HyperlaneCore extends HyperlaneApp<CoreFactories> {
mailbox.on<DispatchEvent>(
mailbox.filters.Dispatch(),
(_sender, _destination, _recipient, message, event) => {
const parsed = HyperlaneCore.parseDispatchedMessage(message);
const destChain = this.getDestination(parsed);
const dispatched = HyperlaneCore.parseDispatchedMessage(message);

// add human readable chain names
dispatched.parsed.originChain = this.getOrigin(dispatched);
dispatched.parsed.destinationChain = this.getDestination(dispatched);

this.logger.info(
`Observed message ${parsed.id} on ${originChain} to ${destChain}`,
`Observed message ${dispatched.id} on ${originChain} to ${dispatched.parsed.destinationChain}`,
);
return handler(parsed, event);
return handler(dispatched, event);
},
);
});
Expand Down
16 changes: 7 additions & 9 deletions typescript/sdk/src/core/HyperlaneRelayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,6 @@ export class HyperlaneRelayer {
whitelist,
(_chain, addresses) => new Set(addresses),
);
for (const [chain, addresses] of Object.entries(this.whitelist)) {
const chainId = this.multiProvider.getChainId(chain);
this.whitelist[chainId] = addresses;
}
}

this.backlog = [];
Expand Down Expand Up @@ -218,6 +214,12 @@ export class HyperlaneRelayer {
message = HyperlaneCore.getDispatchedMessages(dispatchTx)[messageIndex],
): Promise<ethers.ContractReceipt> {
if (this.whitelist) {
// add human readable names for use in whitelist checks
message.parsed = {
originChain: this.core.getOrigin(message),
destinationChain: this.core.getDestination(message),
...message.parsed,
};
assert(
messageMatchesWhitelist(this.whitelist, message.parsed),
`Message ${message.id} does not match whitelist`,
Expand Down Expand Up @@ -319,11 +321,7 @@ export class HyperlaneRelayer {
}

protected whitelistChains() {
return this.whitelist
? Object.keys(this.whitelist).filter(
(chain) => chain in this.core.contractsMap,
)
: undefined;
return this.whitelist ? Object.keys(this.whitelist) : undefined;
}

start(): void {
Expand Down

0 comments on commit 3e85984

Please sign in to comment.