Skip to content

Commit

Permalink
release/4.11.3
Browse files Browse the repository at this point in the history
Signed-off-by: Nischal Sharma <[email protected]>
  • Loading branch information
NickSneo committed May 1, 2024
1 parent 601d57c commit 4f3ee9c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 21 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Java:
<dependency>
<groupId>org.web3j</groupId>
<artifactId>core</artifactId>
<version>4.11.2</version>
<version>4.11.3</version>
</dependency>
```

Expand All @@ -138,7 +138,7 @@ Gradle
Java:

```groovy
implementation ('org.web3j:core:4.11.2')
implementation ('org.web3j:core:4.11.3')
```

Android:
Expand Down
10 changes: 6 additions & 4 deletions abi/src/main/java/org/web3j/abi/TypeEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,11 @@ public static String encode(Type parameter) {
*/
public static String encodePacked(Type parameter) {
if (parameter instanceof Utf8String) {
//removePadding can also be used, but is not necessary
return Numeric.toHexStringNoPrefix(((Utf8String) parameter).getValue().getBytes(StandardCharsets.UTF_8));
// removePadding can also be used, but is not necessary
return Numeric.toHexStringNoPrefix(
((Utf8String) parameter).getValue().getBytes(StandardCharsets.UTF_8));
} else if (parameter instanceof DynamicBytes) {
//removePadding can also be used, but is not necessary
// removePadding can also be used, but is not necessary
return Numeric.toHexStringNoPrefix(((DynamicBytes) parameter).getValue());
} else if (parameter instanceof DynamicArray) {
return arrayEncodePacked((DynamicArray) parameter);
Expand Down Expand Up @@ -144,7 +145,8 @@ static String removePadding(String encodedValue, Type parameter) {
return encodedValue.substring(64, 64 + length * 2);
}
if (parameter instanceof DynamicBytes) {
return encodedValue.substring(64, 64 + ((DynamicBytes) parameter).getValue().length * 2);
return encodedValue.substring(
64, 64 + ((DynamicBytes) parameter).getValue().length * 2);
} else {
throw new UnsupportedOperationException(
"Type cannot be encoded: " + parameter.getClass());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ public void testEncodeConstructorPacked_multipleParameters() {
Arrays.asList(
new Uint32(BigInteger.valueOf(69)),
new Bool(true),
new DynamicBytes((new byte[]{0, 1, 2, 3, 4, 5})))));
new DynamicBytes((new byte[] {0, 1, 2, 3, 4, 5})))));
assertEquals(
"12000102030405",
FunctionEncoder.encodeConstructorPacked(
Arrays.asList(
new DynamicBytes(Numeric.hexStringToByteArray("0x12")),
new DynamicBytes((new byte[]{0, 1, 2, 3, 4, 5})))));
new DynamicBytes((new byte[] {0, 1, 2, 3, 4, 5})))));
}

@Test
Expand Down
16 changes: 4 additions & 12 deletions abi/src/test/java/org/web3j/abi/TypeEncoderPackedTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -904,24 +904,16 @@ public void testStaticArrayEncodePacked() {
@Test
public void testDynamicBytesEncodePacked() {
DynamicBytes dynamicBytes = new DynamicBytes(new byte[] {0, 1, 2, 3, 4, 5});
assertEquals(
"000102030405",
TypeEncoder.encodePacked(dynamicBytes));
assertEquals("000102030405", TypeEncoder.encodePacked(dynamicBytes));

DynamicBytes zero = new DynamicBytes(new byte[] {0});
assertEquals(
"00",
TypeEncoder.encodePacked(zero));
assertEquals("00", TypeEncoder.encodePacked(zero));

DynamicBytes empty = new DynamicBytes(new byte[] {});
assertEquals(
"",
TypeEncoder.encodePacked(empty));
assertEquals("", TypeEncoder.encodePacked(empty));

DynamicBytes dave = new DynamicBytes("dave".getBytes());
assertEquals(
"64617665",
TypeEncoder.encodePacked(dave));
assertEquals("64617665", TypeEncoder.encodePacked(dave));

DynamicBytes loremIpsum =
new DynamicBytes(
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
group=org.web3j
version=4.11.3-SNAPSHOT
version=4.11.3

0 comments on commit 4f3ee9c

Please sign in to comment.