You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.
Aliased methods reference the lookup directly (chain_getFinalisedHead, for example).
Methods which produce a subscription return a Subscription<T>, where T is a union of all possible notifications. A good example of a type applied to T is the notification type of chainHead_unstable_follow.
Should we...
... rename MethodLookup to SubstrateRpcMethods?
... split out any unstable methods into an UnstableMethods lookup?
... provide out-of-the box lookups such as PolkadotRpcMethods and KusamaRpcMethods?
From these lookups, users can narrow their clients.
import*asCfrom"capi";// TODO: `Beacon` branded string typeconstPOLKADOT_BEACON="wss://rpc.polkadot.io"asC.Beacon<C.PolkadotRpcMethods>;// ... or ...constpolkadotBeacon=C.beacon<C.PolkadotRpcMethods>("wss://rpc.polkadot.io");// Produce a narrowly-typed `WsRpcClient`constclient=C.wsRpcClient(POLKADOT_BEACON);
We could of course abstract over the creation of well-known clients.
This is of course a very rough approximation of a solution. I'd imagine there will be a bit of complexity in the generic piping of the beacon's lookup into the methods of client instances.
A good starting place is likely to fine-tune and break apart the lookups so that they're easier to compose within the type system (and some tsdocs, so that we get that attractive guided DX!).
We should also investigate the possibility of generating RPC method lookups per-chain (#109).
The text was updated successfully, but these errors were encountered:
How do we want to approach narrowly-typing RPC methods (defined in
rpc/messages.ts
)?The
rpc/messages.ts
file defines a central lookup of RPC methods of Substrate. This lookup is simply a record of functions. Paraphrasing:A few things to note:
HashHexString
instead ofstring
. The core assumption here is that we may want to validate inputs. Related discussion in Approach to Branded Types & RPC-related Validation #96.chain_getFinalisedHead
, for example).Subscription<T>
, whereT
is a union of all possible notifications. A good example of a type applied toT
is the notification type ofchainHead_unstable_follow
.Should we...
MethodLookup
toSubstrateRpcMethods
?UnstableMethods
lookup?PolkadotRpcMethods
andKusamaRpcMethods
?From these lookups, users can narrow their clients.
We could of course abstract over the creation of well-known clients.
This approach enables users to define custom RPC clients with ease.
This is of course a very rough approximation of a solution. I'd imagine there will be a bit of complexity in the generic piping of the beacon's lookup into the methods of client instances.
A good starting place is likely to fine-tune and break apart the lookups so that they're easier to compose within the type system (and some tsdocs, so that we get that attractive guided DX!).
We should also investigate the possibility of generating RPC method lookups per-chain (#109).
The text was updated successfully, but these errors were encountered: