assertByteArrayIsNotEmptyForCodec function

void assertByteArrayIsNotEmptyForCodec(
  1. String codecDescription,
  2. Uint8List bytes, [
  3. int offset = 0
])

Asserts that the byte array is not empty after the optional offset.

Throws a SolanaError with code SolanaErrorCode.codecsCannotDecodeEmptyByteArray if the byte array has no bytes remaining after offset.

Implementation

void assertByteArrayIsNotEmptyForCodec(
  String codecDescription,
  Uint8List bytes, [
  int offset = 0,
]) {
  if (bytes.length - offset <= 0) {
    throw SolanaError(SolanaErrorCode.codecsCannotDecodeEmptyByteArray, {
      'codecDescription': codecDescription,
    });
  }
}