Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Hrom131 authored Jun 13, 2024
0 parents commit 3ebcf84
Show file tree
Hide file tree
Showing 27 changed files with 14,742 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[*]
charset = utf-8
end_of_line = lf
indent_style = space
insert_final_newline = true
[*.ts]
indent_size = 2
max_line_length = 120
[*.sol]
indent_size = 4
max_line_length = 99
12 changes: 12 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Deployer private key
PRIVATE_KEY=YOUR PRIVATE KEY

# RPC Endpoints
INFURA_KEY=INFURA PROJECT ID

# Additional keys
ETHERSCAN_KEY=ETHERSCAN API KEY
BSCSCAN_KEY=BSCSCAN API KEY
POLYGONSCAN_KEY=POLYGONSCAN API KEY
AVALANCHE_KEY=AVALANCHE API KEY
COINMARKETCAP_KEY=COINMARKETCAP API KEY
30 changes: 30 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Bug Report
description: File a bug report
labels: ['bug']
assignees:
-
body:
- type: markdown
attributes:
value: Thanks for taking the time to fill out this bug report!
- type: input
id: version
attributes:
label: "Project version"
placeholder: "1.2.3"
validations:
required: true
- type: textarea
id: what-happened
attributes:
label: What happened?
description: A brief description of what happened and what you expected to happen
validations:
required: true
- type: textarea
id: reproduction-steps
attributes:
label: "Minimal reproduction steps"
description: "The minimal steps needed to reproduce the bug"
validations:
required: true
13 changes: 13 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Feature request
description: Suggest a new feature
labels: ['feature']
assignees:
-
body:
- type: textarea
id: feature-description
attributes:
label: "Describe the feature"
description: "A description of what you would like to see in the project"
validations:
required: true
4 changes: 4 additions & 0 deletions .github/ISSUE_TEMPLATE/other-issue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
name: Other issue
about: Other kind of issue
---
15 changes: 15 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: setup

description: setup

runs:
using: composite
steps:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: "16.18.x"
cache: npm
- name: Install packages
run: npm install
shell: bash
21 changes: 21 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "checks"

on:
push:
branches:
- master
pull_request:
branches:
- master
- dev

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup
- name: Run tests
run: npm run test
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
node_modules
.env
.DS_Store

# Hardhat files
cache
artifacts
coverage.json
coverage

# Typechain generated files
generated-types

# Hardhat migrate
.storage.json
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm run lint-fix && git add -u
16 changes: 16 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
node_modules
.env
.DS_Store
package-lock.json

# Hardhat files
cache
artifacts
coverage.json
coverage

# Typechain generated files
generated-types

# Hardhat migrate
.storage.json
22 changes: 22 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"plugins": ["prettier-plugin-solidity"],
"overrides": [
{
"files": "*.sol",
"options": {
"printWidth": 99,
"tabWidth": 4,
"useTabs": false,
"singleQuote": false,
"bracketSpacing": false
}
},
{
"files": "*.ts",
"options": {
"printWidth": 120,
"tabWidth": 2
}
}
]
}
4 changes: 4 additions & 0 deletions .solcover.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
skipFiles: [],
configureYulOptimizer: true,
};
14 changes: 14 additions & 0 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "solhint:recommended",
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "warn",
"reentrancy": "off",
"modifier-name-mixedcase": "off",
"no-empty-blocks": "off",
"func-visibility": "off",
"max-states-count": "off",
"not-rely-on-time": "off",
"compiler-version": "off"
}
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Solarity

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
63 changes: 63 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Hardhat template

Template hardhat repository for ad-hoc smart contracts development.

### How to use

The template works out of the box. To clean up the repo, you may need to delete the mock contracts, tests and migration files.

#### Compilation

To compile the contracts, use the next script:

```bash
npm run compile
```

#### Test

To run the tests, execute the following command:

```bash
npm run test
```

Or to see the coverage, run:

```bash
npm run coverage
```

#### Local deployment

To deploy the contracts locally, run the following commands (in the different terminals):

```bash
npm run private-network
npm run deploy-localhost
```

#### Bindings

The command to generate the bindings is as follows:

```bash
npm run generate-types
```

> See the full list of available commands in the `package.json` file.
### Integrated plugins

- Hardhat official `ethers` + `ethers-v6`
- [`Typechain`](https://www.npmjs.com/package/@typechain/hardhat)
- [`hardhat-migrate`](https://www.npmjs.com/package/@solarity/hardhat-migrate), [`hardhat-markup`](https://www.npmjs.com/package/@solarity/hardhat-markup), [`hardhat-gobind`](https://www.npmjs.com/package/@solarity/hardhat-gobind)
- [`hardhat-contract-sizer`](https://www.npmjs.com/package/hardhat-contract-sizer)
- [`hardhat-gas-reporter`](https://www.npmjs.com/package/hardhat-gas-reporter)
- [`solidity-coverage`](https://www.npmjs.com/package/solidity-coverage)

### Other niceties

- The template comes with presetup `prettier` and `solhint` that lint the project via `husky` before compilation hook.
- The `.env.example` file is provided to check what is required as ENVs
- Preinstalled `@openzeppelin/contracts` and `@solarity/solidity-lib`
Empty file added contracts/.gitkeep
Empty file.
28 changes: 28 additions & 0 deletions contracts/mock/tokens/ERC20Mock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract ERC20Mock is ERC20 {
uint8 internal _decimals;

constructor(
string memory name_,
string memory symbol_,
uint8 decimalPlaces_
) ERC20(name_, symbol_) {
_decimals = decimalPlaces_;
}

function decimals() public view override returns (uint8) {
return _decimals;
}

function mint(address to_, uint256 amount_) public {
_mint(to_, amount_);
}

function burn(address to_, uint256 amount_) public {
_burn(to_, amount_);
}
}
9 changes: 9 additions & 0 deletions deploy/1_token.migration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Deployer, Reporter } from "@solarity/hardhat-migrate";

import { ERC20Mock__factory } from "@ethers-v6";

export = async (deployer: Deployer) => {
const erc20 = await deployer.deploy(ERC20Mock__factory, ["Mock", "Mock", 18]);

Reporter.reportContracts(["ERC20Mock", await erc20.getAddress()]);
};
Loading

0 comments on commit 3ebcf84

Please sign in to comment.