dsa-connectors/scripts/tests/deployAndEnableConnector.ts

46 lines
1.3 KiB
TypeScript
Raw Normal View History

2021-12-05 20:15:02 +00:00
import { addresses as addressesPolygon } from "./polygon/addresses";
2021-12-05 20:04:41 +00:00
import { addresses } from "./mainnet/addresses";
2021-12-10 17:29:55 +00:00
import abis from "../constant/abis";
2021-11-29 17:21:11 +00:00
2021-12-05 21:24:36 +00:00
import hre from "hardhat";
import type { Signer, Contract } from "ethers";
import type { ContractJSON } from "ethereum-waffle/dist/esm/ContractJSON";
const { ethers, waffle } = hre;
const { deployContract } = waffle;
interface DeployInterface {
connectorName: string;
contractArtifact: ContractJSON;
signer: Signer;
connectors: Contract;
}
2021-12-05 20:04:41 +00:00
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;
}
2021-12-05 21:24:36 +00:00
export async function deployAndEnableConnector(
{
connectorName,
contractArtifact,
signer,
connectors
} : DeployInterface
) {
const connectorInstanace: Contract = await deployContract(signer, contractArtifact);
2021-11-29 17:21:11 +00:00
await connectors
.connect(signer)
.addConnectors([connectorName], [connectorInstanace.address]);
2021-12-05 20:04:41 +00:00
getAddress(String(process.env.networkType)).connectors[connectorName] =
connectorInstanace.address;
2021-11-29 17:21:11 +00:00
abis.connectors[connectorName] = contractArtifact.abi;
return connectorInstanace;
}