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

Add tests contracts + event attestator simulator #1

Merged
merged 29 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
28b9a7b
forge install: openzeppelin-contracts-upgradeable
gitmp01 Jun 14, 2024
40562a8
chore(solidity): include `remappings.txt` in toml file
gitmp01 Jun 14, 2024
a2a3b85
chore(foundry): add script to print deps versions
gitmp01 Jun 14, 2024
44e4aac
fix(vscode): config
gitmp01 Jun 16, 2024
534aa59
chore(solidity): add Adapter test
gitmp01 Jun 16, 2024
c6e18b6
chore: start settle()
gitmp01 Jun 18, 2024
0bf7fae
fix(solidity): replace xerc20 w/ erc20 bytes in `Operation`
gitmp01 Jun 18, 2024
f2a6316
chore(.prettierrc): set `semi` to `false`
gitmp01 Jun 18, 2024
abdb421
chore(event-attestator): add code
gitmp01 Jun 18, 2024
64cc212
chore(.vscode): change `organizeImports` to `explicit`
gitmp01 Jun 18, 2024
eb9cd75
chore(contracts): add 2e2 test for `settle()`
gitmp01 Jun 18, 2024
54222f6
chore(test): print public key add address
gitmp01 Jun 19, 2024
fb9e95a
fix(event-attestator): apply linting + fix event id
gitmp01 Jun 19, 2024
45898e1
chore(.vscode): add eslint config
gitmp01 Jun 19, 2024
22517a2
chore(solidity): add pegout test
gitmp01 Jun 21, 2024
f537b91
fix(event-attestator): add blockhash + txhash
gitmp01 Jun 21, 2024
61f56d3
chore: setup eslint
gitmp01 Jun 21, 2024
2a84c64
chore(event-attestator): add jest support with ts
gitmp01 Jun 21, 2024
e1ae61f
chore: update `yarn` to v4
gitmp01 Jun 21, 2024
63a2739
fix(solidity): lint errors
gitmp01 Jun 21, 2024
dbdb448
chore: add ci workflow
gitmp01 Jun 21, 2024
392a402
fix(package.json): add `solhint`
gitmp01 Jun 21, 2024
8c0f6bc
chore(solidity): save forge deps versions
gitmp01 Jun 21, 2024
4c118c1
chore(solidity): use MIT
gitmp01 Jun 21, 2024
c7eb07d
chore(solidity): add new linting rules
gitmp01 Jun 21, 2024
261e3d4
fix(XERC20): let anyone set the fee manager for the first time
gitmp01 Jun 21, 2024
7e190e8
fix(XERC20): revert UNLICENSED license
gitmp01 Jun 21, 2024
61da008
chore(tools): move attestator script here
gitmp01 Jun 21, 2024
7bbbde3
fix(eslint): rm comment
gitmp01 Jun 21, 2024
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
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
Loading