tornado-core/migrations/2_deploy_mimc.js

25 lines
727 B
JavaScript
Raw Normal View History

2019-07-16 22:49:45 +02:00
/* global artifacts */
2019-07-16 19:27:20 +02:00
const path = require('path')
2019-07-10 18:58:21 +02:00
2019-07-16 19:27:20 +02:00
const mimcGenContract = require('circomlib/src/mimcsponge_gencontract.js')
const Artifactor = require('truffle-artifactor')
2019-07-10 18:58:21 +02:00
2019-07-16 19:27:20 +02:00
const SEED = 'mimcsponge'
2019-07-10 18:58:21 +02:00
module.exports = function(deployer) {
return deployer.then( async () => {
2019-07-16 19:27:20 +02:00
const contractsDir = path.join(__dirname, '..', 'build/contracts')
let artifactor = new Artifactor(contractsDir)
let mimcContractName = 'MiMC'
2019-07-10 18:58:21 +02:00
await artifactor.save({
contractName: mimcContractName,
abi: mimcGenContract.abi,
unlinked_binary: mimcGenContract.createCode(SEED, 220),
2019-07-16 19:27:20 +02:00
}).then(async () => {
const MiMC = artifacts.require(mimcContractName)
await deployer.deploy(MiMC)
2019-07-10 18:58:21 +02:00
})
2019-07-16 19:27:20 +02:00
})
}