neo3/neo_wallets/wallet/
nep6contract.rs

1use getset::Getters;
2use serde::{Deserialize, Serialize};
3
4use neo3::prelude::ContractParameterType;
5
6/// Represents a NEP-6 contract.
7#[derive(Clone, Debug, Serialize, Deserialize, Getters)]
8pub struct NEP6Contract {
9	/// The script associated with the contract.
10	#[getset(get = "pub")]
11	#[serde(rename = "script")]
12	pub script: Option<String>,
13
14	/// Indicates whether the contract is deployed.
15	#[getset(get = "pub")]
16	#[serde(rename = "deployed")]
17	pub is_deployed: bool,
18
19	/// The NEP-6 parameters associated with the contract.
20	#[getset(get = "pub")]
21	#[serde(rename = "parameters")]
22	pub nep6_parameters: Vec<NEP6Parameter>,
23}
24
25/// Represents a NEP-6 parameter.
26#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Getters)]
27pub struct NEP6Parameter {
28	/// The name of the parameter.
29	#[getset(get = "pub")]
30	#[serde(rename = "name")]
31	pub param_name: String,
32
33	/// The type of the parameter.
34	#[getset(get = "pub")]
35	#[serde(rename = "type")]
36	pub param_type: ContractParameterType,
37}
38
39impl PartialEq for NEP6Contract {
40	/// Checks if two `NEP6Contract` instances are equal.
41	///
42	/// # Example
43	///
44	/// ```
45	/// use neo3::prelude::*;
46	///
47	/// # let contract1 = wallets::NEP6Contract { script: None, is_deployed: false, nep6_parameters: vec![] };
48	/// # let contract2 = wallets::NEP6Contract { script: None, is_deployed: false, nep6_parameters: vec![] };
49	/// assert_eq!(contract1, contract2);
50	/// ```
51	fn eq(&self, other: &Self) -> bool {
52		self.script == other.script
53			&& self.nep6_parameters == other.nep6_parameters
54			&& self.is_deployed == other.is_deployed
55	}
56}