Skip to content

Commit

Permalink
Remove unused JSON and Arbitrary instances from Hydra.Chain.Direct.State
Browse files Browse the repository at this point in the history
  • Loading branch information
locallycompact committed Dec 19, 2024
1 parent db0285d commit 67ce2b6
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 55 deletions.
1 change: 0 additions & 1 deletion hydra-node/hydra-node.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ library
build-depends:
, aeson
, base
, base16-bytestring
, bytestring
, cardano-api:internal
, cardano-binary
Expand Down
7 changes: 0 additions & 7 deletions hydra-node/src/Hydra/Chain/Direct/State.hs
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,6 @@ data InitialState = InitialState
}
deriving stock (Eq, Show, Generic)

instance Arbitrary InitialState where
arbitrary = do
ctx <- genHydraContext maxGenParties
snd <$> genStInitial ctx

shrink = genericShrink

instance HasKnownUTxO InitialState where
getKnownUTxO st =
UTxO $
Expand Down
47 changes: 0 additions & 47 deletions hydra-node/src/Hydra/Chain/Direct/Tx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import Hydra.Prelude hiding (toList)
import Cardano.Api.UTxO qualified as UTxO
import Data.Aeson qualified as Aeson
import Data.ByteString qualified as BS
import Data.ByteString.Base16 qualified as Base16
import GHC.IsList (IsList (..))
import Hydra.Contract.Commit qualified as Commit
import Hydra.Contract.Deposit qualified as Deposit
Expand Down Expand Up @@ -59,16 +58,6 @@ type UTxOWithScript = (TxIn, TxOut CtxUTxO, HashableScriptData)
newtype UTxOHash = UTxOHash ByteString
deriving stock (Eq, Show, Generic)

instance ToJSON UTxOHash where
toJSON (UTxOHash bytes) =
Aeson.String . decodeUtf8 $ Base16.encode bytes

instance FromJSON UTxOHash where
parseJSON = Aeson.withText "UTxOHash" $ \cborText ->
case Base16.decode $ encodeUtf8 cborText of
Left e -> fail e
Right bs -> pure $ UTxOHash bs

instance Arbitrary UTxOHash where
arbitrary = UTxOHash . BS.pack <$> vectorOf 32 arbitrary

Expand All @@ -79,11 +68,6 @@ data InitialThreadOutput = InitialThreadOutput
, initialParties :: [OnChain.Party]
}
deriving stock (Eq, Show, Generic)
deriving anyclass (ToJSON, FromJSON)

instance Arbitrary InitialThreadOutput where
arbitrary = genericArbitrary
shrink = genericShrink

-- * Observe Hydra Head transactions

Expand All @@ -103,9 +87,6 @@ data HeadObservation
| Fanout FanoutObservation
deriving stock (Eq, Show, Generic)

instance Arbitrary HeadObservation where
arbitrary = genericArbitrary

-- | Observe any Hydra head transaction.
observeHeadTx :: NetworkId -> UTxO -> Tx -> HeadObservation
observeHeadTx networkId utxo tx =
Expand Down Expand Up @@ -147,10 +128,6 @@ data NotAnInitReason
| NoSTFound
| NotAHeadPolicy
deriving stock (Show, Eq, Generic)
deriving anyclass (ToJSON, FromJSON)

instance Arbitrary NotAnInitReason where
arbitrary = genericArbitrary

-- | Identify a init tx by checking the output value for holding tokens that are
-- valid head tokens (checked by seed + policy).
Expand Down Expand Up @@ -230,9 +207,6 @@ data CommitObservation = CommitObservation
}
deriving stock (Eq, Show, Generic)

instance Arbitrary CommitObservation where
arbitrary = genericArbitrary

-- | Identify a commit tx by:
--
-- - Check that its spending from the init validator,
Expand Down Expand Up @@ -304,9 +278,6 @@ data CollectComObservation = CollectComObservation
}
deriving stock (Show, Eq, Generic)

instance Arbitrary CollectComObservation where
arbitrary = genericArbitrary

-- | Identify a collectCom tx by lookup up the input spending the Head output
-- and decoding its redeemer.
observeCollectComTx ::
Expand Down Expand Up @@ -352,9 +323,6 @@ data IncrementObservation = IncrementObservation
}
deriving stock (Show, Eq, Generic)

instance Arbitrary IncrementObservation where
arbitrary = genericArbitrary

observeIncrementTx ::
UTxO ->
Tx ->
Expand Down Expand Up @@ -394,9 +362,6 @@ data DecrementObservation = DecrementObservation
}
deriving stock (Show, Eq, Generic)

instance Arbitrary DecrementObservation where
arbitrary = genericArbitrary

observeDecrementTx ::
UTxO ->
Tx ->
Expand Down Expand Up @@ -435,9 +400,6 @@ data CloseObservation = CloseObservation
}
deriving stock (Show, Eq, Generic)

instance Arbitrary CloseObservation where
arbitrary = genericArbitrary

-- | Identify a close tx by lookup up the input spending the Head output and
-- decoding its redeemer.
observeCloseTx ::
Expand Down Expand Up @@ -485,9 +447,6 @@ data ContestObservation = ContestObservation
}
deriving stock (Show, Eq, Generic)

instance Arbitrary ContestObservation where
arbitrary = genericArbitrary

-- | Identify a close tx by lookup up the input spending the Head output and
-- decoding its redeemer.
observeContestTx ::
Expand Down Expand Up @@ -527,9 +486,6 @@ observeContestTx utxo tx = do

newtype FanoutObservation = FanoutObservation {headId :: HeadId} deriving stock (Eq, Show, Generic)

instance Arbitrary FanoutObservation where
arbitrary = genericArbitrary

-- | Identify a fanout tx by lookup up the input spending the Head output and
-- decoding its redeemer.
observeFanoutTx ::
Expand All @@ -550,9 +506,6 @@ observeFanoutTx utxo tx = do

newtype AbortObservation = AbortObservation {headId :: HeadId} deriving stock (Eq, Show, Generic)

instance Arbitrary AbortObservation where
arbitrary = genericArbitrary

-- | Identify an abort tx by looking up the input spending the Head output and
-- decoding its redeemer.
observeAbortTx ::
Expand Down

0 comments on commit 67ce2b6

Please sign in to comment.