import { FundingStrategy } from '@statechannels/client-api-schema' ; import { Participant } from './types' ; type _Objective < Name , Data > = { participants : Participant [ ] ; type : Name ; } & Data ; export type OpenChannel = _Objective < 'OpenChannel' , { targetChannelId : string ; fundingStrategy : FundingStrategy ; } > ; export type VirtuallyFund = _Objective < 'VirtuallyFund' , { targetChannelId : string ; jointChannelId : string ; } > ; export type FundGuarantor = _Objective < 'FundGuarantor' , { jointChannelId : string ; ledgerChannelId : string ; guarantorId : string ; } > ; export type Objective = OpenChannel | VirtuallyFund | FundGuarantor ; const guard = < T extends Objective > ( name ) => ( o ) : o is T => o . type === name ; export const isOpenChannel = guard < OpenChannel > ( 'OpenChannel' ) ; export const isVirtuallyFund = guard < VirtuallyFund > ( 'VirtuallyFund' ) ; export const isFundGuarantor = guard < FundGuarantor > ( 'FundGuarantor' ) ;