dsa-connectors/scripts/tests/deployAndEnableConnector.ts
pradyuman-verma a4c6b685c7 update
2021-12-11 13:37:45 +05:30

36 lines
1.1 KiB
TypeScript

import { addresses as addressesPolygon } from "./polygon/addresses";
import { addresses } from "./mainnet/addresses";
import { abis } from "../constant/abis";
// const { deployContract } = waffle;
// import { ethers } from "hardhat";
// import { promises as fs } from "fs";
// import { deployContract } from "ethereum-waffle";
function getAddress(network: string | undefined) {
if (network === "polygon") return addressesPolygon;
// else if (network === "arbitrum") return addressesPolygon;
// else if (network === "avalanche") return addressesPolygon;
else return addresses;
}
export async function deployAndEnableConnector({
connectorName,
contractArtifact,
signer,
connectors,
}) {
const deployer = new contractArtifact(signer);
const connectorInstanace = await deployer.deploy();
await connectors
.connect(signer)
.addConnectors([connectorName], [connectorInstanace.address]);
getAddress(String(process.env.networkType)).connectors[connectorName] =
connectorInstanace.address;
abis.connectors[connectorName] = contractArtifact.abi;
return connectorInstanace;
}