Skip to content

Commit

Permalink
reintroduce support for dynamic types
Browse files Browse the repository at this point in the history
  • Loading branch information
rvullriede committed Feb 13, 2024
1 parent 65b3dc2 commit 25fe8cb
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>net.osslabz</groupId>
<artifactId>evm-abi-decoder</artifactId>
<version>0.0.9</version>
<version>0.0.10</version>

<name>${project.groupId}:${project.artifactId}</name>
<description>Allows to decode raw input data from an EVM smart contract call (on Ethereum or a compatible chain like
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,11 @@ public TupleType() {

@Override
public boolean isDynamicType() {
return false;
return containsDynamicTypes();
}

private boolean containsDynamicTypes(){
return types.stream().anyMatch(SolidityType::isDynamicType);
}

@Override
Expand Down
24 changes: 24 additions & 0 deletions src/test/java/net/osslabz/evm/abi/AbiDecoderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,30 @@ public void testDecodeFunctionCallUniswapV3SwapRouter02Swap() throws IOException
List<DecodedFunctionCall> decodedFunctionCalls = uniswapv3SwapRouter02Abi.decodeFunctionsCalls(inputData);


int i = 0;
for (DecodedFunctionCall func : decodedFunctionCalls) {
log.debug("{}: function: {}", i, func.getName());
int p = 0;
for (DecodedFunctionCall.Param param : func.getParams()) {
log.debug("param {}: name={}, type={}, value={}", p, param.getName(), param.getType(), param.getValue());
p++;
}
i++;
log.debug("-------------------------");
}
}

@Test
public void testDecodeFunctionCallTupleContainingDynamicTypes() throws IOException {

// https://api-testnet.bscscan.com/api?module=contract&action=getabi&address=0xb7564227245bb161ebf4d350e1056c26801f1366&format=raw
File abiJson = new File(this.getClass().getResource("/abiFiles/SereshForwarder.json").getPath());
AbiDecoder sereshForwarderAbi = new AbiDecoder(abiJson.getAbsolutePath());

// https://testnet.bscscan.com/tx/0x73b80d49777f0c32d45a0a5a7c3487eb9e8da2c93922540c260cdafc3e81a165
String inputData = "0x005575f20000000000000000000000000000000000000000000000000000000000000080967c9812e5f939318262ccbd023be072015c3ad2f470d47ab5e6b13e1ca810a540274bf9ce7b9da08b0003fc05e67d74e993f3381bf00bcba0fef022bf3b8d6a000000000000000000000000000000000000000000000000000000000000001b000000000000000000000000ddcfc6f09a26413c2b0d6224b29738e74102de04000000000000000000000000cbb869911c0acd242c15a03c42ce3ddcdd82ea1b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000038d7ea4c68000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001e4216f62d8000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000003b6261666b7265696263796c746f36667974667336746f796f6f716f6b6272366e333566673767683236646e6f3464766a716c6d743464687a34716d0000000000000000000000000000000000000000000000000000000000000000000000003b6261666b726569647533356c64727965703433797574337275616a747936743278346b3773787077737365347572616b7676366d723763657a696d0000000000000000000000000000000000000000000000000000000000000000000000003b6261666b7265696567616e657563727a6e646b6676726a64346a63346235356174646b707475326d6d3779327372783235617068626b623666373400000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000ddcfc6f09a26413c2b0d6224b29738e74102de0400000000000000000000000000000000000000000000000000000000";
List<DecodedFunctionCall> decodedFunctionCalls = sereshForwarderAbi.decodeFunctionsCalls(inputData);

int i = 0;
for (DecodedFunctionCall func : decodedFunctionCalls) {
log.debug("{}: function: {}", i, func.getName());
Expand Down

0 comments on commit 25fe8cb

Please sign in to comment.