Skip to content

Commit f8e1307

Browse files
committed
Move Arbitrary instances of HeadObservation types
1 parent 542751f commit f8e1307

File tree

13 files changed

+71
-53
lines changed

13 files changed

+71
-53
lines changed

hydra-chain-observer/src/Hydra/ChainObserver/NodeClient.hs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,21 @@ import Hydra.Cardano.Api.Prelude (TxId)
1616
import Hydra.Contract (ScriptInfo)
1717
import Hydra.Ledger.Cardano (adjustUTxO)
1818
import Hydra.Tx.HeadId (HeadId (..))
19-
import Hydra.Tx.Observe (AbortObservation (..), CloseObservation (..), CollectComObservation (..), CommitObservation (..), ContestObservation (..), DecrementObservation (..), DepositObservation (..), FanoutObservation (..), HeadObservation (..), IncrementObservation (..), InitObservation (..), RecoverObservation (..), observeHeadTx)
19+
import Hydra.Tx.Observe (
20+
AbortObservation (..),
21+
CloseObservation (..),
22+
CollectComObservation (..),
23+
CommitObservation (..),
24+
ContestObservation (..),
25+
DecrementObservation (..),
26+
DepositObservation (..),
27+
FanoutObservation (..),
28+
HeadObservation (..),
29+
IncrementObservation (..),
30+
InitObservation (..),
31+
RecoverObservation (..),
32+
observeHeadTx,
33+
)
2034

2135
type ObserverHandler m = [ChainObservation] -> m ()
2236

hydra-tx/src/Hydra/Tx/Abort.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,6 @@ newtype AbortObservation = AbortObservation {headId :: HeadId}
108108
deriving stock (Eq, Show, Generic)
109109
deriving anyclass (ToJSON, FromJSON)
110110

111-
instance Arbitrary AbortObservation where
112-
arbitrary = genericArbitrary
113-
shrink = genericShrink
114-
115111
-- | Identify an abort tx by looking up the input spending the Head output and
116112
-- decoding its redeemer.
117113
observeAbortTx ::

hydra-tx/src/Hydra/Tx/Close.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,6 @@ data CloseObservation = CloseObservation
158158
deriving stock (Show, Eq, Generic)
159159
deriving anyclass (ToJSON, FromJSON)
160160

161-
instance Arbitrary CloseObservation where
162-
arbitrary = genericArbitrary
163-
shrink = genericShrink
164-
165161
-- | Identify a close tx by lookup up the input spending the Head output and
166162
-- decoding its redeemer.
167163
observeCloseTx ::

hydra-tx/src/Hydra/Tx/CollectCom.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,6 @@ data CollectComObservation = CollectComObservation
120120
deriving stock (Show, Eq, Generic)
121121
deriving anyclass (ToJSON, FromJSON)
122122

123-
instance Arbitrary CollectComObservation where
124-
arbitrary = genericArbitrary
125-
shrink = genericShrink
126-
127123
-- | Identify a collectCom tx by lookup up the input spending the Head output
128124
-- and decoding its redeemer.
129125
observeCollectComTx ::

hydra-tx/src/Hydra/Tx/Commit.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,6 @@ data CommitObservation = CommitObservation
157157
deriving stock (Eq, Show, Generic)
158158
deriving anyclass (ToJSON, FromJSON)
159159

160-
instance Arbitrary CommitObservation where
161-
arbitrary = undefined -- TODO: Arbitrary UTxO in hydra-tx
162-
shrink = undefined -- TODO: Arbitrary UTxO in hydra-tx
163-
164160
-- | Identify a commit tx by:
165161
--
166162
-- - Check that its spending from the init validator,

hydra-tx/src/Hydra/Tx/Contest.hs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import PlutusLedgerApi.V1.Crypto qualified as Plutus
2121
import PlutusLedgerApi.V3 (toBuiltin)
2222
import PlutusLedgerApi.V3 qualified as Plutus
2323

24+
import Hydra.Plutus.Orphans ()
25+
2426
-- * Construction
2527

2628
data ClosedThreadOutput = ClosedThreadOutput
@@ -154,16 +156,7 @@ data ContestObservation = ContestObservation
154156
, contesters :: [Plutus.PubKeyHash]
155157
}
156158
deriving stock (Show, Eq, Generic)
157-
158-
instance ToJSON ContestObservation where
159-
toJSON = undefined -- TODO: ToJSON PubKeyHash?
160-
161-
instance FromJSON ContestObservation where
162-
parseJSON = undefined -- TODO: FromJSON PubKeyHash?
163-
164-
instance Arbitrary ContestObservation where
165-
arbitrary = undefined -- TODO: Arbitrary PubKeyHash
166-
shrink = undefined -- TODO: Arbitrary PubKeyHash
159+
deriving anyclass (ToJSON, FromJSON)
167160

168161
-- | Identify a close tx by lookup up the input spending the Head output and
169162
-- decoding its redeemer.

hydra-tx/src/Hydra/Tx/Decrement.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,6 @@ data DecrementObservation = DecrementObservation
101101
deriving stock (Show, Eq, Generic)
102102
deriving anyclass (ToJSON, FromJSON)
103103

104-
instance Arbitrary DecrementObservation where
105-
arbitrary = undefined -- TODO: Arbitrary UTxO in hydra-tx
106-
shrink = undefined -- TODO: Arbitrary UTxO in hydra-tx
107-
108104
observeDecrementTx ::
109105
UTxO ->
110106
Tx ->

hydra-tx/src/Hydra/Tx/Fanout.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,6 @@ data FanoutObservation = FanoutObservation
8282
deriving stock (Eq, Show, Generic)
8383
deriving anyclass (ToJSON, FromJSON)
8484

85-
instance Arbitrary FanoutObservation where
86-
arbitrary = undefined -- TODO: Arbitrary UTxO in hydra
87-
shrink = undefined -- TODO: Arbitrary UTxO in hydra-tx
88-
8985
-- | Identify a fanout tx by lookup up the input spending the Head output and
9086
-- decoding its redeemer.
9187
observeFanoutTx ::

hydra-tx/src/Hydra/Tx/Increment.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,6 @@ data IncrementObservation = IncrementObservation
115115
deriving stock (Show, Eq, Generic)
116116
deriving anyclass (ToJSON, FromJSON)
117117

118-
instance Arbitrary IncrementObservation where
119-
arbitrary = undefined -- TODO: Arbitrary TxId
120-
shrink = undefined -- TODO: Arbitrary TxId
121-
122118
observeIncrementTx ::
123119
UTxO ->
124120
Tx ->

hydra-tx/src/Hydra/Tx/Init.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,6 @@ data InitObservation = InitObservation
9595
deriving stock (Show, Eq, Generic)
9696
deriving anyclass (ToJSON, FromJSON)
9797

98-
instance Arbitrary InitObservation where
99-
arbitrary = genericArbitrary
100-
shrink = genericShrink
101-
10298
data NotAnInitReason
10399
= NoHeadOutput
104100
| NotAHeadDatum

0 commit comments

Comments
 (0)