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

chore: decouple rpc method types from clients #129

Merged
merged 3 commits into from
Jun 20, 2022

Conversation

harrysolovay
Copy link
Contributor

@harrysolovay harrysolovay commented Jun 20, 2022

This PR allows users to supply their own method lookups to beacons. This paves the way for narrow RPC typings for different chains (all in the same env!).

const myBeacon = rpc.beacon<{
  someFn(a: string, b: number): string;
}>();

const client = await rpc.client(myBeacon);
assert(!(client instanceof Error));
const result = await client.call("state_getMetadata", []);
//                               ~~~~~~~~~~~~~~~~~~~
//                               ^
//                               Argument of type '"state_getMetadata"' is not assignable to parameter of type '"someFn"



console.log(result);
await client.close();

@harrysolovay harrysolovay merged commit 16fa61f into main Jun 20, 2022
@harrysolovay harrysolovay deleted the enhance-beacon-type-encoding branch June 20, 2022 13:20
Copy link
Contributor

@tjjfvi tjjfvi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, was going to suggest this

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

Successfully merging this pull request may close these issues.

2 participants