import { InvalidFormatError } from '../common' ; export enum CallFlags { None = 0 , ReadStates = 0b00000001 , WriteStates = 0b00000010 , AllowCall = 0b00000100 , AllowNotify = 0b00001000 , States = ReadStates | WriteStates , ReadOnly = ReadStates | AllowCall , All = States | AllowCall | AllowNotify } export const isCallFlag = ( value ) : value is CallFlags => CallFlags [ value ] !== undefined ; export const assertCallFlags = ( value ) : CallFlags => { if ( isCallFlag ( value ) ) { return value ; } throw new InvalidFormatError ( `Expected StackItemType, found: ${ value }` ) ; } ; export type CallFlagsJSON = keyof typeof CallFlags ; export const isCallFlagsJSON = ( type ) : type is CallFlagsJSON => CallFlags [ type as any ] !== undefined ; export const assertCallFlagsJSON = ( type ) : CallFlagsJSON => { if ( isCallFlagsJSON ( type ) ) { return type ; } throw new InvalidFormatError ( ) ; } ; export const toCallFlagsJSON = ( type ) => assertCallFlagsJSON ( CallFlags [ type ] ) ;