Commit b9049406 authored by Kelvin Fichter's avatar Kelvin Fichter

fix: no gas price for static fns in deploy

parent 12b153ab
---
'@eth-optimism/contracts': patch
---
Use a gas price of zero for static calls in the deploy process
...@@ -6,7 +6,7 @@ import { ...@@ -6,7 +6,7 @@ import {
fundAccount, fundAccount,
sendImpersonatedTx, sendImpersonatedTx,
BIG_BALANCE, BIG_BALANCE,
} from '../src/hardhat-deploy-ethers' } from '../src/deploy-utils'
import { names } from '../src/address-names' import { names } from '../src/address-names'
import { awaitCondition } from '@eth-optimism/core-utils' import { awaitCondition } from '@eth-optimism/core-utils'
......
...@@ -5,7 +5,7 @@ import { DeployFunction } from 'hardhat-deploy/dist/types' ...@@ -5,7 +5,7 @@ import { DeployFunction } from 'hardhat-deploy/dist/types'
import { import {
deployAndVerifyAndThen, deployAndVerifyAndThen,
getContractFromArtifact, getContractFromArtifact,
} from '../src/hardhat-deploy-ethers' } from '../src/deploy-utils'
import { names } from '../src/address-names' import { names } from '../src/address-names'
const deployFn: DeployFunction = async (hre) => { const deployFn: DeployFunction = async (hre) => {
......
...@@ -5,7 +5,7 @@ import { DeployFunction } from 'hardhat-deploy/dist/types' ...@@ -5,7 +5,7 @@ import { DeployFunction } from 'hardhat-deploy/dist/types'
import { import {
deployAndVerifyAndThen, deployAndVerifyAndThen,
getContractFromArtifact, getContractFromArtifact,
} from '../src/hardhat-deploy-ethers' } from '../src/deploy-utils'
import { names } from '../src/address-names' import { names } from '../src/address-names'
const deployFn: DeployFunction = async (hre) => { const deployFn: DeployFunction = async (hre) => {
......
...@@ -5,7 +5,7 @@ import { DeployFunction } from 'hardhat-deploy/dist/types' ...@@ -5,7 +5,7 @@ import { DeployFunction } from 'hardhat-deploy/dist/types'
import { import {
deployAndVerifyAndThen, deployAndVerifyAndThen,
getContractFromArtifact, getContractFromArtifact,
} from '../src/hardhat-deploy-ethers' } from '../src/deploy-utils'
import { names } from '../src/address-names' import { names } from '../src/address-names'
const deployFn: DeployFunction = async (hre) => { const deployFn: DeployFunction = async (hre) => {
......
...@@ -5,7 +5,7 @@ import { DeployFunction } from 'hardhat-deploy/dist/types' ...@@ -5,7 +5,7 @@ import { DeployFunction } from 'hardhat-deploy/dist/types'
import { import {
deployAndVerifyAndThen, deployAndVerifyAndThen,
getContractFromArtifact, getContractFromArtifact,
} from '../src/hardhat-deploy-ethers' } from '../src/deploy-utils'
import { names } from '../src/address-names' import { names } from '../src/address-names'
const deployFn: DeployFunction = async (hre) => { const deployFn: DeployFunction = async (hre) => {
......
...@@ -5,7 +5,7 @@ import { DeployFunction } from 'hardhat-deploy/dist/types' ...@@ -5,7 +5,7 @@ import { DeployFunction } from 'hardhat-deploy/dist/types'
import { import {
deployAndVerifyAndThen, deployAndVerifyAndThen,
getContractFromArtifact, getContractFromArtifact,
} from '../src/hardhat-deploy-ethers' } from '../src/deploy-utils'
import { names } from '../src/address-names' import { names } from '../src/address-names'
const deployFn: DeployFunction = async (hre) => { const deployFn: DeployFunction = async (hre) => {
......
...@@ -6,7 +6,7 @@ import { hexStringEquals, awaitCondition } from '@eth-optimism/core-utils' ...@@ -6,7 +6,7 @@ import { hexStringEquals, awaitCondition } from '@eth-optimism/core-utils'
import { import {
deployAndVerifyAndThen, deployAndVerifyAndThen,
getContractFromArtifact, getContractFromArtifact,
} from '../src/hardhat-deploy-ethers' } from '../src/deploy-utils'
import { names } from '../src/address-names' import { names } from '../src/address-names'
const deployFn: DeployFunction = async (hre) => { const deployFn: DeployFunction = async (hre) => {
......
...@@ -5,7 +5,7 @@ import { DeployFunction } from 'hardhat-deploy/dist/types' ...@@ -5,7 +5,7 @@ import { DeployFunction } from 'hardhat-deploy/dist/types'
import { import {
deployAndVerifyAndThen, deployAndVerifyAndThen,
getContractFromArtifact, getContractFromArtifact,
} from '../src/hardhat-deploy-ethers' } from '../src/deploy-utils'
import { names } from '../src/address-names' import { names } from '../src/address-names'
const deployFn: DeployFunction = async (hre) => { const deployFn: DeployFunction = async (hre) => {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import { DeployFunction } from 'hardhat-deploy/dist/types' import { DeployFunction } from 'hardhat-deploy/dist/types'
/* Imports: Internal */ /* Imports: Internal */
import { deployAndVerifyAndThen } from '../src/hardhat-deploy-ethers' import { deployAndVerifyAndThen } from '../src/deploy-utils'
import { names } from '../src/address-names' import { names } from '../src/address-names'
const deployFn: DeployFunction = async (hre) => { const deployFn: DeployFunction = async (hre) => {
......
...@@ -6,7 +6,7 @@ import { hexStringEquals } from '@eth-optimism/core-utils' ...@@ -6,7 +6,7 @@ import { hexStringEquals } from '@eth-optimism/core-utils'
import { import {
deployAndVerifyAndThen, deployAndVerifyAndThen,
getContractFromArtifact, getContractFromArtifact,
} from '../src/hardhat-deploy-ethers' } from '../src/deploy-utils'
import { names } from '../src/address-names' import { names } from '../src/address-names'
import { predeploys } from '../src/predeploys' import { predeploys } from '../src/predeploys'
......
...@@ -3,10 +3,7 @@ import { hexStringEquals, awaitCondition } from '@eth-optimism/core-utils' ...@@ -3,10 +3,7 @@ import { hexStringEquals, awaitCondition } from '@eth-optimism/core-utils'
import { DeployFunction } from 'hardhat-deploy/dist/types' import { DeployFunction } from 'hardhat-deploy/dist/types'
/* Imports: Internal */ /* Imports: Internal */
import { import { getContractFromArtifact, isHardhatNode } from '../src/deploy-utils'
getContractFromArtifact,
isHardhatNode,
} from '../src/hardhat-deploy-ethers'
import { names } from '../src/address-names' import { names } from '../src/address-names'
const deployFn: DeployFunction = async (hre) => { const deployFn: DeployFunction = async (hre) => {
......
...@@ -3,7 +3,7 @@ import { DeployFunction } from 'hardhat-deploy/dist/types' ...@@ -3,7 +3,7 @@ import { DeployFunction } from 'hardhat-deploy/dist/types'
import { hexStringEquals, awaitCondition } from '@eth-optimism/core-utils' import { hexStringEquals, awaitCondition } from '@eth-optimism/core-utils'
/* Imports: Internal */ /* Imports: Internal */
import { getContractFromArtifact } from '../src/hardhat-deploy-ethers' import { getContractFromArtifact } from '../src/deploy-utils'
import { names } from '../src/address-names' import { names } from '../src/address-names'
const deployFn: DeployFunction = async (hre) => { const deployFn: DeployFunction = async (hre) => {
......
...@@ -8,7 +8,7 @@ import { getContractDefinition } from '../src/contract-defs' ...@@ -8,7 +8,7 @@ import { getContractDefinition } from '../src/contract-defs'
import { import {
getContractFromArtifact, getContractFromArtifact,
deployAndVerifyAndThen, deployAndVerifyAndThen,
} from '../src/hardhat-deploy-ethers' } from '../src/deploy-utils'
import { names } from '../src/address-names' import { names } from '../src/address-names'
const deployFn: DeployFunction = async (hre) => { const deployFn: DeployFunction = async (hre) => {
......
...@@ -9,7 +9,7 @@ import { ...@@ -9,7 +9,7 @@ import {
getContractFromArtifact, getContractFromArtifact,
deployAndVerifyAndThen, deployAndVerifyAndThen,
isHardhatNode, isHardhatNode,
} from '../src/hardhat-deploy-ethers' } from '../src/deploy-utils'
import { names } from '../src/address-names' import { names } from '../src/address-names'
const deployFn: DeployFunction = async (hre) => { const deployFn: DeployFunction = async (hre) => {
......
...@@ -3,7 +3,7 @@ import { DeployFunction } from 'hardhat-deploy/dist/types' ...@@ -3,7 +3,7 @@ import { DeployFunction } from 'hardhat-deploy/dist/types'
import { hexStringEquals, awaitCondition } from '@eth-optimism/core-utils' import { hexStringEquals, awaitCondition } from '@eth-optimism/core-utils'
/* Imports: Internal */ /* Imports: Internal */
import { getContractFromArtifact } from '../src/hardhat-deploy-ethers' import { getContractFromArtifact } from '../src/deploy-utils'
const deployFn: DeployFunction = async (hre) => { const deployFn: DeployFunction = async (hre) => {
const { deployer } = await hre.getNamedAccounts() const { deployer } = await hre.getNamedAccounts()
......
...@@ -5,10 +5,7 @@ import { defaultHardhatNetworkHdAccountsConfigParams } from 'hardhat/internal/co ...@@ -5,10 +5,7 @@ import { defaultHardhatNetworkHdAccountsConfigParams } from 'hardhat/internal/co
import { normalizeHardhatNetworkAccountsConfig } from 'hardhat/internal/core/providers/util' import { normalizeHardhatNetworkAccountsConfig } from 'hardhat/internal/core/providers/util'
/* Imports: Internal */ /* Imports: Internal */
import { import { getContractFromArtifact, isHardhatNode } from '../src/deploy-utils'
getContractFromArtifact,
isHardhatNode,
} from '../src/hardhat-deploy-ethers'
import { names } from '../src/address-names' import { names } from '../src/address-names'
// This is a TEMPORARY way to fund the default hardhat accounts on L2. The better way to do this is // This is a TEMPORARY way to fund the default hardhat accounts on L2. The better way to do this is
......
...@@ -103,8 +103,16 @@ export const getAdvancedContract = (opts: { ...@@ -103,8 +103,16 @@ export const getAdvancedContract = (opts: {
for (const fnName of Object.keys(contract.functions)) { for (const fnName of Object.keys(contract.functions)) {
const fn = contract[fnName].bind(contract) const fn = contract[fnName].bind(contract)
;(contract as any)[fnName] = async (...args: any) => { ;(contract as any)[fnName] = async (...args: any) => {
// We want to use the gas price that has been configured at the beginning of the deployment.
// However, if the function being triggered is a "constant" (static) function, then we don't
// want to provide a gas price because we're prone to getting insufficient balance errors.
let gasPrice = opts.hre.deployConfig.gasPrice || undefined
if (contract.interface.getFunction(fnName).constant) {
gasPrice = 0
}
const tx = await fn(...args, { const tx = await fn(...args, {
gasPrice: opts.hre.deployConfig.gasprice || undefined, gasPrice,
}) })
if (typeof tx !== 'object' || typeof tx.wait !== 'function') { if (typeof tx !== 'object' || typeof tx.wait !== 'function') {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment