radix_transactions/model/v1/
manifest_v1.rs1use super::*;
2use crate::internal_prelude::*;
3
4#[derive(Debug, Clone, Default, PartialEq, Eq, ManifestSbor, ScryptoDescribe)]
12pub struct TransactionManifestV1 {
13 pub instructions: Vec<InstructionV1>,
14 pub blobs: IndexMap<Hash, Vec<u8>>,
15 pub object_names: ManifestObjectNames,
16}
17
18impl ReadableManifestBase for TransactionManifestV1 {
19 fn is_subintent(&self) -> bool {
20 false
21 }
22
23 fn get_blobs<'a>(&'a self) -> impl Iterator<Item = (&'a Hash, &'a Vec<u8>)> {
24 self.blobs.iter()
25 }
26
27 fn get_known_object_names_ref(&self) -> ManifestObjectNamesRef {
28 self.object_names.as_ref()
29 }
30}
31
32impl TypedReadableManifest for TransactionManifestV1 {
33 type Instruction = InstructionV1;
34
35 fn get_typed_instructions(&self) -> &[Self::Instruction] {
36 &self.instructions
37 }
38}
39
40impl BuildableManifest for TransactionManifestV1 {
41 fn add_instruction(&mut self, instruction: Self::Instruction) {
42 self.instructions.push(instruction)
43 }
44
45 fn add_blob(&mut self, hash: Hash, content: Vec<u8>) {
46 self.blobs.insert(hash, content);
47 }
48
49 fn set_names(&mut self, names: KnownManifestObjectNames) {
50 self.object_names = names.into()
51 }
52
53 fn default_test_execution_config_type(&self) -> DefaultTestExecutionConfigType {
54 DefaultTestExecutionConfigType::Test
55 }
56
57 fn into_executable_with_proofs(
58 self,
59 nonce: u32,
60 initial_proofs: BTreeSet<NonFungibleGlobalId>,
61 validator: &TransactionValidator,
62 ) -> Result<ExecutableTransaction, String> {
63 TestTransaction::new_v1_from_nonce(self, nonce, initial_proofs)
64 .into_executable(&validator)
65 .map_err(|err| format!("Could not prepare: {err:?}"))
66 }
67}
68
69impl TransactionManifestV1 {
70 pub fn from_intent(intent: &IntentV1) -> Self {
71 Self {
72 instructions: intent.instructions.clone().into(),
73 blobs: intent.blobs.clone().into(),
74 object_names: Default::default(),
75 }
76 }
77
78 pub fn for_intent(self) -> (InstructionsV1, BlobsV1) {
79 (self.instructions.into(), self.blobs.into())
80 }
81}
82
83#[derive(Debug, Clone, Default, PartialEq, Eq, ManifestSbor, ScryptoDescribe)]
85pub struct LegacyTransactionManifestV1 {
86 pub instructions: Vec<InstructionV1>,
87 pub blobs: IndexMap<Hash, Vec<u8>>,
88 #[sbor(skip)] pub object_names: ManifestObjectNames,
90}
91
92impl From<LegacyTransactionManifestV1> for TransactionManifestV1 {
93 fn from(value: LegacyTransactionManifestV1) -> Self {
94 Self {
95 instructions: value.instructions,
96 blobs: value.blobs,
97 object_names: value.object_names,
98 }
99 }
100}