From 54488e7cb529e3f5975c1db4030c762a90ff183d Mon Sep 17 00:00:00 2001 From: Raphael Vullriede Date: Wed, 8 Nov 2023 14:42:21 +0100 Subject: [PATCH] Revert "fix unable to parse tuples containing dynamic types" --- .../evm/abi/definition/SolidityType.java | 8 +- .../net/osslabz/evm/abi/AbiDecoderTest.java | 23 -- .../resources/abiFiles/SereshForwarder.json | 263 ------------------ 3 files changed, 2 insertions(+), 292 deletions(-) delete mode 100644 src/test/resources/abiFiles/SereshForwarder.json diff --git a/src/main/java/net/osslabz/evm/abi/definition/SolidityType.java b/src/main/java/net/osslabz/evm/abi/definition/SolidityType.java index 17f6ef0..a8dcf56 100644 --- a/src/main/java/net/osslabz/evm/abi/definition/SolidityType.java +++ b/src/main/java/net/osslabz/evm/abi/definition/SolidityType.java @@ -477,11 +477,7 @@ public TupleType() { @Override public boolean isDynamicType() { - return containsDynamicTypes(); - } - - private boolean containsDynamicTypes(){ - return types.stream().anyMatch(SolidityType::isDynamicType); + return false; } @Override @@ -519,4 +515,4 @@ public byte[] encode(Object value) { return super.encode(ByteUtil.merge((byte[]) value, new byte[8])); } } -} +} \ No newline at end of file diff --git a/src/test/java/net/osslabz/evm/abi/AbiDecoderTest.java b/src/test/java/net/osslabz/evm/abi/AbiDecoderTest.java index 94936ea..9f285ec 100644 --- a/src/test/java/net/osslabz/evm/abi/AbiDecoderTest.java +++ b/src/test/java/net/osslabz/evm/abi/AbiDecoderTest.java @@ -126,29 +126,6 @@ public void testDecodeFunctionCallUniswapV3SwapRouter02Swap() throws IOException List 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 - AbiDecoder sereshForwarderAbi = new AbiDecoder(this.getClass().getResource("/abiFiles/SereshForwarder.json").getFile()); - - // https://testnet.bscscan.com/tx/0x73b80d49777f0c32d45a0a5a7c3487eb9e8da2c93922540c260cdafc3e81a165 - String inputData = "0x005575f20000000000000000000000000000000000000000000000000000000000000080967c9812e5f939318262ccbd023be072015c3ad2f470d47ab5e6b13e1ca810a540274bf9ce7b9da08b0003fc05e67d74e993f3381bf00bcba0fef022bf3b8d6a000000000000000000000000000000000000000000000000000000000000001b000000000000000000000000ddcfc6f09a26413c2b0d6224b29738e74102de04000000000000000000000000cbb869911c0acd242c15a03c42ce3ddcdd82ea1b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000038d7ea4c68000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001e4216f62d8000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000003b6261666b7265696263796c746f36667974667336746f796f6f716f6b6272366e333566673767683236646e6f3464766a716c6d743464687a34716d0000000000000000000000000000000000000000000000000000000000000000000000003b6261666b726569647533356c64727965703433797574337275616a747936743278346b3773787077737365347572616b7676366d723763657a696d0000000000000000000000000000000000000000000000000000000000000000000000003b6261666b7265696567616e657563727a6e646b6676726a64346a63346235356174646b707475326d6d3779327372783235617068626b623666373400000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000ddcfc6f09a26413c2b0d6224b29738e74102de0400000000000000000000000000000000000000000000000000000000"; - List decodedFunctionCalls = sereshForwarderAbi.decodeFunctionsCalls(inputData); - int i = 0; for (DecodedFunctionCall func : decodedFunctionCalls) { log.debug("{}: function: {}", i, func.getName()); diff --git a/src/test/resources/abiFiles/SereshForwarder.json b/src/test/resources/abiFiles/SereshForwarder.json deleted file mode 100644 index 5daea06..0000000 --- a/src/test/resources/abiFiles/SereshForwarder.json +++ /dev/null @@ -1,263 +0,0 @@ -[ - { - "inputs": [ - { - "internalType": "uint256", - "name": "_chainId", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, { - "inputs": [], - "name": "InvalidShortString", - "type": "error" -}, { - "inputs": [ - { - "internalType": "string", - "name": "str", - "type": "string" - } - ], - "name": "StringTooLong", - "type": "error" -}, { - "anonymous": false, - "inputs": [], - "name": "EIP712DomainChanged", - "type": "event" -}, { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "previousOwner", - "type": "address" - }, { - "indexed": true, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnershipTransferred", - "type": "event" -}, { - "inputs": [], - "name": "chainId", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" -}, { - "inputs": [], - "name": "eip712Domain", - "outputs": [ - { - "internalType": "bytes1", - "name": "fields", - "type": "bytes1" - }, { - "internalType": "string", - "name": "name", - "type": "string" - }, { - "internalType": "string", - "name": "version", - "type": "string" - }, { - "internalType": "uint256", - "name": "chainId", - "type": "uint256" - }, { - "internalType": "address", - "name": "verifyingContract", - "type": "address" - }, { - "internalType": "bytes32", - "name": "salt", - "type": "bytes32" - }, { - "internalType": "uint256[]", - "name": "extensions", - "type": "uint256[]" - } - ], - "stateMutability": "view", - "type": "function" -}, { - "inputs": [ - { - "components": [ - { - "internalType": "address", - "name": "from", - "type": "address" - }, { - "internalType": "address", - "name": "to", - "type": "address" - }, { - "internalType": "uint256", - "name": "value", - "type": "uint256" - }, { - "internalType": "uint256", - "name": "gas", - "type": "uint256" - }, { - "internalType": "uint256", - "name": "nonce", - "type": "uint256" - }, { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "internalType": "struct SereshForwarder.ForwardRequest", - "name": "req", - "type": "tuple" - }, { - "internalType": "bytes32", - "name": "sigR", - "type": "bytes32" - }, { - "internalType": "bytes32", - "name": "sigS", - "type": "bytes32" - }, { - "internalType": "uint8", - "name": "sigV", - "type": "uint8" - } - ], - "name": "execute", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - }, { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "stateMutability": "payable", - "type": "function" -}, { - "inputs": [ - { - "internalType": "address", - "name": "from", - "type": "address" - } - ], - "name": "getNonce", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" -}, { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" -}, { - "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" -}, { - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" -}, { - "inputs": [ - { - "components": [ - { - "internalType": "address", - "name": "from", - "type": "address" - }, { - "internalType": "address", - "name": "to", - "type": "address" - }, { - "internalType": "uint256", - "name": "value", - "type": "uint256" - }, { - "internalType": "uint256", - "name": "gas", - "type": "uint256" - }, { - "internalType": "uint256", - "name": "nonce", - "type": "uint256" - }, { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "internalType": "struct SereshForwarder.ForwardRequest", - "name": "req", - "type": "tuple" - }, { - "internalType": "bytes32", - "name": "sigR", - "type": "bytes32" - }, { - "internalType": "bytes32", - "name": "sigS", - "type": "bytes32" - }, { - "internalType": "uint8", - "name": "sigV", - "type": "uint8" - } - ], - "name": "verify", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" -} -]