minor script fixes

This commit is contained in:
pradyuman-verma 2022-03-09 17:33:47 +05:30
parent 270a3f79b9
commit 74b0eccec0
No known key found for this signature in database
GPG Key ID: E36FD6BC8923221F
2 changed files with 16 additions and 30 deletions

View File

@ -24,8 +24,8 @@ async function deployRunner() {
name: "chain", name: "chain",
message: "What chain do you want to deploy on?", message: "What chain do you want to deploy on?",
type: "list", type: "list",
choices: ["mainnet", "polygon", "avalanche", "arbitrum"], choices: ["mainnet", "polygon", "avalanche", "arbitrum", "optimism"]
}, }
]); ]);
// let connector = await connectorSelect(chain); // let connector = await connectorSelect(chain);
@ -48,8 +48,8 @@ async function deployRunner() {
{ {
name: "connector", name: "connector",
message: "Enter the connector contract name? (ex: ConnectV2Paraswap)", message: "Enter the connector contract name? (ex: ConnectV2Paraswap)",
type: "input", type: "input"
}, }
]); ]);
let { choice } = await inquirer.prompt([ let { choice } = await inquirer.prompt([
@ -57,39 +57,29 @@ async function deployRunner() {
name: "choice", name: "choice",
message: "Do you wanna try deploy on hardhat first?", message: "Do you wanna try deploy on hardhat first?",
type: "list", type: "list",
choices: ["yes", "no"], choices: ["yes", "no"]
}, }
]); ]);
runchain = choice === "yes" ? "hardhat" : chain; runchain = choice === "yes" ? "hardhat" : chain;
console.log( console.log(`Deploying ${connector} on ${runchain}, press (ctrl + c) to stop`);
`Deploying ${connector} on ${runchain}, press (ctrl + c) to stop`
);
start = Date.now(); start = Date.now();
await execScript({ await execScript({
cmd: "npx", cmd: "npx",
args: [ args: ["hardhat", "run", "scripts/deployment/deploy.ts", "--network", `${runchain}`],
"hardhat",
"run",
"scripts/deployment/deploy.ts",
"--network",
`${runchain}`,
],
env: { env: {
connectorName: connector, connectorName: connector,
networkType: chain, networkType: chain
}, }
}); });
end = Date.now(); end = Date.now();
} }
deployRunner() deployRunner()
.then(() => { .then(() => {
console.log( console.log(`Done successfully, total time taken: ${(end - start) / 1000} sec`);
`Done successfully, total time taken: ${(end - start) / 1000} sec`
);
process.exit(0); process.exit(0);
}) })
.catch((err) => { .catch((err) => {

View File

@ -1,4 +1,4 @@
import { ethers } from "hardhat"; import { ethers, network } from "hardhat";
import { impersonateAccounts } from "./impersonate"; import { impersonateAccounts } from "./impersonate";
import { tokenMapping as mainnetMapping } from "./mainnet/tokens"; import { tokenMapping as mainnetMapping } from "./mainnet/tokens";
@ -12,7 +12,7 @@ const mineTx = async (tx: any) => {
const tokenMapping: Record<string, Record<string, any>> = { const tokenMapping: Record<string, Record<string, any>> = {
mainnet: mainnetMapping, mainnet: mainnetMapping,
polygon: polygonMapping, polygon: polygonMapping,
avalanche: avalancheMapping, avalanche: avalancheMapping
}; };
export async function addLiquidity(tokenName: string, address: any, amt: any) { export async function addLiquidity(tokenName: string, address: any, amt: any) {
@ -20,20 +20,16 @@ export async function addLiquidity(tokenName: string, address: any, amt: any) {
tokenName = tokenName.toLowerCase(); tokenName = tokenName.toLowerCase();
const chain = String(process.env.networkType); const chain = String(process.env.networkType);
if (!tokenMapping[chain][tokenName]) { if (!tokenMapping[chain][tokenName]) {
throw new Error( throw new Error(`Add liquidity doesn't support the following token: ${tokenName}`);
`Add liquidity doesn't support the following token: ${tokenName}`
);
} }
const token = tokenMapping[chain][tokenName]; const token = tokenMapping[chain][tokenName];
const [impersonatedSigner] = await impersonateAccounts([ const [impersonatedSigner] = await impersonateAccounts([token.impersonateSigner]);
token.impersonateSigner,
]);
// send 2 eth to cover any tx costs. // send 2 eth to cover any tx costs.
await network.provider.send("hardhat_setBalance", [ await network.provider.send("hardhat_setBalance", [
impersonatedSigner.address, impersonatedSigner.address,
ethers.utils.parseEther("2").toHexString(), ethers.utils.parseEther("2").toHexString()
]); ]);
await token.process(impersonatedSigner, address, amt); await token.process(impersonatedSigner, address, amt);