From de4f20a5695b62318ae635bba74f754c552dc7c0 Mon Sep 17 00:00:00 2001 From: Justin Starry Date: Wed, 12 Feb 2020 15:06:40 +0800 Subject: [PATCH] fix: add rewards to getConfirmedBlock api --- web3.js/src/connection.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/web3.js/src/connection.js b/web3.js/src/connection.js index d17e0bf49d..1f99a1d4a9 100644 --- a/web3.js/src/connection.js +++ b/web3.js/src/connection.js @@ -201,6 +201,7 @@ const Version = struct({ * @property {Blockhash} previousBlockhash Blockhash of this block's parent * @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 */ type ConfirmedBlock = { blockhash: Blockhash, @@ -215,6 +216,10 @@ type ConfirmedBlock = { status?: SignatureStatusResult, }, }>, + rewards: Array<{ + pubkey: string, + lamports: number, + }>, }; function createRpcRequest(url): RpcRequest { @@ -502,6 +507,15 @@ export const GetConfirmedBlockRpcResult = jsonRpcResult( ]), }), ]), + rewards: struct.union([ + 'undefined', + struct.array([ + struct({ + pubkey: 'string', + lamports: 'number', + }), + ]), + ]), }), ]), ); @@ -1112,6 +1126,7 @@ export class Connection { meta: result.meta, }; }), + rewards: result.result.rewards || [], }; }