Kit
Functions

assertByteArrayIsNotEmptyForCodec

assertByteArrayIsNotEmptyForCodec(codecDescription, bytes, offset?): void

Asserts that a given byte array is not empty (after the optional provided offset).

Returns void if the byte array is not empty but throws a SolanaError otherwise.

Parameters

ParameterTypeDescription
codecDescriptionstringA description of the codec used by the assertion error.
bytesUint8Array<ArrayBufferLike> | ReadonlyUint8ArrayThe byte array to check.
offset?numberThe offset from which to start checking the byte array. If provided, the byte array is considered empty if it has no bytes after the offset.

Returns

void

Example

const bytes = new Uint8Array([0x01, 0x02, 0x03]);
assertByteArrayIsNotEmptyForCodec('myCodec', bytes); // OK
assertByteArrayIsNotEmptyForCodec('myCodec', bytes, 1); // OK
assertByteArrayIsNotEmptyForCodec('myCodec', bytes, 3); // Throws

On this page