Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dappsar committed Jul 26, 2023
1 parent 19301a6 commit 052f3be
Show file tree
Hide file tree
Showing 25 changed files with 736 additions and 2 deletions.
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = false
max_line_length = 120

[*.sol]
indent_size = 4

[*.js]
indent_size = 2

[*.{adoc,md}]
max_line_length = 0
20 changes: 20 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"root": true,
"extends" : [
"eslint:recommended",
"prettier"
],
"env": {
"es2022": true,
"browser": true,
"node": true,
"mocha": true
},
"globals" : {
"artifacts": "readonly",
"contract": "readonly",
"web3": "readonly",
"extendEnvironment": "readonly",
"expect": "readonly"
}
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sol linguist-language=Solidity
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
17 changes: 17 additions & 0 deletions .github/workflows/doc/workflows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Github Actions Workflows


## Action Workflow dependabot.yml

Enabling [Dependabot version updates for actions](https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot) allow us to get notified of new action releases.


## Action Workflow slither.yml


The action supports the Github Code Scanning integration, which will push Slither's alerts to the Security tab of the Github project (see [About code scanning](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/about-code-scanning)). This integration eases the triaging of findings and improves the continuous integration.

We include `fail-on: none` on the Slither action to avoid failing the run if findings are found. Also, it creates/updates pull requests with the contents of Slither's Markdown report.


[More Info](https://github.com/marketplace/actions/slither-action#examples)
26 changes: 26 additions & 0 deletions .github/workflows/scripts/comments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = async ({ github, context, header, body }) => {
const comment = [header, body].join("\n");

const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.number,
});

const botComment = comments.find(
(comment) =>
// github-actions bot user
comment.user.id === 41898282 && comment.body.startsWith(header)
);

const commentFn = botComment ? "updateComment" : "createComment";

await github.rest.issues[commentFn]({
owner: context.repo.owner,
repo: context.repo.repo,
body: comment,
...(botComment
? { comment_id: botComment.id }
: { issue_number: context.payload.number })
});
};
35 changes: 35 additions & 0 deletions .github/workflows/slither.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Slither Analysis
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
analyze:
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Run Slither
uses: crytic/[email protected]
id: slither
with:
node-version: 16
sarif: results.sarif
fail-on: none
slither-args: --checklist --markdown-root ${{ github.server_url }}/${{ github.repository }}/blob/${{ github.sha }}/

- name: Create/update checklist as PR comment
uses: actions/github-script@v6
if: github.event_name == 'pull_request'
with:
script: |
const script = require('.github/scripts/comment')
const header = '# Slither report'
const body = `${{ steps.slither.outputs.stdout }}`
await script({ github, context, header, body })
23 changes: 23 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: unit-test
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 16
- name: Install dependencies
run: npm install --no-warnings
- name: Compile contracts
run: npx hardhat compile
- name: Test deploy harhat
run: npx hardhat node & npx hardhat run --network hardhat scripts/deploy.ts
- name: Run tests
run: npx hardhat test
79 changes: 79 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
*.swp
*.swo

# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed
allFiredEvents
scTopics

# Coverage directory used by tools like istanbul
coverage
coverage.json
coverageEnv

# node-waf configuration
.lock-wscript

# Dependency directory
node_modules

# Debug log from npm
npm-debug.log

# local env variables
.env

# truffle build directory
build/

# macOS
.DS_Store

# truffle
.node-xmlhttprequest-*

# IntelliJ IDE
.idea

# docs artifacts
docs/modules/api

# only used to package @openzeppelin/contracts
contracts/build/
contracts/README.md

# temporary artifact from solidity-coverage
allFiredEvents
.coverage_artifacts
.coverage_cache
.coverage_contracts

# hardat-exposed
contracts-exposed

# Hardhat
/cache
/artifacts
/generated
typechain
typechain-types
src/

# Foundry
/out

# Certora
.certora*
.last_confs
certora_*
.zip-output-url.txt

# git
yarn.lock
package-lock*
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.github
build
node_modules
22 changes: 22 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"printWidth": 120,
"singleQuote": true,
"trailingComma": "none",
"semi": false,
"arrowParens": "avoid",
"plugins": ["prettier-plugin-solidity"],
"overrides": [
{
"files": "*.sol",
"options": {
"parser": "solidity-parse",
"printWidth": 80,
"tabWidth": 4,
"useTabs": false,
"semi": true,
"singleQuote": false,
"bracketSpacing": false
}
}
]
}
13 changes: 13 additions & 0 deletions .solcover.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
norpc: true,
testCommand: 'npm test',
compileCommand: 'npm run compile',
skipFiles: ['mocks'],
providerOptions: {
default_balance_ether: '10000000000000000000000000'
},
mocha: {
fgrep: '[skip-on-coverage]',
invert: true
}
}
8 changes: 8 additions & 0 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "solhint:default",
"plugins": [],
"rules": {
"avoid-suicide": "error",
"avoid-sha3": "warn"
}
}
6 changes: 6 additions & 0 deletions .solhintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules/
test/
scripts/
tasks/
cache/
artifacts/
85 changes: 83 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,83 @@
# giga_gigacounts_blockchain
blockchain codebase for gigacounts
# Gigacounts blockchain

## Requirements

The App requires:

- [Node.js](https://nodejs.org/) v16+ to run (^16.14.2).
- [Yarn.js](https://classic.yarnpkg.com/en/docs/install) v1+ to run (^1.22.19).
- [hardhat](https://hardhat.org/)

- You could check the version of packages (node, yarn) with these commands:

```sh
node -v
yarn -v
```

## Install the dependencies

```sh
- yarn install # with yarn
- npm i OR npm i --legacy-peer-deps # with NPM
```

If you have some trouble with dependencies, try this:

```sh
set http_proxy=
set https_proxy=
npm config rm https-proxy
npm config rm proxy
npm config set registry "https://registry.npmjs.org"
yarn cache clean
yarn config delete proxy
yarn --network-timeout 100000
```

Create a .env file running the command in terminal

```sh
touch .env
```

## Environment variables

The environment variables below needs to be set in the .env file when the project is running locally.

```sh
INFURA_ID={your infura project id}
ALCHEMY_ID={your infura api key}
PUBLIC_ADDRESS={your wallet address}
PRIVATE_KEY={your private key to deploy SCs}
DEPLOYED_GIGACOUNTS_CONTRACT_ADDRESS={the address where contract ERC20 is deploy, just to use in scripts/interact.ts}
```

> Note: You can find more info about the other required `.env` variables inside the `example_env` file.

## Commands

```shell
# Run testnet
yarn hardhat node

# Compile
npx hardhat compile

# Test
npx hardhat test

# Deploy to local
npx hardhat run scripts/deploy.ts --network localhost

# Deploy to Mumnbai
npx hardhat run scripts/deploy.ts --network mumbai

# Solidity Security and Style guides validations with solhint [https://protofire.github.io/solhint/]
npm install -g solhint
solhint 'contracts/**/*.sol'

# Solidity Static Analysis [https://github.com/crytic/slither]
slither .
```
Loading

0 comments on commit 052f3be

Please sign in to comment.