File tree 1 file changed +6
-1
lines changed
abi/src/main/java/org/web3j/abi
1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -101,8 +101,10 @@ public static String encode(Type parameter) {
101
101
*/
102
102
public static String encodePacked (Type parameter ) {
103
103
if (parameter instanceof Utf8String ) {
104
- return removePadding (encode (parameter ), parameter );
104
+ //removePadding can also be used, but is not necessary
105
+ return Numeric .toHexStringNoPrefix (((Utf8String ) parameter ).getValue ().getBytes (StandardCharsets .UTF_8 ));
105
106
} else if (parameter instanceof DynamicBytes ) {
107
+ //removePadding can also be used, but is not necessary
106
108
return Numeric .toHexStringNoPrefix (((DynamicBytes ) parameter ).getValue ());
107
109
} else if (parameter instanceof DynamicArray ) {
108
110
return arrayEncodePacked ((DynamicArray ) parameter );
@@ -140,6 +142,9 @@ static String removePadding(String encodedValue, Type parameter) {
140
142
int length =
141
143
((Utf8String ) parameter ).getValue ().getBytes (StandardCharsets .UTF_8 ).length ;
142
144
return encodedValue .substring (64 , 64 + length * 2 );
145
+ }
146
+ if (parameter instanceof DynamicBytes ) {
147
+ return encodedValue .substring (64 , 64 + ((DynamicBytes ) parameter ).getValue ().length * 2 );
143
148
} else {
144
149
throw new UnsupportedOperationException (
145
150
"Type cannot be encoded: " + parameter .getClass ());
You can’t perform that action at this time.
0 commit comments