radix_engine_interface/blueprints/resource/
proof.rs1use crate::blueprints::resource::*;
2use crate::internal_prelude::*;
3use radix_common::data::scrypto::model::*;
4use radix_common::data::scrypto::ScryptoCustomTypeKind;
5use radix_common::data::scrypto::ScryptoCustomValueKind;
6use radix_common::data::scrypto::*;
7use radix_common::types::*;
8use sbor::rust::prelude::*;
9use sbor::*;
10
11pub const PROOF_DROP_IDENT: &str = "Proof_drop";
12
13#[derive(Debug, Eq, PartialEq, ScryptoSbor)]
14pub struct ProofDropInput {
15 pub proof: Proof,
16}
17
18#[derive(Debug, Eq, PartialEq, ManifestSbor)]
19pub struct ProofDropManifestInput {
20 pub proof: InternalAddress,
21}
22
23pub type ProofDropOutput = ();
24
25pub const PROOF_GET_AMOUNT_IDENT: &str = "Proof_get_amount";
26
27#[derive(Debug, Clone, Eq, PartialEq, Sbor)]
28pub struct ProofGetAmountInput {}
29
30pub type ProofGetAmountManifestInput = ProofGetAmountInput;
31
32pub type ProofGetAmountOutput = Decimal;
33
34pub const PROOF_GET_RESOURCE_ADDRESS_IDENT: &str = "Proof_get_resource_address";
35
36#[derive(Debug, Clone, Eq, PartialEq, Sbor)]
37pub struct ProofGetResourceAddressInput {}
38
39pub type ProofGetResourceAddressManifestInput = ProofGetResourceAddressInput;
40
41pub type ProofGetResourceAddressOutput = ResourceAddress;
42
43pub const PROOF_CLONE_IDENT: &str = "clone";
44
45#[derive(Debug, Clone, Eq, PartialEq, Sbor)]
46pub struct ProofCloneInput {}
47
48pub type ProofCloneManifestInput = ProofCloneInput;
49
50pub type ProofCloneOutput = Proof;
51
52#[derive(Debug, PartialEq, Eq, Hash)]
57#[must_use]
58pub struct Proof(pub Own);
59
60#[derive(Debug, PartialEq, Eq, Hash, ScryptoEncode, ScryptoDecode, ScryptoCategorize)]
61#[sbor(transparent)]
62#[must_use]
63pub struct FungibleProof(pub Proof);
64
65impl AsRef<Proof> for FungibleProof {
66 fn as_ref(&self) -> &Proof {
67 &self.0
68 }
69}
70
71impl From<FungibleProof> for Proof {
72 fn from(value: FungibleProof) -> Self {
73 value.0
74 }
75}
76
77#[derive(Debug, PartialEq, Eq, Hash, ScryptoEncode, ScryptoDecode, ScryptoCategorize)]
78#[sbor(transparent)]
79#[must_use]
80pub struct NonFungibleProof(pub Proof);
81
82impl AsRef<Proof> for NonFungibleProof {
83 fn as_ref(&self) -> &Proof {
84 &self.0
85 }
86}
87
88impl From<NonFungibleProof> for Proof {
89 fn from(value: NonFungibleProof) -> Self {
90 value.0
91 }
92}
93
94impl Categorize<ScryptoCustomValueKind> for Proof {
99 #[inline]
100 fn value_kind() -> ValueKind<ScryptoCustomValueKind> {
101 Own::value_kind()
102 }
103}
104
105impl<E: Encoder<ScryptoCustomValueKind>> Encode<ScryptoCustomValueKind, E> for Proof {
106 #[inline]
107 fn encode_value_kind(&self, encoder: &mut E) -> Result<(), EncodeError> {
108 encoder.write_value_kind(Self::value_kind())
109 }
110
111 #[inline]
112 fn encode_body(&self, encoder: &mut E) -> Result<(), EncodeError> {
113 self.0.encode_body(encoder)
114 }
115}
116
117impl<D: Decoder<ScryptoCustomValueKind>> Decode<ScryptoCustomValueKind, D> for Proof {
118 fn decode_body_with_value_kind(
119 decoder: &mut D,
120 value_kind: ValueKind<ScryptoCustomValueKind>,
121 ) -> Result<Self, DecodeError> {
122 Own::decode_body_with_value_kind(decoder, value_kind).map(|o| Self(o))
123 }
124}
125
126impl Describe<ScryptoCustomTypeKind> for Proof {
127 const TYPE_ID: RustTypeId =
128 RustTypeId::WellKnown(well_known_scrypto_custom_types::OWN_PROOF_TYPE);
129
130 fn type_data() -> TypeData<ScryptoCustomTypeKind, RustTypeId> {
131 well_known_scrypto_custom_types::own_proof_type_data()
132 }
133}
134
135impl Describe<ScryptoCustomTypeKind> for FungibleProof {
136 const TYPE_ID: RustTypeId =
137 RustTypeId::WellKnown(well_known_scrypto_custom_types::OWN_FUNGIBLE_PROOF_TYPE);
138
139 fn type_data() -> TypeData<ScryptoCustomTypeKind, RustTypeId> {
140 well_known_scrypto_custom_types::own_fungible_proof_type_data()
141 }
142}
143
144impl Describe<ScryptoCustomTypeKind> for NonFungibleProof {
145 const TYPE_ID: RustTypeId =
146 RustTypeId::WellKnown(well_known_scrypto_custom_types::OWN_NON_FUNGIBLE_PROOF_TYPE);
147
148 fn type_data() -> TypeData<ScryptoCustomTypeKind, RustTypeId> {
149 well_known_scrypto_custom_types::own_non_fungible_proof_type_data()
150 }
151}