diff --git a/sdk/src/network-client.ts b/sdk/src/network-client.ts index 9af79afb1..77b8992f0 100644 --- a/sdk/src/network-client.ts +++ b/sdk/src/network-client.ts @@ -390,9 +390,9 @@ class AleoNetworkClient { * @example * const latestHeight = networkClient.getLatestHeight(); */ - async getLatestHeight(): Promise { + async getLatestHeight(): Promise { try { - return await this.fetchData("/latest/height"); + return await this.fetchData("/latest/height"); } catch (error) { throw new Error("Error fetching latest height."); } diff --git a/sdk/src/record-provider.ts b/sdk/src/record-provider.ts index f3d025ec8..c56664a90 100644 --- a/sdk/src/record-provider.ts +++ b/sdk/src/record-provider.ts @@ -202,12 +202,8 @@ class NetworkRecordProvider implements RecordProvider { // If the end height is not specified, use the current block height if (endHeight == 0) { - try { - const end = await this.networkClient.getLatestHeight(); - endHeight = end; - } catch (e) { - logAndThrow("Unable to get current block height from the network") - } + const end = await this.networkClient.getLatestHeight(); + endHeight = Number(end); } // If the start height is greater than the end height, throw an error diff --git a/sdk/tests/network-client.test.ts b/sdk/tests/network-client.test.ts index 48a7814a7..287bd607a 100644 --- a/sdk/tests/network-client.test.ts +++ b/sdk/tests/network-client.test.ts @@ -100,7 +100,7 @@ describe('NodeConnection', () => { describe('getLatestHeight', () => { it('should return a number', async () => { const latestHeight = await connection.getLatestHeight(); - expect(typeof latestHeight).toBe('number'); + expect(typeof latestHeight).toBe('bigint'); }, 60000); });