Skip to content

Commit

Permalink
Require multiprovider known chains to match the addresses in MultiPro…
Browse files Browse the repository at this point in the history
…tocolApp
  • Loading branch information
tkporter committed Nov 30, 2023
1 parent 3b44c7d commit b0f111d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion typescript/infra/scripts/helloworld/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export async function getHelloWorldMultiProtocolApp(
}),
);
const app = new HelloMultiProtocolApp(
multiProtocolProvider,
multiProtocolProvider.intersect(Object.keys(routersAndMailboxes)).result,
routersAndMailboxes,
);

Expand Down
18 changes: 17 additions & 1 deletion typescript/sdk/src/app/MultiProtocolApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
ProtocolType,
objMap,
promiseObjAll,
symmetricDifference,
} from '@hyperlane-xyz/utils';

import { ChainMetadata } from '../metadata/chainMetadataTypes';
Expand Down Expand Up @@ -120,7 +121,22 @@ export abstract class MultiProtocolApp<
public readonly addresses: ChainMap<ContractAddrs>,
public readonly logger = debug('hyperlane:MultiProtocolApp'),
) {
multiProvider = multiProvider.intersect(Object.keys(addresses)).result;
const multiProviderChains = multiProvider.getKnownChainNames();
const addressesChains = Object.keys(addresses);
const setDifference = symmetricDifference(
new Set(multiProviderChains),
new Set(addressesChains),
);
if (setDifference.size > 0) {
throw new Error(
`MultiProtocolProvider and addresses must have the same chains. Provider chains: ${multiProviderChains.join(
', ',
)}. Addresses chains: ${addressesChains.join(
', ',
)}. Difference: ${Array.from(setDifference)}`,
);
}

super(multiProvider.metadata);
}

Expand Down

0 comments on commit b0f111d

Please sign in to comment.