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

feat: Create EvmCoreModule with create() #3737

Merged
merged 32 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
638a555
Add ICAModule initial
ltyu May 7, 2024
854a14c
Add create() logic to deploy new ICA Router
ltyu May 8, 2024
f7514fd
Fix logger name
ltyu May 8, 2024
4b0b40a
Add initial commit
ltyu May 8, 2024
7ce2753
[WIP] Add CoreModule.create() logic. Update test config
ltyu May 8, 2024
6fed190
Add mailbox deploy logic, and rest of Core deploy
ltyu May 9, 2024
1fd67f9
Add unit tests for owners
ltyu May 9, 2024
e6ce66d
Remove only
ltyu May 9, 2024
2f17587
Add docs
ltyu May 9, 2024
412a7ce
Add initial commit
ltyu May 8, 2024
c5b68a4
[WIP] Add CoreModule.create() logic. Update test config
ltyu May 8, 2024
f5ae0a6
Add mailbox deploy logic, and rest of Core deploy
ltyu May 9, 2024
794d87b
Add unit tests for owners
ltyu May 9, 2024
4bf300e
Remove only
ltyu May 9, 2024
20e04ea
Add docs
ltyu May 9, 2024
c163375
Fix conflicts
ltyu May 16, 2024
14a81c0
nan ism module for cherry-picking
paulbalaji May 16, 2024
02c8c67
Remove comment
ltyu May 16, 2024
410070e
Update according to review comments
ltyu May 23, 2024
c9eaa23
Add timelock logic
ltyu May 23, 2024
c904b84
Clean up Module
ltyu May 23, 2024
1fe6d96
Update typescript/sdk/src/core/EvmCoreModule.ts
ltyu May 24, 2024
c589a28
Update typescript/sdk/src/core/EvmCoreModule.ts
ltyu May 24, 2024
fdb7680
Update typescript/sdk/src/core/EvmCoreModule.ts
ltyu May 24, 2024
6ec2516
Update typescript/sdk/src/core/EvmCoreModule.ts
ltyu May 24, 2024
88ff03a
Update typescript/sdk/src/core/EvmCoreModule.ts
ltyu May 24, 2024
c1f207d
Update typescript/sdk/src/core/EvmCoreModule.ts
ltyu May 24, 2024
10107e3
Add changeset
ltyu May 24, 2024
ce30d86
Merge branch 'cli-2.0' into ltyu/core-module
ltyu May 25, 2024
bf8558e
Remove cl
ltyu May 25, 2024
4fb0c3e
Merge branch 'ltyu/core-module' of https://github.com/hyperlane-xyz/h…
ltyu May 25, 2024
11fb842
address Yorke's comments
ltyu May 27, 2024
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
5 changes: 5 additions & 0 deletions .changeset/beige-suns-wave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hyperlane-xyz/sdk': minor
---

Add create() with EvmCoreModule
9 changes: 9 additions & 0 deletions typescript/sdk/src/contracts/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,15 @@ export function attachContractsMapAndGetForeignDeployments<
};
}

export function attachAndConnectContracts<F extends HyperlaneFactories>(
addresses: HyperlaneAddresses<F>,
factories: F,
connection: Connection,
): HyperlaneContracts<F> {
const contracts = attachContracts(addresses, factories);
return connectContracts(contracts, connection);
}

export function connectContracts<F extends HyperlaneFactories>(
contracts: HyperlaneContracts<F>,
connection: Connection,
Expand Down
158 changes: 158 additions & 0 deletions typescript/sdk/src/core/EvmCoreModule.hardhat-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers.js';
import { expect } from 'chai';
import { constants } from 'ethers';
import hre from 'hardhat';

import {
Mailbox__factory,
ProxyAdmin__factory,
TestRecipient__factory,
TimelockController__factory,
ValidatorAnnounce__factory,
} from '@hyperlane-xyz/core';
import { objMap } from '@hyperlane-xyz/utils';

import { TestChainName } from '../consts/testChains.js';
import { MultiProvider } from '../providers/MultiProvider.js';
import { testCoreConfig } from '../test/testUtils.js';

import { EvmCoreModule } from './EvmCoreModule.js';

describe('EvmCoreModule', async () => {
const DELAY = 1892391283182;
let signer: SignerWithAddress;
let multiProvider: MultiProvider;
let evmCoreModule: EvmCoreModule;
let proxyAdminContract: any;
let mailboxContract: any;
let validatorAnnounceContract: any;
let testRecipientContract: any;
let timelockControllerContract: any;

before(async () => {
[signer] = await hre.ethers.getSigners();
multiProvider = MultiProvider.createTestMultiProvider({ signer });
const config = {
...testCoreConfig([TestChainName.test1])[TestChainName.test1],
upgrade: {
timelock: {
delay: DELAY,
roles: {
executor: signer.address,
proposer: signer.address,
},
},
},
};

evmCoreModule = await EvmCoreModule.create({
chain: TestChainName.test1,
config,
multiProvider,
});

const {
proxyAdmin,
mailbox,
validatorAnnounce,
testRecipient,
timelockController,
} = evmCoreModule.serialize();

proxyAdminContract = ProxyAdmin__factory.connect(
proxyAdmin!,
multiProvider.getProvider(TestChainName.test1),
);

mailboxContract = Mailbox__factory.connect(
mailbox!,
multiProvider.getProvider(TestChainName.test1),
);

validatorAnnounceContract = ValidatorAnnounce__factory.connect(
validatorAnnounce!,
multiProvider.getProvider(TestChainName.test1),
);

testRecipientContract = TestRecipient__factory.connect(
testRecipient!,
multiProvider.getProvider(TestChainName.test1),
);

timelockControllerContract = TimelockController__factory.connect(
timelockController!,
multiProvider.getProvider(TestChainName.test1),
);
});

describe('Create', async () => {
it('should create deploy an ICA', () => {
const { interchainAccountRouter, interchainAccountIsm } =
evmCoreModule.serialize();
expect(interchainAccountIsm).to.exist;
expect(interchainAccountRouter).to.exist;
});

it('should deploy ISM factories', () => {
// Each ISM factory
objMap(
evmCoreModule.serialize().ismFactoryFactories,
(_: any, factoryAddress: any) => {
expect(factoryAddress).to.exist;
expect(factoryAddress).to.not.equal(constants.AddressZero);
},
);
});

it('should deploy proxyAdmin', () => {
expect(evmCoreModule.serialize().proxyAdmin).to.exist;
});

it('should set proxyAdmin owner to deployer', async () => {
expect(await proxyAdminContract.owner()).to.equal(signer.address);
});

it('should deploy mailbox', () => {
expect(evmCoreModule.serialize().mailbox).to.exist;
});

it('should set mailbox owner to proxyAdmin', async () => {
expect(await mailboxContract.owner()).to.equal(
evmCoreModule.serialize().proxyAdmin,
);
});

it('should deploy mailbox default Ism', async () => {
expect(await mailboxContract.defaultIsm()).to.not.equal(
constants.AddressZero,
);
});

it('should deploy mailbox default hook', async () => {
expect(await mailboxContract.defaultHook()).to.not.equal(
constants.AddressZero,
);
});

it('should deploy mailbox required hook', async () => {
expect(await mailboxContract.requiredHook()).to.not.equal(
constants.AddressZero,
);
});

it('should deploy validatorAnnounce', async () => {
expect(evmCoreModule.serialize().validatorAnnounce).to.exist;
expect(await validatorAnnounceContract.owner()).to.equal(signer.address);
});

it('should deploy testRecipient', async () => {
expect(evmCoreModule.serialize().testRecipient).to.exist;
expect(await testRecipientContract.owner()).to.equal(signer.address);
});

it('should deploy timelock if upgrade is set', async () => {
expect(evmCoreModule.serialize().timelockController).to.exist;
expect(await timelockControllerContract.getMinDelay()).to.equal(DELAY);
});
});
});
Loading
Loading