-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.js
59 lines (52 loc) · 1.68 KB
/
deploy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const hre = require("hardhat");
async function deploy(deployer, contractName, args = []) {
const factory = await hre.ethers.getContractFactory(contractName);
const contract = await factory.connect(deployer).deploy(...args);
await contract.waitForDeployment();
return contract;
}
async function deployIBC(deployer) {
const logicNames = [
"IBCClient",
"IBCConnectionSelfStateNoValidation",
"IBCChannelHandshake",
"IBCChannelPacketSendRecv",
"IBCChannelPacketTimeout",
"IBCChannelUpgradeInitTryAck",
"IBCChannelUpgradeConfirmOpenTimeoutCancel"
];
const logics = [];
for (const name of logicNames) {
const logic = await deploy(deployer, name);
logics.push(logic.target);
}
return await deploy(deployer, "OwnableIBCHandler", logics);
}
async function main() {
// This is just a convenience check
if (network.name === "hardhat") {
console.warn(
"You are trying to deploy a contract to the Hardhat Network, which" +
"gets automatically created and destroyed every time. Use the Hardhat" +
" option '--network localhost'"
);
}
// ethers is available in the global scope
const [deployer] = await hre.ethers.getSigners();
console.log(
"Deploying the contracts with the account:",
await deployer.getAddress()
);
console.log("Account balance:", (await hre.ethers.provider.getBalance(deployer.getAddress())).toString());
const ibcHandler = await deployIBC(deployer);
console.log("IBCHandler address:", ibcHandler.target);
}
if (require.main === module) {
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
}
exports.deployIBC = deployIBC;