import {FundingStrategy} from '@statechannels/client-api-schema'; import {Participant} from './types'; type _Objective = { 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 = (name: Objective['type']) => (o: Objective): o is T => o.type === name; export const isOpenChannel = guard('OpenChannel'); export const isVirtuallyFund = guard('VirtuallyFund'); export const isFundGuarantor = guard('FundGuarantor');