-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4cfae89
Showing
29 changed files
with
16,938 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
extends: | ||
- "@commitlint/config-conventional" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"path": "cz-conventional-changelog" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# EditorConfig http://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
# All files | ||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 2 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.sol] | ||
indent_size = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
INFURA_API_KEY=zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz | ||
MNEMONIC=here is where your twelve words mnemonic should be put my friend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# directories | ||
.yarn/ | ||
**/.coverage_artifacts | ||
**/.coverage_cache | ||
**/.coverage_contracts | ||
**/artifacts | ||
**/build | ||
**/cache | ||
**/coverage | ||
**/dist | ||
**/node_modules | ||
**/types | ||
|
||
# files | ||
*.env | ||
*.log | ||
.pnp.* | ||
coverage.json | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
extends: | ||
- "eslint:recommended" | ||
- "plugin:@typescript-eslint/eslint-recommended" | ||
- "plugin:@typescript-eslint/recommended" | ||
- "prettier" | ||
parser: "@typescript-eslint/parser" | ||
parserOptions: | ||
project: "tsconfig.json" | ||
plugins: | ||
- "@typescript-eslint" | ||
root: true | ||
rules: | ||
"@typescript-eslint/no-floating-promises": | ||
- error | ||
- ignoreIIFE: true | ||
ignoreVoid: true | ||
"@typescript-eslint/no-inferrable-types": "off" | ||
"@typescript-eslint/no-unused-vars": | ||
- error | ||
- argsIgnorePattern: "_" | ||
varsIgnorePattern: "_" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# directories | ||
.yarn | ||
**/artifacts | ||
**/build | ||
**/cache | ||
**/coverage | ||
**/.coverage_artifacts | ||
**/.coverage_cache | ||
**/.coverage_contracts | ||
**/dist | ||
**/node_modules | ||
|
||
# files | ||
*.env | ||
*.log | ||
.pnp.* | ||
coverage.json | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# types | ||
src/types/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
yarn dlx commitlint --edit $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
yarn dlx lint-staged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"*.{js,json,md,sol,ts,yaml,yml}": [ | ||
"prettier --config ./.prettierrc.yaml --write" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# directories | ||
.yarn/ | ||
**/.coverage_artifacts | ||
**/.coverage_cache | ||
**/.coverage_contracts | ||
**/artifacts | ||
**/build | ||
**/cache | ||
**/coverage | ||
**/dist | ||
**/node_modules | ||
**/types | ||
|
||
# files | ||
*.env | ||
*.log | ||
.pnp.* | ||
coverage.json | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
arrowParens: avoid | ||
bracketSpacing: true | ||
endOfLine: auto | ||
printWidth: 120 | ||
singleQuote: false | ||
tabWidth: 2 | ||
trailingComma: all | ||
|
||
overrides: | ||
- files: "*.sol" | ||
options: | ||
tabWidth: 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const shell = require("shelljs"); | ||
|
||
module.exports = { | ||
istanbulReporter: ["html", "lcov"], | ||
providerOptions: { | ||
mnemonic: process.env.MNEMONIC, | ||
}, | ||
skipFiles: ["test"], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"extends": "solhint:recommended", | ||
"plugins": ["prettier"], | ||
"rules": { | ||
"code-complexity": ["error", 8], | ||
"compiler-version": ["error", ">=0.8.4"], | ||
"const-name-snakecase": "off", | ||
"constructor-syntax": "error", | ||
"func-visibility": ["error", { "ignoreConstructors": true }], | ||
"max-line-length": ["error", 120], | ||
"not-rely-on-time": "off", | ||
"prettier/prettier": [ | ||
"error", | ||
{ | ||
"endOfLine": "auto" | ||
} | ||
], | ||
"reason-string": ["warn", { "maxLength": 64 }] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# directories | ||
**/artifacts | ||
**/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
nodeLinker: node-modules | ||
|
||
plugins: | ||
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs | ||
spec: "@yarnpkg/plugin-interactive-tools" | ||
|
||
yarnPath: .yarn/releases/yarn-3.1.0.cjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# Solidity Template | ||
|
||
My favorite setup for writing Solidity smart contracts. | ||
|
||
- [Hardhat](https://github.com/nomiclabs/hardhat): compile and run the smart contracts on a local development network | ||
- [TypeChain](https://github.com/ethereum-ts/TypeChain): generate TypeScript types for smart contracts | ||
- [Ethers](https://github.com/ethers-io/ethers.js/): renowned Ethereum library and wallet implementation | ||
- [Waffle](https://github.com/EthWorks/Waffle): tooling for writing comprehensive smart contract tests | ||
- [Solhint](https://github.com/protofire/solhint): linter | ||
- [Solcover](https://github.com/sc-forks/solidity-coverage): code coverage | ||
- [Prettier Plugin Solidity](https://github.com/prettier-solidity/prettier-plugin-solidity): code formatter | ||
|
||
This is a GitHub template, which means you can reuse it as many times as you want. You can do that by clicking the "Use this | ||
template" button at the top of the page. | ||
|
||
## Usage | ||
|
||
### Pre Requisites | ||
|
||
Before running any command, you need to create a `.env` file and set a BIP-39 compatible mnemonic as an environment | ||
variable. Follow the example in `.env.example`. If you don't already have a mnemonic, use this [website](https://iancoleman.io/bip39/) to generate one. | ||
|
||
Then, proceed with installing dependencies: | ||
|
||
```sh | ||
yarn install | ||
``` | ||
|
||
### Compile | ||
|
||
Compile the smart contracts with Hardhat: | ||
|
||
```sh | ||
$ yarn compile | ||
``` | ||
|
||
### TypeChain | ||
|
||
Compile the smart contracts and generate TypeChain artifacts: | ||
|
||
```sh | ||
$ yarn typechain | ||
``` | ||
|
||
### Lint Solidity | ||
|
||
Lint the Solidity code: | ||
|
||
```sh | ||
$ yarn lint:sol | ||
``` | ||
|
||
### Lint TypeScript | ||
|
||
Lint the TypeScript code: | ||
|
||
```sh | ||
$ yarn lint:ts | ||
``` | ||
|
||
### Test | ||
|
||
Run the Mocha tests: | ||
|
||
```sh | ||
$ yarn test | ||
``` | ||
|
||
### Coverage | ||
|
||
Generate the code coverage report: | ||
|
||
```sh | ||
$ yarn coverage | ||
``` | ||
|
||
### Report Gas | ||
|
||
See the gas usage per unit test and average gas per method call: | ||
|
||
```sh | ||
$ REPORT_GAS=true yarn test | ||
``` | ||
|
||
### Clean | ||
|
||
Delete the smart contract artifacts, the coverage reports and the Hardhat cache: | ||
|
||
```sh | ||
$ yarn clean | ||
``` | ||
|
||
### Deploy | ||
|
||
Deploy the contracts to Hardhat Network: | ||
|
||
```sh | ||
$ yarn deploy --greeting "Bonjour, le monde!" | ||
``` | ||
|
||
## Syntax Highlighting | ||
|
||
If you use VSCode, you can enjoy syntax highlighting for your Solidity code via the | ||
[vscode-solidity](https://github.com/juanfranblanco/vscode-solidity) extension. The recommended approach to set the | ||
compiler version is to add the following fields to your VSCode user settings: | ||
|
||
```json | ||
{ | ||
"solidity.compileUsingRemoteVersion": "v0.8.4+commit.c7e474f2", | ||
"solidity.defaultCompiler": "remote" | ||
} | ||
``` | ||
|
||
Where of course `v0.8.4+commit.c7e474f2` can be replaced with any other version. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.4; | ||
|
||
import "hardhat/console.sol"; | ||
|
||
error GreeterError(); | ||
|
||
contract Greeter { | ||
string public greeting; | ||
|
||
constructor(string memory _greeting) { | ||
console.log("Deploying a Greeter with greeting:", _greeting); | ||
greeting = _greeting; | ||
} | ||
|
||
function greet() public view returns (string memory) { | ||
return greeting; | ||
} | ||
|
||
function setGreeting(string memory _greeting) public { | ||
console.log("Changing greeting from '%s' to '%s'", greeting, _greeting); | ||
greeting = _greeting; | ||
} | ||
|
||
function throwError() external pure { | ||
revert GreeterError(); | ||
} | ||
} |
Oops, something went wrong.