use of org.bcos.web3j.abi.datatypes.DynamicBytes in project web3sdk by FISCO-BCOS.
the class TypeDecoder method decodeDynamicBytes.
static DynamicBytes decodeDynamicBytes(String input, int offset) {
int encodedLength = decodeUintAsInt(input, offset);
int hexStringEncodedLength = encodedLength << 1;
int valueOffset = offset + MAX_BYTE_LENGTH_FOR_HEX_STRING;
String data = input.substring(valueOffset, valueOffset + hexStringEncodedLength);
byte[] bytes = Numeric.hexStringToByteArray(data);
return new DynamicBytes(bytes);
}
use of org.bcos.web3j.abi.datatypes.DynamicBytes in project web3sdk by FISCO-BCOS.
the class TypeDecoder method decodeUtf8String.
static Utf8String decodeUtf8String(String input, int offset) {
DynamicBytes dynamicBytesResult = decodeDynamicBytes(input, offset);
byte[] bytes = dynamicBytesResult.getValue();
return new Utf8String(new String(bytes, StandardCharsets.UTF_8));
}
Aggregations