-
Notifications
You must be signed in to change notification settings - Fork 927
refactor(experimental): move RPC API types from rpc-transport to rpc-types #2049
Conversation
Current dependencies on/for this PR:
This stack of pull requests is managed by Graphite. |
7f85117
to
08a50fe
Compare
08a50fe
to
7dd8a93
Compare
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.
Interesting. Is the API definition alone useful anywhere else as its own library?
Agreed that the two aren't really at parity. The factories use |
I think this commit combined with your next one makes me thing about whether or not we should potentially isolate between the following:
What do you think? |
[A]: Not that I can think of so maybe it's not so much of an issue right now. [B]: I do like RPC Subscription Notifications as a parallel to RPC Methods. My slight concern is people thinking of notifications as subscription events but if we're consistent with the naming that I think that can work. I'm struggling to find a better alternative. [C — splitting RPC types]: That's interesting. Do you mean we'd be splitting |
I guess maybe we could go with something like
Yeah that's exactly what I mean! Because someone who might be defining their own RPC API shouldn't need to also pull in Solana-related types, considering they may define data a totally different way, even if they are still working on Solana. |
[B]: Subscription notifications is fine by me. 👌 [C]: I like that idea very much. If we're gonna do that though, I think we need to rethink our Current we have:
My ideal refactoring of these packages is as-follow:
What do you think? [B+C]: I don't think I'll have time to tackle these before I go on holiday but I can tackle that when I'm back if that's something we all agree on. Ideally I'd love it for that current stack to be merged before I'm OOO though because it changes so many file, I don't think it can afford to be stale for more than a week. |
I think I'm mostly aligned with what you're driving at, yeah. A quick note on GraphQL, it's really Solana-specific atm, so in order to accomplish what you're describing we'd need to basically define an interface for it, and then extract the Solana bits into the new package. I have no idea what that would look like at the moment, so I don't think that will happen anytime soon. As far as the other stuff goes, the naming convention would be:
The fact that the org What would happen to I also like the idea of the umbrellas for both, actually. |
Fair enough about the GraphQL stuff. Yeah I can see the weirdness of An alternative could be |
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.
Y'all have already hashed a lot of this out, and I agree that all of your proposed changes would make an improvement here!
Only other input:
- The dream for
rpc-core
was always to finish it up and then elevate it to the level of Architecture discussion: JSON RPC API specification solana-foundation/specs#22. Whatever gets this closer to that is great. - I'm totally down with changing the subscription type namings. Just don't confuse the action nouns and the data nouns. I don't know how best to map ‘Subscriptions’ and ‘Notifications’ on to this pattern:
- RPC (remote procedure call)
- Calls are the things you make…
- …as part of Requests (ie. to a remote server)…
- …to receive Responses.
- For subscriptions, then.
- ??? are the things you make…
- …as part of ???…
- …to receive Notifications.
- RPC (remote procedure call)
Maybe the unlock is just SubscriptionCall
and SubscriptionRequest
, as you suggested in this PR's description!
Merge activity
|
🎉 This PR is included in version 1.90.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Because there has been no activity on this PR for 14 days since it was merged, it has been automatically locked. Please open a new issue if it requires a follow up. |
This PR moves the following types from
@solana/rpc-transport
to@solana/rpc-types
:Rpc
RpcSubscriptions
IRpcApi
IRpcSubscriptionsApi
IRpcApiMethods
IRpcApiSubscriptions
RpcRequest
RpcSubscription
PendingRpcRequest
PendingRpcSubscription
SendOptions
SubscribeOptions
As a result, packages such as
@solana/accounts
now no longer need to import@solana/rpc-transport
in order to simply define anRpc
type with a few handpicked methods.Side note A: Ideally I wanted
@solana/rpc-core
to also no longer need@solana/transport
but the former doesn't only export type, it also export functions that create an RPC API with transports. I think this is fine but we may consider breaking@solana/rpc-core
into two packages such as one only defined the method/subscription types, and the other one imports everything to offer factory functions.Side note B: When seeing all the exported types laid out like that, we can see the naming for the Subscription side is a little ambiguous. For instance, it is not immediately clear what the difference between
IRpcSubscriptionsApi
andIRpcApiSubscriptions
is. The reason behind this is the Subscription side doesn't have equivalents to the namesMethod
andRequest
. A good refactoring could be to rename types likeIRpcApiSubscriptions
toIRpcApiSubscriptionMethods
orPendingRpcSubscription
toPendingRpcSubscriptionRequest
, so they are consistent with the non-subscription API. What do you think?