Compare commits
4 Commits
v0.1.0-dev
...
v0.1.0-dev
Author | SHA1 | Date |
---|---|---|
semantic-release-bot | c39ba96760 | |
Derrick Hammer | 911c95d9ee | |
Derrick Hammer | f8eba3644b | |
Derrick Hammer | efc657b790 |
|
@ -1,3 +1,5 @@
|
||||||
|
# [0.1.0-develop.8](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.7...v0.1.0-develop.8) (2023-07-11)
|
||||||
|
|
||||||
# [0.1.0-develop.7](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.6...v0.1.0-develop.7) (2023-07-11)
|
# [0.1.0-develop.7](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.6...v0.1.0-develop.7) (2023-07-11)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "@lumeweb/libethclient",
|
"name": "@lumeweb/libethclient",
|
||||||
"version": "0.1.0-develop.7",
|
"version": "0.1.0-develop.8",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@lumeweb/libethclient",
|
"name": "@lumeweb/libethclient",
|
||||||
"version": "0.1.0-develop.7",
|
"version": "0.1.0-develop.8",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@chainsafe/as-sha256": "^0.3.1",
|
"@chainsafe/as-sha256": "^0.3.1",
|
||||||
"@chainsafe/bls": "7.1.1",
|
"@chainsafe/bls": "7.1.1",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@lumeweb/libethsync",
|
"name": "@lumeweb/libethsync",
|
||||||
"version": "0.1.0-develop.7",
|
"version": "0.1.0-develop.8",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { Bytes32, capella, LightClientUpdate } from "#types.js";
|
||||||
import {
|
import {
|
||||||
consensusClient,
|
consensusClient,
|
||||||
deserializePubkeys,
|
deserializePubkeys,
|
||||||
|
getConsensusOptimisticUpdate,
|
||||||
optimisticUpdateFromJSON,
|
optimisticUpdateFromJSON,
|
||||||
optimisticUpdateVerify,
|
optimisticUpdateVerify,
|
||||||
} from "#util.js";
|
} from "#util.js";
|
||||||
|
@ -87,16 +88,8 @@ export default class Client extends BaseClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async getLatestExecution(): Promise<ExecutionInfo | null> {
|
protected async getLatestExecution(): Promise<ExecutionInfo | null> {
|
||||||
const resp = await axios.get(
|
const updateJSON = await getConsensusOptimisticUpdate();
|
||||||
`/eth/v1/beacon/light_client/optimistic_update`,
|
const update = optimisticUpdateFromJSON(updateJSON);
|
||||||
);
|
|
||||||
|
|
||||||
const updateJSON = resp.data;
|
|
||||||
|
|
||||||
if (!updateJSON) {
|
|
||||||
throw Error(`fetching optimistic update failed`);
|
|
||||||
}
|
|
||||||
const update = optimisticUpdateFromJSON(updateJSON.data);
|
|
||||||
const verify = await optimisticUpdateVerify(
|
const verify = await optimisticUpdateVerify(
|
||||||
this.latestCommittee as Uint8Array[],
|
this.latestCommittee as Uint8Array[],
|
||||||
update,
|
update,
|
||||||
|
|
|
@ -12,3 +12,4 @@ function createDefaultClient(beaconUrl: string): Client {
|
||||||
|
|
||||||
export { Client, Prover, Store, createDefaultClient };
|
export { Client, Prover, Store, createDefaultClient };
|
||||||
export * from "#interfaces.js";
|
export * from "#interfaces.js";
|
||||||
|
export { getConsensusOptimisticUpdate, getCommitteeHash } from "#util.js";
|
||||||
|
|
12
src/util.ts
12
src/util.ts
|
@ -77,3 +77,15 @@ export function getCommitteeHash(committee: Uint8Array[]): Uint8Array {
|
||||||
|
|
||||||
export const consensusClient = axios.create();
|
export const consensusClient = axios.create();
|
||||||
axiosRetry(consensusClient, { retries: 3 });
|
axiosRetry(consensusClient, { retries: 3 });
|
||||||
|
|
||||||
|
export async function getConsensusOptimisticUpdate() {
|
||||||
|
const resp = await consensusClient.get(
|
||||||
|
`/eth/v1/beacon/light_client/optimistic_update`,
|
||||||
|
);
|
||||||
|
|
||||||
|
const updateJSON = resp.data;
|
||||||
|
|
||||||
|
if (!updateJSON) {
|
||||||
|
throw Error(`fetching optimistic update failed`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue