@asyncswap/eth-rpc 0.4.8 → 0.4.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @asyncswap/eth-rpc
2
2
 
3
+ ## 0.4.10
4
+
5
+ ### Patch Changes
6
+
7
+ - dc792b1: (refactor): change to `withHeaders` option and update BaseClient source
8
+ - Updated dependencies [dc792b1]
9
+ - @asyncswap/jsonrpc@0.4.9
10
+
11
+ ## 0.4.9
12
+
13
+ ### Patch Changes
14
+
15
+ - e9fc1df: remove biome dep
16
+ - Updated dependencies [e9fc1df]
17
+ - @asyncswap/jsonrpc@0.4.8
18
+
3
19
  ## 0.4.8
4
20
 
5
21
  ### Patch Changes
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@asyncswap/eth-rpc",
3
3
  "description": "A library for ethereum execution clients apis.",
4
4
  "author": "Meek Msaki",
5
- "version": "0.4.8",
5
+ "version": "0.4.10",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
8
  "main": "dist/index.js",
@@ -34,13 +34,12 @@
34
34
  "format": "bun biome format --write"
35
35
  },
36
36
  "devDependencies": {
37
- "@biomejs/biome": "2.3.11",
38
37
  "@types/bun": "latest"
39
38
  },
40
39
  "peerDependencies": {
41
40
  "typescript": "^5"
42
41
  },
43
42
  "dependencies": {
44
- "@asyncswap/jsonrpc": "^0.4.7"
43
+ "@asyncswap/jsonrpc": "^0.4.9"
45
44
  }
46
45
  }
package/src/eth-api.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { BaseClient } from "./base";
1
+ import { BaseClient } from "@asyncswap/jsonrpc";
2
2
 
3
3
  export class ExecutionClient extends BaseClient<EthMethodsSpec> {
4
4
  constructor(url: string) {
package/src/index.ts CHANGED
@@ -1,2 +1 @@
1
- export * from "./base";
2
1
  export * from "./eth-api";
package/tsconfig.json CHANGED
@@ -1,9 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  // Environment setup & latest features
4
- "lib": [
5
- "ESNext"
6
- ],
4
+ "lib": ["ESNext"],
7
5
  "target": "ESNext",
8
6
  "module": "Preserve",
9
7
  "moduleDetection": "force",
@@ -30,11 +28,6 @@
30
28
  "noUnusedParameters": false,
31
29
  "noPropertyAccessFromIndexSignature": false
32
30
  },
33
- "include": [
34
- "src/**/*",
35
- "global.d.ts"
36
- ],
37
- "exclude": [
38
- "example.ts"
39
- ]
31
+ "include": ["src/**/*", "global.d.ts"],
32
+ "exclude": ["example.ts"]
40
33
  }
package/src/base.ts DELETED
@@ -1,49 +0,0 @@
1
- import { JsonRpcClient } from "@asyncswap/jsonrpc";
2
-
3
- export type RpcMethodSpec = {
4
- params: readonly unknown[];
5
- result: unknown;
6
- };
7
- export type RpcSpecBase = Record<string, RpcMethodSpec>;
8
-
9
- export abstract class BaseClient<MethodsSpec extends RpcSpecBase> {
10
- rpc: JsonRpcClient<MethodsSpec>;
11
- protected headers: Record<string, string> = {};
12
-
13
- constructor(url: string) {
14
- this.rpc = new JsonRpcClient(url);
15
-
16
- return new Proxy(this, {
17
- get: (target: this, prop: string | symbol, receiver) => {
18
- // let real properties / methods through
19
- if (prop in target) {
20
- const value = Reflect.get(target, prop, receiver);
21
- if (typeof value === "function") {
22
- return (...args: any[]) => {
23
- const result = value.apply(target, args);
24
- // if method returns target, return proxy instead
25
- return result === target ? receiver : result;
26
- };
27
- }
28
- return value;
29
- }
30
- // dynamic rpc
31
- if (typeof prop !== "string") return undefined;
32
-
33
- const method = prop as keyof MethodsSpec;
34
-
35
- return (
36
- ...params: MethodsSpec[typeof method]["params"]
37
- ): MethodsSpec[typeof method]["result"] =>
38
- this.rpc.call(this.rpc.buildRequest(method, params), this.headers);
39
- },
40
- });
41
- }
42
-
43
- setHeaders(headers: Record<string, string>) {
44
- this.headers = {
45
- ...headers,
46
- };
47
- return this;
48
- }
49
- }