import type { ethers } from "ethers" ; import { NetworkConfig } from "hardhat/types" ; export function addGasToAbiMethods ( networkConfig , abi ) { const { BigNumber } = require ( "ethers" ) as typeof ethers ; let gas ; if ( process . env . COVERAGE === "true" ) { const CoverageAPI = require ( "solidity-coverage/api" ) ; gas = new CoverageAPI ( ) . gasLimit as number ; } else { gas = networkConfig . gas as number ; } const gasLimit = BigNumber . from ( gas ) . sub ( 1000000 ) . toHexString ( ) ; const modifiedAbi = [ ] ; for ( const abiElement of abi ) { if ( abiElement . type !== "function" ) { modifiedAbi . push ( abiElement ) ; continue ; } modifiedAbi . push ( { ... abiElement , gas : gasLimit , } ) ; } return modifiedAbi ; } export function removeGasFromAbiMethods ( abi ) { const modifiedAbi = [ ] ; for ( const abiElement of abi ) { if ( abiElement . type !== "function" ) { modifiedAbi . push ( abiElement ) ; continue ; } delete abiElement . gas ; modifiedAbi . push ( abiElement ) ; } return modifiedAbi ; }