Skip to content

Commit

Permalink
fix: update the filePath if dir option passed and create file if not …
Browse files Browse the repository at this point in the history
…exists
  • Loading branch information
blockchainguyy authored and Ayush Tiwari committed Oct 11, 2023
1 parent 1fbac31 commit 1930f08
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions axelar-chains-config/src/utils/verifyContract.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { exec } = require('child_process');
const { writeFile } = require('fs');
const { writeFile, writeFileSync, existsSync } = require('fs');
const { promisify } = require('util');

const execAsync = promisify(exec);
Expand All @@ -19,7 +19,12 @@ const writeFileAsync = promisify(writeFile);
const verifyContract = async (env, chain, contract, args, options = {}) => {
const stringArgs = args.map((arg) => JSON.stringify(arg));
const content = `module.exports = [\n ${stringArgs.join(',\n ')}\n];`;
const file = 'temp-arguments.js';
const file = options.dir ? `${options.dir}/temp-arguments.js` : 'temp-arguments.js';

if (!existsSync(file)) {
writeFileSync(file, '', 'utf-8');
}

const contractArg = options.contractPath ? `--contract ${options.contractPath}` : '';
const dirPrefix = options.dir ? `cd ${options.dir};` : '';
const cmd = `${dirPrefix} ENV=${env} npx hardhat verify --network ${chain.toLowerCase()} ${contractArg} --no-compile --constructor-args ${file} ${contract} --show-stack-traces`;
Expand Down

0 comments on commit 1930f08

Please sign in to comment.