-
Notifications
You must be signed in to change notification settings - Fork 285
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
Refactor ClusterProvider to remove legacy web3js dependency #267
Merged
mcintyre94
merged 5 commits into
solana-labs:master
from
mcintyre94:home-providers-refactor
Jul 14, 2023
Merged
Refactor ClusterProvider to remove legacy web3js dependency #267
mcintyre94
merged 5 commits into
solana-labs:master
from
mcintyre94:home-providers-refactor
Jul 14, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@mcintyre94 is attempting to deploy a commit to the Solana Labs Team on Vercel. A member of the Team first needs to authorize it. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
steveluscher
approved these changes
Jul 12, 2023
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.
mcintyre94
force-pushed
the
home-providers-refactor
branch
from
July 13, 2023 14:26
1f51286
to
b5fd53a
Compare
- Implement epoch for slot, first slot in epoch, last slot in epoch, in Explorer codebase - Uses the same formulae as the legacy web3js EpochSchedule class - See https://github.com/solana-labs/solana-web3.js/blob/9232d2b1019dc50f852ad70aa81624e751d76161/packages/library-legacy/src/epoch-schedule.ts
utils/index.ts has a dependency on legacy web3js
mcintyre94
force-pushed
the
home-providers-refactor
branch
from
July 14, 2023 13:52
b5fd53a
to
cbd2d1e
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This provider makes 3 requests, and makes their responses available to child components:
getFirstAvailableBlock
getEpochInfo
getEpochSchedule
The first 2 are reasonably straightforward, we have basically the same structure as the legacy web3js, with just number/bigint changes.
getEpochSchedule
is a bit more complex. The existing API exposes a class with a bunch of functionality for finding the epoch for a slot, and the first/last slot for an epoch. None of this is RPC functionality, it's all baked into the legacy web3js code. Since the experimental web3js doesn't do any of that, I've copied these functions into the Explorer codebase, as pure functions that take anEpochSchedule
(pure data returned by the new RPC method) and a slot/epoch (bigint).See existing web3js code here: https://github.com/solana-labs/solana-web3.js/blob/9232d2b1019dc50f852ad70aa81624e751d76161/packages/library-legacy/src/epoch-schedule.ts
Also note that I hit a bug in experimental web3js where some of these functions are incorrectly typed as unknown: solana-labs/solana-web3.js#1389
This was easy enough to work around for now
I've also moved
localStorageIsAvailable
fromutils/index.ts
to its ownutils/local-storage
. This lets us import it without pulling in the web3js dependency inutils/index.ts
The result of this PR is that the
ClusterProvider
in the root layout no longer pulls in the legacy web3js dependency.