generated from ZumZoom/solidity-template
-
Notifications
You must be signed in to change notification settings - Fork 1
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 fddbec4
Showing
20 changed files
with
6,156 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,16 @@ | ||
# Editor configuration, see https://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 4 | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.{json,yml,xml,yaml}] | ||
indent_size = 2 | ||
|
||
[*.md] | ||
max_line_length = off | ||
trim_trailing_whitespace = false |
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,2 @@ | ||
node_modules/ | ||
coverage/ |
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,52 @@ | ||
{ | ||
"extends" : [ | ||
"standard", | ||
"plugin:promise/recommended" | ||
], | ||
"plugins": [ | ||
"promise" | ||
], | ||
"env": { | ||
"browser" : true, | ||
"node" : true, | ||
"mocha" : true, | ||
"jest" : true | ||
}, | ||
"globals" : { | ||
"artifacts": false, | ||
"contract": false, | ||
"assert": false, | ||
"web3": false | ||
}, | ||
"rules": { | ||
|
||
// Strict mode | ||
"strict": [2, "global"], | ||
|
||
// Code style | ||
"indent": [2, 4], | ||
"quotes": [2, "single"], | ||
"semi": ["error", "always"], | ||
"space-before-function-paren": ["error", "always"], | ||
"no-use-before-define": 0, | ||
"no-unused-expressions": "off", | ||
"eqeqeq": [2, "smart"], | ||
"dot-notation": [2, {"allowKeywords": true, "allowPattern": ""}], | ||
"no-redeclare": [2, {"builtinGlobals": true}], | ||
"no-trailing-spaces": [2, { "skipBlankLines": true }], | ||
"eol-last": 1, | ||
"comma-spacing": [2, {"before": false, "after": true}], | ||
"camelcase": [2, {"properties": "always"}], | ||
"no-mixed-spaces-and-tabs": [2, "smart-tabs"], | ||
"comma-dangle": [1, "always-multiline"], | ||
"no-dupe-args": 2, | ||
"no-dupe-keys": 2, | ||
"no-debugger": 0, | ||
"no-undef": 2, | ||
"object-curly-spacing": [2, "always"], | ||
"max-len": [2, 200, 2], | ||
"generator-star-spacing": ["error", "before"], | ||
"promise/avoid-new": 0, | ||
"promise/always-return": 0 | ||
} | ||
} |
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 @@ | ||
*.sol linguist-language=Solidity |
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,41 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20 | ||
cache: 'yarn' | ||
- run: yarn | ||
- run: yarn lint | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20 | ||
cache: 'yarn' | ||
- run: yarn | ||
- run: yarn test:ci | ||
|
||
coverage: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20 | ||
cache: 'yarn' | ||
- run: yarn | ||
- run: yarn coverage | ||
- uses: codecov/codecov-action@v3 |
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 @@ | ||
artifacts | ||
cache | ||
node_modules | ||
coverage | ||
coverage.json | ||
build | ||
.coverage_contracts | ||
.coverage_artifacts | ||
.idea | ||
.env |
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,26 @@ | ||
module.exports = { | ||
configureYulOptimizer: true, | ||
solcOptimizerDetails: { | ||
yul: true, | ||
yulDetails: { | ||
optimizerSteps: | ||
"dhfoDgvlfnTUtnIf" + // None of these can make stack problems worse | ||
"[" + | ||
"xa[r]EscLM" + // Turn into SSA and simplify | ||
"cCTUtTOntnfDIl" + // Perform structural simplification | ||
"Lcl" + // Simplify again | ||
"Vcl [j]" + // Reverse SSA | ||
|
||
// should have good "compilability" property here. | ||
|
||
"Tpel" + // Run functional expression inliner | ||
"xa[rl]" + // Prune a bit more in SSA | ||
"xa[r]cL" + // Turn into SSA again and simplify | ||
"gvf" + // Run full inliner | ||
"CTUca[r]LSsTFOtfDnca[r]Ilc" + // SSA plus simplify | ||
"]" + | ||
"jml[jl] VcTOcl jml : fDnTOcm", | ||
}, | ||
}, | ||
skipFiles: ['mocks', 'interfaces'], | ||
} |
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,8 @@ | ||
{ | ||
"extends": "solhint:recommended", | ||
"rules": { | ||
"compiler-version": ["error", "^0.8.0"], | ||
"private-vars-leading-underscore": "error", | ||
"func-visibility": ["error", { "ignoreConstructors": 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,3 @@ | ||
{ | ||
"solidity.compileUsingRemoteVersion": "v0.8.23" | ||
} |
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 %ADD_YOUR_COMPANY_NAME% | ||
|
||
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,7 @@ | ||
# Solidity Template | ||
|
||
Hardhat template for solidity projects with preconfigured Github Actions and Coveralls support. | ||
|
||
|
||
[![Build Status](https://github.com/zumzoom/solidity-template/workflows/CI/badge.svg)](https://github.com/zumzoom/solidity-template/actions) | ||
[![Coverage Status](https://codecov.io/gh/ZumZoom/solidity-template/branch/master/graph/badge.svg?token=JA2Z2CABZZ)](https://codecov.io/gh/ZumZoom/solidity-template) |
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,24 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.23; | ||
|
||
/** | ||
* @title Example contract | ||
* @author ZumZoom | ||
* @notice Example contract without any meaningful functionality. | ||
*/ | ||
contract Example { | ||
/** | ||
* @notice Example event | ||
* @param a Value to log | ||
*/ | ||
event Log(uint256 a); | ||
|
||
/** | ||
* @notice Example function that is present just to have any function at all. | ||
* @param a Value that will be logged | ||
*/ | ||
function func(uint256 a) public { | ||
emit Log(a); | ||
} | ||
} |
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,44 @@ | ||
const hre = require('hardhat'); | ||
const { getChainId, ethers } = hre; | ||
|
||
module.exports = async ({ deployments, getNamedAccounts }) => { | ||
const networkName = hre.network.name; | ||
console.log(`running ${networkName} deploy script`); | ||
const chainId = await getChainId(); | ||
console.log('network id ', chainId); | ||
if (chainId !== hre.config.networks[networkName].chainId.toString()) { | ||
console.log(`network chain id: ${hre.config.networks[networkName].chainId}, your chain id ${chainId}`); | ||
console.log('skipping wrong chain id deployment'); | ||
return; | ||
} | ||
|
||
const { deploy } = deployments; | ||
const { deployer } = await getNamedAccounts(); | ||
|
||
const constructorArgs = []; | ||
const contractName = 'Example'; | ||
const deploymentName = 'ExampleDeployment'; | ||
const exampleDeployment = await deploy(deploymentName, { | ||
args: constructorArgs, | ||
from: deployer, | ||
contract: contractName, | ||
skipIfAlreadyDeployed: true, | ||
}); | ||
|
||
console.log(`${deploymentName} deployed to: ${exampleDeployment.address}`); | ||
|
||
if (chainId !== '31337') { | ||
await hre.run('verify:verify', { | ||
address: exampleDeployment.address, | ||
constructorArguments: constructorArgs, | ||
}); | ||
} | ||
|
||
const Example = await ethers.getContractFactory('Example'); | ||
const example = Example.attach(exampleDeployment.address); | ||
|
||
const txn = await example.func('1234'); | ||
await txn; | ||
}; | ||
|
||
module.exports.skip = async () => 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,40 @@ | ||
# Example | ||
|
||
|
||
Example contract | ||
|
||
Example contract without any meaningful functionality. | ||
|
||
|
||
|
||
## Functions | ||
### func | ||
```solidity | ||
function func( | ||
uint256 a | ||
) public | ||
``` | ||
Example function that is present just to have any function at all. | ||
|
||
|
||
#### Parameters: | ||
| Name | Type | Description | | ||
| :--- | :--- | :------------------------------------------------------------------- | | ||
|`a` | uint256 | Value that will be logged | ||
|
||
|
||
## Events | ||
### Log | ||
```solidity | ||
event Log( | ||
uint256 a | ||
) | ||
``` | ||
Example event | ||
|
||
|
||
#### Parameters: | ||
| Name | Type | Description | | ||
| :--- | :--- | :------------------------------------------------------------------- | | ||
|`a` | uint256 | Value to log | ||
|
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 @@ | ||
# docs |
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 @@ | ||
# Table of contents | ||
|
||
* [Main Readme](README.md) | ||
* [Example](Example.md) |
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,44 @@ | ||
require('@nomicfoundation/hardhat-chai-matchers'); | ||
require('@nomicfoundation/hardhat-ethers'); | ||
require('@nomicfoundation/hardhat-verify'); | ||
require('dotenv').config(); | ||
require('hardhat-dependency-compiler'); | ||
require('hardhat-deploy'); | ||
require('hardhat-gas-reporter'); | ||
require('hardhat-tracer'); | ||
require('solidity-coverage'); | ||
|
||
const { Networks, getNetwork } = require('@1inch/solidity-utils/hardhat-setup'); | ||
|
||
const { networks, etherscan } = (new Networks()).registerAll(); | ||
|
||
module.exports = { | ||
solidity: { | ||
compilers: [ | ||
{ | ||
version: '0.8.23', | ||
settings: { | ||
optimizer: { | ||
enabled: true, | ||
runs: 1000000, | ||
}, | ||
evmVersion: (networks[getNetwork()])?.hardfork || 'shanghai', | ||
viaIR: true, | ||
}, | ||
}, | ||
], | ||
}, | ||
namedAccounts: { | ||
deployer: { | ||
default: 0, | ||
}, | ||
}, | ||
networks, | ||
etherscan, | ||
tracer: { | ||
enableAllOpcodes: true, | ||
}, | ||
dependencyCompiler: { | ||
paths: [], | ||
}, | ||
}; |
Oops, something went wrong.