From 15ce979b486f439d5e809d2c2fb85ec070257008 Mon Sep 17 00:00:00 2001 From: Evan Saulpaugh Date: Thu, 24 Mar 2022 17:04:13 -0500 Subject: [PATCH] add decodeCall method to Function which accepts indices --- .../java/com/esaulpaugh/headlong/abi/Function.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/esaulpaugh/headlong/abi/Function.java b/src/main/java/com/esaulpaugh/headlong/abi/Function.java index c71f7b3e8..e211de4c1 100644 --- a/src/main/java/com/esaulpaugh/headlong/abi/Function.java +++ b/src/main/java/com/esaulpaugh/headlong/abi/Function.java @@ -227,10 +227,20 @@ public Tuple decodeCall(byte[] call) { * @return the decoded arguments */ public Tuple decodeCall(ByteBuffer abiBuffer) { + return inputTypes.decode(abiBuffer, checkSelector(abiBuffer)); + } + + public T decodeCall(byte[] call, int... indices) { + ByteBuffer bb = ByteBuffer.wrap(call); + checkSelector(bb); + return inputTypes.decode(bb, indices); + } + + private byte[] checkSelector(ByteBuffer bb) { final byte[] unitBuffer = ABIType.newUnitBuffer(); - abiBuffer.get(unitBuffer, 0, SELECTOR_LEN); + bb.get(unitBuffer, 0, SELECTOR_LEN); checkSelector(unitBuffer); - return inputTypes.decode(abiBuffer, unitBuffer); // unitBuffer contents are ignored, overwritten during decode + return unitBuffer; // unitBuffer contents are ignored, overwritten during decode } private void checkSelector(byte[] buffer) {