Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hardhat: stop estimating gas, log like ganache #10

Merged
merged 2 commits into from
Jan 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion scripts/convex.hardhat.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import * as assert from 'assert';

const chalk: any = require('chalk');
import { ethers, network } from 'hardhat';
import '@nomiclabs/hardhat-ethers';

async function main(): Promise<void> {
console.log(chalk.bold('Setting up Hardhat...'));
console.time('setup-hardhat');
console.group();

// Impersonate owner
const abi = ['function shutdownSystem() external', 'function owner() external view returns (address)'];
const convex = new ethers.Contract('0xF403C135812408BFbE8713b5A23a04b3D48AAE31', abi, ethers.provider);
Expand All @@ -14,10 +19,22 @@ async function main(): Promise<void> {
// Fund owner (it's a contract)
await network.provider.send('hardhat_setBalance', [owner.address, '0xffffffffffffffffffff']);

console.groupEnd();
console.timeEnd('setup-hardhat');
console.log('');

// Execute transaction
const tx = await convex.connect(owner).shutdownSystem();
console.log(chalk.bold('Simulating shutdown...'));
console.time('simulate-shutdown');
console.group();
const tx = await convex.connect(owner).shutdownSystem(
{ gasLimit: process.env.GAS_LIMIT }
);
const receipt = await ethers.provider.getTransactionReceipt(tx.hash);
assert.ok(receipt.status, `transaction failed. receipt: ${JSON.stringify(receipt)}`);
console.groupEnd();
console.timeEnd('simulate-shutdown');
console.log('');
}

main()
Expand Down