Skip to content

Commit 6bea15a

Browse files
committed
Implement checkNonADAAssets for offline mode too
Signed-off-by: Sasha Bogicevic <[email protected]>
1 parent 06edd3f commit 6bea15a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

hydra-node/src/Hydra/Chain/Offline.hs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ import Hydra.Chain (
2626
import Hydra.Chain.ChainState (ChainSlot (ChainSlot))
2727
import Hydra.Chain.Direct.State (initialChainState)
2828
import Hydra.Ledger.Cardano.Time (slotNoFromUTCTime, slotNoToUTCTime)
29+
import Hydra.Node.Util (checkNonADAAssetsUTxO)
2930
import Hydra.Options (OfflineChainConfig (..), defaultContestationPeriod)
30-
import Hydra.Tx (HeadId (..), HeadParameters (..), HeadSeed (..), Party)
31+
import Hydra.Tx (HeadId (..), HeadParameters (..), HeadSeed (..), Party, Snapshot (..), getSnapshot)
3132
import Hydra.Utils (readJsonFileThrow)
3233

3334
-- Upstreamed in cardano-api 10.18
@@ -129,7 +130,10 @@ withOfflineChain config party otherParties chainStateHistory callback action = d
129130
, draftCommitTx = \_ _ -> pure $ Left FailedToDraftTxNotInitializing
130131
, draftDepositTx = \_ _ _ _ _ -> pure $ Left FailedToConstructDepositTx{failureReason = "not implemented"}
131132
, postTx = const $ pure ()
132-
, checkNonADAAssets = const $ pure ()
133+
, checkNonADAAssets = \confirmedSnapshot -> do
134+
let Snapshot{utxo, utxoToCommit, utxoToDecommit} = getSnapshot confirmedSnapshot
135+
let snapshotUTxO = utxo <> fromMaybe mempty utxoToCommit <> fromMaybe mempty utxoToDecommit
136+
checkNonADAAssetsUTxO snapshotUTxO
133137
}
134138

135139
initializeOfflineHead = do

0 commit comments

Comments
 (0)