toByteArray method
Implementation
ByteArray toByteArray() => switch (this) {
CompiledMessageLegacy() => ByteArray.merge([
header.toByteArray(),
CompactArray.fromIterable(accountKeys.map((e) => e.toByteArray())).toByteArray(),
ByteArray.fromBase58(recentBlockhash),
CompactArray.fromIterable(instructions.map((e) => e.toByteArray())).toByteArray(),
]),
CompiledMessageV0(:final addressTableLookups) => ByteArray.merge([
ByteArray.u8(1 << 7),
header.toByteArray(),
CompactArray.fromIterable(accountKeys.map((e) => e.toByteArray())).toByteArray(),
ByteArray.fromBase58(recentBlockhash),
CompactArray.fromIterable(instructions.map((e) => e.toByteArray())).toByteArray(),
CompactArray.fromIterable(
addressTableLookups.map(
(e) => ByteArray.merge([
e.accountKey.toByteArray(),
CompactArray(ByteArray(e.writableIndexes)).toByteArray(),
CompactArray(ByteArray(e.readonlyIndexes)).toByteArray(),
]),
),
).toByteArray(),
]),
};