Skip to content

Commit 110b5b1

Browse files
committed
fixup! BalancingError with explicit script evaluation errors
1 parent a6ec467 commit 110b5b1

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/coin-selection/lib/Convex/CoinSelection.hs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
{-# LANGUAGE MultiWayIf #-}
1010
{-# LANGUAGE NamedFieldPuns #-}
1111
{-# LANGUAGE NumericUnderscores #-}
12+
{-# LANGUAGE OverloadedStrings #-}
1213
{-# LANGUAGE RankNTypes #-}
1314
{-# LANGUAGE TemplateHaskell #-}
1415
{-# LANGUAGE TupleSections #-}
@@ -141,7 +142,8 @@ import Convex.Utxos (
141142
import Convex.Utxos qualified as Utxos
142143
import Convex.Wallet (Wallet)
143144
import Convex.Wallet qualified as Wallet
144-
import Data.Aeson (FromJSON (..), ToJSON (..))
145+
import Data.Aeson (FromJSON (..), Options (sumEncoding), SumEncoding (..), ToJSON (..), withObject, (.:))
146+
import Data.Aeson.TH (defaultOptions, deriveFromJSON)
145147
import Data.Bifunctor (Bifunctor (..))
146148
import Data.Default (Default (..))
147149
import Data.Function (on)
@@ -222,9 +224,9 @@ bodyError :: C.TxBodyError -> CoinSelectionError
222224
bodyError = BodyError . Text.pack . C.docToString . C.prettyError
223225

224226
-- Orphan instance, needed to allow full json from here on.
227+
-- TODO: Check that automatic generation is compatible with cardano-api encoding.
225228

226-
instance FromJSON C.ScriptWitnessIndex where
227-
parseJSON = undefined
229+
$(deriveFromJSON defaultOptions{sumEncoding = TaggedObject{tagFieldName = "kind", contentsFieldName = "value"}} ''C.ScriptWitnessIndex)
228230

229231
-- | Balancing errors, including the *special* 'BalancingScriptExecutionErr'.
230232
data BalancingError era

0 commit comments

Comments
 (0)