1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// Copyright 2019-2026 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT
use super::*;
use crate::shim::actors::cron::Entry;
use pastey::paste;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize, JsonSchema, Clone, PartialEq)]
#[serde(rename_all = "PascalCase")]
pub struct CronConstructorParamsLotusJson {
#[schemars(with = "LotusJson<Vec<Entry>>")]
#[serde(with = "crate::lotus_json")]
pub entries: Vec<Entry>,
}
macro_rules! impl_lotus_json_for_cron_constructor_params {
($($version:literal),+) => {
$(
paste! {
mod [<impl_lotus_json_for_cron_constructor_params_ $version>] {
use super::*;
type T = fil_actor_cron_state::[<v $version>]::ConstructorParams;
#[test]
fn snapshots() {
crate::lotus_json::assert_all_snapshots::<T>();
}
impl HasLotusJson for T {
type LotusJson = CronConstructorParamsLotusJson;
#[cfg(test)]
fn snapshots() -> Vec<(serde_json::Value, Self)> {
use crate::shim::address::Address;
vec![(
json!({
"Entries": [
{
"Receiver": "f01",
"MethodNum": 2
},
{
"Receiver": "f02",
"MethodNum": 3
}
]
}),
Self {
entries: vec![
fil_actor_cron_state::[<v $version>]::Entry {
receiver: Address::new_id(1).into(),
method_num: 2,
},
fil_actor_cron_state::[<v $version>]::Entry {
receiver: Address::new_id(2).into(),
method_num: 3,
},
],
},
)]
}
fn into_lotus_json(self) -> Self::LotusJson {
Self::LotusJson {
entries: self.entries.into_iter().map(Entry::[<V $version>]).collect(),
}
}
fn from_lotus_json(json: Self::LotusJson) -> Self {
Self {
entries: json.entries.into_iter().map(|entry| match entry {
Entry::[<V $version>](e) => e,
_ => {
let lotus_entry = entry.into_lotus_json();
fil_actor_cron_state::[<v $version>]::Entry {
receiver: lotus_entry.receiver.into(),
method_num: lotus_entry.method_num,
}
}
}).collect(),
}
}
}
}
}
)+
};
}
impl_lotus_json_for_cron_constructor_params!(8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18);