forest/lotus_json/
tipset_keys.rs

1// Copyright 2019-2025 ChainSafe Systems
2// SPDX-License-Identifier: Apache-2.0, MIT
3
4use super::*;
5use crate::blocks::TipsetKey;
6use ::cid::Cid;
7
8impl HasLotusJson for TipsetKey {
9    type LotusJson = nunny::Vec<<Cid as HasLotusJson>::LotusJson>;
10
11    #[cfg(test)]
12    fn snapshots() -> Vec<(serde_json::Value, Self)> {
13        vec![(
14            json!([{"/": "baeaaaaa"}]),
15            ::nunny::vec![::cid::Cid::default()].into(),
16        )]
17    }
18
19    fn into_lotus_json(self) -> Self::LotusJson {
20        self.into_cids()
21            .into_iter_ne()
22            .map(Cid::into_lotus_json)
23            .collect_vec()
24    }
25
26    fn from_lotus_json(lotus_json: Self::LotusJson) -> Self {
27        lotus_json
28            .into_iter_ne()
29            .map(Cid::from_lotus_json)
30            .collect_vec()
31            .into()
32    }
33}