Skip to content

Commit

Permalink
catch verification error
Browse files Browse the repository at this point in the history
  • Loading branch information
passabilities committed Oct 13, 2023
1 parent 50bee37 commit 9607408
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
6 changes: 2 additions & 4 deletions packages/plugin-hardhat/src/utils/deploy-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from '@openzeppelin/upgrades-core';
import type { ContractFactory, ethers } from 'ethers';
import type { EthereumProvider, HardhatRuntimeEnvironment } from 'hardhat/types';
import { runVerify } from '../verify-proxy';
import { deploy } from './deploy';
import { GetTxResponse, DefenderDeployOptions, StandaloneOptions, UpgradeOptions, withDefaults } from './options';
import { getRemoteDeployment } from '../defender/utils';
Expand Down Expand Up @@ -141,10 +142,7 @@ async function deployImpl(
}
}

await hre.run('verify:verify', {
address: deployment.address,
constructorArguments: opts.constructorArgs ?? [],
});
await runVerify(hre, deployment.address, opts.constructorArgs);

return { impl: deployment.address, txResponse };
}
6 changes: 2 additions & 4 deletions packages/plugin-hardhat/src/utils/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Deployment, RemoteDeploymentId } from '@openzeppelin/upgrades-core
import type { ethers, ContractFactory, ContractMethodArgs } from 'ethers';
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { defenderDeploy } from '../defender/deploy';
import { runVerify } from '../verify-proxy';
import { EthersDeployOptions, DefenderDeployOptions, UpgradeOptions } from './options';

export interface DeployTransaction {
Expand All @@ -27,10 +28,7 @@ export async function deploy(
response = await ethersDeploy(factory, ...args);
}

await hre.run('verify:verify', {
address: response.address,
constructorArguments: opts.constructorArgs ?? [],
});
await runVerify(hre, response.address, opts.constructorArgs);

return response;
}
Expand Down
13 changes: 13 additions & 0 deletions packages/plugin-hardhat/src/verify-proxy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { TASK_VERIFY_VERIFY } from '@nomicfoundation/hardhat-verify/internal/task-names';
import {
getTransactionByHash,
getImplementationAddress,
Expand All @@ -11,6 +12,7 @@ import {
isEmptySlot,
} from '@openzeppelin/upgrades-core';
import artifactsBuildInfo from '@openzeppelin/upgrades-core/artifacts/build-info.json';
import { HARDHAT_NETWORK_NAME } from 'hardhat/plugins';

import { HardhatRuntimeEnvironment, RunSuperFunction } from 'hardhat/types';

Expand Down Expand Up @@ -61,6 +63,17 @@ const verifiableContracts = {
proxyAdmin: { artifact: ProxyAdmin, event: 'OwnershipTransferred(address,address)' },
};

export async function runVerify(hre: HardhatRuntimeEnvironment, address: string, constructorArguments: unknown[] = []) {
try {
await hre.run(TASK_VERIFY_VERIFY, {
address,
constructorArguments,
});
} catch (e) {
// fail silently
}
}

/**
* Overrides hardhat-verify's verify:etherscan subtask to fully verify a proxy or beacon.
*
Expand Down

0 comments on commit 9607408

Please sign in to comment.