Skip to content

Commit

Permalink
chore: change hardhat and prettier settings, and vendor yarn
Browse files Browse the repository at this point in the history
  • Loading branch information
petejkim committed Mar 1, 2022
1 parent 4cfae89 commit f69ea0f
Show file tree
Hide file tree
Showing 19 changed files with 11,358 additions and 16,489 deletions.
29 changes: 28 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
# yarn
.yarn/*
!.yarn/cache
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# mac
.DS_Store
.AppleDouble
.LSOverride
Icon
._*
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

# directories
.yarn
**/artifacts
**/build
**/cache
Expand Down
4 changes: 0 additions & 4 deletions .husky/commit-msg

This file was deleted.

2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn dlx lint-staged
yarn prettier
2 changes: 1 addition & 1 deletion .lintstagedrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"*.{js,json,md,sol,ts,yaml,yml}": [
"prettier --config ./.prettierrc.yaml --write"
"yarn prettier"
]
}
23 changes: 23 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"arrowParens": "always",
"bracketSpacing": true,
"htmlWhitespaceSensitivity": "css",
"insertPragma": false,
"printWidth": 80,
"proseWrap": "preserve",
"quoteProps": "as-needed",
"requirePragma": false,
"semi": true,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false,
"overrides": [
{
"files": "*.sol",
"options": { "tabWidth": 4 }
},
{ "files": "*.md", "options": { "proseWrap": "always" } }
],
"plugins": ["prettier-plugin-solidity"]
}
12 changes: 0 additions & 12 deletions .prettierrc.yaml

This file was deleted.

8 changes: 8 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"recommendations": [
"arcanis.vscode-zipfs",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"juanblanco.solidity"
]
}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"prettier.configPath": ".prettierrc.json",
"typescript.enablePromptUseWorkspaceTsdk": true,
"solidity.compileUsingRemoteVersion": "v0.8.12+commit.f00d7308",
"solidity.defaultCompiler": "remote"
}
7 changes: 0 additions & 7 deletions .yarnrc.yml

This file was deleted.

33 changes: 21 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,31 @@

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
- [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
- [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.
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.
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:

Expand Down Expand Up @@ -100,9 +108,10 @@ $ 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:
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
{
Expand Down
28 changes: 0 additions & 28 deletions contracts/Greeter.sol

This file was deleted.

12 changes: 7 additions & 5 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ const chainIds = {
};

// Ensure that we have all the environment variables we need.
const mnemonic: string | undefined = process.env.MNEMONIC;
let mnemonic: string | undefined = process.env.MNEMONIC;
if (!mnemonic) {
throw new Error("Please set your MNEMONIC in a .env file");
console.warn("MNEMONIC is not set in the .env file");
mnemonic =
"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about";
}

const infuraApiKey: string | undefined = process.env.INFURA_API_KEY;
if (!infuraApiKey) {
throw new Error("Please set your INFURA_API_KEY in a .env file");
console.warn("INFURA_API_KEY is not set in the .env file");
}

function getChainConfig(network: keyof typeof chainIds): NetworkUserConfig {
Expand Down Expand Up @@ -74,7 +76,7 @@ const config: HardhatUserConfig = {
tests: "./test",
},
solidity: {
version: "0.8.9",
version: "0.8.12",
settings: {
metadata: {
// Not including the metadata hash
Expand All @@ -85,7 +87,7 @@ const config: HardhatUserConfig = {
// https://hardhat.org/hardhat-network/#solidity-optimizer-support
optimizer: {
enabled: true,
runs: 800,
runs: 200,
},
},
},
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
"@typescript-eslint/eslint-plugin": "^5.10.2",
"@typescript-eslint/parser": "^5.10.2",
"chai": "^4.3.6",
"commitizen": "^4.2.4",
"cross-env": "^7.0.3",
"cz-conventional-changelog": "^3.3.0",
"dotenv": "^15.0.0",
"eslint": "^8.8.0",
"eslint-config-prettier": "^8.3.0",
Expand Down Expand Up @@ -55,7 +53,6 @@
],
"scripts": {
"clean": "shx rm -rf ./artifacts ./cache ./coverage ./src/types ./coverage.json",
"commit": "git-cz",
"compile": "cross-env TS_NODE_TRANSPILE_ONLY=true hardhat compile",
"coverage": "yarn typechain && hardhat coverage --solcoverjs ./.solcover.js --temp artifacts --testfiles \"test/**/*.ts\"",
"deploy": "hardhat deploy:Greeter",
Expand All @@ -65,9 +62,12 @@
"postinstall": "husky install",
"postpublish": "pinst --enable",
"prepublishOnly": "pinst --disable",
"prettier": "prettier --config ./.prettierrc.yaml --write \"**/*.{js,json,md,sol,ts}\"",
"prettier:check": "prettier --check --config ./.prettierrc.yaml \"**/*.{js,json,md,sol,ts}\"",
"prettier": "prettier --config ./.prettierrc.json --write \"**/*.{js,json,md,sol,ts}\"",
"prettier:check": "prettier --check --config ./.prettierrc.json \"**/*.{js,json,md,sol,ts}\"",
"test": "hardhat test",
"typechain": "cross-env TS_NODE_TRANSPILE_ONLY=true hardhat typechain"
},
"dependencies": {
"@openzeppelin/contracts": "^4.4.2"
}
}
14 changes: 0 additions & 14 deletions tasks/deploy/greeter.ts

This file was deleted.

1 change: 0 additions & 1 deletion tasks/deploy/index.ts
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
import "./greeter";
10 changes: 0 additions & 10 deletions test/greeter/Greeter.behavior.ts

This file was deleted.

26 changes: 0 additions & 26 deletions test/greeter/Greeter.ts

This file was deleted.

16 changes: 0 additions & 16 deletions test/types.ts

This file was deleted.

Loading

0 comments on commit f69ea0f

Please sign in to comment.