mirror of
https://github.com/tornadocash/tornado-aggregator.git
synced 2025-02-14 13:10:27 +01:00
Init
This commit is contained in:
commit
884c48899d
9
.editorconfig
Normal file
9
.editorconfig
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
end_of_line = lf
|
||||||
|
charset = utf-8
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
3
.env.example
Normal file
3
.env.example
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
RPC_URL=
|
||||||
|
INFURA_TOKEN=
|
||||||
|
PRIVATE_KEY=
|
27
.eslintrc
Normal file
27
.eslintrc
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"env": {
|
||||||
|
"node": true,
|
||||||
|
"browser": true,
|
||||||
|
"es6": true,
|
||||||
|
"mocha": true
|
||||||
|
},
|
||||||
|
"extends": ["eslint:recommended", "plugin:prettier/recommended", "prettier"],
|
||||||
|
"globals": {
|
||||||
|
"Atomics": "readonly",
|
||||||
|
"SharedArrayBuffer": "readonly"
|
||||||
|
},
|
||||||
|
"parser": "babel-eslint",
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": 2018
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
"indent": ["error", 2],
|
||||||
|
"linebreak-style": ["error", "unix"],
|
||||||
|
"quotes": ["error", "single"],
|
||||||
|
"semi": ["error", "never"],
|
||||||
|
"object-curly-spacing": ["error", "always"],
|
||||||
|
"comma-dangle": ["error", "always-multiline"],
|
||||||
|
"require-await": "error",
|
||||||
|
"prettier/prettier": ["error", { "printWidth": 110 }]
|
||||||
|
}
|
||||||
|
}
|
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
*.sol linguist-language=Solidity
|
84
.github/workflows/build.yml
vendored
Normal file
84
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
name: build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: ['*']
|
||||||
|
tags: ['v[0-9]+.[0-9]+.[0-9]+']
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
# - uses: actions/setup-node@v1
|
||||||
|
# with:
|
||||||
|
# node-version: 12
|
||||||
|
# - run: yarn install
|
||||||
|
# - 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 }}
|
||||||
|
#
|
||||||
|
# publish:
|
||||||
|
# runs-on: ubuntu-latest
|
||||||
|
# needs: build
|
||||||
|
# if: startsWith(github.ref, 'refs/tags')
|
||||||
|
# steps:
|
||||||
|
# - name: Checkout
|
||||||
|
# uses: actions/checkout@v2
|
||||||
|
#
|
||||||
|
# - name: Install dependencies
|
||||||
|
# run: yarn install
|
||||||
|
#
|
||||||
|
# - name: NPM login
|
||||||
|
# # NPM doesn't understand env vars and needs auth file lol
|
||||||
|
# run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
|
||||||
|
# env:
|
||||||
|
# NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
#
|
||||||
|
# - name: Set vars
|
||||||
|
# id: vars
|
||||||
|
# run: |
|
||||||
|
# echo "::set-output name=version::$(echo ${GITHUB_REF#refs/tags/v})"
|
||||||
|
# echo "::set-output name=repo_name::$(echo ${GITHUB_REPOSITORY#*/})"
|
||||||
|
#
|
||||||
|
# - name: Check package.json version vs tag
|
||||||
|
# run: |
|
||||||
|
# [ ${{ steps.vars.outputs.version }} = $(grep '"version":' package.json | grep -o "[0-9.]*") ] || (echo "Git tag doesn't match version in package.json" && false)
|
||||||
|
#
|
||||||
|
# - name: Publish to npm
|
||||||
|
# run: npm publish
|
||||||
|
#
|
||||||
|
# - name: Create GitHub Release Draft
|
||||||
|
# uses: actions/create-release@v1
|
||||||
|
# with:
|
||||||
|
# tag_name: ${{ github.ref }}
|
||||||
|
# release_name: Release ${{ steps.vars.outputs.version }}
|
||||||
|
# draft: true
|
||||||
|
# env:
|
||||||
|
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
#
|
||||||
|
# - name: Telegram Notification
|
||||||
|
# uses: appleboy/telegram-action@0.0.7
|
||||||
|
# with:
|
||||||
|
# message: 🚀 Published a [${{ steps.vars.outputs.repo_name }}](https://github.com/${{ github.repository }}) version [${{ steps.vars.outputs.version }}](https://hub.docker.com/repository/docker/${{ github.repository }}) to docker hub
|
||||||
|
# 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: ❗ Failed to publish [${{ steps.vars.outputs.repo_name }}](https://github.com/${{ github.repository }}/actions) because of ${{ env.GITHUB_ACTOR }}
|
||||||
|
# format: markdown
|
||||||
|
# to: ${{ secrets.TELEGRAM_CHAT_ID }}
|
||||||
|
# token: ${{ secrets.TELEGRAM_BOT_TOKEN }}
|
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
node_modules
|
||||||
|
build
|
||||||
|
.env
|
4
.prettierignore
Normal file
4
.prettierignore
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
.vscode
|
||||||
|
.idea
|
||||||
|
build
|
||||||
|
scripts
|
16
.prettierrc
Normal file
16
.prettierrc
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"singleQuote": true,
|
||||||
|
"trailingComma": "all",
|
||||||
|
"bracketSpacing": true,
|
||||||
|
"semi": false,
|
||||||
|
"printWidth": 110,
|
||||||
|
"overrides": [
|
||||||
|
{
|
||||||
|
"files": "*.sol",
|
||||||
|
"options": {
|
||||||
|
"singleQuote": false,
|
||||||
|
"printWidth": 130
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
22
LICENSE
Normal file
22
LICENSE
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2018 Truffle
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
22
README.md
Normal file
22
README.md
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# Peppersec solidity template [](https://github.com/peppersec/solidity-template/actions)
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
|
||||||
|
1. node 12
|
||||||
|
2. yarn
|
||||||
|
|
||||||
|
## Start
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ yarn
|
||||||
|
$ cp .env.example .env
|
||||||
|
$ yarn test
|
||||||
|
```
|
||||||
|
|
||||||
|
## Deploying
|
||||||
|
|
||||||
|
Deploy to Kovan:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ yarn deploy:kovan
|
||||||
|
```
|
11
contracts/Echoer.sol
Normal file
11
contracts/Echoer.sol
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
pragma solidity ^0.6.12;
|
||||||
|
|
||||||
|
contract Echoer {
|
||||||
|
event Echo(address indexed who, bytes data);
|
||||||
|
|
||||||
|
function echo(bytes calldata data) external {
|
||||||
|
emit Echo(msg.sender, data);
|
||||||
|
}
|
||||||
|
}
|
10
migrations/1_deploy_echo.js
Normal file
10
migrations/1_deploy_echo.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
/* global artifacts */
|
||||||
|
const Echoer = artifacts.require('Echoer')
|
||||||
|
|
||||||
|
module.exports = function (deployer) {
|
||||||
|
return deployer.then(async () => {
|
||||||
|
const echoer = await deployer.deploy(Echoer)
|
||||||
|
|
||||||
|
console.log('Echoer :', echoer.address)
|
||||||
|
})
|
||||||
|
}
|
47
package.json
Normal file
47
package.json
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
{
|
||||||
|
"name": "solidity-template",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "A template with all preferred configs",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"compile": "yarn truffle compile",
|
||||||
|
"test": "yarn truffle test",
|
||||||
|
"test:stacktrace": "yarn test --stacktrace",
|
||||||
|
"eslint": "eslint --ext .js --ignore-path .gitignore .",
|
||||||
|
"prettier:check": "prettier --check . --config .prettierrc",
|
||||||
|
"prettier:fix": "prettier --write . --config .prettierrc",
|
||||||
|
"lint": "yarn eslint && yarn prettier:check",
|
||||||
|
"deploy:mainnet": "truffle migrate --network mainnet",
|
||||||
|
"deploy:kovan": "truffle migrate --network kovan",
|
||||||
|
"deploy:dev": "truffle migrate --skip-dry-run --network development"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/peppersec/solidity-template.git"
|
||||||
|
},
|
||||||
|
"author": "peppersec.com <hello@peppersec.com>",
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/peppersec/solidity-template/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/peppersec/solidity-template#readme",
|
||||||
|
"devDependencies": {
|
||||||
|
"@openzeppelin/contracts": "^3.1.0",
|
||||||
|
"babel-eslint": "^10.1.0",
|
||||||
|
"bn-chai": "^1.0.1",
|
||||||
|
"chai": "^4.2.0",
|
||||||
|
"chai-as-promised": "^7.1.1",
|
||||||
|
"dotenv": "^8.2.0",
|
||||||
|
"eslint": "^7.5.0",
|
||||||
|
"eslint-config-prettier": "^6.11.0",
|
||||||
|
"eslint-plugin-prettier": "^3.1.4",
|
||||||
|
"prettier": "^2.1.1",
|
||||||
|
"prettier-plugin-solidity": "^1.0.0-alpha.54",
|
||||||
|
"solhint-plugin-prettier": "^0.0.4",
|
||||||
|
"truffle": "^5.1.29",
|
||||||
|
"truffle-flattener": "^1.4.4",
|
||||||
|
"truffle-hdwallet-provider": "^1.0.17",
|
||||||
|
"truffle-plugin-verify": "^0.3.11",
|
||||||
|
"web3": "^1.2.11"
|
||||||
|
}
|
||||||
|
}
|
55
scripts/ganacheHelper.js
Normal file
55
scripts/ganacheHelper.js
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
// This module is used only for tests
|
||||||
|
function send(method, params = []) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
web3.currentProvider.send(
|
||||||
|
{
|
||||||
|
jsonrpc: '2.0',
|
||||||
|
id: Date.now(),
|
||||||
|
method,
|
||||||
|
params,
|
||||||
|
},
|
||||||
|
(err, res) => {
|
||||||
|
return err ? reject(err) : resolve(res)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const takeSnapshot = async () => {
|
||||||
|
return await send('evm_snapshot')
|
||||||
|
}
|
||||||
|
|
||||||
|
const traceTransaction = async (tx) => {
|
||||||
|
return await send('debug_traceTransaction', [tx, {}])
|
||||||
|
}
|
||||||
|
|
||||||
|
const revertSnapshot = async (id) => {
|
||||||
|
await send('evm_revert', [id])
|
||||||
|
}
|
||||||
|
|
||||||
|
const mineBlock = async (timestamp) => {
|
||||||
|
await send('evm_mine', [timestamp])
|
||||||
|
}
|
||||||
|
|
||||||
|
const increaseTime = async (seconds) => {
|
||||||
|
await send('evm_increaseTime', [seconds])
|
||||||
|
}
|
||||||
|
|
||||||
|
const minerStop = async () => {
|
||||||
|
await send('miner_stop', [])
|
||||||
|
}
|
||||||
|
|
||||||
|
const minerStart = async () => {
|
||||||
|
await send('miner_start', [])
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
takeSnapshot,
|
||||||
|
revertSnapshot,
|
||||||
|
mineBlock,
|
||||||
|
minerStop,
|
||||||
|
minerStart,
|
||||||
|
increaseTime,
|
||||||
|
traceTransaction,
|
||||||
|
}
|
32
test/echoer.test.js
Normal file
32
test/echoer.test.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/* global artifacts, web3, contract */
|
||||||
|
require('chai').use(require('bn-chai')(web3.utils.BN)).use(require('chai-as-promised')).should()
|
||||||
|
|
||||||
|
const { takeSnapshot, revertSnapshot } = require('../scripts/ganacheHelper')
|
||||||
|
const Echoer = artifacts.require('./Echoer.sol')
|
||||||
|
|
||||||
|
contract('Echoer', (accounts) => {
|
||||||
|
let echoer
|
||||||
|
let snapshotId
|
||||||
|
|
||||||
|
before(async () => {
|
||||||
|
echoer = await Echoer.deployed()
|
||||||
|
snapshotId = await takeSnapshot()
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('#echo', () => {
|
||||||
|
it('should work', async () => {
|
||||||
|
const data = '0xbeef'
|
||||||
|
const { logs } = await echoer.echo(data)
|
||||||
|
|
||||||
|
logs[0].event.should.be.equal('Echo')
|
||||||
|
logs[0].args.who.should.be.equal(accounts[0])
|
||||||
|
logs[0].args.data.should.be.equal(data)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
afterEach(async () => {
|
||||||
|
await revertSnapshot(snapshotId.result)
|
||||||
|
// eslint-disable-next-line require-atomic-updates
|
||||||
|
snapshotId = await takeSnapshot()
|
||||||
|
})
|
||||||
|
})
|
62
truffle.js
Normal file
62
truffle.js
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
require('dotenv').config()
|
||||||
|
const HDWalletProvider = require('truffle-hdwallet-provider')
|
||||||
|
const utils = require('web3-utils')
|
||||||
|
const { PRIVATE_KEY, INFURA_TOKEN } = process.env
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
// Uncommenting the defaults below
|
||||||
|
// provides for an easier quick-start with Ganache.
|
||||||
|
// You can also follow this format for other networks;
|
||||||
|
// see <http://truffleframework.com/docs/advanced/configuration>
|
||||||
|
// for more details on how to specify configuration options!
|
||||||
|
//
|
||||||
|
networks: {
|
||||||
|
// development: {
|
||||||
|
// host: '127.0.0.1',
|
||||||
|
// port: 8545,
|
||||||
|
// network_id: '*',
|
||||||
|
// },
|
||||||
|
// test: {
|
||||||
|
// host: "127.0.0.1",
|
||||||
|
// port: 7545,
|
||||||
|
// network_id: "*"
|
||||||
|
// }
|
||||||
|
mainnet: {
|
||||||
|
provider: () => new HDWalletProvider(PRIVATE_KEY, `https://mainnet.infura.io/v3/${INFURA_TOKEN}`),
|
||||||
|
network_id: 1,
|
||||||
|
gas: 6000000,
|
||||||
|
gasPrice: utils.toWei('100', 'gwei'),
|
||||||
|
// confirmations: 0,
|
||||||
|
// timeoutBlocks: 200,
|
||||||
|
skipDryRun: true,
|
||||||
|
},
|
||||||
|
kovan: {
|
||||||
|
provider: () => new HDWalletProvider(PRIVATE_KEY, `https://kovan.infura.io/v3/${INFURA_TOKEN}`),
|
||||||
|
network_id: 42,
|
||||||
|
gas: 6000000,
|
||||||
|
gasPrice: utils.toWei('1', 'gwei'),
|
||||||
|
// confirmations: 0,
|
||||||
|
// timeoutBlocks: 200,
|
||||||
|
skipDryRun: true,
|
||||||
|
},
|
||||||
|
coverage: {
|
||||||
|
host: 'localhost',
|
||||||
|
network_id: '*',
|
||||||
|
port: 8554, // <-- If you change this, also set the port option in .solcover.js.
|
||||||
|
gas: 0xfffffffffff, // <-- Use this high gas value
|
||||||
|
gasPrice: 0x01, // <-- Use this low gas price
|
||||||
|
},
|
||||||
|
},
|
||||||
|
compilers: {
|
||||||
|
solc: {
|
||||||
|
version: '0.6.12',
|
||||||
|
settings: {
|
||||||
|
optimizer: {
|
||||||
|
enabled: true,
|
||||||
|
runs: 200,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
plugins: ['truffle-plugin-verify', 'solidity-coverage'],
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user