Skip to content

Commit

Permalink
Adapt wallet logs to use API UTxO
Browse files Browse the repository at this point in the history
This is a half-arsed solution as the real problem is that the wallet
uses ledger types instead of cardano API types (or even that the
wallet exists :-D)
  • Loading branch information
abailly authored and ch1bo committed Jan 9, 2023
1 parent 45cb2b3 commit d0ecf6e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions hydra-node/src/Hydra/Chain/Direct/Wallet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import Hydra.Cardano.Api (
StakeAddressReference (NoStakeAddress),
VerificationKey,
fromConsensusPointInMode,
fromLedgerUTxO,
makeShelleyAddress,
shelleyAddressInEra,
toLedgerAddr,
Expand All @@ -71,6 +72,7 @@ import Hydra.Cardano.Api.TxIn (fromLedgerTxIn)
import Hydra.Chain.CardanoClient (QueryPoint (..))
import Hydra.Chain.Direct.Util (Block, markerDatum)
import qualified Hydra.Chain.Direct.Util as Util
import Hydra.Ledger.Cardano ()
import Hydra.Logging (Tracer, traceWith)
import Ouroboros.Consensus.Block (blockPoint)
import Ouroboros.Consensus.Cardano.Block (HardForkBlock (BlockBabbage))
Expand Down Expand Up @@ -164,13 +166,13 @@ newTinyWallet tracer networkId (vk, sk) queryWalletInfo queryEpochInfo = do
let utxo' = applyBlock block (== ledgerAddress) walletUTxO
writeTVar walletInfoVar $ walletInfo{walletUTxO = utxo', tip = point}
pure utxo'
traceWith tracer $ EndUpdate utxo'
traceWith tracer $ EndUpdate (fromLedgerUTxO (Ledger.UTxO utxo'))
}
where
initialize = do
traceWith tracer BeginInitialize
walletInfo@WalletInfoOnChain{walletUTxO, tip} <- queryWalletInfo QueryTip address
traceWith tracer $ EndInitialize{initialUTxO = walletUTxO, tip}
traceWith tracer $ EndInitialize{initialUTxO = fromLedgerUTxO (Ledger.UTxO walletUTxO), tip}
pure walletInfo

address =
Expand Down Expand Up @@ -414,9 +416,9 @@ estimateScriptsCost pparams systemStart epochInfo utxo tx = do

data TinyWalletLog
= BeginInitialize
| EndInitialize {initialUTxO :: Map TxIn TxOut, tip :: ChainPoint}
| EndInitialize {initialUTxO :: Api.UTxO, tip :: ChainPoint}
| BeginUpdate {point :: ChainPoint}
| EndUpdate {newUTxO :: Map TxIn TxOut}
| EndUpdate {newUTxO :: Api.UTxO}
| SkipUpdate {point :: ChainPoint}
deriving (Eq, Generic, Show)

Expand Down

0 comments on commit d0ecf6e

Please sign in to comment.