diff --git a/web3.js/module.d.ts b/web3.js/module.d.ts index d1dd1ff4e6..187c036dfc 100644 --- a/web3.js/module.d.ts +++ b/web3.js/module.d.ts @@ -183,6 +183,7 @@ declare module '@solana/web3.js' { slotIndex: number; slotsInEpoch: number; absoluteSlot: number; + blockHeight?: number; }; export type EpochSchedule = { diff --git a/web3.js/module.flow.js b/web3.js/module.flow.js index a2ba4e0f4c..8c430d2ead 100644 --- a/web3.js/module.flow.js +++ b/web3.js/module.flow.js @@ -208,6 +208,7 @@ declare module '@solana/web3.js' { slotIndex: number, slotsInEpoch: number, absoluteSlot: number, + blockHeight: ?number, }; declare export type LeaderSchedule = { diff --git a/web3.js/src/connection.js b/web3.js/src/connection.js index ee831a4be2..3a21be55f4 100644 --- a/web3.js/src/connection.js +++ b/web3.js/src/connection.js @@ -246,12 +246,14 @@ const GetInflationGovernorResult = struct({ * @property {number} slotIndex * @property {number} slotsInEpoch * @property {number} absoluteSlot + * @property {number} blockHeight */ type EpochInfo = { epoch: number, slotIndex: number, slotsInEpoch: number, absoluteSlot: number, + blockHeight: number | null, }; const GetEpochInfoResult = struct({ @@ -259,6 +261,7 @@ const GetEpochInfoResult = struct({ slotIndex: 'number', slotsInEpoch: 'number', absoluteSlot: 'number', + blockHeight: 'number?', }); /** @@ -442,9 +445,7 @@ const GetEpochScheduleRpcResult = struct({ /** * Expected JSON RPC response for the "getLeaderSchedule" message */ -const GetLeaderScheduleRpcResult = jsonRpcResult( - GetLeaderScheduleResult, -); +const GetLeaderScheduleRpcResult = jsonRpcResult(GetLeaderScheduleResult); /** * Expected JSON RPC response for the "getBalance" message diff --git a/web3.js/test/connection.test.js b/web3.js/test/connection.test.js index 2e8a54e744..7888fb66b3 100644 --- a/web3.js/test/connection.test.js +++ b/web3.js/test/connection.test.js @@ -394,13 +394,19 @@ test('get epoch info', async () => { slotIndex: 1, slotsInEpoch: 8192, absoluteSlot: 1, + blockHeight: 1, }, }, ]); const epochInfo = await connection.getEpochInfo(); - for (const key of ['epoch', 'slotIndex', 'slotsInEpoch', 'absoluteSlot']) { + for (const key of [ + 'epoch', + 'slotIndex', + 'slotsInEpoch', + 'absoluteSlot' /*, 'blockHeight'*/, // Uncomment blockHeight after 1.1.20 ships + ]) { expect(epochInfo).toHaveProperty(key); expect(epochInfo[key]).toBeGreaterThanOrEqual(0); }