@@ -250,85 +250,102 @@ instance Typeable l => DecCBOR (DijkstraTxBodyRaw l DijkstraEra) where
250250 basicDijkstraTxBodyRaw
251251 bodyFields
252252 requiredFields
253- where
254- bodyFields :: Word -> Field (DijkstraTxBodyRaw l DijkstraEra )
255- bodyFields 0 = field (\ x tx -> tx {dtbrSpendInputs = x}) From
256- bodyFields 1 = field (\ x tx -> tx {dtbrOutputs = x}) From
257- bodyFields 2 = field (\ x tx -> tx {dtbrFee = x}) From
258- bodyFields 3 =
259- ofield
260- (\ x tx -> tx {dtbrVldt = (dtbrVldt tx) {invalidHereafter = x}})
261- From
262- bodyFields 4 =
263- fieldGuarded
264- (emptyFailure " Certificates" " non-empty" )
265- OSet. null
266- (\ x tx -> tx {dtbrCerts = x})
267- From
268- bodyFields 5 =
269- fieldGuarded
270- (emptyFailure " Withdrawals" " non-empty" )
271- (null . unWithdrawals)
272- (\ x tx -> tx {dtbrWithdrawals = x})
273- From
274- bodyFields 7 = ofield (\ x tx -> tx {dtbrAuxDataHash = x}) From
275- bodyFields 8 =
276- ofield
277- (\ x tx -> tx {dtbrVldt = (dtbrVldt tx) {invalidBefore = x}})
278- From
279- bodyFields 9 =
280- fieldGuarded
281- (emptyFailure " Mint" " non-empty" )
282- (== mempty )
283- (\ x tx -> tx {dtbrMint = x})
284- From
285- bodyFields 11 = ofield (\ x tx -> tx {dtbrScriptIntegrityHash = x}) From
286- bodyFields 13 =
287- fieldGuarded
288- (emptyFailure " Collateral Inputs" " non-empty" )
289- null
290- (\ x tx -> tx {dtbrCollateralInputs = x})
291- From
292- bodyFields 14 =
293- ofield
294- (\ x tx -> tx {dtbrGuards = fromSMaybe mempty x})
295- (D decodeGuards)
296- bodyFields 15 = ofield (\ x tx -> tx {dtbrNetworkId = x}) From
297- bodyFields 16 = ofield (\ x tx -> tx {dtbrCollateralReturn = x}) From
298- bodyFields 17 = ofield (\ x tx -> tx {dtbrTotalCollateral = x}) From
299- bodyFields 18 =
300- fieldGuarded
301- (emptyFailure " Reference Inputs" " non-empty" )
302- null
303- (\ x tx -> tx {dtbrReferenceInputs = x})
304- From
305- bodyFields 19 =
306- fieldGuarded
307- (emptyFailure " VotingProcedures" " non-empty" )
308- (null . unVotingProcedures)
309- (\ x tx -> tx {dtbrVotingProcedures = x})
310- From
311- bodyFields 20 =
312- fieldGuarded
313- (emptyFailure " ProposalProcedures" " non-empty" )
314- OSet. null
315- (\ x tx -> tx {dtbrProposalProcedures = x})
316- From
317- bodyFields 21 = ofield (\ x tx -> tx {dtbrCurrentTreasuryValue = x}) From
318- bodyFields 22 =
319- ofield
320- (\ x tx -> tx {dtbrTreasuryDonation = fromSMaybe zero x})
321- (D (decodePositiveCoin $ emptyFailure " Treasury Donation" " non-zero" ))
322- bodyFields n = invalidField n
323- requiredFields :: [(Word , String )]
324- requiredFields =
325- [ (0 , " inputs" )
326- , (1 , " outputs" )
327- , (2 , " fee" )
328- ]
329- emptyFailure fieldName requirement =
330- " TxBody: '" <> fieldName <> " ' must be " <> requirement <> " when supplied"
331- SSubTx -> undefined
253+ SSubTx ->
254+ decode $
255+ SparseKeyed
256+ " SubTxBodyRaw"
257+ basicDijkstraSubTxBodyRaw
258+ bodyFields
259+ requiredFields
260+ where
261+ -- TODO WTH, why is this type checking?
262+ bodyFields :: Word -> Field (DijkstraTxBodyRaw l DijkstraEra )
263+ bodyFields 0 = field (\ x tx -> tx {dtbrSpendInputs = x}) From
264+ bodyFields 1 = field (\ x tx -> tx {dtbrOutputs = x}) From
265+ bodyFields n@ 2 =
266+ withSTxBothLevels @ l $ \ case
267+ STopTx -> field (\ x tx -> tx {dtbrFee = x}) From
268+ SSubTx -> invalidField n
269+ bodyFields n@ 3 =
270+ withSTxBothLevels @ l $ \ case
271+ STopTx ->
272+ ofield
273+ (\ x tx -> tx {dtbrVldt = (dtbrVldt tx) {invalidHereafter = x}})
274+ From
275+ SSubTx -> invalidField n
276+ bodyFields 4 =
277+ fieldGuarded
278+ (emptyFailure " Certificates" " non-empty" )
279+ OSet. null
280+ (\ x tx -> tx {dtbrCerts = x})
281+ From
282+ bodyFields 5 =
283+ fieldGuarded
284+ (emptyFailure " Withdrawals" " non-empty" )
285+ (null . unWithdrawals)
286+ (\ x tx -> tx {dtbrWithdrawals = x})
287+ From
288+ bodyFields 7 = ofield (\ x tx -> tx {dtbrAuxDataHash = x}) From
289+ bodyFields n@ 8 =
290+ withSTxBothLevels @ l $ \ case
291+ STopTx ->
292+ ofield
293+ (\ x tx -> tx {dtbrVldt = (dtbrVldt tx) {invalidBefore = x}})
294+ From
295+ SSubTx ->
296+ invalidField n
297+ bodyFields 9 =
298+ fieldGuarded
299+ (emptyFailure " Mint" " non-empty" )
300+ (== mempty )
301+ (\ x tx -> tx {dtbrMint = x})
302+ From
303+ bodyFields 11 = ofield (\ x tx -> tx {dtbrScriptIntegrityHash = x}) From
304+ bodyFields 13 =
305+ fieldGuarded
306+ (emptyFailure " Collateral Inputs" " non-empty" )
307+ null
308+ (\ x tx -> tx {dtbrCollateralInputs = x})
309+ From
310+ bodyFields 14 =
311+ ofield
312+ (\ x tx -> tx {dtbrGuards = fromSMaybe mempty x})
313+ (D decodeGuards)
314+ bodyFields 15 = ofield (\ x tx -> tx {dtbrNetworkId = x}) From
315+ bodyFields 16 = ofield (\ x tx -> tx {dtbrCollateralReturn = x}) From
316+ bodyFields 17 = ofield (\ x tx -> tx {dtbrTotalCollateral = x}) From
317+ bodyFields 18 =
318+ fieldGuarded
319+ (emptyFailure " Reference Inputs" " non-empty" )
320+ null
321+ (\ x tx -> tx {dtbrReferenceInputs = x})
322+ From
323+ bodyFields 19 =
324+ fieldGuarded
325+ (emptyFailure " VotingProcedures" " non-empty" )
326+ (null . unVotingProcedures)
327+ (\ x tx -> tx {dtbrVotingProcedures = x})
328+ From
329+ bodyFields 20 =
330+ fieldGuarded
331+ (emptyFailure " ProposalProcedures" " non-empty" )
332+ OSet. null
333+ (\ x tx -> tx {dtbrProposalProcedures = x})
334+ From
335+ bodyFields 21 = ofield (\ x tx -> tx {dtbrCurrentTreasuryValue = x}) From
336+ bodyFields 22 =
337+ ofield
338+ (\ x tx -> tx {dtbrTreasuryDonation = fromSMaybe zero x})
339+ (D (decodePositiveCoin $ emptyFailure " Treasury Donation" " non-zero" ))
340+ bodyFields n = invalidField n
341+ requiredFields :: [(Word , String )]
342+ requiredFields =
343+ [ (0 , " inputs" )
344+ , (1 , " outputs" )
345+ , (2 , " fee" )
346+ ]
347+ emptyFailure fieldName requirement =
348+ " TxBody: '" <> fieldName <> " ' must be " <> requirement <> " when supplied"
332349
333350encodeTxBodyRaw ::
334351 DijkstraTxBodyRaw l DijkstraEra ->
@@ -535,7 +552,7 @@ instance EraTxBody DijkstraEra where
535552 mkBasicTxBody =
536553 asSTxBothLevels
537554 (mkMemoizedEra @ DijkstraEra basicDijkstraTxBodyRaw)
538- undefined
555+ (mkMemoizedEra @ DijkstraEra basicDijkstraSubTxBodyRaw)
539556
540557 inputsTxBodyL =
541558 lensMemoRawType @ DijkstraEra
@@ -612,6 +629,25 @@ instance EraTxBody DijkstraEra where
612629 getTotalRefundsTxBody pp lookupStakingDeposit lookupDRepDeposit txBody =
613630 getTotalRefundsTxCerts pp lookupStakingDeposit lookupDRepDeposit (txBody ^. certsTxBodyL)
614631
632+ basicDijkstraSubTxBodyRaw :: DijkstraTxBodyRaw SubTx DijkstraEra
633+ basicDijkstraSubTxBodyRaw =
634+ DijkstraSubTxBodyRaw
635+ mempty
636+ mempty
637+ mempty
638+ mempty
639+ (Withdrawals mempty )
640+ (ValidityInterval SNothing SNothing )
641+ mempty
642+ mempty
643+ SNothing
644+ SNothing
645+ SNothing
646+ (VotingProcedures mempty )
647+ mempty
648+ mempty
649+ mempty
650+
615651upgradeGovAction ::
616652 forall era .
617653 (AlonzoEraPParams era , EraPParams (PreviousEra era )) =>
0 commit comments