1#![cfg_attr(not(feature = "std"), no_std)]
16
17#[cfg(not(feature = "std"))]
18extern crate alloc;
19
20#[cfg(test)]
21mod tests;
22
23pub mod layout;
24mod specs;
25mod utils;
26
27pub use self::specs::{
28 ConstructorSpec,
29 ConstructorSpecBuilder,
30 ContractSpec,
31 ContractSpecBuilder,
32 DisplayName,
33 EventParamSpec,
34 EventParamSpecBuilder,
35 EventSpec,
36 EventSpecBuilder,
37 MessageParamSpec,
38 MessageParamSpecBuilder,
39 MessageSpec,
40 MessageSpecBuilder,
41 ReturnTypeSpec,
42 Selector,
43 TypeSpec,
44};
45
46use impl_serde::serialize as serde_hex;
47
48#[cfg(feature = "derive")]
49use tetsy_scale_info::{
50 form::{
51 FormString,
52 PortableForm,
53 },
54 IntoPortable as _,
55 PortableRegistry,
56 Registry,
57};
58use serde::{
59 de::DeserializeOwned,
60 Deserialize,
61 Serialize,
62};
63
64#[derive(Debug, Serialize, Deserialize)]
66#[serde(bound(deserialize = "S: DeserializeOwned"))]
67pub struct ProProject<S: FormString = &'static str> {
68 #[serde(flatten)]
69 registry: PortableRegistry<S>,
70 #[serde(rename = "storage")]
71 layout: layout::Layout<PortableForm<S>>,
73 spec: ContractSpec<PortableForm<S>>,
74}
75
76impl ProProject {
77 pub fn new<L, S>(layout: L, spec: S) -> Self
78 where
79 L: Into<layout::Layout>,
80 S: Into<ContractSpec>,
81 {
82 let mut registry = Registry::new();
83
84 Self {
85 layout: layout.into().into_portable(&mut registry),
86 spec: spec.into().into_portable(&mut registry),
87 registry: registry.into(),
88 }
89 }
90}
91
92impl<S> ProProject<S>
93where
94 S: FormString,
95{
96 pub fn registry(&self) -> &PortableRegistry<S> {
98 &self.registry
99 }
100
101 pub fn layout(&self) -> &layout::Layout<PortableForm<S>> {
103 &self.layout
104 }
105
106 pub fn spec(&self) -> &ContractSpec<PortableForm<S>> {
108 &self.spec
109 }
110}