import { BN } from 'bn.js' ; import { BinaryWriter } from '../../../BinaryWriter' ; import { IOHelper } from '../../../IOHelper' ; import { JSONHelper } from '../../../JSONHelper' ; import { OracleResponseJSON } from '../../../models/types' ; import { AttributeBaseModel } from './AttributeBaseModel' ; import { AttributeTypeModel } from './AttributeTypeModel' ; import { OracleResponseCode } from './OracleResponseCode' ; export interface OracleResponseModelAdd { readonly id : BN ; readonly code : OracleResponseCode ; readonly result : Buffer ; } export class OracleResponseModel extends AttributeBaseModel { public readonly type = AttributeTypeModel . OracleResponse ; public readonly allowMultiple = false ; public readonly id : BN ; public readonly code : OracleResponseCode ; public readonly result : Buffer ; public constructor ( { id , code , result } ) { super ( ) ; this . id = id ; this . code = code ; this . result = result ; } public serializeJSON ( ) { return { type : 'OracleResponse' , id : this . id . toString ( ) , code : this . code , result : JSONHelper . writeBase64Buffer ( this . result ) } ; } protected serializeWithoutTypeBase ( writer ) { writer . writeUInt64LE ( this . id ) ; writer . writeUInt8 ( this . code ) ; writer . writeVarBytesLE ( this . result ) ; } protected sizeExclusive ( ) { return IOHelper . sizeOfUInt64LE + IOHelper . sizeOfUInt8 + IOHelper . sizeOfVarBytesLE ( this . result ) ; } }