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

Explicitly return service response types #1627

Open
grod220 opened this issue Aug 2, 2024 · 0 comments
Open

Explicitly return service response types #1627

grod220 opened this issue Aug 2, 2024 · 0 comments
Labels
refactor Improving existing system with new design rpc Related to proto rpc services/methods

Comments

@grod220
Copy link
Collaborator

grod220 commented Aug 2, 2024

With the services we implement (in /packages/services), the return type of many of these method implementations return a plain javascript object. Example:

return {
gasPrices,
altGasPrices,

The challenge is that it is not typesafe and can lead to bugs such as #1626

Task: Convert all return types in our service method impls to the explicit return type of the response. Example:

-  return {
+  return new GasPricesResponse({
    gasPrices,
    altGasPrices,
-  };
+  });

This way, invalid fields will not be allowed and the typescript compiler will throw.

@grod220 grod220 added rpc Related to proto rpc services/methods refactor Improving existing system with new design labels Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Improving existing system with new design rpc Related to proto rpc services/methods
Projects
Status: 🗄️ Backlog
Development

No branches or pull requests

1 participant