@@ -4,7 +4,7 @@ use acropolis_common::{
44 messages:: UTXODeltasMessage , params:: SECURITY_PARAMETER_K , Address , BlockInfo , BlockStatus ,
55 Datum , TxInput , TxOutput , UTXODelta ,
66} ;
7- use acropolis_common:: { AddressDelta , UTxOIdentifier , Value , ValueDelta } ;
7+ use acropolis_common:: { AddressDelta , ReferenceScript , UTxOIdentifier , Value , ValueDelta } ;
88use anyhow:: Result ;
99use async_trait:: async_trait;
1010use std:: collections:: HashMap ;
@@ -22,6 +22,9 @@ pub struct UTXOValue {
2222
2323 /// Datum
2424 pub datum : Option < Datum > ,
25+
26+ /// Reference script
27+ pub reference_script : Option < ReferenceScript > ,
2528}
2629
2730/// Address delta observer
@@ -268,6 +271,7 @@ impl State {
268271 address : output. address . clone ( ) ,
269272 value : output. value . clone ( ) ,
270273 datum : output. datum . clone ( ) ,
274+ reference_script : output. reference_script . clone ( ) ,
271275 } ;
272276
273277 // Add to volatile or immutable maps
@@ -406,7 +410,9 @@ impl State {
406410mod tests {
407411 use super :: * ;
408412 use crate :: InMemoryImmutableUTXOStore ;
409- use acropolis_common:: { AssetName , BlockHash , ByronAddress , Era , NativeAsset , Value } ;
413+ use acropolis_common:: {
414+ AssetName , BlockHash , ByronAddress , Era , NativeAsset , ReferenceScript , Value ,
415+ } ;
410416 use config:: Config ;
411417 use tokio:: sync:: Mutex ;
412418
@@ -450,6 +456,7 @@ mod tests {
450456 async fn observe_output_adds_to_immutable_utxos ( ) {
451457 let mut state = new_state ( ) ;
452458 let datum_data = vec ! [ 1 , 2 , 3 , 4 , 5 ] ;
459+ let reference_script_bytes = vec ! [ 0xde , 0xad , 0xbe , 0xef ] ;
453460
454461 let output = TxOutput {
455462 utxo_identifier : UTxOIdentifier :: new ( 0 , 0 , 0 ) ,
@@ -471,6 +478,7 @@ mod tests {
471478 ) ] ,
472479 ) ,
473480 datum : Some ( Datum :: Inline ( datum_data. clone ( ) ) ) ,
481+ reference_script : Some ( ReferenceScript :: PlutusV1 ( reference_script_bytes. clone ( ) ) ) ,
474482 } ;
475483
476484 let block = create_block ( BlockStatus :: Immutable , 1 , 1 ) ;
@@ -503,6 +511,9 @@ mod tests {
503511 value. datum,
504512 Some ( Datum :: Inline ( ref data) ) if data == & datum_data
505513 ) ) ;
514+ assert ! ( matches!(
515+ value. reference_script,
516+ Some ( ReferenceScript :: PlutusV1 ( ref bytes) ) if bytes == & reference_script_bytes) ) ;
506517 }
507518
508519 _ => panic ! ( "UTXO not found" ) ,
@@ -532,6 +543,7 @@ mod tests {
532543 ) ] ,
533544 ) ,
534545 datum : None ,
546+ reference_script : None ,
535547 } ;
536548
537549 let block1 = create_block ( BlockStatus :: Immutable , 1 , 1 ) ;
@@ -576,6 +588,7 @@ mod tests {
576588 ) ] ,
577589 ) ,
578590 datum : None ,
591+ reference_script : None ,
579592 } ;
580593
581594 let block10 = create_block ( BlockStatus :: Volatile , 10 , 10 ) ;
@@ -616,6 +629,7 @@ mod tests {
616629 ) ] ,
617630 ) ,
618631 datum : None ,
632+ reference_script : None ,
619633 } ;
620634
621635 let block10 = create_block ( BlockStatus :: Volatile , 10 , 10 ) ;
@@ -671,6 +685,7 @@ mod tests {
671685 ) ] ,
672686 ) ,
673687 datum : None ,
688+ reference_script : None ,
674689 } ;
675690
676691 let block1 = create_block ( BlockStatus :: Volatile , 1 , 1 ) ;
@@ -718,6 +733,7 @@ mod tests {
718733 ) ] ,
719734 ) ,
720735 datum : None ,
736+ reference_script : None ,
721737 } ;
722738
723739 let block1 = create_block ( BlockStatus :: Volatile , 1 , 1 ) ;
@@ -826,6 +842,7 @@ mod tests {
826842 ) ] ,
827843 ) ,
828844 datum : None ,
845+ reference_script : None ,
829846 } ;
830847
831848 let block1 = create_block ( BlockStatus :: Immutable , 1 , 1 ) ;
@@ -884,6 +901,7 @@ mod tests {
884901 ) ] ,
885902 ) ,
886903 datum : None ,
904+ reference_script : None ,
887905 } ;
888906
889907 let block10 = create_block ( BlockStatus :: Volatile , 10 , 10 ) ;
@@ -938,6 +956,7 @@ mod tests {
938956 ) ] ,
939957 ) ,
940958 datum : None ,
959+ reference_script : None ,
941960 } ;
942961
943962 let block10 = create_block ( BlockStatus :: Volatile , 10 , 10 ) ;
0 commit comments