@asyncswap/eth-rpc 0.4.5 → 0.4.6

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,11 @@
1
1
  # @asyncswap/eth-rpc
2
2
 
3
+ ## 0.4.6
4
+
5
+ ### Patch Changes
6
+
7
+ - 3d6ec6e: add clinet version spec
8
+
3
9
  ## 0.4.5
4
10
 
5
11
  ### Patch Changes
package/README.md CHANGED
@@ -33,6 +33,21 @@ import { FlashbotsClient } from "@asyncswap/eth-rpc";
33
33
 
34
34
  const rpc = "https://relay.flashbots.net";
35
35
  const client = new FlashbotsClient(rpc);
36
+ const bundle = {
37
+ txs: ["0x123abc", "0x456def..."] as Hex[],
38
+
39
+ blockNumber: "0xb63dcd" as Hex,
40
+ minTimestamp: 0,
41
+ maxTimestamp: 1615920932,
42
+ };
43
+ const body = client.rpc.buildRequest("eth_sendBundle", [bundle]);
44
+ // const signature = wallet.sign(body)
45
+ // const sender = wallet.address
46
+ client
47
+ .setHeaders({
48
+ "X-Flashbots-Signature": `0x<sender>:0x<signature>`,
49
+ })
50
+ .eth_sendBundle(bundle);
36
51
  ```
37
52
 
38
53
  ### Engine API Client
@@ -45,11 +60,6 @@ const engine = new EngineExecutionClient(engineUrl, process.env.JWT_TOKEN!);
45
60
  const payload = await engine.engine_getPayloadV1("0x1");
46
61
 
47
62
  console.log(payload);
48
-
49
- import { FlashbotsClient } from '@asyncswap/eth-rpc';
50
-
51
- const rpc = 'https://relay.flashbots.net';
52
- const client = new FlashbotsClient(rpc);
53
63
  ```
54
64
 
55
65
  ## Error Handling
package/example.ts CHANGED
@@ -13,7 +13,11 @@ import { EngineExecutionClient } from "./src";
13
13
 
14
14
  const engineUrl = "https://localhost:8551";
15
15
  const engine = new EngineExecutionClient(engineUrl, process.env.JWT_TOKEN!);
16
- const payload = await engine.engine_getPayloadV1("0x1");
16
+ const payload = await engine
17
+ .setHeaders({
18
+ Authorization: `Bearer <jwt-token>`,
19
+ })
20
+ .engine_getPayloadV1("0x1");
17
21
 
18
22
  console.log(payload);
19
23
 
@@ -21,23 +25,18 @@ import { FlashbotsClient } from "./src";
21
25
 
22
26
  const rpc = "https://relay.flashbots.net";
23
27
  const client = new FlashbotsClient(rpc);
24
- const body = client.rpc.buildRequest("eth_sendBundle", [
25
- {
26
- txs: ["0x123abc", "0x456def..."],
27
- blockNumber: "0xb63dcd",
28
- minTimestamp: 0,
29
- maxTimestamp: 1615920932,
30
- } as EthSendBundleParams,
31
- ]);
28
+ const bundle = {
29
+ txs: ["0x123abc", "0x456def..."] as Hex[],
30
+
31
+ blockNumber: "0xb63dcd" as Hex,
32
+ minTimestamp: 0,
33
+ maxTimestamp: 1615920932,
34
+ };
35
+ const body = client.rpc.buildRequest("eth_sendBundle", [bundle]);
32
36
  // const signature = wallet.sign(body)
33
- // const signature = wallet.address
37
+ // const sender = wallet.address
34
38
  client
35
39
  .setHeaders({
36
40
  "X-Flashbots-Signature": `0x<sender>:0x<signature>`,
37
41
  })
38
- .eth_sendBundle({
39
- txs: ["0x123abc...", "0x456def..."],
40
- blockNumber: "0xb63dcd",
41
- minTimestamp: 0,
42
- maxTimestamp: 1615920932,
43
- });
42
+ .eth_sendBundle(bundle);
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.5",
5
+ "version": "0.4.6",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
8
  "main": "dist/index.js",
package/src/base.ts CHANGED
@@ -19,7 +19,9 @@ export abstract class BaseClient<MethodsSpec extends RpcSpecBase> {
19
19
 
20
20
  const method = prop as keyof MethodsSpec;
21
21
 
22
- return (...params: MethodsSpec[typeof method]["params"]) =>
22
+ return (
23
+ ...params: MethodsSpec[typeof method]["params"]
24
+ ): MethodsSpec[typeof method]["result"] =>
23
25
  this.rpc.call(this.rpc.buildRequest(method, params), this.headers);
24
26
  },
25
27
  });
@@ -0,0 +1,24 @@
1
+ declare global {
2
+ export type ClientVersionV1 = {
3
+ code: ClientCode;
4
+ name: string;
5
+ varsion: string;
6
+ commit: string;
7
+ };
8
+ export type ClientCode =
9
+ | "BU" // besu
10
+ | "EJ" // ethereumJs
11
+ | "EG" // erigon
12
+ | "GE" // go-ethereum
13
+ | "GR" // gradine
14
+ | "LH" // lighthouse
15
+ | "LS" // lodestar
16
+ | "NM" // nethermind
17
+ | "NB" // nimbus
18
+ | "TE" // thin-execution
19
+ | "TK" // teku
20
+ | "PM" // prysm
21
+ | "RH"; // reth
22
+ }
23
+
24
+ export { };
@@ -1,5 +1,11 @@
1
1
  declare global {
2
2
  export type EngineMethodsSpec = {
3
+ // identification
4
+ engine_getClientVersionV1: {
5
+ params: [ClientVersionV1];
6
+ result: ClientVersionV1[];
7
+ };
8
+ // share methods
3
9
  eth_blockNumber: { params: []; result: Uint };
4
10
  eth_call: {
5
11
  params: [GenericTransaction, BlockNumberOrTagOrHash];