Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Decoding multiple return strings error #21

Closed
mawenpeng opened this issue Nov 23, 2016 · 4 comments
Closed

Decoding multiple return strings error #21

mawenpeng opened this issue Nov 23, 2016 · 4 comments

Comments

@mawenpeng
Copy link
Contributor

mawenpeng commented Nov 23, 2016

The code on the bottom should decode the return value of contract function function read(string globalName, uint i) returns (string vid, string pid, string suk, string vuk) as:

def1
ghi1
jkl1
mno2

but shows:

def1
jkl1

Did I miss anything?
Thanks,
Jonathan

List<Type> inputParams=new ArrayList<Type>();
List<TypeReference<?>> outputParams=new ArrayList<TypeReference<?>>();
inputParams.add(new Utf8String("abc"));
inputParams.add(new Uint(BigInteger.valueOf(1)));
 outputParams.add(new TypeReference<Utf8String>() { });
outputParams.add(new TypeReference<Utf8String>() { });
outputParams.add(new TypeReference<Utf8String>() { });
outputParams.add(new TypeReference<Utf8String>() { });
Function function = new Function("read",inputParams,outputParams);
String encodedFunction = FunctionEncoder.encode(function);
System.out.println("encodedFunction: "+encodedFunction);


List<Type> list=FunctionReturnDecoder.decode("0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000464656631000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004676869310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000046a6b6c310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000046d6e6f3200000000000000000000000000000000000000000000000000000000", function.getOutputParameters());
System.out.println(list.size());
for(int i=0;i<list.size();i++)
{
            System.out.println(i+":"+((Utf8String)(list.get(i))).getValue().toString());
 }


@mawenpeng
Copy link
Contributor Author

Looks like some issues with the offset Web3j API code.
Thanks.

@Quiark
Copy link

Quiark commented Nov 24, 2016

Yeah, decoding is buggy.

@conor10
Copy link
Contributor

conor10 commented Nov 24, 2016

Issue is resolved. Will push out a new release in the next day or so.

@Quiark are you seeing any other issues with ABI decoding?

@conor10 conor10 closed this as completed Nov 24, 2016
@mawenpeng
Copy link
Contributor Author

Thanks Conor for the quick fix.

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

No branches or pull requests

3 participants