Gelato-automations/deploy/connectors/ConnectGelatoDataFullMakerToMaker.deploy.js

86 lines
2.6 KiB
JavaScript
Raw Normal View History

const hre = require("hardhat");
2020-11-16 16:55:04 +00:00
const { ethers } = hre;
const { sleep } = require("@gelatonetwork/core");
const assert = require("assert");
2020-11-04 12:21:01 +00:00
module.exports = async (hre) => {
if (hre.network.name === "mainnet") {
console.log(
"\n\n Deploying ConnectGelatoDataFullMakerToMaker to mainnet. Hit ctrl + c to abort"
2020-11-04 12:21:01 +00:00
);
console.log("❗ CONNECTOR DEPLOYMENT: VERIFY & HARDCODE CONNECTOR ID");
console.log(`Connector Id: ${parseInt(process.env.CONNECTOR_ID)}`);
await sleep(10000);
2020-11-04 12:21:01 +00:00
}
2020-11-16 16:55:04 +00:00
const { deployments } = hre;
const { deploy } = deployments;
const { deployer } = await hre.getNamedAccounts();
2020-11-04 12:21:01 +00:00
if (hre.network.name === "hardhat") {
const deployerWallet = await ethers.provider.getSigner(deployer);
const instaMaster = await ethers.provider.getSigner(
hre.network.config.InstaMaster
);
await deployerWallet.sendTransaction({
to: await instaMaster.getAddress(),
value: ethers.utils.parseEther("0.1"),
});
await hre.network.provider.request({
method: "hardhat_impersonateAccount",
params: [await instaMaster.getAddress()],
});
const instaConnectors = await hre.ethers.getContractAt(
2020-11-25 10:50:24 +00:00
"InstaConnectors",
hre.network.config.InstaConnectors
);
const connectorLength = await instaConnectors.connectorLength();
const connectorId = connectorLength.add(1);
await deploy("ConnectGelatoDataFullMakerToMaker", {
from: deployer,
args: [
connectorId,
(await deployments.get("ConnectGelatoExecutorPayment")).address,
],
});
await instaConnectors
.connect(instaMaster)
.enable(
(await ethers.getContract("ConnectGelatoDataFullMakerToMaker")).address
);
await hre.network.provider.request({
method: "hardhat_stopImpersonatingAccount",
params: [await instaMaster.getAddress()],
});
} else {
assert(process.env.CONNECTOR_ID);
// the following will only deploy "ConnectGelatoDataFullMakerToMaker"
// if the contract was never deployed or if the code changed since last deployment
await deploy("ConnectGelatoDataFullMakerToMaker", {
from: deployer,
args: [
parseInt(process.env.CONNECTOR_ID),
(await deployments.get("ConnectGelatoExecutorPayment")).address,
],
gasPrice: hre.network.config.gasPrice,
log: true,
});
}
2020-11-04 12:21:01 +00:00
};
module.exports.skip = async (hre) => {
if (hre.network.name === "mainnet") return true;
if (hre.network.name !== "hardhat")
return process.env.CONNECTOR_ID === undefined;
return false;
};
module.exports.dependencies = ["ConnectGelatoExecutorPayment"];
module.exports.tags = ["ConnectGelatoDataFullMakerToMaker"];