esaulpaugh / headlong

High-performance Contract ABI and RLP for Ethereum

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`TupleType.subTupleType` not unwrapping tuple of a single tuple

devictr opened this issue · comments

Hi,

I've noticed that this function, when called with on a Tuple that looks like this ((address,int256)) and this manifest: [true], will still return ((address,int256)) even though I would expect to get (address,int256).
I'd be happy to help fix this issue, if it is actually an issue 🙂

subtupleType with a manifest of all true values should return a TupleType equal to the input TupleType. An all-true manifest is similar to using str.substring(0, str.length()).

It was originally designed for separating indexed and non-indexed event parameters and isn't intended to treat TupleType elements differently compared to other elements.

I will see about adding some javadoc to it.

I may just rename the method if I can think of one more descriptive.

In addition to adding documentation, I have decided to rename TupleType::subTupleType to select and TupleType::subTupleTypeNegative to exclude.

Ah good to know! Thank you

I just added type inference to TupleType::get. Subtuples should now be accessible like this:

TupleType outer = TupleType.parse("((address,int256))");
TupleType inner = outer.get(0);
assertEquals(TupleType.parse("(address,int)"), inner);

Even better! Thanks