import { Env , Handler , InternalHandler , Message } from "@keplr-wallet/router" ; import { LedgerGetWebHIDFlagMsg , LedgerSetWebHIDFlagMsg } from "./messages" ; import { LedgerService } from "./service" ; export const getHandler = ( service ) => { return ( env , msg ) => { switch ( msg . constructor ) { case LedgerGetWebHIDFlagMsg : return handleLedgerGetWebHIDFlagMsg ( service ) ( env , msg as LedgerGetWebHIDFlagMsg ) ; case LedgerSetWebHIDFlagMsg : return handleLedgerSetWebHIDFlagMsg ( service ) ( env , msg as LedgerSetWebHIDFlagMsg ) ; default : throw new Error ( "Unknown msg type" ) ; } } ; } ; const handleLedgerGetWebHIDFlagMsg = ( service ) => { return async ( _env , _msg ) => { return await service . getWebHIDFlag ( ) ; } ; } ; const handleLedgerSetWebHIDFlagMsg = ( service ) => { return async ( _env , msg ) => { return await service . setWebHIDFlag ( msg . flag ) ; } ; } ;