2024-01-30 05:36:27 +00:00
|
|
|
const { loadZkeyHash } = require ("../verifier/verifier.js")
|
|
|
|
|
2023-04-26 07:44:55 +00:00
|
|
|
const MARKETPLACE_HARDCODED_ADDRESS = "0x59b670e9fA9D0A427751Af201D676719a970857b"
|
|
|
|
|
2024-01-30 05:36:27 +00:00
|
|
|
async function deployMarketplace({ deployments, getNamedAccounts, network }) {
|
2022-02-09 13:17:23 +00:00
|
|
|
const token = await deployments.get("TestToken")
|
2024-01-23 13:14:53 +00:00
|
|
|
const verifier = await deployments.get("Groth16Verifier")
|
2023-01-17 14:09:19 +00:00
|
|
|
const configuration = {
|
|
|
|
collateral: {
|
2023-03-30 09:11:21 +00:00
|
|
|
repairRewardPercentage: 10,
|
|
|
|
maxNumberOfSlashes: 5,
|
2023-01-17 14:09:19 +00:00
|
|
|
slashCriterion: 3,
|
|
|
|
slashPercentage: 10,
|
|
|
|
},
|
|
|
|
proofs: {
|
|
|
|
period: 10,
|
|
|
|
timeout: 5,
|
|
|
|
downtime: 64,
|
2024-01-30 05:36:27 +00:00
|
|
|
zkeyHash: loadZkeyHash(network.name),
|
2023-01-17 14:09:19 +00:00
|
|
|
},
|
|
|
|
}
|
2024-01-23 13:14:53 +00:00
|
|
|
const args = [configuration, token.address, verifier.address]
|
2021-11-16 12:54:38 +00:00
|
|
|
const { deployer } = await getNamedAccounts()
|
2023-01-09 15:01:43 +00:00
|
|
|
await deployments.deploy("Marketplace", { args, from: deployer })
|
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"])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-26 07:44:55 +00:00
|
|
|
async function aliasContract({deployments, network}) {
|
|
|
|
if (network.tags.local) {
|
|
|
|
const marketplaceDeployment = await deployments.get("Marketplace")
|
|
|
|
|
|
|
|
if (marketplaceDeployment.address === MARKETPLACE_HARDCODED_ADDRESS) {
|
2024-01-05 11:27:53 +00:00
|
|
|
return
|
2023-04-26 07:44:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
console.log(`Aliasing marketplace from address ${marketplaceDeployment.address} to ${MARKETPLACE_HARDCODED_ADDRESS}`)
|
|
|
|
await ethers.provider.send("hardhat_setCode", [MARKETPLACE_HARDCODED_ADDRESS, marketplaceDeployment.address])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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)
|
2023-04-26 07:44:55 +00:00
|
|
|
await aliasContract(environment)
|
2022-03-15 15:45:35 +00:00
|
|
|
}
|
|
|
|
|
2023-01-09 15:01:43 +00:00
|
|
|
module.exports.tags = ["Marketplace"]
|
2024-01-23 13:14:53 +00:00
|
|
|
module.exports.dependencies = ["TestToken", "Groth16Verifier"]
|