@asyncswap/eth-rpc 0.4.11 → 0.4.13

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/dist/base.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ import { JsonRpcClient } from "@asyncswap/jsonrpc";
2
+ export type RpcMethodSpec = {
3
+ params: readonly unknown[];
4
+ result: unknown;
5
+ };
6
+ export type RpcSpecBase = Record<string, RpcMethodSpec>;
7
+ export declare abstract class BaseClient<MethodsSpec extends RpcSpecBase> {
8
+ rpc: JsonRpcClient<MethodsSpec>;
9
+ protected headers: Record<string, string>;
10
+ constructor(url: string);
11
+ setHeaders(headers: Record<string, string>): this;
12
+ }
13
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,MAAM,aAAa,GAAG;IAC3B,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC;IAC3B,MAAM,EAAE,OAAO,CAAC;CAChB,CAAC;AACF,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAExD,8BAAsB,UAAU,CAAC,WAAW,SAAS,WAAW;IAC/D,GAAG,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IAChC,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM;gBAEnC,GAAG,EAAE,MAAM;IA8BvB,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAM1C"}
package/dist/base.js ADDED
@@ -0,0 +1,36 @@
1
+ import { JsonRpcClient } from "@asyncswap/jsonrpc";
2
+ export class BaseClient {
3
+ rpc;
4
+ headers = {};
5
+ constructor(url) {
6
+ this.rpc = new JsonRpcClient(url);
7
+ return new Proxy(this, {
8
+ get: (target, prop, receiver) => {
9
+ // let real properties / methods through
10
+ if (prop in target) {
11
+ const value = Reflect.get(target, prop, receiver);
12
+ if (typeof value === "function") {
13
+ return (...args) => {
14
+ const result = value.apply(target, args);
15
+ // if method returns target, return proxy instead
16
+ return result === target ? receiver : result;
17
+ };
18
+ }
19
+ return value;
20
+ }
21
+ // dynamic rpc
22
+ if (typeof prop !== "string")
23
+ return undefined;
24
+ const method = prop;
25
+ return (...params) => this.rpc.call(this.rpc.buildRequest(method, params), this.headers);
26
+ },
27
+ });
28
+ }
29
+ setHeaders(headers) {
30
+ this.headers = {
31
+ ...headers,
32
+ };
33
+ return this;
34
+ }
35
+ }
36
+ //# sourceMappingURL=base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAQnD,MAAM,OAAgB,UAAU;IAC/B,GAAG,CAA6B;IACtB,OAAO,GAA2B,EAAE,CAAC;IAE/C,YAAY,GAAW;QACtB,IAAI,CAAC,GAAG,GAAG,IAAI,aAAa,CAAC,GAAG,CAAC,CAAC;QAElC,OAAO,IAAI,KAAK,CAAC,IAAI,EAAE;YACtB,GAAG,EAAE,CAAC,MAAY,EAAE,IAAqB,EAAE,QAAQ,EAAE,EAAE;gBACtD,wCAAwC;gBACxC,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;oBACpB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;oBAClD,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;wBACjC,OAAO,CAAC,GAAG,IAAW,EAAE,EAAE;4BACzB,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;4BACzC,iDAAiD;4BACjD,OAAO,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;wBAC9C,CAAC,CAAC;oBACH,CAAC;oBACD,OAAO,KAAK,CAAC;gBACd,CAAC;gBACD,cAAc;gBACd,IAAI,OAAO,IAAI,KAAK,QAAQ;oBAAE,OAAO,SAAS,CAAC;gBAE/C,MAAM,MAAM,GAAG,IAAyB,CAAC;gBAEzC,OAAO,CACN,GAAG,MAA4C,EACR,EAAE,CACzC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YACrE,CAAC;SACD,CAAC,CAAC;IACJ,CAAC;IAED,UAAU,CAAC,OAA+B;QACzC,IAAI,CAAC,OAAO,GAAG;YACd,GAAG,OAAO;SACV,CAAC;QACF,OAAO,IAAI,CAAC;IACb,CAAC;CACD"}
@@ -0,0 +1,13 @@
1
+ import { BaseClient } from "./base";
2
+ export declare class EngineExecutionClient extends BaseClient<EngineMethodsSpec> {
3
+ constructor(url: string, jwt_token: string);
4
+ }
5
+ export type EngineRpcMethods<T extends Record<string, {
6
+ params: unknown[];
7
+ result: unknown;
8
+ }>> = {
9
+ [K in keyof T]: (...params: T[K]["params"]) => Promise<T[K]["result"]>;
10
+ };
11
+ export interface EngineExecutionClient extends EngineRpcMethods<EngineMethodsSpec> {
12
+ }
13
+ //# sourceMappingURL=engine-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine-api.d.ts","sourceRoot":"","sources":["../src/engine-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,qBAAa,qBAAsB,SAAQ,UAAU,CAAC,iBAAiB,CAAC;gBAC3D,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;CAM1C;AAED,MAAM,MAAM,gBAAgB,CAC3B,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE;IAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC,IAC7D;KACD,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;CACtE,CAAC;AAEH,MAAM,WAAW,qBAChB,SAAQ,gBAAgB,CAAC,iBAAiB,CAAC;CAAI"}
@@ -0,0 +1,10 @@
1
+ import { BaseClient } from "./base";
2
+ export class EngineExecutionClient extends BaseClient {
3
+ constructor(url, jwt_token) {
4
+ super(url);
5
+ this.headers = {
6
+ Authorization: `Bearer ${jwt_token}`,
7
+ };
8
+ }
9
+ }
10
+ //# sourceMappingURL=engine-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine-api.js","sourceRoot":"","sources":["../src/engine-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,MAAM,OAAO,qBAAsB,SAAQ,UAA6B;IACvE,YAAY,GAAW,EAAE,SAAiB;QACzC,KAAK,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,OAAO,GAAG;YACd,aAAa,EAAE,UAAU,SAAS,EAAE;SACpC,CAAC;IACH,CAAC;CACD"}
@@ -0,0 +1,13 @@
1
+ import { BaseClient } from "@asyncswap/jsonrpc";
2
+ export declare class ExecutionClient extends BaseClient<EthMethodsSpec> {
3
+ constructor(url: string);
4
+ }
5
+ export type EthRpcMethods<MethodsSpec extends Record<string, {
6
+ params: readonly unknown[];
7
+ result: unknown;
8
+ }>> = {
9
+ [Method in keyof MethodsSpec]: (...params: MethodsSpec[Method]["params"]) => Promise<MethodsSpec[Method]["result"]>;
10
+ };
11
+ export interface ExecutionClient extends EthRpcMethods<EthMethodsSpec> {
12
+ }
13
+ //# sourceMappingURL=eth-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eth-api.d.ts","sourceRoot":"","sources":["../src/eth-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,qBAAa,eAAgB,SAAQ,UAAU,CAAC,cAAc,CAAC;gBAClD,GAAG,EAAE,MAAM;CAGvB;AAED,MAAM,MAAM,aAAa,CACxB,WAAW,SAAS,MAAM,CACzB,MAAM,EACN;IAAE,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAC/C,IACE;KACD,MAAM,IAAI,MAAM,WAAW,GAAG,CAC9B,GAAG,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,KACpC,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC;CAC3C,CAAC;AAEH,MAAM,WAAW,eAAgB,SAAQ,aAAa,CAAC,cAAc,CAAC;CAAI"}
@@ -0,0 +1,7 @@
1
+ import { BaseClient } from "@asyncswap/jsonrpc";
2
+ export class ExecutionClient extends BaseClient {
3
+ constructor(url) {
4
+ super(url);
5
+ }
6
+ }
7
+ //# sourceMappingURL=eth-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eth-api.js","sourceRoot":"","sources":["../src/eth-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,MAAM,OAAO,eAAgB,SAAQ,UAA0B;IAC9D,YAAY,GAAW;QACtB,KAAK,CAAC,GAAG,CAAC,CAAC;IACZ,CAAC;CACD"}
@@ -0,0 +1,2 @@
1
+ export * from "./eth-api";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./eth-api";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { BaseClient } from "./base";
2
+ export declare class FlashbotsClient extends BaseClient<FlashbotsMethodsSpec> {
3
+ constructor(url: string);
4
+ }
5
+ export type FlashbotsRpcMethods<T extends Record<string, {
6
+ params: unknown[];
7
+ result: unknown;
8
+ }>> = {
9
+ [M in keyof T]: (...params: T[M]["params"]) => Promise<T[M]["result"]>;
10
+ };
11
+ export interface FlashbotsClient extends FlashbotsRpcMethods<FlashbotsMethodsSpec> {
12
+ }
13
+ //# sourceMappingURL=mev-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mev-api.d.ts","sourceRoot":"","sources":["../src/mev-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,qBAAa,eAAgB,SAAQ,UAAU,CAAC,oBAAoB,CAAC;gBACxD,GAAG,EAAE,MAAM;CAKvB;AAED,MAAM,MAAM,mBAAmB,CAC9B,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE;IAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC,IAC7D;KACD,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;CACtE,CAAC;AACH,MAAM,WAAW,eAChB,SAAQ,mBAAmB,CAAC,oBAAoB,CAAC;CAAI"}
@@ -0,0 +1,7 @@
1
+ import { BaseClient } from "./base";
2
+ export class FlashbotsClient extends BaseClient {
3
+ constructor(url) {
4
+ super(url);
5
+ }
6
+ }
7
+ //# sourceMappingURL=mev-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mev-api.js","sourceRoot":"","sources":["../src/mev-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,MAAM,OAAO,eAAgB,SAAQ,UAAgC;IACpE,YAAY,GAAW;QACtB,KAAK,CAAC,GAAG,CAAC,CAAC;IACZ,CAAC;CAGD"}
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.11",
5
+ "version": "0.4.13",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
8
  "main": "dist/index.js",
@@ -15,6 +15,10 @@
15
15
  "engine-api",
16
16
  "execution-apis"
17
17
  ],
18
+ "files": [
19
+ "dist",
20
+ "src"
21
+ ],
18
22
  "homepage": "https://github.com/asyncswap/eth-libs/tree/main/packages/eth-rpc",
19
23
  "repository": {
20
24
  "type": "git",
@@ -40,6 +44,6 @@
40
44
  "typescript": "^5"
41
45
  },
42
46
  "dependencies": {
43
- "@asyncswap/jsonrpc": "^0.4.10"
47
+ "@asyncswap/jsonrpc": "^0.4.12"
44
48
  }
45
49
  }
package/CHANGELOG.md DELETED
@@ -1,169 +0,0 @@
1
- # @asyncswap/eth-rpc
2
-
3
- ## 0.4.11
4
-
5
- ### Patch Changes
6
-
7
- - 69a2d7e: patch types updates
8
- - Updated dependencies [69a2d7e]
9
- - @asyncswap/jsonrpc@0.4.10
10
-
11
- ## 0.4.10
12
-
13
- ### Patch Changes
14
-
15
- - dc792b1: (refactor): change to `withHeaders` option and update BaseClient source
16
- - Updated dependencies [dc792b1]
17
- - @asyncswap/jsonrpc@0.4.9
18
-
19
- ## 0.4.9
20
-
21
- ### Patch Changes
22
-
23
- - e9fc1df: remove biome dep
24
- - Updated dependencies [e9fc1df]
25
- - @asyncswap/jsonrpc@0.4.8
26
-
27
- ## 0.4.8
28
-
29
- ### Patch Changes
30
-
31
- - cad9042: minimal eth rpc client
32
-
33
- - ported engine api to different package
34
-
35
- ## 0.4.7
36
-
37
- ### Patch Changes
38
-
39
- - ff4e035: fix base client proxy
40
-
41
- ```ts
42
- setHeaders(...) {
43
- this.headers = ...
44
- return this; // ❌ returns the *target*
45
- }
46
- ```
47
-
48
- The correct fix: return the receiver / proxy, not this
49
-
50
- You already have access to the proxy inside the get trap via receiver.
51
-
52
- So you must bind methods so that they return the proxy.
53
-
54
- - setHeaders() mutates the target
55
- - returns receiver (the proxy)
56
- - chaining continues in proxy-land
57
- - RPC methods remain visible
58
-
59
- ## 0.4.6
60
-
61
- ### Patch Changes
62
-
63
- - 3d6ec6e: add clinet version spec
64
-
65
- ## 0.4.5
66
-
67
- ### Patch Changes
68
-
69
- - 0d1be5d: upgrade with parameter typing
70
- - Updated dependencies [882f94f]
71
- - @asyncswap/jsonrpc@0.4.7
72
-
73
- ## 0.4.4
74
-
75
- ### Patch Changes
76
-
77
- - b2b631f: deprecated `EthExecutionClien` use `ExecutionClient`
78
- - Updated dependencies [f7d28d9]
79
- - @asyncswap/jsonrpc@0.4.4
80
-
81
- ## 0.4.3
82
-
83
- ### Patch Changes
84
-
85
- - 7ae86a0: new refactor on methods as data
86
- - Updated dependencies [40a79dc]
87
- - @asyncswap/jsonrpc@0.4.3
88
-
89
- ## 0.4.2
90
-
91
- ### Patch Changes
92
-
93
- - 9512db5: update documentation
94
- - Updated dependencies [9512db5]
95
- - @asyncswap/jsonrpc@0.4.2
96
-
97
- ## 0.4.1
98
-
99
- ### Patch Changes
100
-
101
- - 2598f09: updates docs
102
-
103
- ## 0.4.0
104
-
105
- ### Minor Changes
106
-
107
- - fd79ea3: updates api for eth-client and adds flasbots methods and headers
108
-
109
- ### Patch Changes
110
-
111
- - Updated dependencies [43de065]
112
- - Updated dependencies [7e8300c]
113
- - Updated dependencies [7126afa]
114
- - @asyncswap/jsonrpc@0.5.0
115
-
116
- ## 0.3.0
117
-
118
- ### Minor Changes
119
-
120
- - d2562a2: implemented execution apis methods
121
-
122
- eth/transation
123
-
124
- - eth_getTransactionByHash
125
- - eth_getTransactionByBlockHashAndIndex
126
- - eth_getTransactionReceipt
127
-
128
- eth/submit
129
-
130
- - eth_sendTransaction
131
- - eth_sendRawTransaction
132
-
133
- eth/state
134
-
135
- - eth_getBalance
136
- - eth_getStorageAt
137
- - eth_getTransactionCount
138
- - eth_getCode
139
- - eth_getProof
140
-
141
- eth/sign
142
-
143
- - eth_sign
144
- - eth_signTransaction
145
-
146
- eth/filter
147
-
148
- - eth_newFilter
149
- - eth_newBlockFilter
150
- - eth_newPendingTransactionFilter
151
- - eth_uninstallFilter
152
- - eth_getFilterChanges
153
- - eth_getFilterLogs
154
- - eth_getLogs
155
-
156
- - dc1718c: refactor of types dir to global types
157
-
158
- ### Patch Changes
159
-
160
- - e3ac747: patch
161
- - a9d1a29: add biome formatting
162
- - Updated dependencies [dc1718c]
163
- - Updated dependencies [e15733c]
164
- - Updated dependencies [e3ac747]
165
- - Updated dependencies [abddcdc]
166
- - Updated dependencies [00ba692]
167
- - Updated dependencies [07dc4e5]
168
- - Updated dependencies [ded3e6b]
169
- - @asyncswap/jsonrpc@0.3.0
package/example.ts DELETED
@@ -1,10 +0,0 @@
1
- import { ExecutionClient } from "./src";
2
-
3
- const url = "http://localhost:8545";
4
- const eth = new ExecutionClient(url);
5
- const balance = await eth.eth_getBalance(
6
- "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
7
- "latest",
8
- );
9
- console.log("Balance:", balance);
10
- eth.eth_getTransactionCount("0x34", "safe");
package/tsconfig.json DELETED
@@ -1,33 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- // Environment setup & latest features
4
- "lib": ["ESNext"],
5
- "target": "ESNext",
6
- "module": "Preserve",
7
- "moduleDetection": "force",
8
- "jsx": "react-jsx",
9
- "allowJs": true,
10
- // Bundler mode
11
- "sourceMap": true,
12
- "declaration": true,
13
- "declarationMap": true,
14
- "moduleResolution": "bundler",
15
- "outDir": "dist",
16
- "rootDir": "src",
17
- "allowImportingTsExtensions": false,
18
- "verbatimModuleSyntax": true,
19
- "noEmit": false,
20
- // Best practices
21
- "strict": true,
22
- "skipLibCheck": true,
23
- "noFallthroughCasesInSwitch": true,
24
- "noUncheckedIndexedAccess": true,
25
- "noImplicitOverride": true,
26
- // Some stricter flags (disabled by default)
27
- "noUnusedLocals": false,
28
- "noUnusedParameters": false,
29
- "noPropertyAccessFromIndexSignature": false
30
- },
31
- "include": ["src/**/*", "global.d.ts"],
32
- "exclude": ["example.ts"]
33
- }