Skip to content
This repository has been archived by the owner on May 5, 2023. It is now read-only.

Commit

Permalink
fix logs in js deployContract etherscan verify
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-fruitful committed Apr 2, 2022
1 parent d923d04 commit 0a28117
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions deploy/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,28 @@ export const getAccounts = async () => {

export const getAccountWallet = (address) => accounts.find(a => a.address === address)

export const deployContract = async ({ log, artifacts, getTxParams = defaultGetTxParams }, name, args, overrides = {}) => {
export const deployContract = async ({ ctx = {}, artifacts, getTxParams = defaultGetTxParams }, name, args, overrides = {}) => {
const C = artifacts.require(name)
const c = await C.new(...args, { ...getTxParams(), ...overrides })

await log.task(`Verifying contract ${name} ${c.address} on etherscan`, async task => {
try {
await hre.run("verify:verify", {
address: c.address,
constructorArguments: args,
})
}
catch(e) {
task.log(`hre verify contract error: ${e}`)
}
})
const log = createLog(ctx.log)

const chainId = hre.network.config.chainId
const chainList = [1, 3, 4, 5, 42]

if (chainList.includes(chainId)) {
await log.task(`Verifying contract ${name} ${c.address} on etherscan`, async task => {
try {
await hre.run("verify:verify", {
address: c.address,
constructorArguments: args,
})
}
catch(e) {
task.log(`deployContract() hre etherscan verify contract error: ${e}`)
}
})
}

return c
}
Expand Down

0 comments on commit 0a28117

Please sign in to comment.