Skip to content

Commit

Permalink
Refactor init script a little bit (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmanjunath authored Aug 16, 2019
1 parent 7d4140c commit dda5cf3
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 33 deletions.
76 changes: 44 additions & 32 deletions libs/examples/local_initStakingOperations.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const creatorNodeEndpoint2 = 'http://localhost:4010'
const spEndpoint2 = 'http://localhost:5001'

function throwArgError () {
throw new Error('missing argument - format: node examples/initiateStakingOperations.js [distribute, fundclaim, getclaim, stakeinfo]')
throw new Error('missing argument - format: node examples/initiateStakingOperations.js [distribute, fundclaim, getclaim, stakeinfo, initversions, register-sps, query-sps, init-all]')
}
let testVersionStr = '0.1.0'

Expand All @@ -20,39 +20,51 @@ if (args.length < 3) {
throwArgError()
}

switch (args[2]) {
case 'distribute':
console.log('distribute')
distributeTokens()
break
case 'fundclaim':
console.log('fundclaim')
fundNewClaim()
break
case 'getclaim':
console.log('fundclaim')
getClaimInfo()
break
case 'stakeinfo':
console.log('stakeinfo')
getStakingParameters()
break
case 'initversions':
initializeVersions()
break
case 'register-sps':
registerLocalServices()
break
case 'query-sps':
queryLocalServices()
break
case 'init-all':
initializeLocalEnvironment()
break
default:
throwArgError()
async function run() {
try{
switch (args[2]) {
case 'distribute':
console.log('distribute')
await distributeTokens()
break
case 'fundclaim':
console.log('fundclaim')
await fundNewClaim()
break
case 'getclaim':
console.log('fundclaim')
await getClaimInfo()
break
case 'stakeinfo':
console.log('stakeinfo')
await getStakingParameters()
break
case 'initversions':
await initializeVersions()
break
case 'register-sps':
await registerLocalServices()
break
case 'query-sps':
await queryLocalServices()
break
case 'init-all':
await initializeLocalEnvironment()
break
default:
throwArgError()
}

process.exit(0)
}
catch(e){
console.error(e)
process.exit(1)
}
}

run()

async function getStakingParameters () {
const audius1 = await initAudiusLibs(true)
let min = await audius1.ethContracts.StakingProxyClient.getMinStakeAmount()
Expand Down
2 changes: 1 addition & 1 deletion libs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dda5cf3

Please sign in to comment.