Skip to content

Commit 99cb276

Browse files
committed
fix: Babbage datum option and script ref to Plutus Data
Signed-off-by: Aurora Gaffney <[email protected]>
1 parent 42b1155 commit 99cb276

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

ledger/babbage/babbage.go

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -528,16 +528,38 @@ func (o BabbageTransactionOutput) ToPlutusData() data.PlutusData {
528528
assetDataMap.Pairs...,
529529
)
530530
}
531+
var datumOptionPd data.PlutusData
532+
switch {
533+
case o.DatumOption == nil:
534+
datumOptionPd = data.NewConstr(0)
535+
case o.DatumOption.hash != nil:
536+
datumOptionPd = data.NewConstr(
537+
1,
538+
data.NewByteString(o.DatumOption.hash.Bytes()),
539+
)
540+
case o.DatumOption.data != nil:
541+
datumOptionPd = data.NewConstr(
542+
2,
543+
o.DatumOption.data.Data,
544+
)
545+
}
546+
var scriptRefPd data.PlutusData
547+
if o.TxOutScriptRef == nil {
548+
scriptRefPd = data.NewConstr(1)
549+
} else {
550+
scriptRefPd = data.NewConstr(
551+
0,
552+
data.NewByteString(
553+
o.TxOutScriptRef.Script.Hash().Bytes(),
554+
),
555+
)
556+
}
531557
tmpData := data.NewConstr(
532558
0,
533559
o.OutputAddress.ToPlutusData(),
534560
data.NewMap(valueData),
535-
// Empty datum option
536-
// TODO: implement this
537-
data.NewConstr(0),
538-
// Empty script ref
539-
// TODO: implement this
540-
data.NewConstr(1),
561+
datumOptionPd,
562+
scriptRefPd,
541563
)
542564
return tmpData
543565
}

0 commit comments

Comments
 (0)