import { InvalidFormatError } from './common' ; import { InvalidDesignationRoleError } from './errors' ; export enum DesignationRole { StateValidator = 4 , Oracle = 8 , NeoFSAlphabetNode = 16 } const isDesignationRole = ( value ) : value is DesignationRole => DesignationRole [ value ] !== undefined ; export const assertDesignationRole = ( value ) : DesignationRole => { if ( isDesignationRole ( value ) ) { return value ; } throw new InvalidDesignationRoleError ( value ) ; } ; export type DesignationRoleJSON = keyof typeof DesignationRole ; export const isDesignationRoleJSON = ( state ) : state is DesignationRoleJSON => DesignationRole [ state as any ] !== undefined ; export const assertDesignationRoleJSON = ( state ) : DesignationRoleJSON => { if ( isDesignationRoleJSON ( state ) ) { return state ; } throw new InvalidFormatError ( ) ; } ; export const toDesignationRoleJSON = ( state ) => assertDesignationRoleJSON ( DesignationRole [ state ] ) ;