getLengthEncoded static method

Uint8List getLengthEncoded(
  1. Uint8List encoded
)

Take the first 2 bytes in the byte array (consider the byte array to be an encoding for ABI dynamic typed value) @param encoded an ABI encoding byte array @return the first 2 bytes of the ABI encoding byte array @throws IllegalArgumentException if the encoded byte array has length < 2

Implementation

static Uint8List getLengthEncoded(Uint8List encoded) {
  if (encoded.length < ABI_DYNAMIC_HEAD_BYTE_LEN) {
    throw ArgumentError('encode byte size too small, less than 2 bytes');
  }
  final encodedLength = Uint8List(ABI_DYNAMIC_HEAD_BYTE_LEN);
  Array.copy(encoded, 0, encodedLength, 0, ABI_DYNAMIC_HEAD_BYTE_LEN);
  return encodedLength;
}