Skip to content

Commit

Permalink
fix: checks and no def value for params
Browse files Browse the repository at this point in the history
  • Loading branch information
krogla committed Oct 23, 2023
1 parent a14afc8 commit 39ac4c8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
24 changes: 13 additions & 11 deletions scripts/simpledvt/02-clone-nor.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const {
SIMPLE_DVT_IPFS_CID,
easyTrackABI,
_pause,
_checkLog,
} = require('./helpers')
const { ETH, toBN } = require('../../test/helpers/utils')

Expand Down Expand Up @@ -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!`)
Expand All @@ -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
Expand Down
9 changes: 8 additions & 1 deletion scripts/simpledvt/helpers.js
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -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 })

Expand All @@ -153,6 +159,7 @@ module.exports = {
getDeployer,
getSignature,
_checkEq,
_checkLog,
_pause,
KERNEL_APP_BASES_NAMESPACE,
MANAGE_SIGNING_KEYS,
Expand Down

0 comments on commit 39ac4c8

Please sign in to comment.