Skip to main content

stellar_xdr/generated/
create_contract_args_v2.rs

1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4/// CreateContractArgsV2 is an XDR Struct defined as:
5///
6/// ```text
7/// struct CreateContractArgsV2
8/// {
9///     ContractIDPreimage contractIDPreimage;
10///     ContractExecutable executable;
11///     // Arguments of the contract's constructor.
12///     SCVal constructorArgs<>;
13/// };
14/// ```
15///
16#[cfg_attr(feature = "alloc", derive(Default))]
17#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
18#[cfg_attr(feature = "serde", cfg_eval::cfg_eval)]
19#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
20#[cfg_attr(
21    all(feature = "serde", feature = "alloc"),
22    serde_with::serde_as,
23    derive(serde::Serialize, serde::Deserialize),
24    serde(rename_all = "snake_case")
25)]
26#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
27pub struct CreateContractArgsV2 {
28    pub contract_id_preimage: ContractIdPreimage,
29    pub executable: ContractExecutable,
30    pub constructor_args: VecM<ScVal>,
31}
32
33impl ReadXdr for CreateContractArgsV2 {
34    #[cfg(feature = "std")]
35    fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
36        r.with_limited_depth(|r| {
37            Ok(Self {
38                contract_id_preimage: ContractIdPreimage::read_xdr(r)?,
39                executable: ContractExecutable::read_xdr(r)?,
40                constructor_args: VecM::<ScVal>::read_xdr(r)?,
41            })
42        })
43    }
44}
45
46impl WriteXdr for CreateContractArgsV2 {
47    #[cfg(feature = "std")]
48    fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
49        w.with_limited_depth(|w| {
50            self.contract_id_preimage.write_xdr(w)?;
51            self.executable.write_xdr(w)?;
52            self.constructor_args.write_xdr(w)?;
53            Ok(())
54        })
55    }
56}