import { QueryResult } from '@aragon/connect-thegraph' ; import { VersionData } from '../../types' ; import Version from '../../models/Version' ; export function parseCurrentVersion ( result , connector ) { const agreement = result . data . agreement ; if ( ! agreement || ! agreement . currentVersion ) { throw new Error ( 'Unable to parse current version.' ) ; } return new Version ( agreement . currentVersion , connector ) ; } export function parseVersion ( result , connector ) { const version = result . data . version ; if ( ! version ) { throw new Error ( 'Unable to parse version.' ) ; } return new Version ( version , connector ) ; } export function parseVersions ( result , connector ) { const versions = result . data . versions ; if ( ! versions ) { throw new Error ( 'Unable to parse versions.' ) ; } return versions . map ( ( data ) => { return new Version ( data , connector ) ; } ) ; }