radix_transactions/model/v2/
partial_transaction_v2.rs

1use super::*;
2use crate::internal_prelude::*;
3
4//=================================================================================
5// NOTE:
6// See versioned.rs for tests and a demonstration for the calculation of hashes etc
7//=================================================================================
8
9/// An analogue of a [`TransactionIntentV2`], except with a subintent at the root.
10///
11/// This is intended to represent an incomplete sub-tree of the transaction, and be
12/// a canonical model for building, storing and transferring this subtree.
13///
14/// The corresponding signed model is a [`SignedPartialTransactionV2`].
15#[derive(Debug, Clone, Eq, PartialEq, ManifestSbor, ScryptoDescribe)]
16pub struct PartialTransactionV2 {
17    pub root_subintent: SubintentV2,
18    pub non_root_subintents: NonRootSubintentsV2,
19}
20
21define_transaction_payload!(
22    PartialTransactionV2,
23    RawPartialTransaction,
24    PreparedPartialTransactionV2 {
25        root_subintent: PreparedSubintentV2,
26        non_root_subintents: PreparedNonRootSubintentsV2,
27    },
28    TransactionDiscriminator::V2PartialTransaction,
29);
30
31impl PreparedPartialTransactionV2 {
32    pub fn non_root_subintent_hashes(&self) -> impl Iterator<Item = SubintentHash> + '_ {
33        self.non_root_subintents
34            .subintents
35            .iter()
36            .map(|s| s.subintent_hash())
37    }
38}
39
40impl HasSubintentHash for PreparedPartialTransactionV2 {
41    fn subintent_hash(&self) -> SubintentHash {
42        self.root_subintent.subintent_hash()
43    }
44}