Skip to content

Commit ac984a1

Browse files
fix: filter undefined factory addresses (#5340)
### Description When deploying Hyperlane contracts using `warp deploy`, the core addresses obtained using older version of `core deploy` may not include addresses of newer factories (`staticMessageIdWeightedMultisigIsmFactory` and `staticMessageIdWeightedMultisigIsmFactory`). These `undefined` addresses would cause warp deploy to fail, even though they aren't absolutely necessary for warping. This fix handles undefined factory addresses that are filtered out during `warp deploy`. This way, warp deploy can proceed the weighted factories, and users won't have to pay gas fees for core deployment once again to. Attached LogX chain core deployment lacking weighted factory addresses & the resulting error message from `warp deploy` ![2025-01-30 16 30 55](https://github.com/user-attachments/assets/cbe86080-a944-487f-a8d7-beb5f746b007) ![2025-01-30 16 30 39](https://github.com/user-attachments/assets/b118fe99-4894-43bf-a17b-6561d3052d31) ### Drive-by changes - Added `undefined` address filtering in the `filterAddressesMap` function ### Related issues None ### Backward compatibility Yes ### Testing Manual
1 parent ba50e62 commit ac984a1

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

.changeset/late-fishes-end.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@hyperlane-xyz/sdk': patch
3+
---
4+
5+
Fix contract address filtering to remove undefined factory addresses from the addresses map

typescript/sdk/src/contracts/contracts.ts

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Contract } from 'ethers';
1+
import { Contract, constants } from 'ethers';
22

33
import { Ownable, Ownable__factory } from '@hyperlane-xyz/core';
44
import {
@@ -12,6 +12,7 @@ import {
1212
objMap,
1313
pick,
1414
promiseObjAll,
15+
rootLogger,
1516
} from '@hyperlane-xyz/utils';
1617

1718
import { ChainMetadataManager } from '../metadata/ChainMetadataManager.js';
@@ -62,9 +63,35 @@ export function filterAddressesMap<F extends HyperlaneFactories>(
6263
const pickedAddressesMap = objMap(addressesMap, (_, addresses) =>
6364
pick(addresses, factoryKeys),
6465
);
66+
67+
const chainsWithMissingAddresses = new Set<string>();
68+
const filledAddressesMap = objMap(
69+
pickedAddressesMap,
70+
(chainName, addresses) =>
71+
objMap(addresses, (key, value) => {
72+
if (!value) {
73+
rootLogger.warn(
74+
`Missing address for contract "${key}" on chain ${chainName}`,
75+
);
76+
chainsWithMissingAddresses.add(chainName);
77+
return constants.AddressZero;
78+
}
79+
return value;
80+
}),
81+
);
82+
// Add summary warning if any addresses were missing
83+
if (chainsWithMissingAddresses.size > 0) {
84+
rootLogger.warn(
85+
`Warning: Core deployment incomplete for chain(s): ${Array.from(
86+
chainsWithMissingAddresses,
87+
).join(', ')}. ` +
88+
`Please run 'core deploy' again for these chains to fix the deployment.`,
89+
);
90+
}
91+
6592
// Filter out chains for which we do not have a complete set of addresses
6693
return objFilter(
67-
pickedAddressesMap,
94+
filledAddressesMap,
6895
(_, addresses): addresses is HyperlaneAddresses<F> => {
6996
return Object.keys(addresses).every((a) => factoryKeys.includes(a));
7097
},

0 commit comments

Comments
 (0)