From cfdf3f345dced3b7041856f6e51ceef3dcef6ce2 Mon Sep 17 00:00:00 2001 From: Kollan House Date: Thu, 29 Dec 2022 23:22:56 -0500 Subject: [PATCH] feat: add commission fields matching RPC spec to web3.js client (#29435) * fix: adds commission field matching RPC spec * fix: update optional to follow type pattern --- src/connection.ts | 11 +++++++++++ test/connection.test.ts | 1 + 2 files changed, 12 insertions(+) diff --git a/src/connection.ts b/src/connection.ts index fd7d9b7edda..3ad11570d59 100644 --- a/src/connection.ts +++ b/src/connection.ts @@ -767,6 +767,8 @@ export type InflationReward = { amount: number; /** post balance of the account in lamports */ postBalance: number; + /** vote account commission when the reward was credited */ + commission?: number | null; }; /** @@ -780,6 +782,7 @@ const GetInflationRewardResult = jsonRpcResult( effectiveSlot: number(), amount: number(), postBalance: number(), + commission: optional(nullable(number())), }), ), ), @@ -1232,6 +1235,8 @@ export type BlockResponse = { postBalance: number | null; /** Type of reward received */ rewardType: string | null; + /** Vote account commission when the reward was credited, only present for voting and staking rewards */ + commission?: number | null; }>; /** The unix timestamp of when the block was processed */ blockTime: number | null; @@ -1276,6 +1281,8 @@ export type ParsedBlockResponse = { postBalance: number | null; /** Type of reward received */ rewardType: string | null; + /** Vote account commission when the reward was credited, only present for voting and staking rewards */ + commission?: number | null; }>; /** The unix timestamp of when the block was processed */ blockTime: number | null; @@ -1344,6 +1351,8 @@ export type VersionedBlockResponse = { postBalance: number | null; /** Type of reward received */ rewardType: string | null; + /** Vote account commission when the reward was credited, only present for voting and staking rewards */ + commission?: number | null; }>; /** The unix timestamp of when the block was processed */ blockTime: number | null; @@ -1399,6 +1408,7 @@ export type ConfirmedBlock = { lamports: number; postBalance: number | null; rewardType: string | null; + commission?: number | null; }>; /** The unix timestamp of when the block was processed */ blockTime: number | null; @@ -2297,6 +2307,7 @@ const RewardsResult = pick({ lamports: number(), postBalance: nullable(number()), rewardType: nullable(string()), + commission: optional(nullable(number())), }); /** diff --git a/test/connection.test.ts b/test/connection.test.ts index e77d7aca4ae..1a4b41839c0 100644 --- a/test/connection.test.ts +++ b/test/connection.test.ts @@ -816,6 +816,7 @@ describe('Connection', function () { effectiveSlot: 432000, epoch: 0, postBalance: 30504783, + commission: 0, }, null, ],