Skip to content

Commit

Permalink
use headlong v11.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
esaulpaugh committed Feb 4, 2024
1 parent 304c6ca commit 7d768db
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"))

Expand Down
2 changes: 1 addition & 1 deletion gradle/verification-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<key-servers enabled="true"/>
<trusted-keys>
<trusted-key id="c7be5bcc9fec15518cfda882b0f3710fa64900e7" group="com.google.code.gson"/>
<trusted-key id="d2ea6bcd43b3663cdf6222c135ae09fd38f0cfae" group="com.esaulpaugh" name="headlong" version="10.0.2"/><!-- *** REMEMBER TO UPDATE VERSION ** -->
<trusted-key id="d2ea6bcd43b3663cdf6222c135ae09fd38f0cfae" group="com.esaulpaugh" name="headlong" version="11.0.0"/><!-- *** REMEMBER TO UPDATE VERSION ** -->
<trusted-key id="ff6e2c001948c5f2f38b0cc385911f425ec61b51">
<trusting group="^org[.]junit($|([.].*))" regex="true"/>
<trusting group="org.opentest4j"/>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<argLine>-Dfile.encoding=UTF-8</argLine>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.build.timestamp.format>MMMMM d yyyy</maven.build.timestamp.format>
<headlong.version>10.0.2</headlong.version>
<headlong.version>11.0.0</headlong.version>
<junit.version>5.10.1</junit.version>
</properties>

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/esaulpaugh/headlong/cli/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Tuple> 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<Tuple> 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);
}
Expand All @@ -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<Tuple> tt = TupleType.parse(signature);
abi = tt.encode(SuperSerial.deserialize(tt, values, machine));
}
return Strings.encode(abi.array());
Expand All @@ -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<Tuple> tt;
final Tuple values;
if(function) {
Function f = Function.parse(signature);
Expand Down
5 changes: 3 additions & 2 deletions src/test/java/com/esaulpaugh/headlong/cli/DesugarTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
Expand Down
20 changes: 11 additions & 9 deletions src/test/java/com/esaulpaugh/headlong/cli/MainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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])";
Expand Down Expand Up @@ -175,7 +177,7 @@ public void testDecode() {
@Test
public void testSerial() {

TupleType tt = TupleType.parse(SIGNATURE);
TupleType<Tuple> tt = TupleType.parse(SIGNATURE);

byte[] func = Strings.decode("191c766e29a65787b7155dd05f41292438467db93420cade");

Expand All @@ -185,20 +187,20 @@ 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 },
new int[] { 3, 20, -6 },
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);
Expand Down Expand Up @@ -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<ArrayType<ByteType, String>, String[]> arrayType = TypeFactory.create("string[]");
final ArrayType<ArrayType<ByteType, Byte, String>, String, String[]> arrayType = TypeFactory.create("string[]");
assertEquals(ArrayType.DYNAMIC_LENGTH, arrayType.getLength());
}

Expand Down

0 comments on commit 7d768db

Please sign in to comment.