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

Automatically parse String responses #274

Closed
lock9 opened this issue Mar 31, 2023 · 4 comments
Closed

Automatically parse String responses #274

lock9 opened this issue Mar 31, 2023 · 4 comments

Comments

@lock9
Copy link
Contributor

lock9 commented Mar 31, 2023

Currently, when a method with a return type of "String" is called in Neo Express, the returned value is displayed in hexadecimal format. For instance, the "symbol" method returns "4c494e4b44" instead of the expected value "LINKD".

To fix this, I suggest adding a feature that automatically converts string return types to UTF-8 before displaying them. This would make it easier for developers to read and interpret the output of methods that return strings.

For instance, the "symbol" method in the contract's manifest specifies that it returns a string, as shown in the code snippet below:

{
    "name": "symbol",
    "offset": 0,
    "parameters": [],
    "returntype": "String",
    "safe": true
}

However, the current output of the method is in hexadecimal format, which can be difficult to read and interpret:
Screenshot 2023-03-31 at 10 11 31

I suggest that neo-express (and related tools) convert hex to UTF-8, when the method return type is String

@chenzhitong
Copy link
Member

chenzhitong commented Nov 2, 2023

If the return value is 2222, then what will be displayed, display "" or \"\"?

If the former, it will make the json error, if the latter, it will lose the meaning of the conversion.
I suggest this tool for conversion https://neo.org/converter/index

@lock9
Copy link
Contributor Author

lock9 commented Nov 6, 2023

If the method return type is a string, can't we convert it to utf-8?
We don't need the extra quotes. What if we print the result between line breaks?

@cschuchardt88
Copy link
Member

Its just almost all things in the vm are stored as bytes. It was just a lazy way to display generic data, instead of parsing or validating it. Not checking the contract method return type is the problem.

@cschuchardt88
Copy link
Member

@lock9
I believe #316 does fix this issue? If so can we close?

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

No branches or pull requests

3 participants