rename mimc mentions to a generic hasher

This commit is contained in:
poma 2019-10-04 15:12:22 +03:00
parent 6b067f067f
commit 71b767ade1
6 changed files with 28 additions and 28 deletions

View file

@ -1,7 +1,7 @@
/* global artifacts */
const path = require('path')
const mimcGenContract = require('circomlib/src/mimcsponge_gencontract.js')
const genContract = require('circomlib/src/mimcsponge_gencontract.js')
const Artifactor = require('truffle-artifactor')
const SEED = 'mimcsponge'
@ -11,14 +11,14 @@ module.exports = function(deployer) {
return deployer.then( async () => {
const contractsDir = path.join(__dirname, '..', 'build/contracts')
let artifactor = new Artifactor(contractsDir)
let mimcContractName = 'MiMC'
let contractName = 'Hasher'
await artifactor.save({
contractName: mimcContractName,
abi: mimcGenContract.abi,
unlinked_binary: mimcGenContract.createCode(SEED, 220),
contractName,
abi: genContract.abi,
unlinked_binary: genContract.createCode(SEED, 220),
}).then(async () => {
const MiMC = artifacts.require(mimcContractName)
await deployer.deploy(MiMC)
const hasherContract = artifacts.require(contractName)
await deployer.deploy(hasherContract)
})
})
}

View file

@ -2,15 +2,15 @@
require('dotenv').config({ path: '../.env' })
const ETHMixer = artifacts.require('ETHMixer')
const Verifier = artifacts.require('Verifier')
const MiMC = artifacts.require('MiMC')
const hasherContract = artifacts.require('hasher')
module.exports = function(deployer, network, accounts) {
return deployer.then(async () => {
const { MERKLE_TREE_HEIGHT, ETH_AMOUNT, EMPTY_ELEMENT } = process.env
const verifier = await Verifier.deployed()
const miMC = await MiMC.deployed()
await ETHMixer.link(MiMC, miMC.address)
const hasherInstance = await hasherContract.deployed()
await ETHMixer.link(hasherContract, hasherInstance.address)
const mixer = await deployer.deploy(ETHMixer, verifier.address, ETH_AMOUNT, MERKLE_TREE_HEIGHT, EMPTY_ELEMENT, accounts[0])
console.log('ETHMixer\'s address ', mixer.address)
})

View file

@ -2,7 +2,7 @@
require('dotenv').config({ path: '../.env' })
const ERC20Mixer = artifacts.require('ERC20Mixer')
const Verifier = artifacts.require('Verifier')
const MiMC = artifacts.require('MiMC')
const hasherContract = artifacts.require('hasher')
const ERC20Mock = artifacts.require('ERC20Mock')
@ -10,8 +10,8 @@ module.exports = function(deployer, network, accounts) {
return deployer.then(async () => {
const { MERKLE_TREE_HEIGHT, ETH_AMOUNT, EMPTY_ELEMENT, ERC20_TOKEN, TOKEN_AMOUNT } = process.env
const verifier = await Verifier.deployed()
const miMC = await MiMC.deployed()
await ERC20Mixer.link(MiMC, miMC.address)
const hasherInstance = await hasherContract.deployed()
await ERC20Mixer.link(hasherContract, hasherInstance.address)
let token = ERC20_TOKEN
if(token === '') {
const tokenInstance = await deployer.deploy(ERC20Mock)