Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeVini committed Apr 26, 2022
0 parents commit 1773974
Show file tree
Hide file tree
Showing 22 changed files with 23,621 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ETHERSCAN_API_KEY=

# GAS REPORTER
COINMARKETCAP_API_KEY=
REPORT_GAS=false
TOKEN=AVAX
GAS_PRICE_API=https://api.snowtrace.io/api?module=proxy&action=eth_gasPrice

MNEMONIC="test test test test test test test test test test test junk"
143 changes: 143 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'airbnb-typescript/base',
'prettier',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
],
root: true,
env: {
node: true,
jest: true,
},
settings: { 'import/resolver': { typescript: {} } },
rules: {
'@typescript-eslint/no-useless-constructor': 'off',
camelcase: 'off',
'no-unsafe-finally': 'off',
'import/no-extraneous-dependencies': 'off',
'import/no-cycle': 'off',
'@typescript-eslint/lines-between-class-members': 'off',
'max-classes-per-file': 'off',
semi: 'off',
'no-underscore-dangle': 'off',
'class-methods-use-this': 'off',
curly: ['error', 'all'],
'import/prefer-default-export': 'off',
'array-callback-return': 'error',
'brace-style': ['error', '1tbs', { allowSingleLine: false }],
'no-return-await': 'off',
'no-invalid-this': 'off',
'no-empty-pattern': 'error',
'no-magic-numbers': 'off',
'no-unused-vars': 'error',
'object-shorthand': ['error', 'always'],
'space-before-blocks': 'error',
'@typescript-eslint/array-type': 'error',
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/explicit-member-accessibility': [
'error',
{ accessibility: 'no-public' },
],
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'default',
format: ['camelCase'],
},
{
selector: 'variable',
types: ['function'],
format: ['camelCase', 'PascalCase'],
},
{
selector: 'variable',
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
filter: {
regex: '^(.*-.*)$',
match: false,
},
leadingUnderscore: 'allow',
},
{
selector: 'enumMember',
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
},
{
selector: 'parameter',
format: ['camelCase'],
leadingUnderscore: 'allow',
},
{
selector: 'memberLike',
format: ['camelCase'],
leadingUnderscore: 'allow',
},
{
selector: 'memberLike',
format: null,
filter: {
regex: '[- ]',
match: true,
},
},
{
selector: 'memberLike',
modifiers: ['private'],
format: ['camelCase'],
leadingUnderscore: 'require',
},
{
selector: 'typeLike',
format: ['PascalCase'],
},
],
'@typescript-eslint/no-explicit-any': [
'error',
{ ignoreRestArgs: true },
],
'@typescript-eslint/no-invalid-this': 'error',
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/no-for-in-array': 'error',
'@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/no-magic-numbers': [
'error',
{
ignoreEnums: true,
ignoreArrayIndexes: true,
ignoreNumericLiteralTypes: true,
ignoreReadonlyClassProperties: true,
ignore: [0, 1],
},
],
'@typescript-eslint/return-await': ['error', 'always'],
'@typescript-eslint/semi': ['error', 'never'],
'import/order': [
'error',
{
alphabetize: { order: 'asc' },
'newlines-between': 'always',
groups: [
'builtin',
'external',
'internal',
'parent',
'sibling',
'index',
'object',
],
},
],
'no-restricted-syntax': 'off',
},
ignorePatterns: ['.eslintrc.js'],
}
45 changes: 45 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# compiled output
/dist
/node_modules
/typechain
/artifacts
/cache
/abis
/.openzeppelin
/build

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# OS
.DS_Store

# Tests
coverage.json
/coverage
/.nyc_output

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
args.js

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

.env

4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run pretty-quick
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v14.16.1
24 changes: 24 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = {
overrides: [
{
files: "*.sol",
options: {
bracketSpacing: false,
printWidth: 300,
tabWidth: 4,
useTabs: false,
singleQuote: false,
explicitTypes: "always",
},
},
{
files: "*.ts",
options: {
printWidth: 145,
semi: false,
tabWidth: 4,
trailingComma: "es5",
},
},
],
}
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"solidity.defaultCompiler": "remote",
"solidity.compileUsingRemoteVersion": "0.8.12"
}
Empty file added CHANGELOG.md
Empty file.
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Smart contracts boilerplate
## Installation
```bash
$ npm use
```

```bash
$ npm install
```

## Development

### Creating smart contract
Create your smart contract in `contracts/` folder

### Compilation
Set solidity version in hardhat.config.ts file, solidity -> compilers -> version, then run compilation

```bash
$ npx hardhat compile
```

### Running tests
Create your tests in test folder. To set typed test, describe types in `test.config.d.ts`. Then, use it with Mocha.Context (this)

Run tests with command:
```bash
$ npx hardhat test TEST_PATH
```

## Useful links
1. Hardhat documentation:
https://hardhat.org/getting-started/
19 changes: 19 additions & 0 deletions contracts/mocks/ERC20Mock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.12;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract ERC20Mock is ERC20 {
constructor(
string memory name_,
string memory symbol_,
uint256 totalSupply_
) ERC20(name_, symbol_) {
ERC20._mint(msg.sender, totalSupply_);
}

function decimals() public view virtual override returns (uint8) {
return 6;
}
}
24 changes: 24 additions & 0 deletions deploy/ERC20Mock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { HardhatRuntimeEnvironment } from 'hardhat/types';

module.exports = async function (hre: HardhatRuntimeEnvironment) {
const { deployments, getNamedAccounts, ethers } = hre;
const { deploy } = deployments;

const { deployer } = await getNamedAccounts();

const name = 'ERC20Mock'
const symbol = 'ERC'
const totalSupply = ethers.utils.parseUnits('1000000', 6)

await deploy('ERC20Mock', {
args: [
name,
symbol,
totalSupply
],
from: deployer,
log: true,
});
};

module.exports.tags = ["ERC20Mock"];
Loading

0 comments on commit 1773974

Please sign in to comment.