import { Env , Handler , InternalHandler , Message } from "@keplr-wallet/router" ; import { ApproveInteractionMsg , RejectInteractionMsg } from "./messages" ; import { InteractionService } from "./service" ; export const getHandler = ( service ) => { return ( env , msg ) => { switch ( msg . constructor ) { case ApproveInteractionMsg : return handleApproveInteractionMsg ( service ) ( env , msg as ApproveInteractionMsg ) ; case RejectInteractionMsg : return handleRejectInteractionMsg ( service ) ( env , msg as RejectInteractionMsg ) ; default : throw new Error ( "Unknown msg type" ) ; } } ; } ; const handleApproveInteractionMsg = ( service ) => { return ( _ , msg ) => { return service . approve ( msg . id , msg . result ) ; } ; } ; const handleRejectInteractionMsg = ( service ) => { return ( _ , msg ) => { return service . reject ( msg . id ) ; } ; } ;