Skip to content

Commit

Permalink
feat: improve tooling and workflows (#2)
Browse files Browse the repository at this point in the history
* feat: refactors tooling and adds GitHub workflows
* feat: improves README, removes required proof field from function logic
  • Loading branch information
martines3000 committed Mar 20, 2024
1 parent e30da66 commit f56f380
Show file tree
Hide file tree
Showing 24 changed files with 3,568 additions and 6,267 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
30 changes: 30 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CI
on:
workflow_dispatch:
push:
branches:
- main
- develop
pull_request:
types: [opened, synchronize, reopened]

jobs:
ci:
name: CI
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v3
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Lint
run: pnpm lint
- name: Build
run: pnpm build
- name: Test
run: pnpm test
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
dist
node_modules
node_modules
coverage
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

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

pnpm exec lint-staged
3 changes: 3 additions & 0 deletions .lintstagedrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'*.{js,ts,mts,mjs,cjs,cts,jsx,tsx,json}': ['biome check --apply'],
};
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.11.1
21 changes: 21 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"editor.defaultFormatter": "biomejs.biome",
"typescript.tsdk": "node_modules/typescript/lib",
"json.format.enable": true,
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[javascript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[typescriptreact]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[json]": {
"editor.defaultFormatter": "biomejs.biome"
},
"editor.codeActionsOnSave": {
"source.fixAll": "always",
"source.organizeImports": "never"
}
}
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,23 @@ This package serves to generate a Types object compatible with EIP-712 ( https:/

## Usage

Import `getEthTypesFromInputDoc` into your project and pass in the `message` that you intend to sign using EIP-712, including the `proof` object. This will return an object that can be used as the `types` object passed into `eth_signTypedDatav4`
Import `getEthTypesFromInputDoc` into your project and pass in the `message` that you intend to sign using EIP-712. This will return an object that can be used as the `types` object passed into `eth_signTypedDatav4`

## Developing

Simply run `yarn` to initialize project, then `yarn test` to test.
### Commands

- `pnpm install` - Install dependencies
- `pnpm build` - Build the project
- `pnpm test` - Run tests
- `pnpm lint` - Lint the project
- `pnpm lint:fix` - Fix linting issues

### Tools used

- Node.js
- Pnpm
- TypeScript
- Tsup
- Vitest
- Biome
63 changes: 63 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"$schema": "https://biomejs.dev/schemas/1.6.1/schema.json",
"files": {
"include": [
"**/*.js",
"**/*.ts",
"**/*.jsx",
"**/*.tsx",
"**/*.cjs",
"**/*.cts",
"**/*.mjs",
"**/*.mts",
"**/*.json"
],
"ignore": ["**/node_modules/**", "**/dist/**", "**/coverage/**"]
},
"organizeImports": {
"enabled": false
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"complexity": {
"noStaticOnlyClass": "off",
"noForEach": "off"
},
"style": {
"noNonNullAssertion": "off"
},
"suspicious": {
"noExplicitAny": "off",
"noImplicitAnyLet": "off",
"useValidTypeof": "off"
},
"correctness": {
"useExhaustiveDependencies": "off"
}
}
},
"formatter": {
"enabled": true,
"indentStyle": "tab"
},
"javascript": {
"formatter": {
"indentStyle": "space",
"quoteStyle": "single",
"trailingComma": "es5",
"indentWidth": 2,
"lineEnding": "lf",
"semicolons": "always"
}
},
"json": {
"formatter": {
"enabled": true,
"indentWidth": 2,
"indentStyle": "space",
"lineEnding": "lf"
}
}
}
1 change: 1 addition & 0 deletions commitlint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { extends: ['@commitlint/config-conventional'] };
16 changes: 0 additions & 16 deletions jest.config.js

This file was deleted.

50 changes: 39 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,51 @@
{
"name": "eip-712-types-generation",
"version": "0.1.3",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"author": "Nick Reynolds",
"license": "MIT",
"private": false,
"devDependencies": {
"@types/jest": "27.0.2",
"jest": "27.2.5",
"jest-extended": "^0.11.5",
"ts-jest": "27.0.5",
"typescript": "4.4.3"
},
"type": "module",
"main": "./dist/index.js",
"module": "./dist/index.js",
"source": "./src/index.ts",
"types": "./dist/index.d.ts",
"files": ["dist/**", "README.md", "package.json", "CHANGELOG.md"],
"scripts": {
"build": "tsc",
"test": "jest"
"build": "pnpm clean && pnpm compile",
"clean": "rimraf dist",
"compile": "tsup",
"lint": "biome check .",
"lint:fix": "biome check --apply .",
"test": "pnpm cross-env NODE_NO_WARNINGS=1 vitest",
"prepare": "husky"
},
"dependencies": {
"json-canonicalize": "^1.0.4"
},
"devDependencies": {
"@biomejs/biome": "1.6.1",
"@commitlint/cli": "^19.0.3",
"@commitlint/config-conventional": "^19.0.3",
"@types/node": "^20.11.30",
"@vitest/coverage-v8": "1.4.0",
"cross-env": "^7.0.3",
"husky": "^9.0.11",
"lint-staged": "^15.2.2",
"rimraf": "^5.0.5",
"tsup": "^8.0.2",
"typescript": "^5.3.3",
"vite-tsconfig-paths": "^4.3.1",
"vitest": "1.4.0"
},
"packageManager": "[email protected]",
"engines": {
"node": ">=20.11.1"
},
"volta": {
"node": "20.11.1",
"pnpm": "8.15.5"
},
"publishConfig": {
"access": "public"
}
}
Loading

0 comments on commit f56f380

Please sign in to comment.