forked from raid-guild/CypherShares
-
Notifications
You must be signed in to change notification settings - Fork 0
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 42deb9d
Showing
29 changed files
with
10,834 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,3 @@ | ||
module.exports = { | ||
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,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,13 @@ | ||
# folders | ||
artifacts/ | ||
build/ | ||
cache/ | ||
coverage/ | ||
dist/ | ||
lib/ | ||
node_modules/ | ||
typechain/ | ||
|
||
# files | ||
.solcover.js | ||
coverage.json |
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/@typescript-eslint | ||
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 @@ | ||
*.sol linguist-language=Solidity |
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 @@ | ||
# folders | ||
.coverage_artifacts/ | ||
.coverage_cache/ | ||
.coverage_contracts/ | ||
artifacts/ | ||
build/ | ||
cache/ | ||
coverage/ | ||
dist/ | ||
lib/ | ||
node_modules/ | ||
typechain/ | ||
|
||
# files | ||
*.env | ||
*.log | ||
*.tsbuildinfo | ||
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,5 @@ | ||
{ | ||
"hooks": { | ||
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS" | ||
} | ||
} |
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,6 @@ | ||
{ | ||
"extension": ["ts"], | ||
"recursive": "test", | ||
"require": ["hardhat/register"], | ||
"timeout": 20000 | ||
} |
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 @@ | ||
# folders | ||
artifacts/ | ||
build/ | ||
cache/ | ||
coverage/ | ||
dist/ | ||
lib/ | ||
node_modules/ | ||
typechain/ | ||
|
||
# files | ||
coverage.json |
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,17 @@ | ||
{ | ||
"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,23 @@ | ||
const shell = require("shelljs"); | ||
|
||
// The environment variables are loaded in hardhat.config.ts | ||
const mnemonic = process.env.MNEMONIC; | ||
if (!mnemonic) { | ||
throw new Error("Please set your MNEMONIC in a .env file"); | ||
} | ||
|
||
module.exports = { | ||
istanbulReporter: ["html"], | ||
onCompileComplete: async function (_config) { | ||
await run("typechain"); | ||
}, | ||
onIstanbulComplete: async function (_config) { | ||
// We need to do this because solcover generates bespoke artifacts. | ||
shell.rm("-rf", "./artifacts"); | ||
shell.rm("-rf", "./typechain"); | ||
}, | ||
providerOptions: { | ||
mnemonic, | ||
}, | ||
skipFiles: ["mocks", "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", 7], | ||
"compiler-version": ["error", "^0.7.0"], | ||
"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,5 @@ | ||
# folders | ||
.yarn/ | ||
build/ | ||
dist/ | ||
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 @@ | ||
# WTFPL | ||
|
||
by Paul Razvan Berg (@PaulRBerg) | ||
|
||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | ||
|
||
0. You just DO WHAT THE FUCK YOU WANT TO. |
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,80 @@ | ||
# Solidity Template | ||
|
||
My favourite 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, make sure to install 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 build | ||
``` | ||
|
||
### 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 | ||
``` | ||
|
||
### Clean | ||
|
||
Delete the smart contract artifacts, the coverage reports and the Hardhat cache: | ||
|
||
```sh | ||
$ yarn clean | ||
``` |
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 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.7.0; | ||
|
||
import "hardhat/console.sol"; | ||
|
||
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; | ||
} | ||
} |
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,86 @@ | ||
import { config as dotenvConfig } from "dotenv"; | ||
import { resolve } from "path"; | ||
dotenvConfig({ path: resolve(__dirname, "./.env") }); | ||
|
||
import { HardhatUserConfig } from "hardhat/config"; | ||
import { NetworkUserConfig } from "hardhat/types"; | ||
import "./tasks/accounts"; | ||
import "./tasks/clean"; | ||
|
||
import "@nomiclabs/hardhat-waffle"; | ||
import "hardhat-typechain"; | ||
import "solidity-coverage"; | ||
|
||
const chainIds = { | ||
ganache: 1337, | ||
goerli: 5, | ||
hardhat: 31337, | ||
kovan: 42, | ||
mainnet: 1, | ||
rinkeby: 4, | ||
ropsten: 3, | ||
}; | ||
|
||
// Ensure that we have all the environment variables we need. | ||
let mnemonic: string; | ||
if (!process.env.MNEMONIC) { | ||
throw new Error("Please set your MNEMONIC in a .env file"); | ||
} else { | ||
mnemonic = process.env.MNEMONIC; | ||
} | ||
|
||
let infuraApiKey: string; | ||
if (!process.env.INFURA_API_KEY) { | ||
throw new Error("Please set your INFURA_API_KEY in a .env file"); | ||
} else { | ||
infuraApiKey = process.env.INFURA_API_KEY; | ||
} | ||
|
||
function createTestnetConfig(network: keyof typeof chainIds): NetworkUserConfig { | ||
const url: string = "https://" + network + ".infura.io/v3/" + infuraApiKey; | ||
return { | ||
accounts: { | ||
count: 10, | ||
initialIndex: 0, | ||
mnemonic, | ||
path: "m/44'/60'/0'/0", | ||
}, | ||
chainId: chainIds[network], | ||
url, | ||
}; | ||
} | ||
|
||
const config: HardhatUserConfig = { | ||
defaultNetwork: "hardhat", | ||
networks: { | ||
hardhat: { | ||
chainId: chainIds.hardhat, | ||
}, | ||
goerli: createTestnetConfig("goerli"), | ||
kovan: createTestnetConfig("kovan"), | ||
rinkeby: createTestnetConfig("rinkeby"), | ||
ropsten: createTestnetConfig("ropsten"), | ||
}, | ||
paths: { | ||
artifacts: "./artifacts", | ||
cache: "./cache", | ||
sources: "./contracts", | ||
tests: "./test", | ||
}, | ||
solidity: { | ||
version: "0.7.4", | ||
settings: { | ||
// https://hardhat.org/hardhat-network/#solidity-optimizer-support | ||
optimizer: { | ||
enabled: true, | ||
runs: 200, | ||
}, | ||
}, | ||
}, | ||
typechain: { | ||
outDir: "typechain", | ||
target: "ethers-v5", | ||
}, | ||
}; | ||
|
||
export default config; |
Oops, something went wrong.