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

Convert all client responses to typed objects #771

Open
Eric-Warehime opened this issue Apr 26, 2023 · 2 comments
Open

Convert all client responses to typed objects #771

Eric-Warehime opened this issue Apr 26, 2023 · 2 comments
Assignees
Labels
new-feature-request Feature request that needs triage Team Lamprey

Comments

@Eric-Warehime
Copy link
Contributor

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

// eslint-disable-next-line class-methods-use-this
prepare(body: Record<string, any>): BoxesResponse {
return BoxesResponse.from_obj_for_encoding(body);
}
), 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.

@jasonpaulos
Copy link
Contributor

jasonpaulos commented May 3, 2023

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.

@Eric-Warehime
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-feature-request Feature request that needs triage Team Lamprey
Projects
None yet
Development

No branches or pull requests

3 participants
@jasonpaulos @Eric-Warehime and others