import { Assignable , SCHEMA } from '../solanaBorsh' ; import { MessageData } from './MessageData' ; import { DEFAULT_MAX_MESSAGE_COUNT , MESSAGE_SIZE_BYTES } from '../../constants' ; export class ChannelData extends Assignable { name : string ; messages : MessageData [ ] ; static fromAccount ( accountData ) { return ChannelData . decode < ChannelData > ( accountData ) ; } static empty ( name ) { return new ChannelData ( { name , messages : [ ] , } ) ; } static sizeBytes ( ) { return MESSAGE_SIZE_BYTES * DEFAULT_MAX_MESSAGE_COUNT + 64 ; } } SCHEMA . set ( ChannelData , { kind : 'struct' , fields : [ [ 'name' , 'string' ] , [ 'messages' , [ MessageData ] ] , ] , } ) ;