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

Decode API responses #291

Closed
9 tasks
agraebe opened this issue Oct 13, 2020 · 6 comments
Closed
9 tasks

Decode API responses #291

agraebe opened this issue Oct 13, 2020 · 6 comments
Labels
enhancement New feature or request

Comments

@agraebe
Copy link
Contributor

agraebe commented Oct 13, 2020

Currently, the API returns encoded strings in multiple places. These need to be decoded in tooling manually and are hard to read. A developer, for instance, couldn't easily verify if a response is correct or not. It makes the development cycle longer as it should be. We could add a layer of abstraction to our endpoints to decode Clarity values by default with additional repr fields.

Here is a list of endpoints that currently expose encoded hex strings in one of the fields:

@agraebe agraebe added the enhancement New feature or request label Oct 13, 2020
@zone117x
Copy link
Member

My preference would be adding a repr sibling field, and have it there by default without any params required.
For example:

{
  "output": "0xabcf...",
  "output_repr": "(int 3)",
}

@zone117x
Copy link
Member

Also note, I don't think we have defined JSON encoding for Clarity values. For example, a Clarity tuple can have an easily human readable string format, while being just as difficult to use programmatically as decoding a hex string.

We could define a JSON Clarity encoding, something like an extension of the json ABI schema but with additional fields for the literal values?

@agraebe
Copy link
Contributor Author

agraebe commented Oct 16, 2020

Ah, nice! The repr field works as well (updated the issue description to cover that). We already use that in some places. Also like the idea of a JSON Clarity encoding!

@stale
Copy link

stale bot commented Apr 14, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 14, 2021
@agraebe agraebe removed the stale label Apr 15, 2021
@zone117x
Copy link
Member

I looked through the referenced endpoints and all the non-proxied endpoints appear to have repr properties now.

For the proxied endpoints, the API would have to make a bunch of semi-redundant wrapper endpoints around the /v2/* paths to add repr properties.
For example /v2/contracts/call-read/{contract_address}/{contract_name}/{function_name} would need something like /extended/v2_wrapper/contracts/call-read/{contract_address}/{contract_name}/{function_name}. I don't think that approach is a good idea. It seems like the stacks-node API should implement these changes itself, because the alternatives seem like bandaids.

@agraebe
Copy link
Contributor Author

agraebe commented Jul 13, 2021

would you like to propose this through an issue on their repo and close out the issue in this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants