dsa-connectors/scripts/tests/buildDSAv2.ts

34 lines
1.4 KiB
TypeScript
Raw Normal View History

2021-12-05 05:23:21 +00:00
import { ethers } from "hardhat";
2021-12-05 20:15:02 +00:00
import { addresses as addressesPolygon } from "./polygon/addresses";
2021-12-10 19:44:04 +00:00
import { addresses as addressesArbitrum } from "./arbitrum/addresses";
import { addresses as addressesAvalanche } from "./avalanche/addresses";
import { addresses as addressesOptimism } from "./optimism/addresses";
2022-06-15 15:26:46 +00:00
import { addresses as addressesFantom } from "./fantom/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-05 05:23:21 +00:00
import { abi } from "../../deployements/mainnet/Implementation_m1.sol/InstaImplementationM1.json";
2021-12-05 20:04:41 +00:00
function getAddress(network: string | undefined) {
if (network === "polygon") return addressesPolygon.core.instaIndex;
2021-12-10 19:44:04 +00:00
else if (network === "arbitrum") return addressesArbitrum.core.instaIndex;
else if (network === "avalanche") return addressesAvalanche.core.instaIndex;
else if (network === "optimism") return addressesOptimism.core.instaIndex;
2022-06-15 15:26:46 +00:00
else if (network === "fantom") return addressesFantom.core.instaIndex;
2021-12-05 20:04:41 +00:00
else return addresses.core.instaIndex;
}
2021-12-05 19:10:22 +00:00
export async function buildDSAv2(owner: any) {
2021-12-05 05:23:21 +00:00
const instaIndex = await ethers.getContractAt(
abis.core.instaIndex,
2021-12-05 20:04:41 +00:00
getAddress(String(process.env.networkType))
2021-12-05 05:23:21 +00:00
);
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);
2021-12-05 19:10:22 +00:00
}