import { ArrayContractParameterJSON , BinaryWriter , IOHelper , utils } from '@neo-one/client-common' ; import { ContractParameter } from './ContractParameter' ; import { ContractParameterBase } from './ContractParameterBase' ; import { ContractParameterType } from './ContractParameterType' ; export class ArrayContractParameter extends ContractParameterBase < ArrayContractParameter , ArrayContractParameterJSON , ContractParameterType . Array > { public readonly type = ContractParameterType . Array ; public readonly value : readonly ContractParameter [ ] ; private readonly sizeInternal : ( ) => number ; public constructor ( value ) { super ( ) ; this . value = value ; this . sizeInternal = utils . lazy ( ( ) => IOHelper . sizeOfArray ( this . value , ( val ) => val . size ) ) ; } public get size ( ) : number { return this . sizeInternal ( ) ; } public asBoolean ( ) { return this . value . length > 0 ; } public serializeWireBase ( writer ) { super . serializeWireBase ( writer ) ; writer . writeArray ( this . value , ( parameter ) => parameter . serializeWireBase ( writer ) ) ; } public serializeJSON ( ) { return { type : 'Array' , value : this . value . map ( ( val ) => val . serializeJSON ( ) ) } ; } }