Skip to content

Commit

Permalink
Migrate from config object to address map
Browse files Browse the repository at this point in the history
  • Loading branch information
yorhodes committed Jul 27, 2023
1 parent c7ad0f4 commit a8e35be
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 16 deletions.
31 changes: 20 additions & 11 deletions typescript/infra/config/environments/mainnet2/core.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
import {
AggregationIsmConfig,
ChainMap,
CoreConfig,
objMap,
} from '@hyperlane-xyz/sdk';
import { ChainMap, Chains, CoreConfig, objMap } from '@hyperlane-xyz/sdk';

import { aggregationIsm } from '../../aggregationIsm';
import { Contexts } from '../../contexts';

import { owners } from './owners';

const aggregationIsmAddresses: Record<string, string> = {
[Chains.arbitrum]: '0x7995D00bdDb146334d6568b627bcd2a7DdA3B005',
[Chains.avalanche]: '0xF6bF41939ebA2363A6e311E886Ed4a5ab3dc1F5D',
[Chains.bsc]: '0x294F19d5fe29646f8E2cA4A71b6B18b78db10F9f',
[Chains.celo]: '0x656bF500F0E2EE55F26dF3bc69b44c6eA84dd065',
[Chains.ethereum]: '0xe39eA548F36d1c3DA9b871Badd11345f836a290A',
[Chains.gnosis]: '0xD0Ec4de35069520CD17522281D36DD299525d85f',
[Chains.moonbeam]: '0x04100049AC8e279C85E895d48aab1E188152e939',
[Chains.optimism]: '0x99663d142576204284b91e96d39771db94eD5188',
[Chains.polygon]: '0x0673cc1cc5eb80816E0d0E2dA5FE10053Da97943',
};

export const core: ChainMap<CoreConfig> = objMap(owners, (local, owner) => {
const defaultIsm: AggregationIsmConfig = aggregationIsm(
'mainnet2',
local,
Contexts.Hyperlane,
);
const defaultIsm = aggregationIsmAddresses[local];

// const defaultIsm: AggregationIsmConfig = aggregationIsm(
// 'mainnet2',
// local,
// Contexts.Hyperlane,
// );

if (local === 'arbitrum') {
return {
Expand Down
8 changes: 6 additions & 2 deletions typescript/sdk/src/core/HyperlaneCoreDeployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class HyperlaneCoreDeployer extends HyperlaneDeployer<

async deployMailbox(
chain: ChainName,
ismConfig: IsmConfig,
ismConfig: IsmConfig | types.Address,
proxyAdmin: types.Address,
owner: types.Address,
): Promise<Mailbox> {
Expand All @@ -53,7 +53,11 @@ export class HyperlaneCoreDeployer extends HyperlaneDeployer<
return cachedMailbox;
}

const defaultIsmAddress = await this.deployIsm(chain, ismConfig);
const defaultIsmAddress =
typeof ismConfig === 'string'
? ismConfig
: await this.deployIsm(chain, ismConfig);

const domain = this.multiProvider.getDomainId(chain);
return this.deployProxiedContract(
chain,
Expand Down
2 changes: 1 addition & 1 deletion typescript/sdk/src/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { IsmConfig } from '../ism/types';
import { ChainName } from '../types';

export type CoreConfig = {
defaultIsm: IsmConfig;
defaultIsm: IsmConfig | types.Address;
owner: types.Address;
remove?: boolean;
upgrade?: UpgradeConfig;
Expand Down
14 changes: 12 additions & 2 deletions typescript/sdk/src/ism/HyperlaneIsmFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,11 +356,15 @@ export async function moduleCanCertainlyVerify(
export async function moduleMatchesConfig(
chain: ChainName,
moduleAddress: types.Address,
config: IsmConfig,
config: IsmConfig | types.Address,
multiProvider: MultiProvider,
contracts: HyperlaneContracts<IsmFactoryFactories>,
origin?: ChainName,
): Promise<boolean> {
if (typeof config === 'string') {
return utils.eqAddress(moduleAddress, config);
}

const provider = multiProvider.getProvider(chain);
const module = IInterchainSecurityModule__factory.connect(
moduleAddress,
Expand Down Expand Up @@ -483,8 +487,14 @@ export async function moduleMatchesConfig(

export function collectValidators(
origin: ChainName,
config: IsmConfig,
config: IsmConfig | types.Address,
): Set<string> {
// TODO: support address configurations in collectValidators
if (typeof config === 'string') {
console.warn('Validators not fetched from address ISM config');
return new Set([]);
}

let validators: string[] = [];
if (
config.type === ModuleType.MERKLE_ROOT_MULTISIG ||
Expand Down

0 comments on commit a8e35be

Please sign in to comment.