Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulRBerg committed Jul 6, 2020
0 parents commit e35b229
Show file tree
Hide file tree
Showing 26 changed files with 12,198 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .commitlintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ["@commitlint/config-conventional"],
};
16 changes: 16 additions & 0 deletions .editorconfig
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
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ETHERSCAN_API_KEY=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
INFURA_API_KEY=zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
MNEMONIC=here is where your twelve words mnemonic should be put my friend
14 changes: 14 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# folders
artifacts/
build/
cache/
coverage/
dist/
lib/
node_modules/
typechain/

# files
.eslintrc.js
.solcover.js
coverage.json
21 changes: 21 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"prettier/@typescript-eslint",
],
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
root: true,
rules: {
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "_",
varsIgnorePattern: "_",
},
],
},
};
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sol linguist-language=Solidity
21 changes: 21 additions & 0 deletions .gitignore
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*
5 changes: 5 additions & 0 deletions .huskyrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
}
7 changes: 7 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"delay": true,
"extension": ["ts"],
"recursive": "test",
"require": ["@nomiclabs/buidler/register"],
"timeout": 20000
}
12 changes: 12 additions & 0 deletions .prettierignore
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
16 changes: 16 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"arrowParens": "avoid",
"bracketSpacing": true,
"printWidth": 120,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "all",
"overrides": [
{
"files": "*.sol",
"options": {
"tabWidth": 4
}
}
]
}
7 changes: 7 additions & 0 deletions .solcover.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
istanbulReporter: ["html"],
mocha: {
delay: true,
},
skipFiles: ["mocks", "test"],
};
12 changes: 12 additions & 0 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "solhint:recommended",
"plugins": ["prettier"],
"rules": {
"code-complexity": ["error", 7],
"compiler-version": ["error", "^0.6.10"],
"constructor-syntax": "error",
"max-line-length": ["error", 120],
"not-rely-on-time": "off",
"prettier/prettier": "error"
}
}
5 changes: 5 additions & 0 deletions .solhintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# folders
.yarn/
build/
dist/
node_modules/
7 changes: 7 additions & 0 deletions @types/augmentations.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Greeter } from "../typechain/Greeter";

declare module "mocha" {
export interface Context {
greeter: Greeter;
}
}
3 changes: 3 additions & 0 deletions @types/buidler-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/// <reference types="@nomiclabs/buidler/types" />
/// <reference types="@nomiclabs/buidler-ethers/src/type-extensions" />
/// <reference types="@nomiclabs/buidler-waffle/src/type-extensions" />
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Default Solidity Template

To be used when building a new solidity project from scratch.
85 changes: 85 additions & 0 deletions buidler.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import { config as dotenvConfig } from "dotenv";
import { resolve } from "path";
dotenvConfig({ path: resolve(__dirname, "./.env") });

import { BuidlerConfig, usePlugin } from "@nomiclabs/buidler/config";
import { HDAccountsConfig } from "@nomiclabs/buidler/types";
import "./tasks/accounts";

usePlugin("@nomiclabs/buidler-waffle");
usePlugin("solidity-coverage");

interface HDAccountsConfigExtended extends HDAccountsConfig {
url: string;
}

/**
* @dev You must have a `.env` file. Follow the example in `.env.example`.
* @param {string} network The name of the testnet
*/
function createHDAccountConfig(network: string): HDAccountsConfigExtended {
if (!process.env.MNEMONIC) {
console.log("Please set your MNEMONIC in a .env file");
process.exit(1);
}

if (!process.env.INFURA_API_KEY) {
console.log("Please set your INFURA_API_KEY");
process.exit(1);
}

return {
initialIndex: 0,
mnemonic: process.env.MNEMONIC,
path: "m/44'/60'/0'/0",
url: `https://${network}.infura.io/v3/${process.env.INFURA_API_KEY}`,
};
}

const config: BuidlerConfig = {
defaultNetwork: "buidlerevm",
mocha: {
delay: true,
},
networks: {
buidlerevm: {
chainId: 31337,
},
coverage: {
url: "http://127.0.0.1:8555",
},
goerli: {
...createHDAccountConfig("goerli"),
chainId: 5,
},
kovan: {
...createHDAccountConfig("kovan"),
chainId: 42,
},
rinkeby: {
...createHDAccountConfig("rinkeby"),
chainId: 4,
},
ropsten: {
...createHDAccountConfig("ropsten"),
chainId: 3,
},
},
paths: {
artifacts: "./artifacts",
cache: "./cache",
root: "./",
sources: "./contracts",
tests: "./test",
},
solc: {
/* https://buidler.dev/buidler-evm/#solidity-optimizer-support */
optimizer: {
enabled: false,
runs: 200,
},
version: "0.6.10",
},
};

export default config;
22 changes: 22 additions & 0 deletions contracts/Greeter.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* SPDX-License-Identifier: MIT */
pragma solidity ^0.6.10;

import "@nomiclabs/buidler/console.sol";

contract Greeter {
string public greeting;

constructor(string memory _greeting) public {
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;
}
}
80 changes: 80 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"name": "@paulrberg/solidity-template",
"description": "To be used when building a new solidity project from scratch",
"version": "1.0.0",
"author": {
"name": "Sablier",
"email": "[email protected]",
"url": "https://sablier.finance"
},
"bugs": {
"url": "https://github.com/paulrberg/solidity-template/issues"
},
"devDependencies": {
"@commitlint/cli": "^9.0.1",
"@commitlint/config-conventional": "^9.0.1",
"@ethersproject/abstract-signer": "^5.0.1",
"@ethersproject/bignumber": "^5.0.3",
"@ethersproject/wallet": "^5.0.1",
"@nomiclabs/buidler": "^1.3.8",
"@nomiclabs/buidler-ethers": "^2.0.0",
"@nomiclabs/buidler-waffle": "^2.0.0",
"@typechain/ethers-v5": "^0.0.2",
"@types/chai": "^4.2.11",
"@types/mocha": "^7.0.2",
"@types/node": "^14.0.14",
"@typescript-eslint/eslint-plugin": "^3.6.0",
"@typescript-eslint/parser": "^3.6.0",
"chai": "^4.2.0",
"commitizen": "^4.1.2",
"cz-conventional-changelog": "^3.2.0",
"dotenv": "^8.2.0",
"eslint": "^7.4.0",
"eslint-config-prettier": "^6.11.0",
"ethereum-waffle": "^3.0.1",
"ethers": "^5.0.4",
"husky": "^4.2.5",
"mocha": "^8.0.1",
"prettier": "^2.0.5",
"prettier-plugin-solidity": "^1.0.0-alpha.54",
"shx": "^0.3.2",
"solc": "0.6.10",
"solhint": "^3.0.0",
"solhint-plugin-prettier": "^0.0.4",
"solidity-coverage": "^0.7.9",
"ts-node": "^8.10.2",
"typechain": "^2.0.0",
"typescript": "^3.9.6"
},
"files": [
"/contracts"
],
"homepage": "https://github.com/paulrberg/solidity-template#readme",
"keywords": [
"blockchain",
"ethereum",
"smart-contracts",
"solidity"
],
"license": "LGPL-3.0-or-later",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "https://github.com/paulrberg/solidity-template"
},
"scripts": {
"build": "yarn run compile && yarn run typechain",
"clean": "shx rm -rf ./artifacts ./cache ./typechain ./tsconfig.build.tsbuildinfo",
"commit": "git-cz",
"compile": "buidler compile",
"coverage": "buidler coverage --solcoverjs ./.solcover.js --network coverage --temp artifacts --testfiles './test/**/*.ts'",
"lint:sol": "solhint --config ./.solhint.json --max-warnings 0 'contracts/**/*.sol'",
"lint:ts": "eslint --config ./.eslintrc.js --ignore-path ./.eslintignore --ext .js,.ts .",
"prettier": "prettier --config .prettierrc --write '**/*.{js,json,md,sol,ts}'",
"prettier:list-different": "prettier --config .prettierrc --list-different '**/*.{js,json,md,sol,ts}'",
"test": "buidler test",
"typechain": "typechain --outDir typechain --target ethers-v5 'artifacts/*.json'"
}
}
29 changes: 29 additions & 0 deletions scripts/deploy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// We require the Buidler Runtime Environment explicitly here. This is optional
// but useful for running the script in a standalone fashion through `node <script>`.
// When running the script with `buidler run <script>` you'll find the Buidler
// Runtime Environment's members available in the global scope.
import { ethers } from "@nomiclabs/buidler";
import { Contract, ContractFactory } from "ethers";

async function main(): Promise<void> {
// Buidler always runs the compile task when running scripts through it.
// If this runs in a standalone fashion you may want to call compile manually
// to make sure everything is compiled
// await run("compile");

// We get the contract to deploy
const Greeter: ContractFactory = await ethers.getContractFactory("Greeter");
const greeter: Contract = await Greeter.deploy("Hello, Buidler!");
await greeter.deployed();

console.log("Greeter deployed to: ", greeter.address);
}

// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main()
.then(() => process.exit(0))
.catch((error: Error) => {
console.error(error);
process.exit(1);
});
Loading

0 comments on commit e35b229

Please sign in to comment.