dsa-connectors/scripts/deployment/deployConnector.ts

37 lines
964 B
TypeScript
Raw Normal View History

2021-12-26 07:47:07 +00:00
import hre, { ethers } from "hardhat";
2021-11-29 17:21:11 +00:00
import { execScript } from "../tests/command";
export const deployConnector = async (connectorName?: string) => {
connectorName = String(process.env.connectorName) ?? connectorName;
2021-11-29 17:21:11 +00:00
const Connector = await ethers.getContractFactory(connectorName);
const connector = await Connector.deploy();
await connector.deployed();
console.log(`${connectorName} Deployed: ${connector.address}`);
2021-12-26 07:47:07 +00:00
2022-01-11 08:19:13 +00:00
const chain = String(hre.network.name);
if (chain !== "hardhat") {
try {
await execScript({
cmd: "npx",
args: [
"hardhat",
"verify",
"--network",
`${chain}`,
`${connector.address}`,
],
env: {
networkType: chain,
},
});
} catch (error) {
console.log(`Failed to verify: ${connectorName}@${connector.address}`);
console.log(error);
console.log();
}
2021-12-26 07:47:07 +00:00
}
2022-01-11 08:19:13 +00:00
2021-11-29 17:21:11 +00:00
return connector.address;
};