@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 +6 -0
- package/README.md +15 -5
- package/example.ts +15 -16
- package/package.json +1 -1
- package/src/base.ts +3 -1
- package/src/types/engine/identification.d.ts +24 -0
- package/src/types/engine/methods.d.ts +6 -0
package/CHANGELOG.md
CHANGED
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
|
|
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
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
|
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
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 (
|
|
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];
|