Skip to main content

miden_objects/decoded/transaction/
effects.rs

1use miden_protobuf::unwrap_infallible;
2pub use proto::transaction::DecodedTransactionEffects as TransactionEffects;
3
4use crate::decoded::VerificationError;
5use crate::{Verify, proto};
6
7/// Dispatches the decoded version.
8impl Verify for TransactionEffects {
9    type Verified = miden_protocol::transaction::TransactionEffects;
10    type Error = VerificationError;
11    fn verify(self) -> Result<Self::Verified, Self::Error> {
12        let proto::transaction::transaction_effects::DecodedVersion::V1(effects) = self.version;
13        effects.verify()
14    }
15}
16
17pub use proto::transaction::DecodedTransactionEffectsV1 as TransactionEffectsV1;
18
19/// Verifies the effects. The account patch, the input notes and the output notes are each
20/// verified, and both note collections are checked for duplicates and length limits.
21///
22/// The reference block commitment is not checked against the reference block number, the account
23/// patch is not checked to belong to the account the transaction ran against, and input notes are
24/// not authenticated.
25impl Verify for TransactionEffectsV1 {
26    type Verified = miden_protocol::transaction::TransactionEffects;
27    type Error = VerificationError;
28    fn verify(self) -> Result<Self::Verified, Self::Error> {
29        Ok(Self::Verified::new(
30            self.initial_state_commitment,
31            self.final_state_commitment,
32            self.account_patch.verify()?,
33            self.input_notes.verify()?,
34            self.output_notes.verify()?,
35            unwrap_infallible(self.ref_block_number.verify()),
36            self.ref_block_commitment,
37            unwrap_infallible(self.expiration_block_num.verify()),
38        ))
39    }
40}