Skip to content

Commit

Permalink
refactor(cli-template-contracts-hardhat): update cli contracts hardha…
Browse files Browse the repository at this point in the history
…t template
  • Loading branch information
vplasencia committed Feb 25, 2024
1 parent 6f1b279 commit 05c57f5
Show file tree
Hide file tree
Showing 17 changed files with 2,413 additions and 123 deletions.
13 changes: 13 additions & 0 deletions packages/cli-template-contracts-hardhat/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#root = true

[*]
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 120
indent_size = 4

[*.md]
trim_trailing_whitespace = false
2 changes: 1 addition & 1 deletion packages/cli-template-contracts-hardhat/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ INFURA_API_KEY=
ETHEREUM_PRIVATE_KEY=
REPORT_GAS=false
ETHERSCAN_API_KEY=
COINMARKETCAP_API_KEY=
COINMARKETCAP_API_KEY=
39 changes: 39 additions & 0 deletions packages/cli-template-contracts-hardhat/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# dependencies
node_modules
package-lock.json
yarn.lock
.yarn

# testing
coverage
coverage.json

# hardhat
artifacts
cache
typechain-types

# types
types

# circuits
circuits

# production
dist
build
docs

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# packages
cli-template-*

snark-artifacts
24 changes: 24 additions & 0 deletions packages/cli-template-contracts-hardhat/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"root": true,
"env": {
"es6": true
},
"extends": ["airbnb-base", "airbnb-typescript/base", "prettier"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"project": ["./tsconfig.json", "./packages/**/tsconfig.json"]
},
"plugins": ["@typescript-eslint"],
"rules": {
"no-underscore-dangle": "off",
"import/no-extraneous-dependencies": "off",
"no-bitwise": "off",
"no-await-in-loop": "off",
"no-restricted-syntax": "off",
"no-console": ["warn", { "allow": ["info", "warn", "error", "log"] }],
"@typescript-eslint/lines-between-class-members": "off",
"no-param-reassign": "off"
}
}
73 changes: 67 additions & 6 deletions packages/cli-template-contracts-hardhat/.gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,71 @@
node_modules
.env
coverage
coverage.json
typechain
typechain-types

# Hardhat files
cache
artifacts
/cache
/artifacts

# TypeChain files
/typechain
/typechain-types

# solidity-coverage files
/coverage
/coverage.json

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# IDE
.vscode
.idea

# Dependency directories
node_modules/

# Output of 'npm pack'
*.tgz

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Yarn Integrity file
.yarn-integrity

# vercel
.vercel

# dotenv environment variable files
.env

# Optional npm cache directory
.npm
.DS_Store

# yarn v3
.pnp.*
.pnp.js
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
37 changes: 37 additions & 0 deletions packages/cli-template-contracts-hardhat/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# dependencies
node_modules
package-lock.json
yarn.lock
.yarn


# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# testing
coverage
coverage.json

# hardhat
artifacts
cache
typechain-types
packages/contracts/deployed-contracts/undefined.json
packages/contracts/deployed-contracts/hardhat.json
packages/contracts/deployed-contracts/localhost.json

# contracts
Verifier*.sol

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

zk-artifacts
5 changes: 5 additions & 0 deletions packages/cli-template-contracts-hardhat/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"semi": false,
"arrowParens": "always",
"trailingComma": "none"
}
3 changes: 3 additions & 0 deletions packages/cli-template-contracts-hardhat/.solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "solhint:default"
}
893 changes: 893 additions & 0 deletions packages/cli-template-contracts-hardhat/.yarn/releases/yarn-4.1.0.cjs

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions packages/cli-template-contracts-hardhat/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
compressionLevel: mixed

enableGlobalCache: false

nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.1.0.cjs
32 changes: 29 additions & 3 deletions packages/cli-template-contracts-hardhat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@ This project demonstrates a basic Semaphore use case. It comes with a sample con

## Usage

### Compile
### Install dependencies

```bash
yarn
```

### Compile contracts

```bash
yarn compile
```

### Testing
### Test contracts

```bash
yarn test
Expand All @@ -28,7 +34,7 @@ Or a test gas report:
yarn test:report-gas
```

### Deploy
### Deploy contracts

1. Copy the `.env.example` file as `.env`.

Expand All @@ -52,3 +58,23 @@ yarn deploy --semaphore <semaphore-address> --group <group-id> --network sepolia
> **Warning**
> The group id is a number!
### Code quality and formatting

Run [ESLint](https://eslint.org/) and [solhint](https://github.com/protofire/solhint) to analyze the code and catch bugs:

```bash
yarn lint
```

Run [Prettier](https://prettier.io/) to check formatting rules:

```bash
yarn prettier
```

Or to automatically format the code:

```bash
yarn prettier:write
```
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ contract Feedback {

uint256 public groupId;

constructor(ISemaphore _semaphore, uint256 _groupId) {
semaphore = _semaphore;
constructor(address semaphoreAddress, uint256 _groupId) {
semaphore = ISemaphore(semaphoreAddress);
groupId = _groupId;

semaphore.createGroup(groupId, address(this));
Expand Down
17 changes: 5 additions & 12 deletions packages/cli-template-contracts-hardhat/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import "@nomicfoundation/hardhat-chai-matchers"
import "@nomicfoundation/hardhat-ethers"
import "@nomicfoundation/hardhat-verify"
import "@semaphore-protocol/hardhat"
import "@typechain/hardhat"
import { config as dotenvConfig } from "dotenv"
import "hardhat-gas-reporter"
import { HardhatUserConfig } from "hardhat/config"
import { NetworksUserConfig } from "hardhat/types"
import "solidity-coverage"
import "@nomicfoundation/hardhat-toolbox"
import "dotenv/config"
import "@semaphore-protocol/hardhat"
import "./tasks/deploy"

dotenvConfig()

function getNetworks(): NetworksUserConfig {
if (!process.env.INFURA_API_KEY || !process.env.ETHEREUM_PRIVATE_KEY) {
return {}
Expand Down Expand Up @@ -49,7 +42,7 @@ function getNetworks(): NetworksUserConfig {
}
}

const hardhatConfig: HardhatUserConfig = {
const config: HardhatUserConfig = {
solidity: "0.8.23",
networks: {
hardhat: {
Expand All @@ -73,4 +66,4 @@ const hardhatConfig: HardhatUserConfig = {
}
}

export default hardhatConfig
export default config

0 comments on commit 05c57f5

Please sign in to comment.