Skip to content

Commit

Permalink
lint verify script
Browse files Browse the repository at this point in the history
  • Loading branch information
tmsdkeys committed Apr 12, 2024
1 parent f441202 commit 6e5429a
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions scripts/private/_verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// You can also run a script with `npx hardhat run <script>`. If you do that, Hardhat
// will compile your contracts, add the Hardhat Runtime Environment's members to the
// global scope, and execute the script.
const { exec } = require("child_process");
const {getConfigPath, getWhitelistedNetworks} = require('./_helpers.js');
const { exec } = require('child_process');
const { getConfigPath, getWhitelistedNetworks } = require('./_helpers.js');
const { getDispatcherAddress, getUcHandlerAddress } = require('./_vibc-helpers.js');

const network = process.argv[2];
Expand All @@ -17,7 +17,7 @@ if (!network || !address) {

function runVerifyContractCommand(command) {
return new Promise((resolve, reject) => {
exec(command, (error, stdout, stderr) => {
exec(command, (error, stdout) => {
if (error) {
console.error(`exec error: ${error}`);
reject(error);
Expand All @@ -33,29 +33,28 @@ async function runVerifyContract(constructorArgs) {
// Check if the chain from user input is whitelisted
const allowedNetworks = getWhitelistedNetworks();
if (!allowedNetworks.includes(network)) {
console.error("❌ Invalid network specified. Please provide one of the following whitelisted networks: " + allowedNetworks.join(', '));
console.error('❌ Invalid network specified. Please provide one of the following whitelisted networks: ' + allowedNetworks.join(', '));
process.exit(1);
}

const command = `npx hardhat verify --network ${network} ${address} ${constructorArgs.join(' ')}`;
try {
await runVerifyContractCommand(command);
} catch (error) {
console.error("❌ Error verifying contract: ", error);
console.error('❌ Error verifying contract: ', error);
process.exit(1);
}
}


async function main() {
const config = require(getConfigPath());
const argsObject = require('../../contracts/arguments.js');

// The config should have a deploy object with the network name as the key and contract type as the value
const contractType = config["deploy"][`${network}`];
const contractType = config['deploy'][`${network}`];
const args = argsObject[`${contractType}`];
if (!args) {
console.warn(`No arguments found for contract type: ${contractType}`);
console.warn(`No arguments found for contract type: ${contractType}`);
}
let constructorArgs;
if (config.isUniversal) {
Expand All @@ -74,4 +73,4 @@ async function main() {
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
});

0 comments on commit 6e5429a

Please sign in to comment.