From 661e146636a9f685e8cbae04c52b1d0a1ede3bff Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Thu, 13 Jul 2023 04:31:55 -0400 Subject: [PATCH] feat: add getCurrentBlock and getLastBlock methods --- src/baseClient.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/baseClient.ts b/src/baseClient.ts index 5a81ac5..8f6863d 100644 --- a/src/baseClient.ts +++ b/src/baseClient.ts @@ -77,6 +77,19 @@ export default abstract class BaseClient { ); } + public getCurrentBlock(): number { + return getCurrentSlot(this.config.chainConfig, this.genesisTime); + } + public getLastBlock(): number | null { + if (this._latestOptimisticUpdate) { + return capella.ssz.LightClientOptimisticUpdate.deserialize( + this._latestOptimisticUpdate, + ).attestedHeader.beacon.slot; + } + + return null; + } + public async getNextValidExecutionInfo( retry: number = 10, ): Promise {