Skip to content

Commit

Permalink
feat: Web3 RPC Handler (npm package) (#1) (#4)
Browse files Browse the repository at this point in the history
* feat: web3 rpc handler npm package

* feat: web3 rpc handler npm package

* chore: configurable, add kebab, remove dist

* chore: readme

* chore: add workflow scripts

* chore: remove build workflow

* Delete .github/workflows/scripts/kebabalize.sh

This is destructive and renames files so lets not use it.

* chore: improved race, tests and readme, removed ubq rpcs

* chore: script permission

* chore: type the constants remove bad else

* fix: type out path to src

* chore: type the promises, add ts config and jest workflow

* chore: final touch ups

* chore: export all from index

* fix: readme

* Update package.json

* Update README.md

---------

Co-authored-by: Keyrxng <[email protected]>
Co-authored-by: アレクサンダー.eth <[email protected]>
  • Loading branch information
3 people committed Mar 14, 2024
1 parent 3ef38df commit 0d964b0
Show file tree
Hide file tree
Showing 39 changed files with 3,813 additions and 289 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@babel/preset-env", "@babel/preset-typescript"]
}
5 changes: 3 additions & 2 deletions .cspell.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
"version": "0.2",
"ignorePaths": ["**/*.json", "**/*.css", "node_modules", "**/*.log"],
"ignorePaths": ["**/*.json", "**/*.css", "node_modules", "**/*.log", "lib", "dist"],
"useGitignore": true,
"language": "en",
"words": ["dataurl", "devpool", "outdir", "servedir"],
"dictionaries": ["typescript", "node", "software-terms"],
"import": ["@cspell/dict-typescript/cspell-ext.json", "@cspell/dict-node/cspell-ext.json", "@cspell/dict-software-terms"],
"ignoreRegExpList": ["[0-9a-fA-F]{6}"]
"ignoreRegExpList": ["[0-9a-fA-F]{6}"],
"ignoreWords": ["Rpcs", "ethersproject", "publicnode", "WXDAI", "XDAI", "chainlist", "Knip"]
}
1 change: 0 additions & 1 deletion .env.example

This file was deleted.

155 changes: 136 additions & 19 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,55 @@
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": ["./tsconfig.json"]
"project": [
"./tsconfig.json"
]
},
"plugins": ["@typescript-eslint", "sonarjs"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:sonarjs/recommended"],
"ignorePatterns": ["**/*.js"],
"plugins": [
"@typescript-eslint",
"sonarjs"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:sonarjs/recommended"
],
"ignorePatterns": [
"**/*.js",
"**/*.d.ts",
"**/*.test.ts",
"**/*-test.ts",
"jest.config.ts",
"knip.ts",
"build",
"./lib",
"./dist"
],
"rules": {
"prefer-arrow-callback": ["warn", { "allowNamedFunctions": true }],
"func-style": ["warn", "declaration", { "allowArrowFunctions": false }],
"prefer-arrow-callback": [
"warn",
{
"allowNamedFunctions": true
}
],
"func-style": [
"warn",
"declaration",
{
"allowArrowFunctions": false
}
],
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-non-null-assertion": "error",
"constructor-super": "error",
"no-invalid-this": "off",
"@typescript-eslint/no-invalid-this": ["error"],
"no-restricted-syntax": ["error", "ForInStatement"],
"@typescript-eslint/no-invalid-this": [
"error"
],
"no-restricted-syntax": [
"error",
"ForInStatement"
],
"use-isnan": "error",
"@typescript-eslint/no-unused-vars": [
"error",
Expand All @@ -38,16 +73,98 @@
"sonarjs/no-identical-expressions": "error",
"@typescript-eslint/naming-convention": [
"error",
{ "selector": "interface", "format": ["PascalCase"], "custom": { "regex": "^I[A-Z]", "match": false } },
{ "selector": "memberLike", "modifiers": ["private"], "format": ["camelCase"], "leadingUnderscore": "require" },
{ "selector": "typeLike", "format": ["PascalCase"] },
{ "selector": "typeParameter", "format": ["PascalCase"], "prefix": ["T"] },
{ "selector": "variable", "format": ["camelCase", "UPPER_CASE"], "leadingUnderscore": "allow", "trailingUnderscore": "allow" },
{ "selector": "variable", "format": ["camelCase"], "leadingUnderscore": "allow", "trailingUnderscore": "allow" },
{ "selector": "variable", "modifiers": ["destructured"], "format": null },
{ "selector": "variable", "types": ["boolean"], "format": ["PascalCase"], "prefix": ["is", "should", "has", "can", "did", "will", "does"] },
{ "selector": "variableLike", "format": ["camelCase"] },
{ "selector": ["function", "variable"], "format": ["camelCase"] }
{
"selector": "interface",
"format": [
"PascalCase"
],
"custom": {
"regex": "^I[A-Z]",
"match": false
}
},
{
"selector": "memberLike",
"modifiers": [
"private"
],
"format": [
"camelCase"
],
"leadingUnderscore": "require"
},
{
"selector": "typeLike",
"format": [
"PascalCase"
]
},
{
"selector": "typeParameter",
"format": [
"PascalCase"
],
"prefix": [
"T"
]
},
{
"selector": "variable",
"format": [
"camelCase",
"UPPER_CASE"
],
"leadingUnderscore": "allow",
"trailingUnderscore": "allow"
},
{
"selector": "variable",
"format": [
"camelCase"
],
"leadingUnderscore": "allow",
"trailingUnderscore": "allow"
},
{
"selector": "variable",
"modifiers": [
"destructured"
],
"format": null
},
{
"selector": "variable",
"types": [
"boolean"
],
"format": [
"PascalCase"
],
"prefix": [
"is",
"should",
"has",
"can",
"did",
"will",
"does"
]
},
{
"selector": "variableLike",
"format": [
"camelCase"
]
},
{
"selector": [
"function",
"variable"
],
"format": [
"camelCase"
]
}
]
}
}
}
42 changes: 0 additions & 42 deletions .github/workflows/build.yml

This file was deleted.

33 changes: 33 additions & 0 deletions .github/workflows/jest-testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Run Jest testing suite
on:
workflow_dispatch:
pull_request_target:
types: [opened, synchronize]

env:
NODE_ENV: "test"

jobs:
testing:
permissions: write-all
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v4
with:
node-version: "20.10.0"
- uses: actions/checkout@master
with:
fetch-depth: 0
- name: Build & Run test suite
run: |
yarn && yarn build
yarn test | tee ./coverage.txt && exit ${PIPESTATUS[0]}
- name: Jest Coverage Comment
# Ensures this step is run even on previous step failure (e.g. test failed)
if: always()
uses: MishaKav/jest-coverage-comment@main
with:
coverage-summary-path: coverage/coverage-summary.json
junitxml-path: junit.xml
junitxml-title: JUnit
coverage-path: ./coverage.txt
15 changes: 15 additions & 0 deletions .github/workflows/kebab-case.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Enforce kebab-case

on:
push:
pull_request:

jobs:
check-filenames:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4

- name: Check For Non Kebab-Cased TypeScript Files
run: .github/workflows/scripts/kebab-case.sh
2 changes: 1 addition & 1 deletion .github/workflows/knip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ jobs:
comment_id: ${{ github.workflow }}-reporter
command_script_name: knip-ci
annotations: true
ignore_results: false
ignore_results: false
30 changes: 30 additions & 0 deletions .github/workflows/scripts/kebab-case.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
non_compliant_files=()
ignoreList=("^\.\/.git" "^\.\/\..*" "^\.\/[^\/]*$")
ignoreList+=("^\.\/node_modules")
while IFS= read -r line; do
ignoreList+=(".*$line")
done < .gitignore
while read -r file; do
basefile=$(basename "$file")
ignoreFile=false
for pattern in "${ignoreList[@]}"; do
if [[ "$file" =~ $pattern ]]; then
ignoreFile=true
break
fi
done
if $ignoreFile; then
continue
elif ! echo "$basefile" | grep -q -E "^([a-z0-9]+-)*[a-z0-9]+(\.[a-zA-Z0-9]+)?$|^([a-z0-9]+_)*[a-z0-9]+(\.[a-zA-Z0-9]+)?$"; then
non_compliant_files+=("$file")
echo "::warning file=$file::This file is not in kebab-case or snake_case"
fi
done < <(find . -type f -name '*.ts' -print | grep -E '/[a-z]+[a-zA-Z]*\.ts$')
if [ ${#non_compliant_files[@]} -ne 0 ]; then
echo "The following files are not in kebab-case or snake_case:"
for file in "${non_compliant_files[@]}"; do
echo " - $file"
done
exit 1
fi
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ node_modules
.pnp.cjs
.pnp.loader.mjs
.env
static/dist
dist

coverage
junit.xml
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "lib/chainlist"]
path = lib/chainlist
url = https://github.com/DefiLlama/chainlist.git
Loading

0 comments on commit 0d964b0

Please sign in to comment.