-
Notifications
You must be signed in to change notification settings - Fork 321
feature: add an alias for the technology preview of the new web3.js #163
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
base: master
Are you sure you want to change the base?
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.
Thank you for adding this.
More on the new web3.js, here: https://www.youtube.com/watch?v=JUJtAPhES5g
Great talk 👏
https://user-images.githubusercontent.com/13243/281195443-4d112114-ca79-49ae-aa4b-d014fbc90a3b.png
Judging by the image(web3tp.generateKeyPair()
), do some types not work as expected?
This thing definitely does not work with TypeScript 4.x. I'm trying to upgrade TypeScript in the playground right now (and thereby |
I think this particular issue is caused by types being exported from dependencies but currently, playground only imports the package itself and not its transitive dependencies. For example, if we were to declare the Declaring the packages in There was an issue with the build when I last updated the |
Wow, I'm really glad you know how all this fits together so that I don't have to go figure it all out :) Let me know if there's anything more I can do on this PR! |
Thanks, the PR looks great but is the I think we'd want the transitive types working before this PR otherwise it will be very difficult for people use it. |
Yeah, for sure difficult. Sorry, I'm just dumb – I can't parse whether “it's probably best if I take care of the types later and save you some time” means:
|
Sorry I wasn't clear, I meant that I'll fix the types(landing the whole enchilada at once option) but I can only start after I finish what I'm currently working on because I'm not sure how long it will take to fix the types. Of course, you can also fix it if you're feeling extra adventurous. |
One step closer to the new `web3.js` #163
I didn't want to make you wait so I added transitive deps in e41c1b2 (ended up being easier than I thought) Pretty nice that playnet still works with the new lib( There are still some type issues but this solved the majority of them. |
* `monaco-editor` had a bug(microsoft/monaco-editor#2295) where paths with `@` wouldn't work, this seems to have been fixed in microsoft/monaco-editor#3057 * Types from package name with file paths e.g. `import type { Rpc, RpcSubscriptions } from '@solana/rpc-transport/dist/types/json-rpc-types';` now works properly * We can now get the types for the RPC methods in `@solana/web3.js-tp`(#163)
Type imports from package names with file paths e.g. Problems
|
1 second? That's pretty awesome. It used to be 14. In all seriousness, though, presumably it's slower here than with an LSP because typechecking is happening on the client side here, right? I'm hoping that we can hold the dam back until TypeScript resolves microsoft/TypeScript#14107
Oh, weird. In my editor (TypeScript 5.2.2) it looks like this. ![]() Is this a TypeScript version problem? It's 4.x that's running in playground, right? Seems like that interface has been in the DOM types for quite a while. |
14 -> 1 sounds great to hear 😅 and yes, it's happening on the client side and it's a bit slower because it's running in a browser but the type resolution is usually fast enough that you wouldn't notice the difference.
Looks like it's going to get resolved anytime now 👍
Yeah, this seems to be a playground specific problem, haven't debugged yet.
|
I removed |
Thanks, I've added a lighter version of Only the incorrect rpc method types issue remains. It's interesting that but other methods have overload types also work: but it's just that the first overload is incorrect which makes the return types I've tested it with different TypeScript and |
Summary
By no means a complete solution, this PR is the start of adding support for the Technology Preview version of
@solana/web3.js
.Here, we import the
tp
version of the library and alias it toweb3tp
.More on the new web3.js, here: https://www.youtube.com/watch?v=JUJtAPhES5g
Test Plan
Create a wallet and airdrop some SOL to it.
Create a client like so:
Observe output