generated from dl-solarity/hardhat-template
-
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 9a4f91e
Showing
24 changed files
with
40,012 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,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 |
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,19 @@ | ||
# 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 | ||
|
||
# Available targets: 'ethers-v6', 'truffle-v5' and 'web3-v1' | ||
# By default 'ethers-v6' | ||
TYPECHAIN_TARGET=TYPECHAIN TARGET | ||
|
||
# Set 'false' to not automatically generate types | ||
TYPECHAIN_FORCE=TYPECHAIN FORCE |
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,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 |
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 @@ | ||
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 |
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 @@ | ||
node_modules | ||
.env | ||
.DS_Store | ||
|
||
# Hardhat files | ||
cache | ||
artifacts | ||
coverage.json | ||
coverage | ||
|
||
# Typechain generated files | ||
generated-types |
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,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npm run lint-fix && git add -u |
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 @@ | ||
node_modules | ||
.env | ||
.DS_Store | ||
package-lock.json | ||
|
||
# Hardhat files | ||
cache | ||
artifacts | ||
coverage.json | ||
coverage | ||
|
||
# Typechain generated files | ||
generated-types |
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 @@ | ||
{ | ||
"overrides": [ | ||
{ | ||
"files": "*.sol", | ||
"options": { | ||
"printWidth": 99, | ||
"tabWidth": 4, | ||
"useTabs": false, | ||
"singleQuote": false, | ||
"bracketSpacing": false | ||
} | ||
}, | ||
{ | ||
"files": "*.ts", | ||
"options": { | ||
"printWidth": 120, | ||
"tabWidth": 2 | ||
} | ||
} | ||
] | ||
} |
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,4 @@ | ||
module.exports = { | ||
skipFiles: [], | ||
configureYulOptimizer: true, | ||
}; |
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,14 @@ | ||
{ | ||
"extends": "solhint:recommended", | ||
"plugins": ["prettier"], | ||
"rules": { | ||
"reentrancy": "off", | ||
"prettier/prettier": "off", | ||
"modifier-name-mixedcase": "off", | ||
"no-empty-blocks": "off", | ||
"func-visibility": "off", | ||
"max-states-count": "off", | ||
"not-rely-on-time": "off", | ||
"compiler-version": "off" | ||
} | ||
} |
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 @@ | ||
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. |
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,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.
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,28 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.20; | ||
|
||
import "@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_); | ||
} | ||
} |
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,10 @@ | ||
import { Deployer, Logger } from "@solarity/hardhat-migrate"; | ||
import { artifacts } from "hardhat"; | ||
|
||
const ERC20Mock = artifacts.require("ERC20Mock"); | ||
|
||
export = async (deployer: Deployer, logger: Logger) => { | ||
const erc20 = await deployer.deploy(ERC20Mock, "Mock", "Mock", 18); | ||
|
||
logger.logContracts(["ERC20Mock", erc20.address]); | ||
}; |
Oops, something went wrong.