The home for Hyperlane core contracts, sdk packages, and other infrastructure
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
hyperlane-monorepo/solidity/apps/test/governance/lib/GovernanceDeploy.ts

48 lines
1.4 KiB

import { ethers } from 'ethers';
import { types } from '@abacus-network/utils';
import { TestAbacusDeploy, TestRouterDeploy } from '@abacus-network/hardhat';
import { GovernanceRouter__factory, GovernanceRouter } from '../../../types';
export type Governor = {
domain: types.Domain;
address: types.Address;
};
export type GovernanceConfig = {
signer: ethers.Signer;
timelock: number;
governor: Governor;
recoveryManager: types.Address;
};
export class GovernanceDeploy extends TestRouterDeploy<
GovernanceRouter,
GovernanceConfig
> {
async deploy(abacus: TestAbacusDeploy) {
await super.deploy(abacus);
for (const domain of this.domains) {
if (domain == this.config.governor.domain) {
await this.router(domain).setGovernor(this.config.governor.address);
} else {
await this.router(domain).setGovernor(ethers.constants.AddressZero);
}
}
}
async deployInstance(
domain: types.Domain,
abacus: TestAbacusDeploy,
): Promise<GovernanceRouter> {
const routerFactory = new GovernanceRouter__factory(this.config.signer);
const router = await routerFactory.deploy(this.config.timelock);
await router.initialize(abacus.xAppConnectionManager(domain).address);
await router.transferOwnership(this.config.recoveryManager);
return router;
}
router(domain: types.Domain): GovernanceRouter {
return this.instances[domain];
}
}