From 12a5eb76c32e5cdcd28756c04d9730caf2b44404 Mon Sep 17 00:00:00 2001 From: blockchainguyy Date: Mon, 15 Apr 2024 19:01:37 +0530 Subject: [PATCH 1/7] fix: add try catch to continue verifying if task fails for fantom testnet --- axelar-chains-config/src/utils/verifyContract.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/axelar-chains-config/src/utils/verifyContract.js b/axelar-chains-config/src/utils/verifyContract.js index 0924b6f5..0868d650 100644 --- a/axelar-chains-config/src/utils/verifyContract.js +++ b/axelar-chains-config/src/utils/verifyContract.js @@ -27,7 +27,12 @@ const verifyContract = (env, chain, contract, args, options = {}) => { console.log(`Verifying contract ${contract} with args '${stringArgs.join(',')}'`); console.log(cmd); - execSync(cmd, { stdio: 'inherit' }); + try { + execSync(cmd, { stdio: 'inherit' }); + } catch (error) { + console.log(`Contract verification task failed for contract ${contract} on chain ${chain} with error: `, error); + return; + } console.log('Verified!'); }; From 77a784286f2f785480431683f27d24a79f144128 Mon Sep 17 00:00:00 2001 From: blockchainguyy Date: Mon, 15 Apr 2024 19:04:49 +0530 Subject: [PATCH 2/7] refactor: update explorer for scroll mainnet --- axelar-chains-config/info/mainnet.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/axelar-chains-config/info/mainnet.json b/axelar-chains-config/info/mainnet.json index 79d4b259..c3d94ea0 100644 --- a/axelar-chains-config/info/mainnet.json +++ b/axelar-chains-config/info/mainnet.json @@ -1859,8 +1859,8 @@ }, "explorer": { "name": "Scroll Explorer", - "url": "https://blockscout.scroll.io", - "api": "https://blockscout.scroll.io/api" + "url": "https://scrollscan.com/", + "api": "https://api.scrollscan.com/api" }, "confirmations": 2, "gasOptions": { From be3a728f7029764988c587f276d1e6a5d8327abc Mon Sep 17 00:00:00 2001 From: blockchainguyy Date: Mon, 15 Apr 2024 19:14:27 +0530 Subject: [PATCH 3/7] refactor: console chain name instead of object --- axelar-chains-config/src/utils/verifyContract.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/axelar-chains-config/src/utils/verifyContract.js b/axelar-chains-config/src/utils/verifyContract.js index 0868d650..fb656df1 100644 --- a/axelar-chains-config/src/utils/verifyContract.js +++ b/axelar-chains-config/src/utils/verifyContract.js @@ -30,7 +30,7 @@ const verifyContract = (env, chain, contract, args, options = {}) => { try { execSync(cmd, { stdio: 'inherit' }); } catch (error) { - console.log(`Contract verification task failed for contract ${contract} on chain ${chain} with error: `, error); + console.log(`Contract verification task failed for contract ${contract} on chain ${chain.name} with error: `, error); return; } From 4e0cef65654df53346c35eea49002c78ddca25b5 Mon Sep 17 00:00:00 2001 From: blockchainguyy Date: Thu, 2 May 2024 18:57:33 +0530 Subject: [PATCH 4/7] refactor: replace execSync with exec --- .../src/utils/verifyContract.js | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/axelar-chains-config/src/utils/verifyContract.js b/axelar-chains-config/src/utils/verifyContract.js index fb656df1..26c65213 100644 --- a/axelar-chains-config/src/utils/verifyContract.js +++ b/axelar-chains-config/src/utils/verifyContract.js @@ -1,4 +1,4 @@ -const { execSync } = require('child_process'); +const { exec } = require('child_process'); const { writeFileSync } = require('fs'); /** @@ -12,7 +12,7 @@ const { writeFileSync } = require('fs'); * @param {any[]} args * @returns {void} */ -const verifyContract = (env, chain, contract, args, options = {}) => { +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'; @@ -27,14 +27,26 @@ const verifyContract = (env, chain, contract, args, options = {}) => { console.log(`Verifying contract ${contract} with args '${stringArgs.join(',')}'`); console.log(cmd); - try { - execSync(cmd, { stdio: 'inherit' }); - } catch (error) { - console.log(`Contract verification task failed for contract ${contract} on chain ${chain.name} with error: `, error); - return; - } + await new Promise((resolve, reject) => { + exec(cmd, { stdio: 'inherit' }, (error, stdout, stderr) => { + console.log(stdout); - console.log('Verified!'); + if (error) { + if (stderr && stderr.includes('Reason: Already Verified')) { + resolve(); + return; + } + + console.error(`Error occured while trying to verify ${contract} on ${chain.toLowerCase()}.`); + reject(error); + return; + } + + resolve(); + }); + }); + + console.log('Verified'); }; module.exports = { From a755ddc5d0b830f0a8f04da465e1677be04da53b Mon Sep 17 00:00:00 2001 From: blockchainguyy Date: Mon, 6 May 2024 18:02:34 +0530 Subject: [PATCH 5/7] chore: use try catch with execsync --- .../src/utils/verifyContract.js | 29 +++++-------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/axelar-chains-config/src/utils/verifyContract.js b/axelar-chains-config/src/utils/verifyContract.js index 26c65213..f0562879 100644 --- a/axelar-chains-config/src/utils/verifyContract.js +++ b/axelar-chains-config/src/utils/verifyContract.js @@ -1,4 +1,4 @@ -const { exec } = require('child_process'); +const { execSync } = require('child_process'); const { writeFileSync } = require('fs'); /** @@ -12,7 +12,7 @@ const { writeFileSync } = require('fs'); * @param {any[]} args * @returns {void} */ -const verifyContract = async (env, chain, contract, args, options = {}) => { +const verifyContract = (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'; @@ -27,26 +27,13 @@ const verifyContract = async (env, chain, contract, args, options = {}) => { console.log(`Verifying contract ${contract} with args '${stringArgs.join(',')}'`); console.log(cmd); - await new Promise((resolve, reject) => { - exec(cmd, { stdio: 'inherit' }, (error, stdout, stderr) => { - console.log(stdout); + try { + execSync(cmd, { stdio: 'inherit' }); + console.log('Verified!'); + } catch(error) { + console.error(`Error occured while trying to verify ${contract} on ${chain.toLowerCase()}: ${error}`); + } - if (error) { - if (stderr && stderr.includes('Reason: Already Verified')) { - resolve(); - return; - } - - console.error(`Error occured while trying to verify ${contract} on ${chain.toLowerCase()}.`); - reject(error); - return; - } - - resolve(); - }); - }); - - console.log('Verified'); }; module.exports = { From e6a4aa373c3fce6ef6ea9bcd138820bff8f8528a Mon Sep 17 00:00:00 2001 From: blockchainguyy Date: Mon, 6 May 2024 19:28:28 +0530 Subject: [PATCH 6/7] chore: pipe stderr and stdout while running cmd --- axelar-chains-config/src/utils/verifyContract.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/axelar-chains-config/src/utils/verifyContract.js b/axelar-chains-config/src/utils/verifyContract.js index f0562879..ab664cbc 100644 --- a/axelar-chains-config/src/utils/verifyContract.js +++ b/axelar-chains-config/src/utils/verifyContract.js @@ -28,12 +28,15 @@ const verifyContract = (env, chain, contract, args, options = {}) => { console.log(cmd); try { - execSync(cmd, { stdio: 'inherit' }); + execSync(cmd, { stdio: ['inherit', 'pipe', 'pipe'] }); console.log('Verified!'); - } catch(error) { - console.error(`Error occured while trying to verify ${contract} on ${chain.toLowerCase()}: ${error}`); + } catch (error) { + if (error.message.includes('Reason: Already Verified')) { + console.log(`Contract ${contract} is already verified on ${chain.toLowerCase()}.`); + } else { + throw new Error(`An error occurred while trying to verify ${contract} on ${chain.toLowerCase()}: ${error}`); + } } - }; module.exports = { From 63a81d4468953599e73a7f7edad0343e530c003d Mon Sep 17 00:00:00 2001 From: Blockchain Guy Date: Mon, 13 May 2024 11:43:05 +0530 Subject: [PATCH 7/7] chore: update error statement Co-authored-by: Milap Sheth --- axelar-chains-config/src/utils/verifyContract.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/axelar-chains-config/src/utils/verifyContract.js b/axelar-chains-config/src/utils/verifyContract.js index ab664cbc..ab8fe4b9 100644 --- a/axelar-chains-config/src/utils/verifyContract.js +++ b/axelar-chains-config/src/utils/verifyContract.js @@ -34,7 +34,7 @@ const verifyContract = (env, chain, contract, args, options = {}) => { if (error.message.includes('Reason: Already Verified')) { console.log(`Contract ${contract} is already verified on ${chain.toLowerCase()}.`); } else { - throw new Error(`An error occurred while trying to verify ${contract} on ${chain.toLowerCase()}: ${error}`); + throw new Error(`An error occurred while trying to verify ${contract} on ${chain.toLowerCase()}:\n${error}`); } } };