import { InvalidFormatError } from '@neo-one/client-common' ; import { InvalidActionTypeError } from '../errors' ; export enum ActionType { Log = 0x00 , Notification = 0x01 } const isActionType = ( value ) : value is ActionType => ActionType [ value ] !== undefined ; export const assertActionType = ( value ) : ActionType => { if ( isActionType ( value ) ) { return value ; } throw new InvalidActionTypeError ( value ) ; } ; export enum ActionSource { Block = 0x00 , Transaction = 0x01 } type ActionSourceJSON = keyof typeof ActionSource ; const isActionSourceJSON = ( source ) : source is ActionSourceJSON => ActionSource [ source as any ] !== undefined ; const assertActionSourceJSON = ( source ) : ActionSourceJSON => { if ( isActionSourceJSON ( source ) ) { return source ; } throw new InvalidFormatError ( ) ; } ; export const actionSourceToJSON = ( source ) => assertActionSourceJSON ( ActionSource [ source ] ) ;