Skip to content

Commit

Permalink
Update cli to zeronaut proxies
Browse files Browse the repository at this point in the history
  • Loading branch information
eternauta1337 committed Oct 6, 2024
1 parent c59bd19 commit 1fe9780
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 25 deletions.
18 changes: 15 additions & 3 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion packages/ethernaut-zeronaut/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"nyc-report-lcov-absolute": "^1.0.0"
},
"dependencies": {
"zeronaut": "file:~/zeronaut/zeronaut",
"zeronaut-contracts": "file:~/zeronaut/zeronaut-contracts",
"@noir-lang/backend_barretenberg": "0.31.0",
"@noir-lang/noir_js": "0.31.0"
},
Expand Down
9 changes: 6 additions & 3 deletions packages/ethernaut-zeronaut/src/internal/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ async function connect(network, hre) {

// Retrieve the deployed addresses for the given network
const addresses = _getDeployedAddresses(network)
const address = addresses['Zeronaut#Zeronaut']
const address = addresses['ProxyModule#UUPSProxy']
debug.log(`Main contract address: ${address}`, 'zeronaut')

// Retrieve the game abi
Expand All @@ -25,7 +25,10 @@ function _getGameAbi(network) {
_getNetworkFolderPath(network),
'artifacts',
)
const abiPath = path.join(artifactsFolderPath, 'Zeronaut#Zeronaut.json')
const abiPath = path.join(
artifactsFolderPath,
'ProxyModule#WrappedProxy.json',
)
return JSON.parse(fs.readFileSync(abiPath, 'utf8')).abi
}

Expand Down Expand Up @@ -71,7 +74,7 @@ function _getIgnitionFolderPath() {
}

function _getZeronautFolderPath() {
const zeronautPkgPath = require.resolve('zeronaut/package.json')
const zeronautPkgPath = require.resolve('zeronaut-contracts/package.json')
return path.dirname(zeronautPkgPath)
}

Expand Down
25 changes: 7 additions & 18 deletions packages/ethernaut-zeronaut/src/tasks/play-level.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const output = require('ethernaut-common/src/ui/output')
const { getChainId } = require('ethernaut-common/src/util/network')
const { connect, getLevelContract } = require('../internal/connect')
const { prompt } = require('ethernaut-common/src/ui/prompt')
const { buildProof, buildSignature } = require('zeronaut/utils/build-proof')
const { buildProof } = require('zeronaut-contracts/utils/build-proof')

require('../scopes/zeronaut')
.task('play-level', 'Plays a level')
Expand Down Expand Up @@ -33,28 +33,17 @@ require('../scopes/zeronaut')
// Build the circuit and collect the parameters
const circuit = JSON.parse(levelCircuitData)
const { inputs, publicInputs } = await _collectInputs(circuit.abi)
// console.log('inputs', inputs)
// console.log('publicInputs', publicInputs)

// Retrieve the signer
const signer = (await hre.ethers.getSigners())[0]

// Build the signature, and include it in the inputs
const { signature, pubKeyX, pubKeyY, hashedMsg } =
await buildSignature(signer)
inputs.signature = signature
inputs.pubKeyX = pubKeyX
inputs.pubKeyY = pubKeyY
inputs.hashedMsg = hashedMsg
// Also include it in the public inputs
publicInputs.push(...pubKeyX)
publicInputs.push(...pubKeyY)
console.log('inputs', inputs)
console.log('publicInputs', publicInputs)

// Build the proof
const proof = await buildProof(circuit, inputs)
// console.log('proof', proof)
const { proof, publicInputs: morePublicInputs } = await buildProof(
signer,
circuit,
inputs,
)
publicInputs.push(...morePublicInputs)

// Check the proof
const success = await level.check(proof, publicInputs)
Expand Down

0 comments on commit 1fe9780

Please sign in to comment.