2024-01-25 09:49:53 +00:00
|
|
|
const { loadZkeyHash } = require("../verifier/verifier.js")
|
2024-01-30 05:36:27 +00:00
|
|
|
|
2024-01-25 09:49:53 +00:00
|
|
|
// marketplace configuration
|
|
|
|
const CONFIGURATION = {
|
|
|
|
collateral: {
|
|
|
|
repairRewardPercentage: 10,
|
|
|
|
maxNumberOfSlashes: 5,
|
|
|
|
slashCriterion: 3,
|
|
|
|
slashPercentage: 10,
|
|
|
|
},
|
|
|
|
proofs: {
|
2024-02-20 16:37:41 +00:00
|
|
|
period: 60,
|
|
|
|
timeout: 30,
|
|
|
|
// `downtime` needs to be larger than `period` when running hardhat
|
|
|
|
// in automine mode, because it can produce a block every second
|
2024-01-25 09:49:53 +00:00
|
|
|
downtime: 64,
|
|
|
|
},
|
2021-11-16 12:54:38 +00:00
|
|
|
}
|
|
|
|
|
2022-03-15 15:45:35 +00:00
|
|
|
async function mine256blocks({ network, ethers }) {
|
|
|
|
if (network.tags.local) {
|
|
|
|
await ethers.provider.send("hardhat_mine", ["0x100"])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-25 09:49:53 +00:00
|
|
|
// deploys a marketplace with a real Groth16 verifier
|
2024-01-25 14:00:46 +00:00
|
|
|
async function deployMarketplace({ deployments, getNamedAccounts }) {
|
2024-01-25 09:49:53 +00:00
|
|
|
const token = await deployments.get("TestToken")
|
|
|
|
const verifier = await deployments.get("Groth16Verifier")
|
|
|
|
const zkeyHash = loadZkeyHash(network.name)
|
2024-01-31 14:58:18 +00:00
|
|
|
let configuration = CONFIGURATION
|
|
|
|
configuration.proofs.zkeyHash = zkeyHash
|
2024-01-25 09:49:53 +00:00
|
|
|
const args = [configuration, token.address, verifier.address]
|
|
|
|
const { deployer: from } = await getNamedAccounts()
|
|
|
|
const marketplace = await deployments.deploy("Marketplace", { args, from })
|
2024-01-25 14:00:46 +00:00
|
|
|
console.log("Deployed Marketplace with Groth16 Verifier at:")
|
|
|
|
console.log(marketplace.address)
|
|
|
|
console.log()
|
2024-01-25 09:49:53 +00:00
|
|
|
}
|
2023-04-26 07:44:55 +00:00
|
|
|
|
2024-01-25 09:49:53 +00:00
|
|
|
// deploys a marketplace with a testing verifier
|
|
|
|
async function deployTestMarketplace({
|
|
|
|
network,
|
|
|
|
deployments,
|
|
|
|
getNamedAccounts,
|
|
|
|
}) {
|
|
|
|
if (network.tags.local) {
|
|
|
|
const token = await deployments.get("TestToken")
|
|
|
|
const verifier = await deployments.get("TestVerifier")
|
|
|
|
const zkeyHash = loadZkeyHash(network.name)
|
2024-01-31 14:58:18 +00:00
|
|
|
let configuration = CONFIGURATION
|
|
|
|
configuration.proofs.zkeyHash = zkeyHash
|
2024-01-25 09:49:53 +00:00
|
|
|
const args = [configuration, token.address, verifier.address]
|
|
|
|
const { deployer: from } = await getNamedAccounts()
|
|
|
|
const marketplace = await deployments.deploy("Marketplace", { args, from })
|
2024-01-25 14:00:46 +00:00
|
|
|
console.log("Deployed Marketplace with Test Verifier at:")
|
|
|
|
console.log(marketplace.address)
|
|
|
|
console.log()
|
2023-04-26 07:44:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-15 15:45:35 +00:00
|
|
|
module.exports = async (environment) => {
|
|
|
|
await mine256blocks(environment)
|
2023-01-09 15:01:43 +00:00
|
|
|
await deployMarketplace(environment)
|
2024-01-25 09:49:53 +00:00
|
|
|
await deployTestMarketplace(environment)
|
2022-03-15 15:45:35 +00:00
|
|
|
}
|
|
|
|
|
2023-01-09 15:01:43 +00:00
|
|
|
module.exports.tags = ["Marketplace"]
|
2024-01-25 09:49:53 +00:00
|
|
|
module.exports.dependencies = ["TestToken", "Verifier"]
|