Merge branch 'hardhat' of github.com:tornadocash/tornado-trees into hardhat

This commit is contained in:
Alexey 2021-02-03 20:59:49 +03:00
commit 362b126e17
6 changed files with 42 additions and 18 deletions

2
.env.example Normal file

@ -0,0 +1,2 @@
PRIVATE_KEY=0x
INFURA_TOKEN=

@ -20,12 +20,12 @@ jobs:
- run: yarn circuit - run: yarn circuit
- run: yarn test - run: yarn test
- run: yarn lint - run: yarn lint
# - name: Telegram Failure Notification - name: Telegram Failure Notification
# uses: appleboy/telegram-action@0.0.7 uses: appleboy/telegram-action@0.0.7
# if: failure() if: failure()
# with: with:
# message: ❗ Build failed for [${{ github.repository }}](https://github.com/${{ github.repository }}/actions) because of ${{ github.actor }} message: ❗ Build failed for [${{ github.repository }}](https://github.com/${{ github.repository }}/actions) because of ${{ github.actor }}
# format: markdown format: markdown
# to: ${{ secrets.TELEGRAM_CHAT_ID }} to: ${{ secrets.TELEGRAM_CHAT_ID }}
# token: ${{ secrets.TELEGRAM_BOT_TOKEN }} token: ${{ secrets.TELEGRAM_BOT_TOKEN }}

1
.gitignore vendored

@ -3,3 +3,4 @@ node_modules
#Hardhat files #Hardhat files
cache cache
artifacts artifacts
.env

@ -1,4 +1,4 @@
# Tornado.cash trees [![Build Status](https://github.com/tornadocash/tornado-anonymity-mining/workflows/build/badge.svg)](https://github.com/tornadocash/tornado-anonymity-mining/actions) [![npm](https://img.shields.io/npm/v/tornado-anonymity-mining)](https://www.npmjs.com/package/tornado-anonymity-mining) # Tornado.cash trees [![Build Status](https://github.com/tornadocash/tornado-trees/workflows/build/badge.svg)](https://github.com/tornadocash/tornado-trees/actions)
This repo implements a more optimized version of the [TornadoTrees](https://github.com/tornadocash/tornado-anonymity-mining/blob/080d0f83665fa686d7fe42dd57fb5975d0f1ca58/contracts/TornadoTrees.sol) mechanism. This repo implements a more optimized version of the [TornadoTrees](https://github.com/tornadocash/tornado-anonymity-mining/blob/080d0f83665fa686d7fe42dd57fb5975d0f1ca58/contracts/TornadoTrees.sol) mechanism.
@ -12,7 +12,6 @@ This repo implements a more optimized version of the [TornadoTrees](https://gith
```bash ```bash
$ yarn $ yarn
$ cp .env.example .env
$ yarn circuit $ yarn circuit
$ yarn test $ yarn test
``` ```

@ -1,6 +1,6 @@
/* global task, ethers */ /* global task, ethers */
require('@nomiclabs/hardhat-waffle') require('@nomiclabs/hardhat-waffle')
require('dotenv').config()
// This is a sample Hardhat task. To learn how to create your own go to // This is a sample Hardhat task. To learn how to create your own go to
// https://hardhat.org/guides/create-task.html // https://hardhat.org/guides/create-task.html
task('accounts', 'Prints the list of accounts', async () => { task('accounts', 'Prints the list of accounts', async () => {
@ -19,4 +19,10 @@ task('accounts', 'Prints the list of accounts', async () => {
*/ */
module.exports = { module.exports = {
solidity: '0.6.12', solidity: '0.6.12',
networks: {
goerli: {
url: `https://goerli.infura.io/v3/${process.env.INFURA_TOKEN}`,
accounts: [process.env.PRIVATE_KEY],
},
},
} }

@ -4,6 +4,9 @@
// When running the script with `hardhat run <script>` you'll find the Hardhat // When running the script with `hardhat run <script>` you'll find the Hardhat
// Runtime Environment's members available in the global scope. // Runtime Environment's members available in the global scope.
const hre = require('hardhat') const hre = require('hardhat')
const { toFixedHex, poseidonHash2 } = require('../src/utils')
const toEns = (addr) => toFixedHex(addr, 20).padEnd(66, '0')
const MerkleTree = require('fixed-merkle-tree')
async function main() { async function main() {
// Hardhat always runs the compile task when running scripts with its command // Hardhat always runs the compile task when running scripts with its command
@ -13,13 +16,26 @@ async function main() {
// manually to make sure everything is compiled // manually to make sure everything is compiled
// await hre.run('compile'); // await hre.run('compile');
// We get the contract to deploy const BatchTreeUpdateVerifier = await hre.ethers.getContractFactory('BatchTreeUpdateVerifier')
const Greeter = await hre.ethers.getContractFactory('Greeter') const verifier = await BatchTreeUpdateVerifier.deploy()
const greeter = await Greeter.deploy('Hello, Hardhat!') await verifier.deployed()
const TornadoTrees = await hre.ethers.getContractFactory('TornadoTrees')
await greeter.deployed() // bytes32 _governance,
// bytes32 _tornadoProxy,
console.log('Greeter deployed to:', greeter.address) // bytes32 _treeUpdateVerifier,
// bytes32 _depositRoot,
// bytes32 _withdrawalRoot
const levels = 20
const tree = new MerkleTree(levels, [], { hashFunction: poseidonHash2 })
const tornadoTrees = await TornadoTrees.deploy(
toEns('0x5efda50f22d34F262c29268506C5Fa42cB56A1Ce'),
toEns('0x905b63Fff465B9fFBF41DeA908CEb12478ec7601'),
toEns(verifier.address),
toFixedHex(tree.root()),
toFixedHex(tree.root()),
)
await tornadoTrees.deployed()
console.log('tornadoTrees deployed to:', tornadoTrees.address)
} }
// We recommend this pattern to be able to use async/await everywhere // We recommend this pattern to be able to use async/await everywhere