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
View File

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

View File

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

1
.gitignore vendored
View File

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

View File

@ -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.
@ -12,7 +12,6 @@ This repo implements a more optimized version of the [TornadoTrees](https://gith
```bash
$ yarn
$ cp .env.example .env
$ yarn circuit
$ yarn test
```

View File

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

View File

@ -4,6 +4,9 @@
// When running the script with `hardhat run <script>` you'll find the Hardhat
// Runtime Environment's members available in the global scope.
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() {
// 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
// await hre.run('compile');
// We get the contract to deploy
const Greeter = await hre.ethers.getContractFactory('Greeter')
const greeter = await Greeter.deploy('Hello, Hardhat!')
await greeter.deployed()
console.log('Greeter deployed to:', greeter.address)
const BatchTreeUpdateVerifier = await hre.ethers.getContractFactory('BatchTreeUpdateVerifier')
const verifier = await BatchTreeUpdateVerifier.deploy()
await verifier.deployed()
const TornadoTrees = await hre.ethers.getContractFactory('TornadoTrees')
// bytes32 _governance,
// bytes32 _tornadoProxy,
// 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