forest/lotus_json/
extended_sector_info.rs1use super::*;
5use crate::shim::sector::{ExtendedSectorInfo, RegisteredSealProof};
6use ::cid::Cid;
7
8#[derive(Serialize, Deserialize, JsonSchema)]
9#[serde(rename_all = "PascalCase")]
10#[schemars(rename = "ExtendedSectorInfo")]
11pub struct ExtendedSectorInfoLotusJson {
12 #[schemars(with = "LotusJson<RegisteredSealProof>")]
13 #[serde(with = "crate::lotus_json")]
14 seal_proof: RegisteredSealProof,
15 sector_number: u64,
16 #[schemars(with = "LotusJson<Option<Cid>>")]
17 #[serde(with = "crate::lotus_json")]
18 sector_key: Option<Cid>,
19 #[schemars(with = "LotusJson<Cid>")]
20 #[serde(with = "crate::lotus_json")]
21 sealed_c_i_d: Cid,
22}
23
24impl HasLotusJson for ExtendedSectorInfo {
25 type LotusJson = ExtendedSectorInfoLotusJson;
26
27 #[cfg(test)]
28 fn snapshots() -> Vec<(serde_json::Value, Self)> {
29 vec![(
30 json!({
31 "SealProof": 0,
32 "SectorNumber": 0,
33 "SectorKey": null,
34 "SealedCID": {
35 "/": "baeaaaaa"
36 }
37 }),
38 Self {
39 proof: fvm_shared3::sector::RegisteredSealProof::StackedDRG2KiBV1.into(),
40 sector_number: 0,
41 sector_key: None,
42 sealed_cid: ::cid::Cid::default(),
43 },
44 )]
45 }
46
47 fn into_lotus_json(self) -> Self::LotusJson {
48 Self::LotusJson {
49 seal_proof: self.proof,
50 sector_number: self.sector_number,
51 sector_key: self.sector_key,
52 sealed_c_i_d: self.sealed_cid,
53 }
54 }
55
56 fn from_lotus_json(lotus_json: Self::LotusJson) -> Self {
57 let Self::LotusJson {
58 seal_proof,
59 sector_number,
60 sector_key,
61 sealed_c_i_d,
62 } = lotus_json;
63 Self {
64 proof: seal_proof,
65 sector_number,
66 sector_key,
67 sealed_cid: sealed_c_i_d,
68 }
69 }
70}