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 minContextSlot configuration to (almost) all web3.js methods #26296

Merged
merged 15 commits into from Jun 29, 2022
Merged

feat: add minContextSlot configuration to (almost) all web3.js methods #26296

merged 15 commits into from Jun 29, 2022

Conversation

steveluscher
Copy link
Contributor

Problem

A new config param was added that lets you perform API calls while enforcing that the receiving RPC must have proceeded past a given slot. This API needs to be added to web3.js

Summary of Changes

Fixes #26276.

@steveluscher steveluscher added enhancement New feature or request javascript Pull requests that update Javascript code labels Jun 28, 2022
Comment on lines +301 to +315
function extractCommitmentFromConfig<TConfig>(
commitmentOrConfig?: Commitment | ({commitment?: Commitment} & TConfig),
) {
let commitment: Commitment | undefined;
let config: Omit<TConfig, 'commitment'> | undefined;
if (typeof commitmentOrConfig === 'string') {
commitment = commitmentOrConfig;
} else if (commitmentOrConfig) {
const {commitment: specifiedCommitment, ...specifiedConfig} =
commitmentOrConfig;
commitment = specifiedCommitment;
config = specifiedConfig;
}
return {commitment, config};
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have been in a separate commit for the purpose of review, sorry.

@codecov
Copy link

codecov bot commented Jun 28, 2022

Codecov Report

Merging #26296 (62c8ab7) into master (028c3eb) will increase coverage by 0.2%.
The diff coverage is n/a.

❗ Current head 62c8ab7 differs from pull request most recent head fba5eeb. Consider uploading reports for the commit fba5eeb to get more accurate results

@@            Coverage Diff            @@
##           master   #26296     +/-   ##
=========================================
+ Coverage    75.7%    75.9%   +0.2%     
=========================================
  Files          40       40             
  Lines        2350     2358      +8     
  Branches      340      338      -2     
=========================================
+ Hits         1781     1792     +11     
+ Misses        450      449      -1     
+ Partials      119      117      -2     

@jstarry
Copy link
Member

jstarry commented Jun 29, 2022

minContextSlot is especially useful if the error code can be returned to the user so that they know if a request failed due to hitting a lagging node. Could you add the error code number to the thrown errors?

@steveluscher
Copy link
Contributor Author

Could you add the error code number to the thrown errors?

Totally. Let me do that properly in a separate PR.

@steveluscher steveluscher merged commit f57f228 into solana-labs:master Jun 29, 2022
@steveluscher steveluscher deleted the add-min-context-slot-to-web3js branch June 29, 2022 16:22
@steveluscher
Copy link
Contributor Author

PR'd up in #26318.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request javascript Pull requests that update Javascript code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

web3.js add minContextSlot param to every RPC method that supports it
2 participants