Skip to content

Commit 3caed1e

Browse files
committed
✨ github actions
1 parent 4f08ea2 commit 3caed1e

19 files changed

+410
-0
lines changed

Diff for: .env.example

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ETHERSCAN_API_KEY=ABC123ABC123ABC123ABC123ABC123ABC1
2+
ROPSTEN_URL=https://eth-ropsten.alchemyapi.io/v2/<YOUR ALCHEMY KEY>
3+
PRIVATE_KEY=0xabc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1

Diff for: .eslintignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
artifacts
3+
cache
4+
coverage

Diff for: .eslintrc.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module.exports = {
2+
env: {
3+
browser: false,
4+
es2021: true,
5+
mocha: true,
6+
node: true,
7+
},
8+
plugins: ["@typescript-eslint"],
9+
extends: [
10+
"standard",
11+
"plugin:prettier/recommended",
12+
"plugin:node/recommended",
13+
],
14+
parser: "@typescript-eslint/parser",
15+
parserOptions: {
16+
ecmaVersion: 12,
17+
},
18+
rules: {
19+
"node/no-unsupported-features/es-syntax": [
20+
"error",
21+
{ ignores: ["modules"] },
22+
],
23+
},
24+
};

Diff for: .github/workflows/push_check.yml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Test workflow
2+
on: push
3+
jobs:
4+
lint:
5+
name: Lint sources
6+
runs-on: ubuntu-latest
7+
strategy:
8+
matrix:
9+
node-version: [16.x]
10+
11+
steps:
12+
- name: Checkout
13+
uses: 'actions/checkout@master'
14+
15+
- name: Set Node.js
16+
uses: actions/setup-node@v1
17+
with:
18+
node-version: ${{ matrix.node-version }}
19+
- name: Install dependencies
20+
run: npm ci
21+
- name: Lint sources
22+
run:
23+
npm run lint
24+
25+
unit_test:
26+
name: Unit tests
27+
runs-on: ubuntu-latest
28+
strategy:
29+
matrix:
30+
node-version: [16.x]
31+
32+
steps:
33+
- name: Checkout
34+
uses: 'actions/checkout@master'
35+
36+
- name: Set Node.js
37+
uses: actions/setup-node@v1
38+
with:
39+
node-version: ${{ matrix.node-version }}
40+
41+
- name: Install dependencies
42+
run: npm ci
43+
- name: Run tests
44+
run: npm run test:coverage
45+
- name: Coveralls GitHub Action
46+
uses: coverallsapp/[email protected]
47+
with:
48+
github-token: ${{ secrets.GITHUB_TOKEN }}

Diff for: .gitignore

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
9+
# Diagnostic reports (https://nodejs.org/api/report.html)
10+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11+
12+
# Runtime data
13+
pids
14+
*.pid
15+
*.seed
16+
*.pid.lock
17+
18+
# Directory for instrumented libs generated by jscoverage/JSCover
19+
lib-cov
20+
21+
# Coverage directory used by tools like istanbul
22+
coverage
23+
*.lcov
24+
25+
# nyc test coverage
26+
.nyc_output
27+
28+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29+
.grunt
30+
31+
# Bower dependency directory (https://bower.io/)
32+
bower_components
33+
34+
# node-waf configuration
35+
.lock-wscript
36+
37+
# Compiled binary addons (https://nodejs.org/api/addons.html)
38+
build/Release
39+
40+
# Dependency directories
41+
node_modules/
42+
jspm_packages/
43+
44+
# TypeScript v1 declaration files
45+
typings/
46+
47+
# TypeScript cache
48+
*.tsbuildinfo
49+
50+
# Optional npm cache directory
51+
.npm
52+
53+
# Optional eslint cache
54+
.eslintcache
55+
56+
# Microbundle cache
57+
.rpt2_cache/
58+
.rts2_cache_cjs/
59+
.rts2_cache_es/
60+
.rts2_cache_umd/
61+
62+
# Optional REPL history
63+
.node_repl_history
64+
65+
# Output of 'npm pack'
66+
*.tgz
67+
68+
# Yarn Integrity file
69+
.yarn-integrity
70+
71+
# dotenv environment variables file
72+
.env
73+
.env.test
74+
75+
# parcel-bundler cache (https://parceljs.org/)
76+
.cache
77+
78+
# Next.js build output
79+
.next
80+
81+
# Nuxt.js build / generate output
82+
.nuxt
83+
dist
84+
85+
# Gatsby files
86+
.cache/
87+
# Comment in the public line in if your project uses Gatsby and *not* Next.js
88+
# https://nextjs.org/blog/next-9-1#public-directory-support
89+
# public
90+
91+
# vuepress build output
92+
.vuepress/dist
93+
94+
# Serverless directories
95+
.serverless/
96+
97+
# FuseBox cache
98+
.fusebox/
99+
100+
# DynamoDB Local files
101+
.dynamodb/
102+
103+
# TernJS port file
104+
.tern-port
105+
106+
node_modules
107+
.idea
108+
109+
#Hardhat files
110+
cache
111+
artifacts
112+
113+
node_modules
114+
.env
115+
coverage
116+
coverage.json
117+
typechain
118+
119+
#Hardhat files
120+
cache
121+
artifacts
122+
123+
node_modules
124+
.env
125+
coverage
126+
coverage.json
127+
typechain
128+
129+
#Hardhat files
130+
cache
131+
artifacts

Diff for: .husky/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npm run lint:fix

Diff for: .npmignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
hardhat.config.ts
2+
scripts
3+
test

Diff for: .prettierignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
artifacts
3+
cache
4+
coverage*
5+
gasReporterOutput.json

Diff for: .prettierrc

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"overrides": [
3+
{
4+
"files": "*.sol",
5+
"options": {
6+
"printWidth": 80,
7+
"tabWidth": 4,
8+
"useTabs": false,
9+
"singleQuote": false,
10+
"bracketSpacing": true,
11+
"explicitTypes": "never"
12+
}
13+
}
14+
]
15+
}

Diff for: .solcover.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
skipFiles: []
3+
};

Diff for: .solhint.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "solhint:recommended",
3+
"rules": {
4+
"compiler-version": ["error", "^0.8.9"],
5+
"func-visibility": ["warn", { "ignoreConstructors": true }]
6+
}
7+
}

Diff for: .solhintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

Diff for: LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Adam Boudjemaa
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Diff for: contracts/Greeter.sol

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//SPDX-License-Identifier: Unlicense
2+
pragma solidity ^0.8.0;
3+
4+
import "hardhat/console.sol";
5+
6+
contract Greeter {
7+
string private greeting;
8+
9+
constructor(string memory _greeting) {
10+
console.log("Deploying a Greeter with greeting:", _greeting);
11+
greeting = _greeting;
12+
}
13+
14+
function greet() public view returns (string memory) {
15+
return greeting;
16+
}
17+
18+
function setGreeting(string memory _greeting) public {
19+
console.log("Changing greeting from '%s' to '%s'", greeting, _greeting);
20+
greeting = _greeting;
21+
}
22+
}

Diff for: hardhat.config.ts

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import * as dotenv from "dotenv";
2+
3+
import { HardhatUserConfig, task } from "hardhat/config";
4+
import "@nomiclabs/hardhat-etherscan";
5+
import "@nomiclabs/hardhat-waffle";
6+
import "@typechain/hardhat";
7+
import "hardhat-gas-reporter";
8+
import "solidity-coverage";
9+
10+
dotenv.config();
11+
12+
// This is a sample Hardhat task. To learn how to create your own go to
13+
// https://hardhat.org/guides/create-task.html
14+
task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
15+
const accounts = await hre.ethers.getSigners();
16+
17+
for (const account of accounts) {
18+
console.log(account.address);
19+
}
20+
});
21+
22+
// You need to export an object to set up your config
23+
// Go to https://hardhat.org/config/ to learn more
24+
25+
const config: HardhatUserConfig = {
26+
solidity: "0.8.4",
27+
networks: {
28+
ropsten: {
29+
url: process.env.ROPSTEN_URL || "",
30+
accounts:
31+
process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
32+
},
33+
},
34+
gasReporter: {
35+
enabled: process.env.REPORT_GAS !== undefined,
36+
currency: "USD",
37+
},
38+
etherscan: {
39+
apiKey: process.env.ETHERSCAN_API_KEY,
40+
},
41+
};
42+
43+
export default config;

Diff for: scripts/deploy.ts

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// We require the Hardhat Runtime Environment explicitly here. This is optional
2+
// but useful for running the script in a standalone fashion through `node <script>`.
3+
//
4+
// When running the script with `npx hardhat run <script>` you'll find the Hardhat
5+
// Runtime Environment's members available in the global scope.
6+
import { ethers } from "hardhat";
7+
8+
async function main() {
9+
// Hardhat always runs the compile task when running scripts with its command
10+
// line interface.
11+
//
12+
// If this script is run directly using `node` you may want to call compile
13+
// manually to make sure everything is compiled
14+
// await hre.run('compile');
15+
16+
// We get the contract to deploy
17+
const Greeter = await ethers.getContractFactory("Greeter");
18+
const greeter = await Greeter.deploy("Hello, Hardhat!");
19+
20+
await greeter.deployed();
21+
22+
console.log("Greeter deployed to:", greeter.address);
23+
}
24+
25+
// We recommend this pattern to be able to use async/await everywhere
26+
// and properly handle errors.
27+
main().catch((error) => {
28+
console.error(error);
29+
process.exitCode = 1;
30+
});

Diff for: test/helpers.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const { utils } = require("ethers");
2+
3+
function n18(amount) {
4+
return utils.parseUnits(amount, "ether");
5+
}
6+
7+
async function increaseTime(duration) {
8+
await ethers.provider.send("evm_increaseTime", [duration]);
9+
await ethers.provider.send("evm_mine");
10+
}
11+
12+
module.exports = {
13+
n18,
14+
increaseTime,
15+
};

0 commit comments

Comments
 (0)