@@ -153,8 +153,7 @@ func (t TxInfoV3) ToPlutusData() data.PlutusData {
153
153
toPlutusData (t .Outputs ),
154
154
data .NewInteger (new (big.Int ).SetUint64 (t .Fee )),
155
155
t .Mint .ToPlutusData (),
156
- // TODO: certs
157
- toPlutusData ([]any {}),
156
+ certificatesToPlutusData (t .Certificates ),
158
157
toPlutusData (t .Withdrawals ),
159
158
t .ValidRange .ToPlutusData (),
160
159
toPlutusData (t .Signatories ),
@@ -165,10 +164,8 @@ func (t TxInfoV3) ToPlutusData() data.PlutusData {
165
164
data .NewMap ([][2 ]data.PlutusData {}),
166
165
// TODO: proposal procedures
167
166
toPlutusData ([]any {}),
168
- // TODO: current treasury amount
169
- data .NewConstr (1 ),
170
- // TODO: treasury donation
171
- data .NewConstr (1 ),
167
+ t .CurrentTreasuryAmount .ToPlutusData (),
168
+ t .TreasuryDonation .ToPlutusData (),
172
169
)
173
170
}
174
171
@@ -187,7 +184,7 @@ func NewTxInfoV3FromTransaction(
187
184
resolvedInputs ,
188
185
inputs ,
189
186
* assetMint ,
190
- // TODO: certificates
187
+ tx . Certificates (),
191
188
tx .Withdrawals (),
192
189
// TODO: proposal procedures
193
190
// TODO: votes
@@ -207,15 +204,20 @@ func NewTxInfoV3FromTransaction(
207
204
tx .TTL (),
208
205
tx .ValidityIntervalStart (),
209
206
},
210
- Withdrawals : tx .Withdrawals (),
211
- Signatories : signatoriesInfo (tx .RequiredSigners ()),
212
- Redeemers : redeemers ,
213
- Data : tmpData ,
214
- Id : tx .Hash (),
207
+ Certificates : tx .Certificates (),
208
+ Withdrawals : tx .Withdrawals (),
209
+ Signatories : signatoriesInfo (tx .RequiredSigners ()),
210
+ Redeemers : redeemers ,
211
+ Data : tmpData ,
212
+ Id : tx .Hash (),
215
213
// TODO: Votes
216
214
// TODO: ProposalProcedures
217
- // TODO: CurrentTreasuryAmount
218
- // TODO: TreasuryDonation
215
+ }
216
+ if amt := tx .CurrentTreasuryValue (); amt > 0 {
217
+ ret .CurrentTreasuryAmount .Value = amt
218
+ }
219
+ if amt := tx .Donation (); amt > 0 {
220
+ ret .TreasuryDonation .Value = amt
219
221
}
220
222
return ret
221
223
}
@@ -396,3 +398,144 @@ func signatoriesInfo(
396
398
)
397
399
return tmp
398
400
}
401
+
402
+ func certificatesToPlutusData (
403
+ certificates []lcommon.Certificate ,
404
+ ) data.PlutusData {
405
+ tmpCerts := make ([]data.PlutusData , len (certificates ))
406
+ for idx , cert := range certificates {
407
+ tmpCerts [idx ] = certificateToPlutusData (cert )
408
+ }
409
+ return data .NewList (tmpCerts ... )
410
+ }
411
+
412
+ func certificateToPlutusData (
413
+ certificate lcommon.Certificate ,
414
+ ) data.PlutusData {
415
+ switch c := certificate .(type ) {
416
+ case * lcommon.StakeRegistrationCertificate :
417
+ return data .NewConstr (
418
+ 0 ,
419
+ c .StakeCredential .ToPlutusData (),
420
+ data .NewConstr (1 ),
421
+ )
422
+ case * lcommon.RegistrationCertificate :
423
+ return data .NewConstr (
424
+ 0 ,
425
+ c .StakeCredential .ToPlutusData (),
426
+ data .NewConstr (1 ),
427
+ )
428
+ case * lcommon.StakeDeregistrationCertificate :
429
+ return data .NewConstr (
430
+ 1 ,
431
+ c .StakeCredential .ToPlutusData (),
432
+ data .NewConstr (1 ),
433
+ )
434
+ case * lcommon.DeregistrationCertificate :
435
+ return data .NewConstr (
436
+ 1 ,
437
+ c .StakeCredential .ToPlutusData (),
438
+ data .NewConstr (1 ),
439
+ )
440
+ case * lcommon.StakeDelegationCertificate :
441
+ return data .NewConstr (
442
+ 2 ,
443
+ c .StakeCredential .ToPlutusData (),
444
+ data .NewConstr (
445
+ 0 ,
446
+ c .PoolKeyHash .ToPlutusData (),
447
+ ),
448
+ )
449
+ case * lcommon.VoteDelegationCertificate :
450
+ return data .NewConstr (
451
+ 2 ,
452
+ c .StakeCredential .ToPlutusData (),
453
+ data .NewConstr (
454
+ 1 ,
455
+ c .Drep .ToPlutusData (),
456
+ ),
457
+ )
458
+ case * lcommon.StakeVoteDelegationCertificate :
459
+ return data .NewConstr (
460
+ 2 ,
461
+ c .StakeCredential .ToPlutusData (),
462
+ data .NewConstr (
463
+ 2 ,
464
+ toPlutusData (c .PoolKeyHash ),
465
+ c .Drep .ToPlutusData (),
466
+ ),
467
+ )
468
+ case * lcommon.StakeRegistrationDelegationCertificate :
469
+ return data .NewConstr (
470
+ 3 ,
471
+ c .StakeCredential .ToPlutusData (),
472
+ data .NewConstr (
473
+ 0 ,
474
+ toPlutusData (c .PoolKeyHash ),
475
+ ),
476
+ data .NewInteger (big .NewInt (c .Amount )),
477
+ )
478
+ case * lcommon.VoteRegistrationDelegationCertificate :
479
+ return data .NewConstr (
480
+ 3 ,
481
+ c .StakeCredential .ToPlutusData (),
482
+ data .NewConstr (
483
+ 1 ,
484
+ c .Drep .ToPlutusData (),
485
+ ),
486
+ data .NewInteger (big .NewInt (c .Amount )),
487
+ )
488
+ case * lcommon.StakeVoteRegistrationDelegationCertificate :
489
+ return data .NewConstr (
490
+ 3 ,
491
+ c .StakeCredential .ToPlutusData (),
492
+ data .NewConstr (
493
+ 2 ,
494
+ c .PoolKeyHash .ToPlutusData (),
495
+ c .Drep .ToPlutusData (),
496
+ ),
497
+ data .NewInteger (big .NewInt (c .Amount )),
498
+ )
499
+ case * lcommon.RegistrationDrepCertificate :
500
+ return data .NewConstr (
501
+ 4 ,
502
+ c .DrepCredential .ToPlutusData (),
503
+ data .NewInteger (big .NewInt (c .Amount )),
504
+ )
505
+ case * lcommon.UpdateDrepCertificate :
506
+ return data .NewConstr (
507
+ 5 ,
508
+ c .DrepCredential .ToPlutusData (),
509
+ )
510
+ case * lcommon.DeregistrationDrepCertificate :
511
+ return data .NewConstr (
512
+ 6 ,
513
+ c .DrepCredential .ToPlutusData (),
514
+ data .NewInteger (big .NewInt (c .Amount )),
515
+ )
516
+ case * lcommon.PoolRegistrationCertificate :
517
+ return data .NewConstr (
518
+ 7 ,
519
+ toPlutusData (c .Operator ),
520
+ toPlutusData (c .VrfKeyHash ),
521
+ )
522
+ case * lcommon.PoolRetirementCertificate :
523
+ return data .NewConstr (
524
+ 8 ,
525
+ toPlutusData (c .PoolKeyHash ),
526
+ data .NewInteger (new (big.Int ).SetUint64 (c .Epoch )),
527
+ )
528
+ case * lcommon.AuthCommitteeHotCertificate :
529
+ return data .NewConstr (
530
+ 9 ,
531
+ c .ColdCredential .ToPlutusData (),
532
+ c .HotCredential .ToPlutusData (),
533
+ )
534
+ case * lcommon.ResignCommitteeColdCertificate :
535
+ return data .NewConstr (
536
+ 10 ,
537
+ c .ColdCredential .ToPlutusData (),
538
+ )
539
+ }
540
+ return nil
541
+ }
0 commit comments