Skip to content

Commit

Permalink
Merge pull request #1 from pnetwork-association/chore/test-contracts
Browse files Browse the repository at this point in the history
Add tests contracts + event attestator simulator
  • Loading branch information
gitmp01 authored Jun 21, 2024
2 parents 5ca6ca0 + 7bbbde3 commit dbd782a
Show file tree
Hide file tree
Showing 59 changed files with 7,637 additions and 1,602 deletions.
47 changes: 0 additions & 47 deletions .code-workspace

This file was deleted.

4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

37 changes: 25 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,42 @@
name: CI
name: test
on:
push:
branches:
- master
branches: [master]
pull_request:

env:
FOUNDRY_PROFILE: ci

jobs:
run-ci:
yarn-ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: recursive

- name: 'Enable corepack'
run: corepack enable

- name: Install Foundry
- name: 'Install Foundry'
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Install deps
run: forge install
- name: 'Setup Node.js'
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'yarn'

- name: 'Install'
run: yarn install

- name: 'Build'
run: yarn build

- name: Check gas snapshots
run: forge snapshot --check
- name: 'Lint'
run: yarn lint

- name: Run tests
run: forge test
- name: 'Test'
run: yarn test
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
.yarn

dist
coverage
node_modules
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
[submodule "solidity/lib/Solidity-RLP"]
path = solidity/lib/Solidity-RLP
url = https://github.com/hamdiallam/Solidity-RLP
[submodule "solidity/lib/openzeppelin-contracts-upgradeable"]
path = solidity/lib/openzeppelin-contracts-upgradeable
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
9 changes: 7 additions & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"semi": false,
"tabWidth": 2,
"arrowParens": "avoid",
"singleQuote": true,
"trailingComma": "all",
"overrides": [
Expand All @@ -14,9 +16,12 @@
}
}
],
"importOrder": ["^@hyperlane-xyz/(.*)$", "^../(.*)$", "^./(.*)$"],
"importOrder": ["<THIRD_PARTY_MODULES>", "^[./]"],
"importOrderSeparation": true,
"importOrderSortSpecifiers": true,
"importOrderParserPlugins": ["importAssertions", "typescript", "jsx"],
"plugins": ["prettier-plugin-solidity", "@trivago/prettier-plugin-sort-imports"]
"plugins": [
"prettier-plugin-solidity",
"@trivago/prettier-plugin-sort-imports"
]
}
7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"recommendations": [
"esbenp.prettier-vscode",
"bierner.github-markdown-preview",
"nomicfoundation.hardhat-solidity"
]
}
41 changes: 41 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"npm.packageManager": "yarn",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.organizeImports": "explicit"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[markdown]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[solidity]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"files.watcherExclude": {
"**/.git/**": true,
"./solidity/lib": true,
"**/node_modules/*/**": true
},
"files.exclude": {
"**/node_modules": true,
"**/*.js": {
"when": "$(basename).ts"
},
"**/*.map": {
"when": "$(basename).map"
},
"**/artifacts": true,
"**/cache": true,
"**/dist": true,
"**/types": true
}
}
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: "node-modules"
24 changes: 24 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// @ts-check
import eslint from '@eslint/js'
import prettierConfig from 'eslint-config-prettier'
import globals from 'globals'
import tseslint from 'typescript-eslint'

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
prettierConfig,
{
languageOptions: {
globals: {
...globals.node,
},
},
rules: {
'no-console': 'error',
},
},
{
ignores: ['**/lib'],
},
)
21 changes: 15 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,30 @@
"version": "0.0.0",
"private": true,
"description": "pNetwork v4 monorepo",
"main": " ",
"type": "module",
"author": "pNetwork Devs",
"license": "MIT",
"workspaces": [
"solidity"
"solidity",
"typescript/*"
],
"scripts": {
"test": "yarn workspaces run test",
"prettier": "yarn workspaces run prettier"
"test": "yarn workspaces foreach --all --parallel --no-private run test",
"lint": "yarn workspaces foreach --all --parallel --no-private run lint",
"build": "yarn workspaces foreach --all --parallel --no-private run build",
"prettier": "yarn workspaces foreach --all --parallel --no-private run prettier"
},
"devDependencies": {
"@eslint/js": "^9.5.0",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/eslint__js": "^8.42.3",
"eslint": "8.57.0",
"eslint-config-prettier": "^9.1.0",
"prettier": "3.3.2",
"prettier-plugin-solidity": "^1.3.1"
}
"prettier-plugin-solidity": "^1.3.1",
"solhint": "^5.0.1",
"typescript": "4.7.4",
"typescript-eslint": "^7.13.1"
},
"packageManager": "[email protected]"
}
14 changes: 14 additions & 0 deletions pnetwork-v4.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"folders": [
{
"name": "root",
"path": "./",
},
{
"path": "typescript",
},
{
"path": "solidity",
},
]
}
4 changes: 4 additions & 0 deletions solidity/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ docs/

# Dotenv file
.env

# Private keys
*.key
*.keys
6 changes: 5 additions & 1 deletion solidity/.solhint.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"extends": "solhint:default"
"extends": "solhint:default",
"rules": {
"ordering": "warn",
"private-vars-leading-underscore": ["warn", { "strict": false }]
}
}
13 changes: 0 additions & 13 deletions solidity/.vscode/settings.json

This file was deleted.

3 changes: 3 additions & 0 deletions solidity/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import config from '../eslint.config.js'

export default [...config, { rules: { 'no-console': 'off' } }]
5 changes: 5 additions & 0 deletions solidity/forge-dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

ls lib/ | \
xargs -I % bash -c \
'cat ./lib/%/package.json | jq -r "@text \"\(.name)@\(.version)\""'
4 changes: 4 additions & 0 deletions solidity/forge-dependencies.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[email protected]
[email protected]
[email protected]
[email protected]
7 changes: 7 additions & 0 deletions solidity/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@
src = "src"
out = "out"
libs = ["lib"]
evm_version="cancun"

gas_reports = ["Adapter"]
remappings = [
"forge-std/=lib/forge-std/src/",
"solidity-rlp/=lib/Solidity-RLP/",
]

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
1 change: 1 addition & 0 deletions solidity/lib/openzeppelin-contracts-upgradeable
15 changes: 11 additions & 4 deletions solidity/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
{
"name": "@pnetwork/contracts",
"version": "1.0.0",
"type": "module",
"description": "pNetwork v4 contracts",
"directories": {
"lib": "lib",
"test": "test"
},
"scripts": {
"test": "yarn test:forge",
"test:forge": "forge test",
"lint": "solhint contracts/**/*.sol",
"prettier": "prettier --write ./src ./test"
"build": "forge build",
"test": "forge test",
"lint": "npx solhint src/**/*.sol",
"prettier": "prettier --write ./src ./test",
"coverage": "forge coverage --report summary"
},
"devDependencies": {
"@pnetwork/event-attestator": "*",
"commander": "^12.1.0",
"ramda": "^0.30.1"
},
"author": "gitmp01",
"license": "MIT"
Expand Down
1 change: 0 additions & 1 deletion solidity/remappings.txt

This file was deleted.

Loading

0 comments on commit dbd782a

Please sign in to comment.