neo-express icon indicating copy to clipboard operation
neo-express copied to clipboard

Automatically parse String responses

Open lock9 opened this issue 2 years ago • 4 comments

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

lock9 avatar Mar 31 '23 13:03 lock9

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

chenzhitong avatar Nov 02 '23 05:11 chenzhitong

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?

lock9 avatar Nov 06 '23 01:11 lock9

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 avatar Nov 06 '23 02:11 cschuchardt88

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

cschuchardt88 avatar Nov 23 '23 09:11 cschuchardt88