diff --git a/apps/extension/src/hooks/latest-block-height.ts b/apps/extension/src/hooks/latest-block-height.ts index 6dd35982..a170c2da 100644 --- a/apps/extension/src/hooks/latest-block-height.ts +++ b/apps/extension/src/hooks/latest-block-height.ts @@ -23,7 +23,7 @@ const fetchBlockHeightWithFallback = async (endpoints: string[]): Promise endpoint !== randomGrpcEndpoint); @@ -31,11 +31,29 @@ const fetchBlockHeightWithFallback = async (endpoints: string[]): Promise => { + const tendermintClient = createPromiseClient( + TendermintProxyService, + createGrpcWebTransport({ baseUrl: grpcEndpoint }), + ); + + const result = await tendermintClient.getStatus({}, { signal: AbortSignal.timeout(timeoutMs) }); + if (!result.syncInfo) { + throw new Error('No syncInfo in getStatus result'); + } + return Number(result.syncInfo.latestBlockHeight); +}; + +// Fetch the block height from a specific RPC endpoint. export const fetchBlockHeight = async (grpcEndpoint: string): Promise => { const tendermintClient = createPromiseClient( TendermintProxyService, - createGrpcWebTransport({ baseUrl: grpcEndpoint, defaultTimeoutMs: 2000 }), + createGrpcWebTransport({ baseUrl: grpcEndpoint }), ); const result = await tendermintClient.getStatus({});