Skip to content

Commit

Permalink
Bug fix for BytesType.bytes32PaddedLength
Browse files Browse the repository at this point in the history
  • Loading branch information
junsung-cho committed Jul 25, 2024
1 parent 8d9e8ee commit ac871cb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions abi/src/main/java/org/web3j/abi/datatypes/BytesType.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ public BytesType(byte[] src, String type) {

@Override
public int bytes32PaddedLength() {
return value.length <= 32
? MAX_BYTE_LENGTH
: (value.length / MAX_BYTE_LENGTH + 1) * MAX_BYTE_LENGTH;
if (value.length < MAX_BYTE_LENGTH) {
return MAX_BYTE_LENGTH;
} else if (value.length % MAX_BYTE_LENGTH == 0) {
return value.length;
} else {
return (value.length / MAX_BYTE_LENGTH + 1) * MAX_BYTE_LENGTH;
}
}

@Override
Expand Down

0 comments on commit ac871cb

Please sign in to comment.