@asyncswap/eth-rpc 0.4.12 → 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.12",
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.11"
47
+ "@asyncswap/jsonrpc": "^0.4.12"
44
48
  }
45
49
  }
package/CHANGELOG.md DELETED
@@ -1,177 +0,0 @@
1
- # @asyncswap/eth-rpc
2
-
3
- ## 0.4.12
4
-
5
- ### Patch Changes
6
-
7
- - 2f7dece: fixes build
8
- - Updated dependencies [2f7dece]
9
- - @asyncswap/jsonrpc@0.4.11
10
-
11
- ## 0.4.11
12
-
13
- ### Patch Changes
14
-
15
- - 69a2d7e: patch types updates
16
- - Updated dependencies [69a2d7e]
17
- - @asyncswap/jsonrpc@0.4.10
18
-
19
- ## 0.4.10
20
-
21
- ### Patch Changes
22
-
23
- - dc792b1: (refactor): change to `withHeaders` option and update BaseClient source
24
- - Updated dependencies [dc792b1]
25
- - @asyncswap/jsonrpc@0.4.9
26
-
27
- ## 0.4.9
28
-
29
- ### Patch Changes
30
-
31
- - e9fc1df: remove biome dep
32
- - Updated dependencies [e9fc1df]
33
- - @asyncswap/jsonrpc@0.4.8
34
-
35
- ## 0.4.8
36
-
37
- ### Patch Changes
38
-
39
- - cad9042: minimal eth rpc client
40
-
41
- - ported engine api to different package
42
-
43
- ## 0.4.7
44
-
45
- ### Patch Changes
46
-
47
- - ff4e035: fix base client proxy
48
-
49
- ```ts
50
- setHeaders(...) {
51
- this.headers = ...
52
- return this; // ❌ returns the *target*
53
- }
54
- ```
55
-
56
- The correct fix: return the receiver / proxy, not this
57
-
58
- You already have access to the proxy inside the get trap via receiver.
59
-
60
- So you must bind methods so that they return the proxy.
61
-
62
- - setHeaders() mutates the target
63
- - returns receiver (the proxy)
64
- - chaining continues in proxy-land
65
- - RPC methods remain visible
66
-
67
- ## 0.4.6
68
-
69
- ### Patch Changes
70
-
71
- - 3d6ec6e: add clinet version spec
72
-
73
- ## 0.4.5
74
-
75
- ### Patch Changes
76
-
77
- - 0d1be5d: upgrade with parameter typing
78
- - Updated dependencies [882f94f]
79
- - @asyncswap/jsonrpc@0.4.7
80
-
81
- ## 0.4.4
82
-
83
- ### Patch Changes
84
-
85
- - b2b631f: deprecated `EthExecutionClien` use `ExecutionClient`
86
- - Updated dependencies [f7d28d9]
87
- - @asyncswap/jsonrpc@0.4.4
88
-
89
- ## 0.4.3
90
-
91
- ### Patch Changes
92
-
93
- - 7ae86a0: new refactor on methods as data
94
- - Updated dependencies [40a79dc]
95
- - @asyncswap/jsonrpc@0.4.3
96
-
97
- ## 0.4.2
98
-
99
- ### Patch Changes
100
-
101
- - 9512db5: update documentation
102
- - Updated dependencies [9512db5]
103
- - @asyncswap/jsonrpc@0.4.2
104
-
105
- ## 0.4.1
106
-
107
- ### Patch Changes
108
-
109
- - 2598f09: updates docs
110
-
111
- ## 0.4.0
112
-
113
- ### Minor Changes
114
-
115
- - fd79ea3: updates api for eth-client and adds flasbots methods and headers
116
-
117
- ### Patch Changes
118
-
119
- - Updated dependencies [43de065]
120
- - Updated dependencies [7e8300c]
121
- - Updated dependencies [7126afa]
122
- - @asyncswap/jsonrpc@0.5.0
123
-
124
- ## 0.3.0
125
-
126
- ### Minor Changes
127
-
128
- - d2562a2: implemented execution apis methods
129
-
130
- eth/transation
131
-
132
- - eth_getTransactionByHash
133
- - eth_getTransactionByBlockHashAndIndex
134
- - eth_getTransactionReceipt
135
-
136
- eth/submit
137
-
138
- - eth_sendTransaction
139
- - eth_sendRawTransaction
140
-
141
- eth/state
142
-
143
- - eth_getBalance
144
- - eth_getStorageAt
145
- - eth_getTransactionCount
146
- - eth_getCode
147
- - eth_getProof
148
-
149
- eth/sign
150
-
151
- - eth_sign
152
- - eth_signTransaction
153
-
154
- eth/filter
155
-
156
- - eth_newFilter
157
- - eth_newBlockFilter
158
- - eth_newPendingTransactionFilter
159
- - eth_uninstallFilter
160
- - eth_getFilterChanges
161
- - eth_getFilterLogs
162
- - eth_getLogs
163
-
164
- - dc1718c: refactor of types dir to global types
165
-
166
- ### Patch Changes
167
-
168
- - e3ac747: patch
169
- - a9d1a29: add biome formatting
170
- - Updated dependencies [dc1718c]
171
- - Updated dependencies [e15733c]
172
- - Updated dependencies [e3ac747]
173
- - Updated dependencies [abddcdc]
174
- - Updated dependencies [00ba692]
175
- - Updated dependencies [07dc4e5]
176
- - Updated dependencies [ded3e6b]
177
- - @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/**/*"],
32
- "exclude": ["example.ts"]
33
- }