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-10 19:44:04 +00:00
|
|
|
import { addresses as addressesArbitrum } from "./arbitrum/addresses";
|
|
|
|
import { addresses as addressesAvalanche } from "./avalanche/addresses";
|
2022-04-06 15:55:49 +00:00
|
|
|
import { addresses as addressesOptimism } from "./optimism/addresses";
|
2021-12-10 19:44:04 +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;
|
2021-12-10 19:44:04 +00:00
|
|
|
else if (network === "arbitrum") return addressesArbitrum.core.instaIndex;
|
|
|
|
else if (network === "avalanche") return addressesAvalanche.core.instaIndex;
|
2022-04-06 15:55:49 +00:00
|
|
|
else if (network === "optimism") return addressesOptimism.core.instaIndex;
|
2021-12-05 20:04:41 +00:00
|
|
|
else return addresses.core.instaIndex;
|
|
|
|
}
|
|
|
|
|
2021-11-29 17:21:11 +00:00
|
|
|
export async function getMasterSigner() {
|
2021-06-04 10:47:16 +00:00
|
|
|
const [_, __, ___, wallet3] = await ethers.getSigners();
|
|
|
|
const instaIndex = new ethers.Contract(
|
2021-12-05 20:04:41 +00:00
|
|
|
getAddress(String(process.env.networkType)),
|
2021-06-04 10:47:16 +00:00
|
|
|
abis.core.instaIndex,
|
|
|
|
wallet3
|
|
|
|
);
|
2021-05-14 19:16:54 +00:00
|
|
|
|
2021-12-10 19:44:04 +00:00
|
|
|
const masterAddress = await instaIndex.master();
|
2021-11-29 17:21:11 +00:00
|
|
|
await network.provider.request({
|
2021-06-04 10:47:16 +00:00
|
|
|
method: "hardhat_impersonateAccount",
|
|
|
|
params: [masterAddress],
|
|
|
|
});
|
2021-12-10 19:44:04 +00:00
|
|
|
|
|
|
|
await network.provider.send("hardhat_setBalance", [
|
|
|
|
masterAddress,
|
|
|
|
"0x8ac7230489e80000", // 1e19 wei
|
|
|
|
]);
|
2021-05-14 19:16:54 +00:00
|
|
|
|
2021-06-04 10:47:16 +00:00
|
|
|
return await ethers.getSigner(masterAddress);
|
2021-11-29 17:21:11 +00:00
|
|
|
}
|