import { Message , Quantifier , QuantifierResult , SignedByDBInterface , SignedMessage , } from '../../types' ; import { deserializeMessage } from '../serialization' ; interface SignedByQuantifierParameters { address : string ; channelID ? : string ; } export class SignedByQuantifier implements Quantifier { constructor ( private readonly db , private readonly myAddress ) { } param signerParams public async getAllQuantified ( signerParams ) { let signedMessages = await this . db . getAllSignedBy ( signerParams . address ) ; if ( 'channelID' in signerParams && signerParams [ 'channelID' ] ) { signedMessages = signedMessages . filter ( ( m ) => { try { const message = deserializeMessage ( m . serializedMessage ) ; return signerParams . channelID === message . channelID ; } catch ( e ) { return false ; } } ) ; } return { results : signedMessages , allResultsQuantified : signerParams . address === this . myAddress , } ; } }