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

36 lines
1.2 KiB
TypeScript

import { ethers, network } from "hardhat";
import { addresses } from "./mainnet/addresses";
import { addresses as addressesPolygon } from "./polygon/addresses";
import { addresses as addressesArbitrum } from "./arbitrum/addresses";
import { addresses as addressesAvalanche } from "./avalanche/addresses";
import { abis } from "../constant/abis";
function getAddress(network: string | undefined) {
if (network === "polygon") return addressesPolygon.core.instaIndex;
else if (network === "arbitrum") return addressesArbitrum.core.instaIndex;
else if (network === "avalanche") return addressesAvalanche.core.instaIndex;
else return addresses.core.instaIndex;
}
export async function getMasterSigner() {
const [_, __, ___, wallet3] = await ethers.getSigners();
const instaIndex = new ethers.Contract(
getAddress(String(process.env.networkType)),
abis.core.instaIndex,
wallet3
);
const masterAddress = await instaIndex.master();
await network.provider.request({
method: "hardhat_impersonateAccount",
params: [masterAddress],
});
await network.provider.send("hardhat_setBalance", [
masterAddress,
"0x8ac7230489e80000", // 1e19 wei
]);
return await ethers.getSigner(masterAddress);
}