dsa-connectors/scripts/tests/buildDSAv2.ts
2021-12-11 13:37:45 +05:30

28 lines
1.0 KiB
TypeScript

import { ethers } from "hardhat";
import { addresses as addressesPolygon } from "./polygon/addresses";
import { addresses } from "./mainnet/addresses";
import abis from "../constant/abis";
import { abi } from "../../deployements/mainnet/Implementation_m1.sol/InstaImplementationM1.json";
function getAddress(network: string | undefined) {
if (network === "polygon") return addressesPolygon.core.instaIndex;
// else if (network === "arbitrum") return addressesPolygon.core.instaIndex;
// else if (network === "avalanche") return addressesPolygon.core.instaIndex;
else return addresses.core.instaIndex;
}
export async function buildDSAv2(owner: any) {
const instaIndex = await ethers.getContractAt(
abis.core.instaIndex,
getAddress(String(process.env.networkType))
);
const tx = await instaIndex.build(owner, 2, owner);
const receipt = await tx.wait();
const event = receipt.events.find(
(a: { event: string }) => a.event === "LogAccountCreated"
);
return await ethers.getContractAt(abi, event.args.account);
}