hydra-tui
Safe HaskellSafe-Inferred
LanguageGHC2021

Hydra.TUI.Handlers

Synopsis

Documentation

handleEvent :: CardanoClient -> Client Tx IO -> BChan (TUIEvent Tx) -> BrickEvent Name (TUIEvent Tx) -> EventM Name RootState () Source #

AppEvent handlers

VtyEvent handlers

handleVtyEventsHeadState :: CardanoClient -> Client Tx IO -> BChan (TUIEvent Tx) -> Event -> EventM Name HeadState () Source #

handleVtyEventsActiveLink :: CardanoClient -> Client Tx IO -> BChan (TUIEvent Tx) -> Event -> EventM Name ActiveLink () Source #

handleVtyEventsActiveHeadState :: CardanoClient -> Client Tx IO -> BChan (TUIEvent Tx) -> UTxO -> [PendingIncrement] -> Event -> EventM Name ActiveHeadState () Source #

handleVtyEventsOpen :: CardanoClient -> Client Tx IO -> BChan (TUIEvent Tx) -> UTxO -> [PendingIncrement] -> Event -> EventM Name OpenScreen () Source #

handleVtyEventsFanoutPossible :: Client Tx IO -> Event -> EventM Name s () Source #

handleVtyEventsFinal :: Client Tx IO -> Event -> EventM Name s () Source #

myAvailableUTxO :: NetworkId -> VerificationKey PaymentKey -> UTxO -> Map TxIn (TxOut CtxUTxO) Source #

mkMyAddress :: CardanoClient -> Client Tx IO -> Address ShelleyAddr Source #

mkFuelAddress :: CardanoClient -> VerificationKey PaymentKey -> Address ShelleyAddr Source #

Derive the node's internal-wallet (fuel) address from its verification key.

adaToLovelace :: Double -> Integer -> Integer Source #

Convert a user-entered ADA amount to lovelace. The TUI accepts amounts as Double for usability (typing decimals), so any precision finer than one lovelace is silently rounded. Double represents integers exactly up to 2^53 lovelace (~9e15), well above any realistic UTxO value, so the only practical loss is sub-lovelace fractional input from the user. The min clamp defends against floating-point overshoot of the form validator's upper bound.

setPendingAction :: Event -> EventM Name RootState () Source #

useOpenScreen :: EventM Name RootState (Maybe OpenScreen) Source #

Read the current OpenScreen, if the head is currently Open.

zoomOpenScreen :: EventM Name OpenScreen () -> EventM Name RootState () Source #

Mutate the current OpenScreen. No-op if the head isn't Open.

enterModal :: EventM Name RootState () Source #

Switch to the modal tab, remembering the currently-active tab so we can return to it later via leaveModal.

leaveModal :: EventM Name RootState () Source #

Return from the modal tab to whichever tab was active before.

refreshRecoveryForm :: EventM Name RootState () Source #

If the recovery modal is open, rebuild its form from the current $sel:pendingIncrements:ActiveLink. Keeps the user's selection if that deposit is still pending, otherwise falls back to the first entry. If the list is now empty (e.g. the selected deposit was finalized or recovered), close the modal and surface a message in the pending-action slot. Should be called after any node event that may mutate $sel:pendingIncrements:ActiveLink.

refreshFanoutForm :: EventM Name RootState () Source #

Keep an open partial-fanout selection modal in sync with the head's remaining UTxO. When a HeadPartiallyFannedOut step lands, the displayed utxoL shrinks; rebuild the form against it so the user cannot tick (and submit) UTxOs that were already fanned out. Still-valid ticks are preserved. If the head is no longer fanning out (finalized, or otherwise left a fanout-capable state), close the modal.

forkWithErrorReport :: BChan (TUIEvent Tx) -> Text -> [TUIEvent Tx] -> IO () -> IO () Source #

Run an IO action in a background thread, reporting any exception through the TUI's event channel as a TxBuildError (visible in the pending-action slot). cleanup events, if any, are written before the error so the TUI can reset transient loading state. Order matters — TxBuildError is written last so its message wins over anything cleanup might display.

Forking is essential for any blocking call against the hydra-node or cardano-node: if the remote is unresponsive a synchronous call would block the brick event loop, leaving no way to press Esc or Ctrl-C.

queryL1UTxOAsync :: CardanoClient -> Address ShelleyAddr -> BChan (TUIEvent Tx) -> (Map TxIn (TxOut CtxUTxO) -> TUIEvent Tx) -> Text -> IO () Source #

Query L1 UTxO at the given address in a background thread. On success, the result is wrapped via mkResult and written to the channel. On exception, an empty result is written first (so the TUI clears any loading-state spinner) followed by a TxBuildError with the real cause.

recoverCommitAsync :: Client Tx IO -> BChan (TUIEvent Tx) -> TxId -> IO () Source #

externalCommitAsync :: Client Tx IO -> BChan (TUIEvent Tx) -> UTxO -> IO () Source #

triggerL1Query :: CardanoClient -> Client Tx IO -> BChan (TUIEvent Tx) -> EventM Name RootState () Source #

triggerL1IfNeeded :: CardanoClient -> Client Tx IO -> BChan (TUIEvent Tx) -> EventM Name RootState () Source #