Skip to content

Commit

Permalink
Show campaign levels
Browse files Browse the repository at this point in the history
  • Loading branch information
eternauta1337 committed Sep 26, 2024
1 parent 1e260f5 commit bbfc535
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/ethernaut-zeronaut/src/tasks/get-campaign.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const types = require('ethernaut-common/src/validation/types')
const output = require('ethernaut-common/src/ui/output')
const { getChainId } = require('ethernaut-common/src/util/network')
const { connect } = require('../internal/connect')
const debug = require('ethernaut-common/src/ui/debug')
const { connect, getLevelContract } = require('../internal/connect')

require('../scopes/zeronaut')
.task('get-campaign', 'Retrieves details for a campaign')
Expand All @@ -21,8 +20,18 @@ require('../scopes/zeronaut')
const campaign = await contract.getCampaign(id)

let str = ''
str += `\n name: ${hre.ethers.decodeBytes32String(campaign.id)}`
str += ` name: ${hre.ethers.decodeBytes32String(campaign.id)}`
str += `\n owner: ${campaign.owner}`
str += `\n levels: ${campaign.levels.length}`

for (let i = 0; i < campaign.levels.length; i++) {
const levelId = campaign.levels[i]
const levelData = await contract.getLevel(levelId)
const levelAddress = levelData.addr
const level = await getLevelContract(hre, levelAddress)
const levelName = hre.ethers.decodeBytes32String(await level.name())
str += `\n [${i + 1}] "${levelName}"`
}

return output.resultBox(str)
} catch (err) {
Expand Down

0 comments on commit bbfc535

Please sign in to comment.