diff --git a/build.gradle b/build.gradle index 2956c47..514db26 100644 --- a/build.gradle +++ b/build.gradle @@ -27,7 +27,7 @@ repositories { // mavenLocal() } -final String headlongVersion = '10.0.2' +final String headlongVersion = '11.0.0' final String junitVersion = '5.10.1' final DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("MMMM d yyyy", Locale.ENGLISH).withZone(ZoneId.of("UTC")) diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index c90972f..c7bd667 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -6,7 +6,7 @@ - + diff --git a/pom.xml b/pom.xml index dc57dc3..0bd9156 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ -Dfile.encoding=UTF-8 UTF-8 MMMMM d yyyy - 10.0.2 + 11.0.0 5.10.1 diff --git a/src/main/java/com/esaulpaugh/headlong/cli/Main.java b/src/main/java/com/esaulpaugh/headlong/cli/Main.java index 027efb5..8af4b7e 100644 --- a/src/main/java/com/esaulpaugh/headlong/cli/Main.java +++ b/src/main/java/com/esaulpaugh/headlong/cli/Main.java @@ -22,7 +22,7 @@ import com.esaulpaugh.headlong.abi.Function; import com.esaulpaugh.headlong.abi.Tuple; import com.esaulpaugh.headlong.abi.TupleType; -import com.esaulpaugh.headlong.abi.util.Uint; +import com.esaulpaugh.headlong.util.Uint; import com.esaulpaugh.headlong.rlp.Notation; import com.esaulpaugh.headlong.rlp.RLPEncoder; import com.esaulpaugh.headlong.util.Strings; @@ -141,12 +141,12 @@ private static String validateCommand(String command) { private static String encodeABIPacked(String[] args, boolean machine) { final String signature = DATA_FIRST.from(args); final String values = parseVals(DATA_SECOND.from(args), machine, true); - final TupleType tt = TupleType.parse(signature); + final TupleType tt = TupleType.parse(signature); return Strings.encode(tt.encodePacked(SuperSerial.deserialize(tt, values, machine)).array()); } private static String decodeABIPacked(String[] args, boolean compact) { - final TupleType tt = TupleType.parse(DATA_FIRST.from(args)); + final TupleType tt = TupleType.parse(DATA_FIRST.from(args)); final byte[] packedAbi = Strings.decode(DATA_SECOND.from(args)); return compacted(SuperSerial.serialize(tt, tt.decodePacked(packedAbi), false), compact); } @@ -159,7 +159,7 @@ private static String encodeABI(String[] args, boolean machine, boolean function Function f = Function.parse(signature); abi = f.encodeCall(SuperSerial.deserialize(f.getInputs(), values, machine)); } else { - TupleType tt = TupleType.parse(signature); + TupleType tt = TupleType.parse(signature); abi = tt.encode(SuperSerial.deserialize(tt, values, machine)); } return Strings.encode(abi.array()); @@ -168,7 +168,7 @@ private static String encodeABI(String[] args, boolean machine, boolean function private static String decodeABI(String[] args, boolean machine, boolean function, boolean compact) { final String signature = DATA_FIRST.from(args); final byte[] abiBytes = Strings.decode(DATA_SECOND.from(args)); - final TupleType tt; + final TupleType tt; final Tuple values; if(function) { Function f = Function.parse(signature); diff --git a/src/test/java/com/esaulpaugh/headlong/cli/DesugarTest.java b/src/test/java/com/esaulpaugh/headlong/cli/DesugarTest.java index 80ba83e..0a3628a 100644 --- a/src/test/java/com/esaulpaugh/headlong/cli/DesugarTest.java +++ b/src/test/java/com/esaulpaugh/headlong/cli/DesugarTest.java @@ -16,6 +16,7 @@ package com.esaulpaugh.headlong.cli; import com.esaulpaugh.headlong.abi.Function; +import com.esaulpaugh.headlong.abi.Single; import com.esaulpaugh.headlong.abi.Tuple; import com.esaulpaugh.headlong.abi.TupleType; import com.esaulpaugh.headlong.util.FastHex; @@ -32,8 +33,8 @@ public class DesugarTest { @Test public void testBool() throws Throwable { TupleType tt = TupleType.parse("(bool)"); - Tuple _true = Tuple.of(true); - Tuple _false = Tuple.of(false); + Tuple _true = Single.of(true); + Tuple _false = Single.of(false); assertEquals("01", SuperSerial.serialize(tt, _true, true)); assertEquals("80", SuperSerial.serialize(tt, _false, true)); diff --git a/src/test/java/com/esaulpaugh/headlong/cli/MainTest.java b/src/test/java/com/esaulpaugh/headlong/cli/MainTest.java index 9c2ce83..f6459b7 100644 --- a/src/test/java/com/esaulpaugh/headlong/cli/MainTest.java +++ b/src/test/java/com/esaulpaugh/headlong/cli/MainTest.java @@ -20,6 +20,8 @@ import com.esaulpaugh.headlong.abi.ArrayType; import com.esaulpaugh.headlong.abi.ByteType; import com.esaulpaugh.headlong.abi.Function; +import com.esaulpaugh.headlong.abi.Single; +import com.esaulpaugh.headlong.abi.Triple; import com.esaulpaugh.headlong.abi.Tuple; import com.esaulpaugh.headlong.abi.TupleType; import com.esaulpaugh.headlong.abi.TypeFactory; @@ -59,7 +61,7 @@ public void testLenient() throws Throwable { + "0000000000000000000000000000000000000000000000000000000000000004" + "7730307400000000000000000000000000000000000000000000000000000000"); - assertThrown(IllegalArgumentException.class, "unsigned val exceeds bit limit: 254 > 19", () -> FUNCTION.decodeReturn(tooSmallOffset)); + assertThrown(IllegalArgumentException.class, "unsigned val exceeds bit limit: 254 > 21", () -> FUNCTION.decodeReturn(tooSmallOffset)); } private static final String SIGNATURE = "(function[2][][],bytes24,string[1][1],address[],uint72,(uint8),(int16)[2][][1],(int32)[],uint40,(int48)[],(uint),bool,string,bool[2],int24[],uint40[1])"; @@ -175,7 +177,7 @@ public void testDecode() { @Test public void testSerial() { - TupleType tt = TupleType.parse(SIGNATURE); + TupleType tt = TupleType.parse(SIGNATURE); byte[] func = Strings.decode("191c766e29a65787b7155dd05f41292438467db93420cade"); @@ -185,12 +187,12 @@ public void testSerial() { new String[][] { new String[] { "z" } }, new Address[] { Address.wrap("0xFF00eE01dd02cC03cafEBAbe9906880777086609") }, BigInteger.valueOf(Long.MAX_VALUE).multiply(BigInteger.valueOf(Byte.MAX_VALUE << 2)), - Tuple.of(7), - new Tuple[][][] { new Tuple[][] { new Tuple[] { Tuple.singleton(9), Tuple.singleton(-11) } } }, - new Tuple[] { Tuple.singleton(17), Tuple.singleton(-19) }, + Single.of(7), + new Tuple[][][] { new Tuple[][] { new Tuple[] { Single.of(9), Single.of(-11) } } }, + new Tuple[] { Single.of(17), Single.of(-19) }, Long.MAX_VALUE / 8_500_000, - new Tuple[] { Tuple.singleton((long) 0x7e), Tuple.singleton((long) -0x7e) }, - Tuple.singleton(BigInteger.TEN), + new Tuple[] { Single.of((long) 0x7e), Single.of((long) -0x7e) }, + Single.of(BigInteger.TEN), true, "farout", new boolean[] { true, true }, @@ -198,7 +200,7 @@ public void testSerial() { new long[] { Integer.MAX_VALUE * 2L } }; - Tuple tuple = Tuple.of(argsIn); + Tuple tuple = Tuple.from(argsIn); String str = SuperSerial.serialize(tt, tuple, false); Tuple deserial = SuperSerial.deserialize(tt, str, false); @@ -260,7 +262,7 @@ public void testHexToUtf8() throws Throwable { public void testTypeFactory() { final ABIType type = TypeFactory.create("string[]"); assertEquals(ABIType.TYPE_CODE_ARRAY, type.typeCode()); - final ArrayType, String[]> arrayType = TypeFactory.create("string[]"); + final ArrayType, String, String[]> arrayType = TypeFactory.create("string[]"); assertEquals(ArrayType.DYNAMIC_LENGTH, arrayType.getLength()); }