Skip to content

Commit

Permalink
Internally compute transaction ID
Browse files Browse the repository at this point in the history
  • Loading branch information
thibault-martinez committed Nov 5, 2023
1 parent 3ecbc84 commit 3f67968
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 0 additions & 2 deletions sdk/src/client/api/block_builder/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,13 @@ pub fn verify_semantic(
input_signing_data: &[InputSigningData],
transaction_payload: &SignedTransactionPayload,
) -> crate::client::Result<Option<TransactionFailureReason>> {
let transaction_id = transaction_payload.transaction().id();
let inputs = input_signing_data
.iter()
.map(|input| (input.output_id(), &input.output))
.collect::<Vec<(&OutputId, &Output)>>();

let context = SemanticValidationContext::new(
transaction_payload.transaction(),
&transaction_id,
&inputs,
Some(transaction_payload.unlocks()),
);
Expand Down
7 changes: 4 additions & 3 deletions sdk/src/types/block/semantic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::types::block::{
AnchorOutput, ChainId, FoundryId, NativeTokens, Output, OutputId, StateTransitionError, TokenId,
UnlockCondition,
},
payload::signed_transaction::{Transaction, TransactionCapabilityFlag, TransactionId, TransactionSigningHash},
payload::signed_transaction::{Transaction, TransactionCapabilityFlag, TransactionSigningHash},
unlock::Unlocks,
Error,
};
Expand Down Expand Up @@ -212,10 +212,11 @@ impl<'a> SemanticValidationContext<'a> {
///
pub fn new(
transaction: &'a Transaction,
transaction_id: &TransactionId,
inputs: &'a [(&'a OutputId, &'a Output)],
unlocks: Option<&'a Unlocks>,
) -> Self {
let transaction_id = transaction.id();

Self {
transaction,
transaction_signing_hash: transaction.signing_hash(),
Expand All @@ -242,7 +243,7 @@ impl<'a> SemanticValidationContext<'a> {
.filter_map(|(index, output)| {
output.chain_id().map(|chain_id| {
(
chain_id.or_from_output_id(&OutputId::new(*transaction_id, index as u16).unwrap()),
chain_id.or_from_output_id(&OutputId::new(transaction_id, index as u16).unwrap()),
output,
)
})
Expand Down

0 comments on commit 3f67968

Please sign in to comment.