-
Notifications
You must be signed in to change notification settings - Fork 155
/
TxBody.hs
696 lines (626 loc) · 19.2 KB
/
TxBody.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE ViewPatterns #-}
module Cardano.Ledger.Alonzo.TxBody
( TxOut (TxOut, TxOutCompact),
TxBody
( TxBody,
inputs,
txinputs_fee,
outputs,
txcerts,
txwdrls,
txfee,
txvldt,
txUpdates,
reqSignerHashes,
mint,
wppHash,
adHash,
txnetworkid
),
inputs',
inputs_fee',
outputs',
certs',
wdrls',
txfee',
vldt',
update',
reqSignerHashes',
mint',
wppHash',
adHash',
txnetworkid',
AlonzoBody,
EraIndependentWitnessPPData,
WitnessPPDataHash,
ppTxBody,
ppTxOut,
)
where
import Cardano.Binary (FromCBOR (..), ToCBOR (..))
import Cardano.Ledger.Alonzo.Data (AuxiliaryDataHash (..), DataHash)
import Cardano.Ledger.Coin (Coin)
import Cardano.Ledger.Compactible
import qualified Cardano.Ledger.Core as Core
import qualified Cardano.Ledger.Crypto as CC
import Cardano.Ledger.Era (Crypto, Era)
import Cardano.Ledger.Hashes
( EraIndependentTxBody,
EraIndependentWitnessPPData,
)
import Cardano.Ledger.Mary.Value (Value (..), policies, policyID, ppValue)
import qualified Cardano.Ledger.Mary.Value as Mary
import Cardano.Ledger.Pretty
( PDoc,
PrettyA (..),
ppAddr,
ppCoin,
ppDCert,
ppKeyHash,
ppNetwork,
ppRecord,
ppSafeHash,
ppSet,
ppSexp,
ppStrictMaybe,
ppStrictSeq,
ppTxIn,
ppUpdate,
ppWdrl,
)
import Cardano.Ledger.SafeHash
( HashAnnotated,
SafeHash,
SafeToHash,
)
import Cardano.Ledger.Shelley.Constraints (PParamsDelta)
import Cardano.Ledger.ShelleyMA.Timelocks (ValidityInterval (..), ppValidityInterval)
import Cardano.Ledger.Val
( DecodeNonNegative,
decodeMint,
decodeNonNegative,
encodeMint,
isZero,
)
import Data.Coders
import Data.Maybe (fromMaybe)
import Data.MemoBytes (Mem, MemoBytes (..), memoBytes)
import Data.Sequence.Strict (StrictSeq)
import qualified Data.Sequence.Strict as StrictSeq
import Data.Set (Set)
import qualified Data.Set as Set
import Data.Typeable (Typeable)
import GHC.Generics (Generic)
import GHC.Records (HasField (..))
import GHC.Stack (HasCallStack)
import NoThunks.Class (InspectHeapNamed (..), NoThunks)
import Shelley.Spec.Ledger.Address (Addr)
import Shelley.Spec.Ledger.BaseTypes (Network, StrictMaybe (..))
import Shelley.Spec.Ledger.CompactAddr (CompactAddr, compactAddr, decompactAddr)
import Shelley.Spec.Ledger.Delegation.Certificates (DCert)
import Shelley.Spec.Ledger.Keys (KeyHash, KeyRole (..))
import Shelley.Spec.Ledger.PParams (Update)
import Shelley.Spec.Ledger.Scripts (ScriptHash)
import Shelley.Spec.Ledger.TxBody (TxIn (..), Wdrl (Wdrl), unWdrl)
import Prelude hiding (lookup)
data TxOut era
= TxOutCompact
{-# UNPACK #-} !(CompactAddr (Crypto era))
!(CompactForm (Core.Value era))
!(StrictMaybe (DataHash (Crypto era)))
deriving (Generic)
deriving stock instance
( Eq (Core.Value era),
Compactible (Core.Value era)
) =>
Eq (TxOut era)
deriving instance
( Show (CompactAddr (Crypto era)),
Show (Core.Value era),
Show (CompactForm (Core.Value era))
) =>
Show (TxOut era)
deriving via InspectHeapNamed "TxOut" (TxOut era) instance NoThunks (TxOut era)
pattern TxOut ::
( Era era,
Compactible (Core.Value era),
Show (Core.Value era),
HasCallStack
) =>
Addr (Crypto era) ->
Core.Value era ->
StrictMaybe (DataHash (Crypto era)) ->
TxOut era
pattern TxOut addr vl dh <-
TxOutCompact (decompactAddr -> addr) (fromCompact -> vl) dh
where
TxOut addr vl dh =
TxOutCompact
(compactAddr addr)
( fromMaybe (error $ "Illegal value in txout: " <> show vl) $
toCompact vl
)
dh
{-# COMPLETE TxOut #-}
-- ======================================
type WitnessPPDataHash crypto = SafeHash crypto EraIndependentWitnessPPData
data TxBodyRaw era = TxBodyRaw
{ _inputs :: !(Set (TxIn (Crypto era))),
_inputs_fee :: !(Set (TxIn (Crypto era))),
_outputs :: !(StrictSeq (TxOut era)),
_certs :: !(StrictSeq (DCert (Crypto era))),
_wdrls :: !(Wdrl (Crypto era)),
_txfee :: !Coin,
_vldt :: !ValidityInterval,
_update :: !(StrictMaybe (Update era)),
_reqSignerHashes :: Set (KeyHash 'Witness (Crypto era)),
_mint :: !(Value (Crypto era)),
-- The spec makes it clear that the mint field is a
-- Cardano.Ledger.Mary.Value.Value, not a Core.Value.
-- Operations on the TxBody in the AlonzoEra depend upon this.
_wppHash :: !(StrictMaybe (WitnessPPDataHash (Crypto era))),
_adHash :: !(StrictMaybe (AuxiliaryDataHash (Crypto era))),
_txnetworkid :: !(StrictMaybe Network)
}
deriving (Generic, Typeable)
deriving instance
( Eq (Core.Value era),
CC.Crypto (Crypto era),
Compactible (Core.Value era),
Eq (PParamsDelta era)
) =>
Eq (TxBodyRaw era)
instance
(Typeable era, NoThunks (Core.Value era), NoThunks (PParamsDelta era)) =>
NoThunks (TxBodyRaw era)
deriving instance
( Era era,
Show (Core.Value era),
Show (PParamsDelta era),
Show (CompactAddr (Crypto era))
) =>
Show (TxBodyRaw era)
newtype TxBody era = TxBodyConstr (MemoBytes (TxBodyRaw era))
deriving (ToCBOR)
deriving newtype (SafeToHash)
deriving newtype instance
( Eq (Core.Value era),
Compactible (Core.Value era),
CC.Crypto (Crypto era),
Eq (PParamsDelta era)
) =>
Eq (TxBody era)
deriving instance
( Typeable era,
NoThunks (Core.Value era),
NoThunks (PParamsDelta era)
) =>
NoThunks (TxBody era)
deriving instance
( Era era,
Compactible (Core.Value era),
Show (Core.Value era),
Show (PParamsDelta era),
Show (CompactAddr (Crypto era))
) =>
Show (TxBody era)
deriving via
(Mem (TxBodyRaw era))
instance
( Era era,
Typeable (Core.Script era),
Typeable (Core.AuxiliaryData era),
Compactible (Core.Value era),
Show (Core.Value era),
DecodeNonNegative (Core.Value era),
FromCBOR (Annotator (Core.Script era)),
Core.SerialisableData (PParamsDelta era)
) =>
FromCBOR (Annotator (TxBody era))
-- The Set of constraints necessary to use the TxBody pattern
type AlonzoBody era =
( Era era,
Compactible (Core.Value era),
ToCBOR (Core.Script era),
Core.SerialisableData (PParamsDelta era)
)
pattern TxBody ::
AlonzoBody era =>
Set (TxIn (Crypto era)) ->
Set (TxIn (Crypto era)) ->
StrictSeq (TxOut era) ->
StrictSeq (DCert (Crypto era)) ->
Wdrl (Crypto era) ->
Coin ->
ValidityInterval ->
StrictMaybe (Update era) ->
Set (KeyHash 'Witness (Crypto era)) ->
Value (Crypto era) ->
StrictMaybe (WitnessPPDataHash (Crypto era)) ->
StrictMaybe (AuxiliaryDataHash (Crypto era)) ->
StrictMaybe (Network) ->
TxBody era
pattern TxBody
{ inputs,
txinputs_fee,
outputs,
txcerts,
txwdrls,
txfee,
txvldt,
txUpdates,
reqSignerHashes,
mint,
wppHash,
adHash,
txnetworkid
} <-
TxBodyConstr
( Memo
TxBodyRaw
{ _inputs = inputs,
_inputs_fee = txinputs_fee,
_outputs = outputs,
_certs = txcerts,
_wdrls = txwdrls,
_txfee = txfee,
_vldt = txvldt,
_update = txUpdates,
_reqSignerHashes = reqSignerHashes,
_mint = mint,
_wppHash = wppHash,
_adHash = adHash,
_txnetworkid = txnetworkid
}
_
)
where
TxBody
inputsX
inputs_feeX
outputsX
certsX
wdrlsX
txfeeX
vldtX
updateX
reqSignerHashesX
mintX
wppHashX
adHashX
txnetworkidX =
TxBodyConstr $
memoBytes
( encodeTxBodyRaw $
TxBodyRaw
inputsX
inputs_feeX
outputsX
certsX
wdrlsX
txfeeX
vldtX
updateX
reqSignerHashesX
mintX
wppHashX
adHashX
txnetworkidX
)
{-# COMPLETE TxBody #-}
instance (c ~ Crypto era, Era era) => HashAnnotated (TxBody era) EraIndependentTxBody c
-- ==============================================================================
-- We define these accessor functions manually, because if we define them using
-- the record syntax in the TxBody pattern, they inherit the (AlonzoBody era)
-- constraint as a precondition. This is unnecessary, as one can see below
-- they need not be constrained at all. This should be fixed in the GHC compiler.
inputs' :: TxBody era -> Set (TxIn (Crypto era))
inputs_fee' :: TxBody era -> Set (TxIn (Crypto era))
outputs' :: TxBody era -> StrictSeq (TxOut era)
certs' :: TxBody era -> StrictSeq (DCert (Crypto era))
txfee' :: TxBody era -> Coin
wdrls' :: TxBody era -> Wdrl (Crypto era)
vldt' :: TxBody era -> ValidityInterval
update' :: TxBody era -> StrictMaybe (Update era)
reqSignerHashes' :: TxBody era -> Set (KeyHash 'Witness (Crypto era))
adHash' :: TxBody era -> StrictMaybe (AuxiliaryDataHash (Crypto era))
mint' :: TxBody era -> Value (Crypto era)
wppHash' :: TxBody era -> StrictMaybe (WitnessPPDataHash (Crypto era))
inputs' (TxBodyConstr (Memo raw _)) = _inputs raw
txnetworkid' :: TxBody era -> StrictMaybe Network
inputs_fee' (TxBodyConstr (Memo raw _)) = _inputs_fee raw
outputs' (TxBodyConstr (Memo raw _)) = _outputs raw
certs' (TxBodyConstr (Memo raw _)) = _certs raw
wdrls' (TxBodyConstr (Memo raw _)) = _wdrls raw
txfee' (TxBodyConstr (Memo raw _)) = _txfee raw
vldt' (TxBodyConstr (Memo raw _)) = _vldt raw
update' (TxBodyConstr (Memo raw _)) = _update raw
reqSignerHashes' (TxBodyConstr (Memo raw _)) = _reqSignerHashes raw
adHash' (TxBodyConstr (Memo raw _)) = _adHash raw
mint' (TxBodyConstr (Memo raw _)) = _mint raw
wppHash' (TxBodyConstr (Memo raw _)) = _wppHash raw
txnetworkid' (TxBodyConstr (Memo raw _)) = _txnetworkid raw
--------------------------------------------------------------------------------
-- Serialisation
--------------------------------------------------------------------------------
instance
( Era era,
Compactible (Core.Value era)
) =>
ToCBOR (TxOut era)
where
toCBOR (TxOutCompact addr cv dh) =
encode $
Rec
(TxOutCompact @era)
!> To addr
!> To cv
!> To dh
instance
( Era era,
DecodeNonNegative (Core.Value era),
Show (Core.Value era),
Compactible (Core.Value era),
ToCBOR (PParamsDelta era)
) =>
FromCBOR (TxOut era)
where
fromCBOR =
decode $
RecD TxOutCompact
<! From
<! D decodeNonNegative
<! From
encodeTxBodyRaw ::
( Era era,
ToCBOR (PParamsDelta era)
) =>
TxBodyRaw era ->
Encode ('Closed 'Sparse) (TxBodyRaw era)
encodeTxBodyRaw
TxBodyRaw
{ _inputs,
_inputs_fee,
_outputs,
_certs,
_wdrls,
_txfee,
_vldt = ValidityInterval bot top,
_update,
_reqSignerHashes,
_mint,
_wppHash,
_adHash,
_txnetworkid
} =
Keyed
( \i ifee o f t c w u b rsh mi sh ah ni ->
TxBodyRaw i ifee o c w f (ValidityInterval b t) u rsh mi sh ah ni
)
!> Key 0 (E encodeFoldable _inputs)
!> Key 13 (E encodeFoldable _inputs_fee)
!> Key 1 (E encodeFoldable _outputs)
!> Key 2 (To _txfee)
!> encodeKeyedStrictMaybe 3 top
!> Omit null (Key 4 (E encodeFoldable _certs))
!> Omit (null . unWdrl) (Key 5 (To _wdrls))
!> encodeKeyedStrictMaybe 6 _update
!> encodeKeyedStrictMaybe 8 bot
!> Key 14 (E encodeFoldable _reqSignerHashes)
!> Omit isZero (Key 9 (E encodeMint _mint))
!> encodeKeyedStrictMaybe 11 _wppHash
!> encodeKeyedStrictMaybe 12 _adHash
!> encodeKeyedStrictMaybe 15 _txnetworkid
where
encodeKeyedStrictMaybe key x =
Omit isSNothing (Key key (E (toCBOR . fromSJust) x))
isSNothing :: StrictMaybe a -> Bool
isSNothing SNothing = True
isSNothing _ = False
fromSJust :: StrictMaybe a -> a
fromSJust (SJust x) = x
fromSJust SNothing = error "SNothing in fromSJust. This should never happen, it is guarded by isSNothing"
instance
forall era.
( Era era,
Typeable (Core.Script era),
Typeable (Core.AuxiliaryData era),
Compactible (Core.Value era),
Show (Core.Value era),
DecodeNonNegative (Core.Value era),
FromCBOR (Annotator (Core.Script era)),
FromCBOR (PParamsDelta era),
ToCBOR (PParamsDelta era)
) =>
FromCBOR (TxBodyRaw era)
where
fromCBOR =
decode $
SparseKeyed
"TxBodyRaw"
initial
bodyFields
requiredFields
where
initial :: TxBodyRaw era
initial =
TxBodyRaw
mempty
mempty
StrictSeq.empty
StrictSeq.empty
(Wdrl mempty)
mempty
(ValidityInterval SNothing SNothing)
SNothing
mempty
mempty
SNothing
SNothing
SNothing
bodyFields :: (Word -> Field (TxBodyRaw era))
bodyFields 0 =
field
(\x tx -> tx {_inputs = x})
(D (decodeSet fromCBOR))
bodyFields 13 =
field
(\x tx -> tx {_inputs_fee = x})
(D (decodeSet fromCBOR))
bodyFields 1 =
field
(\x tx -> tx {_outputs = x})
(D (decodeStrictSeq fromCBOR))
bodyFields 2 = field (\x tx -> tx {_txfee = x}) From
bodyFields 3 =
field
(\x tx -> tx {_vldt = (_vldt tx) {invalidHereafter = x}})
(D (SJust <$> fromCBOR))
bodyFields 4 =
field
(\x tx -> tx {_certs = x})
(D (decodeStrictSeq fromCBOR))
bodyFields 5 = field (\x tx -> tx {_wdrls = x}) From
bodyFields 6 = field (\x tx -> tx {_update = x}) (D (SJust <$> fromCBOR))
bodyFields 14 = field (\x tx -> tx {_reqSignerHashes = x}) (D (decodeSet fromCBOR))
bodyFields 8 =
field
(\x tx -> tx {_vldt = (_vldt tx) {invalidBefore = x}})
(D (SJust <$> fromCBOR))
bodyFields 9 = field (\x tx -> tx {_mint = x}) (D decodeMint)
bodyFields 11 = field (\x tx -> tx {_wppHash = x}) (D (SJust <$> fromCBOR))
bodyFields 12 =
field
(\x tx -> tx {_adHash = x})
(D (SJust <$> fromCBOR))
bodyFields 15 = field (\x tx -> tx {_txnetworkid = x}) (D (SJust <$> fromCBOR))
bodyFields n = field (\_ t -> t) (Invalid n)
requiredFields =
[ (0, "inputs"),
(1, "outputs"),
(2, "fee")
]
instance
( Era era,
Typeable (Core.Script era),
Typeable (Core.AuxiliaryData era),
Compactible (Core.Value era),
Show (Core.Value era),
DecodeNonNegative (Core.Value era),
FromCBOR (Annotator (Core.Script era)),
FromCBOR (PParamsDelta era),
ToCBOR (PParamsDelta era)
) =>
FromCBOR (Annotator (TxBodyRaw era))
where
fromCBOR = pure <$> fromCBOR
-- ====================================================
-- HasField instances to be consistent with earlier Eras
instance (Crypto era ~ c) => HasField "inputs" (TxBody era) (Set (TxIn c)) where
getField (TxBodyConstr (Memo m _)) = Set.union (_inputs m) (_inputs_fee m)
instance HasField "outputs" (TxBody era) (StrictSeq (TxOut era)) where
getField (TxBodyConstr (Memo m _)) = _outputs m
instance Crypto era ~ crypto => HasField "certs" (TxBody era) (StrictSeq (DCert crypto)) where
getField (TxBodyConstr (Memo m _)) = _certs m
instance Crypto era ~ crypto => HasField "wdrls" (TxBody era) (Wdrl crypto) where
getField (TxBodyConstr (Memo m _)) = _wdrls m
instance HasField "txfee" (TxBody era) Coin where
getField (TxBodyConstr (Memo m _)) = _txfee m
instance HasField "update" (TxBody era) (StrictMaybe (Update era)) where
getField (TxBodyConstr (Memo m _)) = _update m
instance
(Crypto era ~ c) =>
HasField "reqSignerHashes" (TxBody era) (Set (KeyHash 'Witness c))
where
getField (TxBodyConstr (Memo m _)) = _reqSignerHashes m
instance (Crypto era ~ c) => HasField "mint" (TxBody era) (Mary.Value c) where
getField (TxBodyConstr (Memo m _)) = _mint m
instance (Crypto era ~ c) => HasField "txinputs_fee" (TxBody era) (Set (TxIn c)) where
getField (TxBodyConstr (Memo m _)) = _inputs_fee m
instance (Crypto era ~ c) => HasField "minted" (TxBody era) (Set (ScriptHash c)) where
getField (TxBodyConstr (Memo m _)) = Set.map policyID (policies (_mint m))
instance HasField "vldt" (TxBody era) ValidityInterval where
getField (TxBodyConstr (Memo m _)) = _vldt m
instance
c ~ (Crypto era) =>
HasField "adHash" (TxBody era) (StrictMaybe (AuxiliaryDataHash c))
where
getField (TxBodyConstr (Memo m _)) = _adHash m
instance
c ~ (Crypto era) =>
HasField "wppHash" (TxBody era) (StrictMaybe (WitnessPPDataHash c))
where
getField (TxBodyConstr (Memo m _)) = _wppHash m
instance HasField "txnetworkid" (TxBody era) (StrictMaybe Network) where
getField (TxBodyConstr (Memo m _)) = _txnetworkid m
instance (Crypto era ~ c) => HasField "compactAddress" (TxOut era) (CompactAddr c) where
getField (TxOutCompact a _ _) = a
instance (CC.Crypto c, Crypto era ~ c) => HasField "address" (TxOut era) (Addr c) where
getField (TxOutCompact a _ _) = decompactAddr a
instance c ~ (Crypto era) => HasField "datahash" (TxOut era) (StrictMaybe (DataHash c)) where
getField (TxOutCompact _ _ datahash) = datahash
instance (Core.Value era ~ val, Compactible val) => HasField "value" (TxOut era) val where
getField (TxOutCompact _ v _) = fromCompact v
-- ===================================================
ppTxOut ::
( Era era,
Show (Core.Value era),
PrettyA (Core.Value era)
) =>
TxOut era ->
PDoc
ppTxOut (TxOut addr val dhash) =
ppSexp "TxOut" [ppAddr addr, prettyA val, ppStrictMaybe ppSafeHash dhash]
ppTxBody ::
( Era era,
Show (Core.Value era),
PrettyA (Core.Value era),
PrettyA (PParamsDelta era)
) =>
TxBody era ->
PDoc
ppTxBody (TxBodyConstr (Memo (TxBodyRaw i ifee o c w fee vi u rsh mnt sdh axh ni) _)) =
ppRecord
"TxBody(Alonzo)"
[ ("inputs", ppSet ppTxIn i),
("inputs_fee", ppSet ppTxIn ifee),
("outputs", ppStrictSeq ppTxOut o),
("certificates", ppStrictSeq ppDCert c),
("withdrawals", ppWdrl w),
("txfee", ppCoin fee),
("vldt", ppValidityInterval vi),
("update", ppStrictMaybe ppUpdate u),
("reqSignerHashes", ppSet ppKeyHash rsh),
("mint", ppValue mnt),
("wppHash", ppStrictMaybe ppSafeHash sdh),
("adHash", ppStrictMaybe ppAuxDataHash axh),
("txnetworkid", ppStrictMaybe ppNetwork ni)
]
ppAuxDataHash :: AuxiliaryDataHash crypto -> PDoc
ppAuxDataHash (AuxiliaryDataHash axh) = ppSafeHash axh
instance
( Era era,
PrettyA (Core.Value era),
PrettyA (PParamsDelta era),
Show (Core.Value era)
) =>
PrettyA (TxBody era)
where
prettyA = ppTxBody