diff --git a/contracts/README.md b/contracts/README.md index e794daded6..42ea91f6e1 100644 --- a/contracts/README.md +++ b/contracts/README.md @@ -265,3 +265,15 @@ yarn test:fork:coverage ``` The CI will upload the coverage reports to Codecov if they complete successfully. + +# Utils + +## Transaction gas inspector + +To measure the gas usage of any transaction wrap it into `GetGas` globally defined function. Example: +``` + const gas = await GetGas(await cEvilContract.connect(daniel).approveAllTokens()); + console.log('Gas used: ' + gas); +``` + + diff --git a/contracts/hardhat.config.js b/contracts/hardhat.config.js index 2c4107683f..ef94de5ba7 100644 --- a/contracts/hardhat.config.js +++ b/contracts/hardhat.config.js @@ -12,6 +12,7 @@ require("hardhat-deploy-ethers"); require("hardhat-gas-reporter"); require("solidity-coverage"); require("@openzeppelin/hardhat-upgrades"); +require("hardhat-gas-trackooor"); require("./tasks/tasks"); const { accounts } = require("./tasks/account"); diff --git a/contracts/package.json b/contracts/package.json index 7798c3595d..2f415af7b6 100644 --- a/contracts/package.json +++ b/contracts/package.json @@ -59,6 +59,7 @@ "hardhat-deploy": "^0.11.30", "hardhat-deploy-ethers": "^0.3.0-beta.13", "hardhat-gas-reporter": "^1.0.9", + "hardhat-gas-trackooor": "^1.0.2", "hardhat-tracer": "^2.3.2", "husky": "^7.0.2", "lodash": "^4.17.21", diff --git a/contracts/yarn.lock b/contracts/yarn.lock index d897222ba5..6561fc6f18 100644 --- a/contracts/yarn.lock +++ b/contracts/yarn.lock @@ -2957,7 +2957,7 @@ ethers@^4.0.40: uuid "2.0.1" xmlhttprequest "1.8.0" -ethers@^5.4.6, ethers@^5.5.3, ethers@^5.6.1, ethers@^5.7.1: +ethers@^5.0.0, ethers@^5.4.6, ethers@^5.5.3, ethers@^5.6.1, ethers@^5.7.1: version "5.7.2" resolved "https://registry.yarnpkg.com/ethers/-/ethers-5.7.2.tgz#3a7deeabbb8c030d4126b24f84e525466145872e" integrity sha512-wswUsmWo1aOK8rR7DIKiWSw9DbLWe6x98Jrn8wcTflTVvaXhAMaB5zGAXy0GYQEQp9iO1iSHWVyARQm11zUtyg== @@ -3624,6 +3624,13 @@ hardhat-gas-reporter@^1.0.9: eth-gas-reporter "^0.2.25" sha1 "^1.1.1" +hardhat-gas-trackooor@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/hardhat-gas-trackooor/-/hardhat-gas-trackooor-1.0.2.tgz#8490bebf2a33242a0bcc210edb1a84ca358a6c1d" + integrity sha512-k8qvLBB0+vG/XET8ArgYBoBOB9C9SyonFew9vHmJ8qxVqAv4UL9bSB1SuSQt9dbTPWbZI9mmhbUmoTshJF13cQ== + dependencies: + ethers "^5.0.0" + hardhat-tracer@^2.3.2: version "2.4.0" resolved "https://registry.yarnpkg.com/hardhat-tracer/-/hardhat-tracer-2.4.0.tgz#c650251cc504e68e890edf3675b132bcd7cc2322"