dsa-connectors/scripts/tests/getMasterSigner.ts

33 lines
1.1 KiB
TypeScript
Raw Normal View History

2021-11-29 17:21:11 +00:00
import { ethers, network } from "hardhat";
2021-12-05 20:04:41 +00:00
import { addresses } from "./mainnet/addresses";
2021-12-05 20:11:21 +00:00
import { addresses as addressesPolygon } from "./polygon/addresses";
2021-12-05 19:10:22 +00:00
import { abis } from "../constant/abis";
2021-05-14 19:16:54 +00:00
2021-12-05 20:04:41 +00:00
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;
}
2021-11-29 17:21:11 +00:00
export async function getMasterSigner() {
const [_, __, ___, wallet3] = await ethers.getSigners();
const instaIndex = new ethers.Contract(
2021-12-05 20:04:41 +00:00
getAddress(String(process.env.networkType)),
abis.core.instaIndex,
wallet3
);
2021-05-14 19:16:54 +00:00
const masterAddress = await instaIndex.master(); // TODO: make it constant?
2021-11-29 17:21:11 +00:00
await network.provider.request({
method: "hardhat_impersonateAccount",
params: [masterAddress],
});
await wallet3.sendTransaction({
to: masterAddress,
value: ethers.utils.parseEther("10"),
});
2021-05-14 19:16:54 +00:00
return await ethers.getSigner(masterAddress);
2021-11-29 17:21:11 +00:00
}