Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add commission fields matching RPC spec #29435

Merged
merged 2 commits into from Dec 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions web3.js/src/connection.ts
Expand Up @@ -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;
};

/**
Expand All @@ -780,6 +782,7 @@ const GetInflationRewardResult = jsonRpcResult(
effectiveSlot: number(),
amount: number(),
postBalance: number(),
commission: optional(nullable(number())),
}),
),
),
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -2297,6 +2307,7 @@ const RewardsResult = pick({
lamports: number(),
postBalance: nullable(number()),
rewardType: nullable(string()),
commission: optional(nullable(number())),
});

/**
Expand Down
1 change: 1 addition & 0 deletions web3.js/test/connection.test.ts
Expand Up @@ -808,6 +808,7 @@ describe('Connection', function () {
effectiveSlot: 432000,
epoch: 0,
postBalance: 30504783,
commission: 0,
},
null,
],
Expand Down