Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Kathy sending from PolygonZkEvm & require MultiProtocolProvider chains to match addresses in MultiProtocolApp #3001

Merged
merged 7 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion typescript/helloworld/src/multiProtocolApp/evmAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class EvmHelloWorldAdapter
destination: ChainName,
message: string,
value: string,
sender: Address,
tkporter marked this conversation as resolved.
Show resolved Hide resolved
): Promise<EthersV5Transaction> {
const contract = this.getConnectedContract();
const toDomain = this.multiProvider.getDomainId(destination);
Expand All @@ -44,7 +45,14 @@ export class EvmHelloWorldAdapter
const estimated = await contract.estimateGas.sendHelloWorld(
toDomain,
message,
{ ...transactionOverrides, value: BigNumber.from(value).add(quote) },
{
...transactionOverrides,
// Some networks, like PolygonZkEvm, require a `from` address
// with funds to be specified when estimating gas for a transaction
// that provides non-zero `value`.
from: sender,
value: BigNumber.from(value).add(quote),
},
);
const gasLimit = estimated.mul(12).div(10);

Expand Down
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
17 changes: 17 additions & 0 deletions 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,6 +121,22 @@ export abstract class MultiProtocolApp<
public readonly addresses: ChainMap<ContractAddrs>,
public readonly logger = debug('hyperlane:MultiProtocolApp'),
) {
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
Loading