-
Notifications
You must be signed in to change notification settings - Fork 4.6k
feat: add commission fields matching RPC spec #29435
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
automerge label removed due to a CI failure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you have some Typescript errors. Want to fix those up and resubmit, @R-K-H?
Pull request has been modified.
ef1b4d8
to
abbfc60
Compare
Sure thing, I've updated the PR and refactored the previous git commit message to pass lint there as well. I've ran the tests locally with one error from VoteProgram on live test (unrelated I think). Aside: Looks like it didn't like |
web3.js/src/connection.ts
Outdated
@@ -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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure this is right? The JSON-RPC docs describe this property as commission: <u8|undefined>
.
commission: number | null; | |
commission?: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're correct! Will fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, I'm really just asking. It's a distinct possibility that the docs are wrong. #27655
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it is returning null from the request, when doing the live testing it does seem to require that the field is nullable. And I know from my own use that making the request to mainnet the JSON response is returning the commission (at least for InflationReward) as a number.
But I'm fixing right now which I suppose supporting the optional(nullable(number()))
more closely matches the JSON RPC spec with it being ABLE to be undefined (although I'm not certain it does return without the field).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allowing for undefined
would definitely protect against a response from an old RPC fataling the client. I don't think there are any RPCs old enough to return undefined
for this property but ¯_(°ペ)_/¯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed and agreed. Updated.
abbfc60
to
e24e84c
Compare
Pull request has been modified.
Codecov Report
@@ Coverage Diff @@
## master #29435 +/- ##
=======================================
Coverage 76.5% 76.5%
=======================================
Files 54 54
Lines 3129 3129
Branches 470 470
=======================================
Hits 2396 2396
Misses 568 568
Partials 165 165 |
…na-labs#29435) * fix: adds commission field matching RPC spec * fix: update optional to follow type pattern
…na-labs#29435) * fix: adds commission field matching RPC spec * fix: update optional to follow type pattern
…na-labs#29435) * fix: adds commission field matching RPC spec * fix: update optional to follow type pattern
…na-labs#29435) * fix: adds commission field matching RPC spec * fix: update optional to follow type pattern
Problem
The
@solana/web3.js
SDKInflationReward
type andrewards
in themeta
fortransaction status metadata object
properties do not match the JSON RPC spec in that they are missing thecommission
field. This is causing an issue with the types when attempting to access field value.See:
Summary of Changes
Adds the commission field in the
src/connection.ts
InflationReward
RewardsResult
GetInflationRewardResult
BlockResponse
ParsedBlockResponse
VersionedBlockResponse
ConfirmedBlock
Adds commission field in the
mockRpcResponse
in thetests/connection.test.ts
file.