Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added contracts and tests #7

Merged
merged 24 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
692ff4a
feat: added contracts, tests, and workflows
heueristik Oct 20, 2023
c01e93e
refactor: removed NetworkNameMapping and added base and sepolia support
heueristik Oct 20, 2023
77b2e07
ci: improvements
heueristik Oct 23, 2023
d729b1d
ci: fix subgraph workflow
heueristik Oct 23, 2023
e3223e8
ci: fix contracts workflow
heueristik Oct 23, 2023
846c46c
ci: added contracts subfolder to subgraph workflow triggers
heueristik Oct 23, 2023
8ec3491
refactor: improved proxy deployment helpers
heueristik Oct 23, 2023
244264a
refactor: folder structure
heueristik Oct 23, 2023
f61f238
test: added tests
heueristik Oct 23, 2023
3932311
style: formatting
heueristik Oct 23, 2023
d52643d
refactor: ProxyFactory and TestGovernanceERC20
heueristik Oct 23, 2023
f473fd4
test: add tests for proxy factory
heueristik Oct 23, 2023
259f08b
docs: NatSpec improvments
heueristik Oct 23, 2023
3884d0b
test: remove only
heueristik Oct 23, 2023
2caede5
style: fix formatting
heueristik Oct 23, 2023
a8913e2
chore: maintained changelog
heueristik Oct 23, 2023
f23d742
chore: added version number and descriptions
heueristik Oct 23, 2023
e673b0e
refactor: split helpers into proxy and event
heueristik Oct 23, 2023
0717be2
refactor: revert proxy factory addition
heueristik Oct 24, 2023
9314689
Terminal chore: maintained changelog 0717be
heueristik Oct 24, 2023
c7ae989
refactor: remove unused file
heueristik Oct 24, 2023
b7e0261
test: remove only
heueristik Oct 25, 2023
31d9dea
ci: removed comments
heueristik Oct 25, 2023
b3af749
refactor: remove redundant line number
heueristik Oct 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# GENERAL

## The network used for testing purposes
NETWORK_NAME="mainnet" # ["mainnet", "goerli", "polygon", "polygonMumbai"]

# CONTRACTS

## Hex encoded private keys separated by a comma `,`a
PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" # Default hardhat account 0 private key. DON'T USE FOR DEPLOYMENTS

## Infura credentials
INFURA_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"

## Gas Reporting
REPORT_GAS='true'
COINMARKETCAP_API_KEY="zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz"

## Block explorers
ETHERSCAN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
POLYGONSCAN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
BASESCAN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"

# SUBGRAPH

## The Graph credentials
GRAPH_KEY="zzzzzzzzzzzz"

## Subgraph
SUBGRAPH_NAME="osx"
SUBGRAPH_VERSION="alice-debug-1s"
SUBGRAPH_NETWORK_NAME="goerli" # ["mainnet", "goerli", "polygon", "polygonMumbai"]
39 changes: 39 additions & 0 deletions .github/workflows/contracts-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: 'contracts'

on:
workflow_dispatch:
push:
paths:
- 'contracts/**'
- '.github/workflows/contracts-*.yml'

jobs:
formatting-linting:
uses: ./.github/workflows/formatting-linting.yml
tests:
runs-on: 'ubuntu-latest'
defaults:
run:
working-directory: contracts
steps:
- name: 'Check out the repo'
uses: 'actions/checkout@v3'

- name: 'Install Node.js'
uses: 'actions/setup-node@v3'
with:
cache: 'yarn'
node-version: 18

- name: 'Install the dependencies'
run: 'yarn install'

- name: 'Build the contracts'
run: 'yarn build'
env:
INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }}

- name: 'Test the contracts and generate the coverage report'
run: 'yarn coverage >> $GITHUB_STEP_SUMMARY'
env:
INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }}
18 changes: 12 additions & 6 deletions .github/workflows/formatting-linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,17 @@ jobs:
- name: 'Install the dependencies'
run: 'yarn install'

- name: 'Install subgraph dependencies'
run: 'cd subgraph/ && yarn install'

- name: 'Lint subgraph'
run: 'yarn lint:subgraph:ts >> $GITHUB_STEP_SUMMARY'

- name: 'Check code formatting'
run: yarn prettier:check

- name: 'Lint contracts solidity'
run: yarn lint:contracts:sol >> $GITHUB_STEP_SUMMARY

- name: 'Lint contracts ts and js'
run: yarn lint:contracts:ts >> $GITHUB_STEP_SUMMARY

#- name: 'Lint js-client ts and js'
# run: yarn lint:js-client:ts >> $GITHUB_STEP_SUMMARY

- name: 'Lint subgraph ts and js'
run: yarn lint:subgraph:ts >> $GITHUB_STEP_SUMMARY
39 changes: 25 additions & 14 deletions .github/workflows/subgraph-tests.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,39 @@
name: Subgraph
name: 'subgraph'

on:
workflow_dispatch:
push:
paths:
- 'contracts/**'
- 'subgraph/**'
- '.github/workflows/subgraph-*.yml'

env:
working-directory: subgraph

jobs:
formatting-linting:
uses: ./.github/workflows/formatting-linting.yml
tests:
runs-on: ubuntu-latest
runs-on: 'ubuntu-latest'
defaults:
run:
working-directory: ${{env.working-directory}}
working-directory: subgraph
steps:
- uses: actions/checkout@v2
- name: Install node
uses: actions/setup-node@v3
- name: 'Check out the repo'
uses: 'actions/checkout@v3'

- name: 'Install Node.js'
uses: 'actions/setup-node@v3'
with:
node-version: 16
- name: Install dependencies
run: yarn install --pure-lockfile
- name: Run Tests
run: yarn run coverage >> $GITHUB_STEP_SUMMARY
cache: 'yarn'
node-version: 18

- name: 'Install the dependencies'
run: 'yarn install'

#- name: 'Build the subgraph'
# run: 'yarn build'
# env:
# INFURA_API_KEY: ${{secrets.INFURA_API_KEY}}
# NETWORK_NAME: 'goerli'
heueristik marked this conversation as resolved.
Show resolved Hide resolved

- name: 'Test the subgraph'
run: 'yarn test >> $GITHUB_STEP_SUMMARY'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ yarn-error.log*

# generated
generated
reference-guide
.bin
coverage.json
.latest.json
19 changes: 19 additions & 0 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": "solhint:recommended",
"plugins": ["prettier"],
"rules": {
"code-complexity": ["error", 8],
"compiler-version": ["error", ">=0.8.4"],
"func-visibility": ["error", {"ignoreConstructors": true}],
"max-line-length": ["off", 120],
mathewmeconry marked this conversation as resolved.
Show resolved Hide resolved
"named-parameters-mapping": "warn",
"no-console": "off",
"not-rely-on-time": "off",
"prettier/prettier": [
"error",
{
"endOfLine": "auto"
}
]
}
}
3 changes: 3 additions & 0 deletions .solhintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# directories
**/artifacts
**/node_modules
18 changes: 18 additions & 0 deletions contracts/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
parser: '@typescript-eslint/parser'
parserOptions:
project: './contracts/tsconfig.json'

# Custom eslint settings for the contracts can be defined here
ignorePatterns:
# directories
- .coverage_artifacts
- .coverage_cache
- .coverage_contracts
- artifacts
- build
- cache
- coverage
- dist
- typechain
# files
- coverage.json
7 changes: 7 additions & 0 deletions contracts/.solcover.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
istanbulReporter: ['html', 'lcov'],
providerOptions: {
privateKey: process.env.PRIVATE_KEY,
},
skipFiles: ['test'],
};
35 changes: 35 additions & 0 deletions contracts/docs/templates/common.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{{h 2}} {{visibility}} {{toLowerCase type}} {{name}}

{{{natspec.notice}}}

{{#if signature}}
```solidity
{{{signature}}}
```
{{/if}}

{{#if natspec.params}}
| Input | Type | Description |
|:----- | ---- | ----------- |
{{#each params}}
| `{{{name}}}` | `{{{type}}}` | {{{joinLines natspec}}} |
{{/each}}
{{#if natspec.returns}}
| **Output** | |
{{#each returns}}
| {{#if name}} `{{name}}` {{else}} `{{@index}}` {{/if}} | `{{type}}` | {{{joinLines natspec}}} |
{{/each}}
{{/if}}
{{else}}
{{#if natspec.returns}}
| Output | Type | Description |
| ------ | ---- | ----------- |
{{#each returns}}
| {{#if name}} `{{{name}}}` {{else}} `{{{@index}}}` {{/if}} | `{{type}}` | {{{joinLines natspec}}} |
{{/each}}
{{/if}}
{{/if}}

{{#if natspec.dev}}
*{{{natspec.dev}}}*
{{/if}}
12 changes: 12 additions & 0 deletions contracts/docs/templates/contract.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## Description

{{{natspec.notice}}}

{{{natspec.dev}}}

## Implementation

{{#each items}}
{{>item}}
{{/each}}
<!--CONTRACT_END-->
9 changes: 9 additions & 0 deletions contracts/docs/templates/enum.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{>common}}

```solidity
enum {{name}} {
{{#each members}}
{{name}}{{#unless @last}},{{/unless}}
{{/each}}
}
```
1 change: 1 addition & 0 deletions contracts/docs/templates/error.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{>common}}
1 change: 1 addition & 0 deletions contracts/docs/templates/event.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{>common}}
1 change: 1 addition & 0 deletions contracts/docs/templates/function.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{>common}}
66 changes: 66 additions & 0 deletions contracts/docs/templates/helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import {HelperOptions, Utils} from 'handlebars';

/**
* Returns a Markdown heading marker. An optional number increases the heading level.
*
* Input Output
* {{h}} {{name}} # Name
* {{h 2}} {{name}} ## Name
*/
export function h(opts: HelperOptions): string;
export function h(hsublevel: number, opts: HelperOptions): string;
export function h(hsublevel: number | HelperOptions, opts?: HelperOptions) {
const {hlevel} = getHLevel(hsublevel, opts);
return new Array(hlevel).fill('#').join('');
}

/**
* Delineates a section where headings should be increased by 1 or a custom number.
*
* {{#hsection}}
* {{>partial-with-headings}}
* {{/hsection}}
*/
export function hsection(opts: HelperOptions): string;
export function hsection(hsublevel: number, opts: HelperOptions): string;
export function hsection(
this: unknown,
hsublevel: number | HelperOptions,
opts?: HelperOptions
) {
let hlevel;
({hlevel, opts} = getHLevel(hsublevel, opts));
opts.data = Utils.createFrame(opts?.data);
opts.data.hlevel = hlevel;
return opts.fn(this as unknown, opts);
}

/**
* Helper for dealing with the optional hsublevel argument.
*/
function getHLevel(hsublevel: number | HelperOptions, opts?: HelperOptions) {
if (typeof hsublevel === 'number') {
hsublevel = Math.max(1, hsublevel);
} else {
opts = hsublevel;
hsublevel = 1;
}
const contextHLevel: number = opts?.data?.hlevel ?? 0;
return {opts, hlevel: contextHLevel + hsublevel};
}

export function trim(text: string) {
if (typeof text === 'string') {
return text.trim();
}
}

export function toLowerCase(text: string) {
return text.toLowerCase();
}

export function joinLines(text?: string) {
if (typeof text === 'string') {
return text.replace(/\n+/g, ' ');
}
}
1 change: 1 addition & 0 deletions contracts/docs/templates/modifier.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{>common}}
7 changes: 7 additions & 0 deletions contracts/docs/templates/page.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

{{#each items}}
{{#hsection}}
{{>item}}
{{/hsection}}

{{/each}}
9 changes: 9 additions & 0 deletions contracts/docs/templates/struct.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{>common}}

```solidity
struct {{name}} {
{{#each members}}
{{{typeName.typeDescriptions.typeString}}} {{name}};
{{/each}}
}
```
1 change: 1 addition & 0 deletions contracts/docs/templates/user-defined-value-type.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{>common}}
1 change: 1 addition & 0 deletions contracts/docs/templates/variable.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{>common}}
Loading