From 39ac4c8fcc891ffc6d22ed7767735e8bfe48da64 Mon Sep 17 00:00:00 2001 From: KRogLA Date: Mon, 23 Oct 2023 13:45:22 +0200 Subject: [PATCH] fix: checks and no def value for params --- scripts/simpledvt/02-clone-nor.js | 24 +++++++++++++----------- scripts/simpledvt/helpers.js | 9 ++++++++- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/scripts/simpledvt/02-clone-nor.js b/scripts/simpledvt/02-clone-nor.js index e277e218c..7e8025e7a 100644 --- a/scripts/simpledvt/02-clone-nor.js +++ b/scripts/simpledvt/02-clone-nor.js @@ -30,6 +30,7 @@ const { SIMPLE_DVT_IPFS_CID, easyTrackABI, _pause, + _checkLog, } = require('./helpers') const { ETH, toBN } = require('../../test/helpers/utils') @@ -106,20 +107,21 @@ async function deploySimpleDVT({ web3, artifacts, trgAppName = APP_TRG, ipfsCid log.splitter() const { moduleName, - moduleType = 'curated', - targetShare = 1000, - moduleFee = 500, - treasuryFee = 500, + moduleType, + targetShare, + moduleFee, + treasuryFee, penaltyDelay, easyTrackAddress, easyTrackFactories = {}, } = state[`app:${trgAppName}`].stakingRouterModuleParams - log(`Target SR Module name`, yl(moduleName)) - log(`Target SR Module type`, yl(moduleType)) - log(`Target SR Module fee`, yl(moduleFee)) - log(`Target SR Module targetShare`, yl(targetShare)) - log(`Target SR Module treasuryFee`, yl(treasuryFee)) - log(`Target SR Module penaltyDelay`, yl(penaltyDelay)) + + _checkLog(moduleName, `Target SR Module name`) + _checkLog(moduleType, `Target SR Module type`) + _checkLog(moduleFee, `Target SR Module fee`) + _checkLog(targetShare, `Target SR Module targetShare`) + _checkLog(treasuryFee, `Target SR Module treasuryFee`) + _checkLog(penaltyDelay, `Target SR Module penaltyDelay`) if (!trgProxyAddress || (await web3.eth.getCode(trgProxyAddress)) === '0x') { log.error(`Target app proxy is not yet deployed!`) @@ -128,7 +130,7 @@ async function deploySimpleDVT({ web3, artifacts, trgAppName = APP_TRG, ipfsCid const trgRepoAddress = await resolveEnsAddress(artifacts, ens, trgAppId) - if (trgRepoAddress && (await web3.eth.getCode(trgProxyAddress)) !== '0x') { + if (trgRepoAddress && (await web3.eth.getCode(trgRepoAddress)) !== '0x') { log(`Target App APM repo:`, yl(trgRepoAddress)) log.error(`Target app is already deployed!`) return diff --git a/scripts/simpledvt/helpers.js b/scripts/simpledvt/helpers.js index 5eab31cc9..3eba3b807 100644 --- a/scripts/simpledvt/helpers.js +++ b/scripts/simpledvt/helpers.js @@ -1,6 +1,6 @@ const readline = require('readline') const { assert } = require('chai') -const { log, rd, mg } = require('../helpers/log') +const { log, rd, mg, yl } = require('../helpers/log') const KERNEL_APP_BASES_NAMESPACE = '0xf1f3eb40f5bc1ad1344716ced8b8a0431d840b5783aea1fd01786bc26f35ac0f' @@ -133,6 +133,12 @@ function _checkEq(a, b, descr = '') { log.success(descr) } +function _checkLog(value, msg) { + log(msg, yl(value)) + if (value === undefined) { + throw new Error('Parameter missing') + } +} function _pause(query = mg('>>> Enter Y to continue, interrupt process otherwise:')) { const rl = readline.createInterface({ input: process.stdin, output: process.stdout }) @@ -153,6 +159,7 @@ module.exports = { getDeployer, getSignature, _checkEq, + _checkLog, _pause, KERNEL_APP_BASES_NAMESPACE, MANAGE_SIGNING_KEYS,