mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import { addresses as addressesPolygon } from "./polygon/addresses";
|
|
import { addresses } from "./mainnet/addresses";
|
|
import { abis } from "../constant/abis";
|
|
|
|
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;
|
|
}
|
|
|
|
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
|
|
} : DeployInterface
|
|
) {
|
|
const connectorInstanace: Contract = await deployContract(signer, contractArtifact);
|
|
|
|
await connectors
|
|
.connect(signer)
|
|
.addConnectors([connectorName], [connectorInstanace.address]);
|
|
|
|
getAddress(String(process.env.networkType)).connectors[connectorName] =
|
|
connectorInstanace.address;
|
|
abis.connectors[connectorName] = contractArtifact.abi;
|
|
|
|
return connectorInstanace;
|
|
}
|