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 19:44:04 +00:00
|
|
|
import { abis } from "../constant/abis";
|
2021-12-10 22:12:05 +00:00
|
|
|
import { addresses as addressesArbitrum } from "./arbitrum/addresses";
|
|
|
|
import { addresses as addressesAvalanche } from "./avalanche/addresses";
|
2022-04-06 15:55:49 +00:00
|
|
|
import { addresses as addressesOptimism } from "./optimism/addresses";
|
2022-06-15 15:26:46 +00:00
|
|
|
import { addresses as addressesFantom } from "./fantom/addresses";
|
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;
|
2021-12-10 22:12:05 +00:00
|
|
|
else if (network === "arbitrum") return addressesArbitrum;
|
|
|
|
else if (network === "avalanche") return addressesAvalanche;
|
2022-04-06 15:55:49 +00:00
|
|
|
else if (network === "optimism") return addressesOptimism;
|
2022-06-15 15:26:46 +00:00
|
|
|
else if (network === "fantom") return addressesFantom;
|
2021-12-05 20:04:41 +00:00
|
|
|
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;
|
|
|
|
}
|