mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
28 lines
1.0 KiB
TypeScript
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);
|
|
}
|