Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

Config -> RuntimeConfig #253

Closed
harrysolovay opened this issue Oct 2, 2022 · 1 comment
Closed

Config -> RuntimeConfig #253

harrysolovay opened this issue Oct 2, 2022 · 1 comment
Labels

Comments

@harrysolovay
Copy link
Contributor

#226 states the intention to invert the flow of types. We initially planned to encapsulate all types (RPC and FRAME types) in a Config, which would flow through the DX. Now, we're going in the other direction (initial work in #229): type-safe bindings wrap the dynamic usage (potentially injecting pre-computed codecs, keys, misc.). This brings up some important questions: should we even bother encoding static type info in a Config?

Let's take a look at the current Config:

export class Config<
  DiscoveryValue = any,
  RpcCallMethods extends rpc.ProviderMethods = rpc.ProviderMethods,
  RpcSubscriptionMethods extends rpc.ProviderMethods = rpc.ProviderMethods,
  RpcErrorDetails extends rpc.ErrorDetails = rpc.ErrorDetails,
> {
  RpcMethods!: RpcCallMethods & RpcSubscriptionMethods;
  RpcCallMethods!: RpcCallMethods;
  RpcSubscriptionMethods!: RpcSubscriptionMethods;
  RpcErrorDetails!: RpcErrorDetails;

  constructor(
    readonly discoveryValue: DiscoveryValue,
    readonly addressPrefix: number,
  ) {}
}

What would happen if we got rid of the RPC phantoms?

export class RuntimeConfig<DiscoveryValue> {
  constructor(
    readonly discoveryValue: DiscoveryValue,
    readonly addressPrefix: number,
  ) {}
}

Of course, this would result in type errors in the current RPC client. Perhaps this is a good thing though... it does feel like too much typing at too low a level.

We can address this after #251.

@harrysolovay
Copy link
Contributor Author

Closed as of #233

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant