Skip to content

Commit

Permalink
Add a new BuildTxWith type
Browse files Browse the repository at this point in the history
During tx construction we want to annotate the scripts into their use
sites, however the final representation of txs puts the scripts
separately. Unfortunately we cannot reverse this transformation so we
end up with this asymmetry between building and viewing a transaction.

This data type helps us deal with this asymmetry, at tx build type it
lets us annotate with another type, but provides nothing when viewing.
The build vs view mode is determined by another type param.
  • Loading branch information
dcoutts authored and Jimbo4350 committed Apr 8, 2021
1 parent df80382 commit 30c0372
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions cardano-api/src/Cardano/Api/TxBody.hs
Expand Up @@ -633,6 +633,22 @@ updateProposalSupportedInEra AllegraEra = Just UpdateProposalInAllegraEra
updateProposalSupportedInEra MaryEra = Just UpdateProposalInMaryEra


-- ----------------------------------------------------------------------------
-- Building vs viewing transactions
--

data BuildTx
data ViewTx

data BuildTxWith build a where

ViewTx :: BuildTxWith ViewTx a
BuildTxWith :: a -> BuildTxWith BuildTx a

deriving instance Eq a => Eq (BuildTxWith build a)
deriving instance Show a => Show (BuildTxWith build a)


-- ----------------------------------------------------------------------------
-- Transaction output values (era-dependent)
--
Expand Down

0 comments on commit 30c0372

Please sign in to comment.