Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rpc): favour zod types only #828

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

Conversation

kyranjamie
Copy link
Collaborator

@kyranjamie kyranjamie commented Jan 23, 2025

Figuring out best way to handle some message passing and continually running into need to runtime check a payload & narrow the type. This is only possible if all method requests and response are available as schemas. I regret setting up this type structure and not going validator first from the start.

I know we don't follow the convention of "section comments" like I've used here, but find schema heavy files hard to navigate without.

There's a pretty crazy type overload here. The tricky part is that some methods do / do not have params defined. And, based on whether or not a params schema is defined, the inferred type should know whether or not there's a params object. I tried using a conditional type e.g. TParams extends undefined ? X : Y but it didn't infer correctly.

Copy link

codecov bot commented Jan 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 40.09%. Comparing base (17ea4a6) to head (7617bf2).

Additional details and impacted files
@@           Coverage Diff           @@
##              dev     #828   +/-   ##
=======================================
  Coverage   40.09%   40.09%           
=======================================
  Files         207      207           
  Lines        9651     9651           
  Branches      567      567           
=======================================
  Hits         3870     3870           
  Misses       5781     5781           
Components Coverage Δ
bitcoin 64.15% <ø> (ø)
query 12.60% <ø> (ø)
utils 83.23% <ø> (ø)
crypto 68.21% <ø> (ø)
stacks 71.78% <ø> (ø)

@kyranjamie kyranjamie force-pushed the fix/non-zod-schemas branch 2 times, most recently from ab7ac77 to f2f4637 Compare January 24, 2025 16:47
@kyranjamie kyranjamie requested a review from fbwoolf January 24, 2025 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants