import { InvalidAttributeTypeError , InvalidAttributeTypeJSONError } from '../../../errors' ; import { AttributeTypeJSON } from '../../types' ; export enum AttributeTypeModel { HighPriority = 0x01 , OracleResponse = 0x11 } const isAttributeType = ( value ) : value is AttributeTypeModel => AttributeTypeModel [ value ] !== undefined ; export const assertAttributeType = ( value ) : AttributeTypeModel => { if ( isAttributeType ( value ) ) { return value ; } throw new InvalidAttributeTypeError ( value ) ; } ; export const toJSONAttributeType = ( type ) : AttributeTypeJSON => assertAttributeTypeJSON ( AttributeTypeModel [ type ] ) ; export const isAttributeTypeJSON = ( type ) : type is AttributeTypeJSON => AttributeTypeModel [ type as any ] !== undefined ; export const assertAttributeTypeJSON = ( type ) : AttributeTypeJSON => { if ( isAttributeTypeJSON ( type ) ) { return type ; } throw new InvalidAttributeTypeJSONError ( type ) ; } ; export const toAttributeType = ( type ) : AttributeTypeModel => assertAttributeType ( AttributeTypeModel [ type ] ) ;