js-algorand-sdk
js-algorand-sdk copied to clipboard
Convert all client responses to typed objects
Problem
Responses from the client are not automatically converted into the defined model types (for all endpoints).
We've done this for some endpoints (see https://github.com/algorand/js-algorand-sdk/blob/a89046acaf9502f496fca9d781bf33047c969c01/src/client/v2/algod/getApplicationBoxes.ts#L57-L60), but other endpoints, in order to avoid backwards incompatible changes, do not implement this (see https://github.com/algorand/js-algorand-sdk/blob/a89046acaf9502f496fca9d781bf33047c969c01/src/client/v2/algod/getApplicationByID.ts for example).
Solution
Implement the response.from_obj_for_encoding(body)
for all endpoints which return structured data.
Dependencies
N/A
Urgency
We should group this with any other breaking changes being made in the next major version bump.
If we want to make typed response objects available sooner, we could consider introducing a new set of functions that can be used in place of do
, e.g. doTyped
or execute
, which would return a typed response. We could then consider deprecating and removing do
in v3 -- this would arguably be a safer way of swapping the behavior, since instead of changing a function's return type, we'd be removing the function in favor of a different one.
An additional issue to consider w/ this mentioned in #533 is handling the conversion of the returned keys which include hyphens to the JS camel case keys.