Skip to content

Commit efc5e37

Browse files
committed
Added functions get_auxiliary_data and build_tx
1 parent 94c2f73 commit efc5e37

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

rust/src/tx_builder.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,10 @@ impl TransactionBuilder {
489489
};
490490
}
491491

492+
pub fn get_auxiliary_data(&self) -> Option<AuxiliaryData> {
493+
self.auxiliary_data.clone()
494+
}
495+
492496
/// Set explicit auxiliary data via an AuxiliaryData object
493497
/// It might contain some metadata plus native or Plutus scripts
494498
pub fn set_auxiliary_data(&mut self, auxiliary_data: &AuxiliaryData) {
@@ -899,6 +903,9 @@ impl TransactionBuilder {
899903
return self.outputs.0.iter().map(|o| { o.to_bytes().len() }).collect();
900904
}
901905

906+
/// Returns object the body of the new transaction
907+
/// Auxiliary data itself is not included
908+
/// You can use `get_auxiliary_date` or `build_tx`
902909
pub fn build(&self) -> Result<TransactionBody, JsError> {
903910
let (body, full_tx_size) = self.build_and_size()?;
904911
if full_tx_size > self.max_tx_size as usize {
@@ -912,6 +919,18 @@ impl TransactionBuilder {
912919
}
913920
}
914921

922+
/// Returns full Transaction object with the body and the auxiliary data
923+
/// NOTE: witness_set is set to just empty set
924+
/// NOTE: is_valid set to true
925+
pub fn build_tx(&self) -> Result<Transaction, JsError> {
926+
Ok(Transaction {
927+
body: self.build()?,
928+
witness_set: TransactionWitnessSet::new(),
929+
is_valid: true,
930+
auxiliary_data: self.auxiliary_data.clone(),
931+
})
932+
}
933+
915934
/// warning: sum of all parts of a transaction must equal 0. You cannot just set the fee to the min value and forget about it
916935
/// warning: min_fee may be slightly larger than the actual minimum fee (ex: a few lovelaces)
917936
/// this is done to simplify the library code, but can be fixed later

0 commit comments

Comments
 (0)