Skip to content

Commit

Permalink
Merge pull request #26 from EresDevOrg/development
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4007 authored Jun 27, 2024
2 parents 30022f4 + 30eb11a commit 1d963bc
Show file tree
Hide file tree
Showing 17 changed files with 19,100 additions and 12,273 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/jest-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ jobs:
- name: Install dependencies
run: yarn install

- name: Setup tests
run: yarn pretest

- name: Build & Run test suite
run: |
yarn test | tee ./coverage.txt && exit ${PIPESTATUS[0]}
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This packages leverages [Chainlist's](https://github.com/DefiLlama/chainlist) ne
- Can re-test the cached RPCs by calling `handler.getFastestRpcProvider()`
- Can be used in both the browser and Node.js
- Fully configurable and extendable
- Only uses endpoints which Chainlist report as tracking _no_ data (see [`extraRpcs.js`](https://github.com/DefiLlama/chainlist/blob/main/constants/extraRpcs.js))
- Uses endpoints from Chainlist (see [`extraRpcs.js`](https://github.com/DefiLlama/chainlist/blob/main/constants/extraRpcs.js))

## Installation

Expand All @@ -33,6 +33,7 @@ export function useHandler(networkId: number) {
networkName: null, // the name will be deduced from the networkId, unless using a custom network
networkRpcs: null, // same as networkName, but for injecting additional RPCs
runtimeRpcs: null, // same as networkRpcs, although these are considered error-free
tracking: "yes", // accepted values: "yes" | "limited" | "none"
};
// No RPCs are tested at this point
return new RPCHandler(config);
Expand All @@ -51,7 +52,7 @@ app.provider = await handler.getFastestRpcProvider();

- The RPCs are not tested on instantiation, but are tested on each call to `handler.getFastestRpcProvider()` or `handler.testRpcPerformance()`

- See the full [config](src\handler.ts) object (optionally passed in the constructor) for more options
- See the full [config](types/handler.ts) object (optionally passed in the constructor) for more options

- Local storage is not enabled by default, but can be enabled by passing `autoStorage: true` in the config object

Expand Down
3 changes: 1 addition & 2 deletions build/dynamic-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ export async function createDynamicTypes() {
}

if (rpc && rpc.length > 0) {
const rpcs = rpc.filter((rpc: { url: string }) => rpc.url);
extraRpcs[chainId] = rpcs.map((rpc: { url: string }) => rpc.url);
extraRpcs[chainId] = rpc;
}

idToNativeCurrency[chainId] = nativeCurrency;
Expand Down
63 changes: 0 additions & 63 deletions build/esbuild-build-tests.ts

This file was deleted.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
"postinstall": "git submodule update --init --recursive",
"build": "run-s clean build:types",
"build:types": "tsx build/esbuild-build.ts && tsc --emitDeclarationOnly --declaration --outDir dist",
"build:tests": "tsx build/esbuild-build-tests.ts && tsc --emitDeclarationOnly --declaration --project tsconfig.tests.json",
"postbuild": "rm -rf dist/src",
"pretest": "run-s clean build:tests",
"test": "jest",
"clean": "rm -rf dist"
},
Expand Down Expand Up @@ -89,4 +87,4 @@
]
},
"packageManager": "yarn@4.2.2"
}
}
4 changes: 3 additions & 1 deletion tests/benchmark.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { JsonRpcProvider } from "@ethersproject/providers";
import { RPCHandler, HandlerConstructorConfig } from "../dist";
import { RPCHandler } from "../types/rpc-handler";
import { HandlerConstructorConfig } from "../types/handler";

export const testConfig: HandlerConstructorConfig = {
networkId: "1",
Expand All @@ -9,6 +10,7 @@ export const testConfig: HandlerConstructorConfig = {
networkRpcs: null,
rpcTimeout: 1500,
runtimeRpcs: null,
tracking: "yes",
};

describe("RPCHandler", () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/env.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RPCHandler } from "../dist";
import { RPCHandler } from "../types/rpc-handler";
import { testConfig } from "./rpc-handler.test";

describe("Browser env detection", () => {
Expand Down
64 changes: 0 additions & 64 deletions tests/mocks/handler.ts

This file was deleted.

171 changes: 0 additions & 171 deletions tests/mocks/rpc-handler.ts

This file was deleted.

Loading

1 comment on commit 1d963bc

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines Statements Branches Functions
Coverage: 71%
72.19% (148/205) 52.77% (38/72) 70.83% (34/48)

JUnit

Tests Skipped Failures Errors Time
38 0 💤 0 ❌ 0 🔥 16.112s ⏱️
Coverage Report (71%)
File% Stmts% Branch% Funcs% LinesUncovered Line #s
All files72.1952.7770.8371.87 
src/services60.2943.3378.9460.31 
   rpc-service.ts79.4857.1492.378.9442, 77–90
   storage-service.ts34.4831.2550325–30, 35, 41
types78.159.5265.5177.51 
   constants.ts10010085.71100 
   dynamic.ts100100100100 
   handler.ts85.715010085.7180
   rpc-handler.ts68.1352.945568.8834, 36, 47, 61–62, 71, 78–79, 83, 91, 97–107, 115–123, 131–135, 162, 166, 170, 182–184, 197

Please sign in to comment.