Recommended pattern for Return Types on RPC functions
Hi there,
I have some rpc's that return JSON for use in my frontend. Previously, I had their corresponding return types declared in my typescript and used
leads to
With Array<>, I get a different error message:
leads to
To me, it looks like these error messages are conflicting. Is there something I'm overlooking? What is the recommended way to deal with RPC's returning JSON?
I have some rpc's that return JSON for use in my frontend. Previously, I had their corresponding return types declared in my typescript and used
.returns(MyType) - this worked well.
.returns no longer works and .overrideTypes is the new way. However, I can not get this to work with the existing RPC's:leads to
Error: "Type mismatch: Cannot cast array result to a single object. Use .overrideTypes<Array<YourType>> or .returns<Array<YourType>> (deprecated) for array results or .single() to convert the result to a single object";With Array<>, I get a different error message:
leads to
Type mismatch: Cannot cast single object to array type. Remove Array wrapper from return type or make sure you are not using .single() up in the calling chainTo me, it looks like these error messages are conflicting. Is there something I'm overlooking? What is the recommended way to deal with RPC's returning JSON?