chore: add lint-staged

This commit is contained in:
Wanseob Lim
2020-08-17 03:20:03 +09:00
parent b218565c52
commit 7a382e781f
8 changed files with 71 additions and 47 deletions

View File

@@ -68,9 +68,9 @@ members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
available at <https://www.contributor-covenant.org/version/1/4/code-of-conduct.html>
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
<https://www.contributor-covenant.org/faq>

View File

@@ -1,6 +1,6 @@
# Contributing to Zkopru👋
Thanks for taking a time to read this document. This document includes how to contribute to the project including testing and commits.
Thanks for taking a time to read this document. This document includes how to contribute to the project including testing and commits.
## Table of Content
@@ -21,46 +21,50 @@ In this case, please report the bug via [security@zkopru.network](mailto:securit
This project follows the conventional commit rule.
To check the full specification, please see [https://www.conventionalcommits.org/](https://www.conventionalcommits.org/)
Here is the sample commits.
1. Commit message with description and breaking change footer
```
```text
feat: allow provided config object to extend other configs
BREAKING CHANGE: `extends` key in config file is now used for extending other config files
```
2. Commit message with ! to draw attention to breaking change
```
```text
refactor!: drop support for Node 6
```
3. Commit message with both ! and BREAKING CHANGE footer
```
```text
refactor!: drop support for Node 6
BREAKING CHANGE: refactor to use JavaScript features not available in Node 6.
```
4. Commit message with no body
```
```text
docs: correct spelling of CHANGELOG
```
5. Commit message with scope
```
```text
feat(lang): add polish language
```
6. Commit message with multi-paragraph body and multiple footers
```
```text
fix: correct minor typos in code
see the issue for details
see the issue for details
on typos fixed.
Reviewed-by: Z
Refs #133
```
@@ -82,11 +86,14 @@ This uses airbnb eslint, and husky will automatically prettify using commit-hook
* Get nvm [here](https://github.com/nvm-sh/nvm#installing-and-updating)
* Download node version 12 and set to use it.
```shell
nvm install 12
nvm use 12
```
If you want to make node 12 as the default option run && yarn build:keys
```shell
nvm alias default 12
```
@@ -118,14 +125,14 @@ This uses airbnb eslint, and husky will automatically prettify using commit-hook
```
This command will run the coordinator & cli wallet using docker and you can easily access to the running programs via web browser.
* coordinator: http://localhost:1234
* cli wallet: http://localhost:4321
* coordinator: <http://localhost:1234>
* cli wallet: <http://localhost:4321>
Or you can setup the environment without docker-compose. Please check ["Manually setup Run cli applications"](#manually-setup-run-cli-applications) section.
### Integration test
```
```shell
yarn test
```
@@ -144,47 +151,56 @@ yarn test
```shell
cd packages/cli && yarn dev:coordinator
```
This will give you a cli menu to operate coordinator locally.
This will give you a cli menu to operate coordinator locally.
4. Go to the cli package and run wallet with a pre-configured test account.
```shell
cd packages/cli && yarn dev:wallet
```
This will give you a cli menu to run wallet locally.
5. It stores the dev log in `packages/cli/WALLET_LOG` and `packages/cli/COORDINATOR_LOG`. You can beautify the logs using this command.
```shell
$ npm install -g pino-pretty
$ tail -f packages/cli/WALLET_LOG | pino-pretty
$ tail -f packages/cli/COORDINATOR_LOG | pino-pretty
npm install -g pino-pretty
tail -f packages/cli/WALLET_LOG | pino-pretty
tail -f packages/cli/COORDINATOR_LOG | pino-pretty
```
### How to make changes of the circuit package.
### How to make changes of the circuit package
1. Add a test circuit in the directory `packages/circuits/tester/`
2. Write testcase in the directory `packages/circuits/tests`
3. Run test command
```shell
lerna run test --scope=@zkopru/circuits
```
or
```
cd packages/circuits
yarn test
```
4. After the testing, build a docker image to use the compiled circuit and keys
```
# root directory of the project
yarn build:images
# Or you can build only the zkoprunet/circuits image with this command
docker-compose -f dockerfiles/docker-compose.yml build circuits
```
This command will compile and setup circuits in the `impls` directory.
5. (maintainer only) Update dockerifles/docker-compose.yml to modify tag and run following:
```shell
lerna run test --scope=@zkopru/circuits
```
or
```shell
cd packages/circuits
yarn test
```
4. After the testing, build a docker image to use the compiled circuit and keys
```shell
# root directory of the project
yarn build:images
# Or you can build only the zkoprunet/circuits image with this command
docker-compose -f dockerfiles/docker-compose.yml build circuits
```
This command will compile and setup circuits in the `impls` directory.
5. (maintainer only) Update dockerifles/docker-compose.yml to modify tag and run following:
```shell
yarn build:images
docker-compose -f dockerfiles/docker-compose.yml push
```
@@ -198,15 +214,19 @@ You can open the Prisma Studio to explore the database with following steps:
2. Write up the database connection information.
* for dev coordinator
```
```shell
# file packages/prisma/prisma/.env
DATABASE_URL="file:../../cli/zkopru-coordinator.db"
```
* for dev wallet
```
```shell
# file packages/prisma/prisma/.env
DATABASE_URL="file:../../cli/zkopru-wallet.db"
```
3. Run `yarn studio`
```shell
@@ -218,9 +238,11 @@ You can open the Prisma Studio to explore the database with following steps:
1. Modify `packages/prisma/prisma/schema.prisma`
2. Run the following command will update the typescript automatically.
```shell
yarn build:prisma
```
3. Update mockup database (WIP)
### Optional commands
@@ -237,7 +259,6 @@ yarn build:fresh
yarn build:ts
```
This command will re-build the whole packages by wiping away every artifacts.
#### Setting up new snark keys

View File

@@ -2,11 +2,11 @@
![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/zkopru-network/zkopru)
Zkopru testnet, Arctic Roll, has launched! Please visit https://zkopru.network and try it now :)
Zkopru testnet, Arctic Roll, has launched! Please visit <https://zkopru.network> and try it now :)
![Banner](https://docs.google.com/drawings/d/e/2PACX-1vRwGTvmJAbNBZCK5syubcrWZgYc3wuK9cHZScbc5lgyLbBYsx42Xzo60unw4-oLlPg_-nwXxaE3t9c6/pub?w=1280)
## What is zkopru?
## What is zkopru
Zkopru(zk-optimistic-rollup) is a layer-2 scaling solution for private transactions using zk-SNARK and optimistic rollup. It supports private transfer and private atomic swap within the layer-2 network between ETH, ERC20, ERC721 at a low cost. Also, with the pay-in-advance feature, users can withdraw assets from the layer-2 before the finalization.

View File

@@ -40,7 +40,7 @@
"format": "yarn lint --fix",
"format:md": "yarn lint:md --fix",
"husky-skip": "cross-env HUSKY_SKIP_HOOKS=1",
"precommit": "lerna run --concurrency 1 --stream precommit --since HEAD",
"precommit": "lint-staged && lerna run --concurrency 1 --stream precommit --since HEAD",
"commit": "git cz"
},
"husky": {

View File

@@ -1,4 +1,5 @@
# @zkopru/circuits
## Testcases
[../packages/dataset/test/circuits](../packages/dataset/test/circuits)

View File

@@ -4,6 +4,7 @@ import Web3 from 'web3'
import { verifyProof } from '@zkopru/tree'
import { DB } from '@zkopru/prisma'
import { Bytes32 } from 'soltypes'
import { logger } from '@zkopru/utils'
import { L1Contract } from './layer1'
import { Verifier, VerifyOption } from './verifier'
import { L2Chain } from './layer2'
@@ -11,7 +12,6 @@ import { BootstrapHelper } from './bootstrap'
import { Block, headerHash } from './block'
import { Synchronizer } from './synchronizer'
import { ZkOPRUNode } from './zkopru-node'
import { logger } from '@zkopru/utils'
type provider = WebsocketProvider | IpcProvider

View File

@@ -1,6 +1,7 @@
import path from 'path'
import { buildKeys } from './testset-zktxs'
// eslint-disable-next-line prettier/prettier
(async () => {
const keyPath = path.join(path.dirname(__filename), '../keys')
await buildKeys(keyPath)

View File

@@ -1,5 +1,6 @@
import { getDummyBody } from './testset-block'
// eslint-disable-next-line prettier/prettier
(async () => {
await getDummyBody()
})().catch(e => {