Skip to main content

stellar_xdr/generated/
invoke_contract_args.rs

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