-
Notifications
You must be signed in to change notification settings - Fork 70
Open
Description
Now that RFC-8 has been finally implemented in PolkadotSDK 🎉, I think this is a great opportunity to improve the ergonomics and clarity of the public API by revisiting the Client interface.
Specifically, I’d like to propose a redesign of the Client interface to make it more ergonomic and less error-prone. One key motivation is to remove the problematic potentialRelayChains property, which has historically caused confusion and race conditions.
Proposed Interface
type JsonChainOptions = {
disableJsonRpc?: boolean;
jsonRpcMaxPendingRequests?: number;
jsonRpcMaxSubscriptions?: number;
};
type AddRelayChainOptions = {
chainSpec: string;
databaseContent?: string;
} & JsonChainOptions;
type AddParaChainFromParaIdOptions = {
paraId: number;
} & JsonChainOptions;
type AddParaChainFromChainSpecOptions = {
chainSpec: string;
} & JsonChainOptions;
type AddParaChainOptions =
| AddParaChainFromParaIdOptions
| AddParaChainFromChainSpecOptions;
// Reuses the existing `Chain` interface
type RelayChain = Chain & {
addParaChain: (options: AddParaChainOptions) => Promise<Chain>;
};
interface Client {
addRelayChain(options: AddRelayChainOptions): Promise<RelayChain>;
terminate(): Promise<void>;
}Benefits
- Simplifies API ergonomics: Easier to understand and more intuitive to use.
- Removes race conditions: Eliminates
potentialRelayChains, addressing an important source of bugs and complexity. - Improves developer experience: Clearer structure for adding relay and parachains.
Example Usage
const smoldot = start();
const polkadot = await smoldot.addRelayChain({ chainSpec });
const assetHub = await polkadot.addParaChain({ paraId: 1000 });WDYT?
Also, we (the PAPI team) would like to help with this.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels