From 0988c2f1d6abf1bc603d43079dac8cf69880d5b2 Mon Sep 17 00:00:00 2001 From: Josh Date: Thu, 18 Mar 2021 07:10:48 -0700 Subject: [PATCH] feat: add support for blockTime on confirmed block (#15968) --- web3.js/src/connection.ts | 3 +++ web3.js/test/connection.test.ts | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/web3.js/src/connection.ts b/web3.js/src/connection.ts index 4326ce10ff..ea293dbbd8 100644 --- a/web3.js/src/connection.ts +++ b/web3.js/src/connection.ts @@ -602,6 +602,7 @@ export type ParsedConfirmedTransaction = { * @property {number} parentSlot Slot index of this block's parent * @property {Array} transactions Vector of transactions and status metas * @property {Array} rewards Vector of block rewards + * @property {number|null} blockTime The unix timestamp of when the block was processed */ export type ConfirmedBlock = { blockhash: Blockhash; @@ -617,6 +618,7 @@ export type ConfirmedBlock = { postBalance: number | null; rewardType: string | null; }>; + blockTime: number | null; }; /** @@ -1247,6 +1249,7 @@ export const GetConfirmedBlockRpcResult = jsonRpcResult( }), ), ), + blockTime: nullable(number()), }), ), ); diff --git a/web3.js/test/connection.test.ts b/web3.js/test/connection.test.ts index 68ed5c74ae..2e81e7d30a 100644 --- a/web3.js/test/connection.test.ts +++ b/web3.js/test/connection.test.ts @@ -528,6 +528,7 @@ describe('Connection', () => { method: 'getConfirmedBlock', params: [1], value: { + blockTime: 1614281964, blockhash: '57zQNBZBEiHsCZFqsaY6h176ioXy5MsSLmcvHkEyaLGy', previousBlockhash: 'H5nJ91eGag3B5ZSRHZ7zG5ZwXJ6ywCt2hyR8xCsV7xMo', parentSlot: 0, @@ -663,6 +664,7 @@ describe('Connection', () => { method: 'getConfirmedBlock', params: [1], value: { + blockTime: 1614281964, blockhash: '57zQNBZBEiHsCZFqsaY6h176ioXy5MsSLmcvHkEyaLGy', previousBlockhash: 'H5nJ91eGag3B5ZSRHZ7zG5ZwXJ6ywCt2hyR8xCsV7xMo', parentSlot: 0, @@ -917,6 +919,7 @@ describe('Connection', () => { method: 'getConfirmedBlock', params: [0], value: { + blockTime: 1614281964, blockhash: 'H5nJ91eGag3B5ZSRHZ7zG5ZwXJ6ywCt2hyR8xCsV7xMo', previousBlockhash: 'H5nJ91eGag3B5ZSRHZ7zG5ZwXJ6ywCt2hyR8xCsV7xMo', parentSlot: 0, @@ -936,6 +939,7 @@ describe('Connection', () => { method: 'getConfirmedBlock', params: [1], value: { + blockTime: 1614281964, blockhash: '57zQNBZBEiHsCZFqsaY6h176ioXy5MsSLmcvHkEyaLGy', previousBlockhash: 'H5nJ91eGag3B5ZSRHZ7zG5ZwXJ6ywCt2hyR8xCsV7xMo', parentSlot: 0,