Skip to content

Commit 67282ee

Browse files
committed
Review feedback
1 parent bcce79a commit 67282ee

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

docs/ADR-10-cardano-api-script-witness-api.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,6 @@ data Witnessable thing era where
7373
=> Voter -> Witnessable Voter era
7474
WitProposal :: L.ConwayEraScript era => Proposal -> Witnessable Proposal era
7575

76-
instance Ord (Witnessable thing era) where
77-
compare a b =
78-
case (a, b) of
79-
(WitTxIn txinA, WitTxIn txinB) -> compare txinA txinB
80-
(WitTxCert{}, WitTxCert{}) -> LT -- Certificates in the ledger are in an `OSet` therefore we preserve the order.
81-
(WitMint mintA, WitMint mintB) -> compare mintA mintB
82-
(WitWithdrawal (stakeAddrA, _), WitWithdrawal (stakeAddrB, _)) -> compare stakeAddrA stakeAddrB
83-
(WitVote voterA, WitVote voterB) -> compare voterA voterB
84-
(WitProposal propA, WitProposal propB) -> compare propA propB
8576

8677
type Mint = (PolicyId, AssetName, Quantity)
8778

@@ -174,7 +165,18 @@ createIndexedPlutusScriptWitnesses witnessableThings =
174165
| (index, (thing, AnyPlutusScriptWitness sWit)) <- zip [0 ..] $ enforceOrdering witnessableThings
175166
]
176167
where
177-
enforceOrdering = List.sortBy (compare `on` fst)
168+
enforceOrdering = List.sortBy (compareWitnesses `on` fst)
169+
170+
compareWitnesses :: Witnessable thing era -> Witnessable thing era -> Ordering
171+
compareWitnesses a b =
172+
case (a, b) of
173+
(WitTxIn txinA, WitTxIn txinB) -> compare txinA txinB
174+
(WitTxCert{}, WitTxCert{}) -> LT -- Certificates in the ledger are in an `OSet` therefore we preserve the order.
175+
(WitMint mintA, WitMint mintB) -> compare mintA mintB
176+
(WitWithdrawal (stakeAddrA, _), WitWithdrawal (stakeAddrB, _)) -> compare stakeAddrA stakeAddrB
177+
(WitVote voterA, WitVote voterB) -> compare voterA voterB
178+
(WitProposal propA, WitProposal propB) -> compare propA propB
179+
178180
```
179181

180182
## New `PlutusScriptInEra` type

0 commit comments

Comments
 (0)