1pub mod timeline;
2
3use std::collections::HashSet;
4
5pub use self::timeline::TimelineStatus;
6
7use crate::str_serializers::*;
8
9use near_sdk::{near, AccountId, BlockHeight, Timestamp};
10
11pub type RFPId = u32;
12
13type PostTag = String;
14
15#[near(serializers=[borsh, json])]
16#[derive(Clone)]
17#[serde(tag = "rfp_version")]
18pub enum VersionedRFP {
19 V0(RFP),
20}
21
22#[near(serializers=[borsh, json])]
23#[derive(Clone)]
24pub struct RFP {
25 pub id: RFPId,
26 pub author_id: AccountId,
27 #[serde(
28 serialize_with = "u64_dec_format::serialize",
29 deserialize_with = "u64_dec_format::deserialize"
30 )]
31 pub social_db_post_block_height: BlockHeight,
32 pub snapshot: RFPSnapshot,
33 pub snapshot_history: Vec<BlockHeight>,
36}
37
38impl From<VersionedRFP> for RFP {
39 fn from(vp: VersionedRFP) -> Self {
40 match vp {
41 VersionedRFP::V0(v0) => v0,
42 }
43 }
44}
45
46impl From<RFP> for VersionedRFP {
47 fn from(p: RFP) -> Self {
48 VersionedRFP::V0(p)
49 }
50}
51
52#[near(serializers=[borsh, json])]
53#[derive(Clone)]
54pub struct RFPSnapshot {
55 pub editor_id: AccountId,
56 #[serde(
57 serialize_with = "u64_dec_format::serialize",
58 deserialize_with = "u64_dec_format::deserialize"
59 )]
60 pub timestamp: Timestamp,
61 #[serde(
62 serialize_with = "u64_dec_format::serialize",
63 deserialize_with = "u64_dec_format::deserialize"
64 )]
65 pub block_height: BlockHeight,
66 pub labels: HashSet<PostTag>,
67 #[serde(flatten)]
68 pub body: VersionedRFPBody,
69 pub linked_proposals: HashSet<RFPId>,
70}
71
72#[near(serializers=[borsh, json])]
73#[derive(Clone)]
74pub struct RFPBodyV0 {
75 pub name: String,
76 pub summary: String,
77 pub description: String,
78 pub timeline: TimelineStatus,
79 #[serde(
80 serialize_with = "u64_dec_format::serialize",
81 deserialize_with = "u64_dec_format::deserialize"
82 )]
83 pub submission_deadline: Timestamp,
84}
85
86#[near(serializers=[borsh, json])]
87#[derive(Clone)]
88#[serde(tag = "rfp_body_version")]
89pub enum VersionedRFPBody {
90 V0(RFPBodyV0),
91}
92
93impl From<VersionedRFPBody> for RFPBodyV0 {
94 fn from(solution: VersionedRFPBody) -> Self {
95 match solution {
96 VersionedRFPBody::V0(v0) => v0,
97 }
98 }
99}
100
101impl From<RFPBodyV0> for VersionedRFPBody {
102 fn from(p: RFPBodyV0) -> Self {
103 VersionedRFPBody::V0(p)
104 }
105}
106
107impl VersionedRFPBody {
108 pub fn latest_version(self) -> RFPBodyV0 {
109 self.into()
110 }
111}
112
113pub enum LinkedProposalChangeOperation {
114 Add,
115 Remove,
116}