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
use cid::{multihash::MultihashDigest, Cid, Code::Identity, RAW};
lazy_static! {
pub static ref SYSTEM_ACTOR_CODE_ID: Cid = make_builtin(b"fil/3/system");
pub static ref INIT_ACTOR_CODE_ID: Cid = make_builtin(b"fil/3/init");
pub static ref CRON_ACTOR_CODE_ID: Cid = make_builtin(b"fil/3/cron");
pub static ref ACCOUNT_ACTOR_CODE_ID: Cid = make_builtin(b"fil/3/account");
pub static ref POWER_ACTOR_CODE_ID: Cid = make_builtin(b"fil/3/storagepower");
pub static ref MINER_ACTOR_CODE_ID: Cid = make_builtin(b"fil/3/storageminer");
pub static ref MARKET_ACTOR_CODE_ID: Cid = make_builtin(b"fil/3/storagemarket");
pub static ref PAYCH_ACTOR_CODE_ID: Cid = make_builtin(b"fil/3/paymentchannel");
pub static ref MULTISIG_ACTOR_CODE_ID: Cid = make_builtin(b"fil/3/multisig");
pub static ref REWARD_ACTOR_CODE_ID: Cid = make_builtin(b"fil/3/reward");
pub static ref VERIFREG_ACTOR_CODE_ID: Cid = make_builtin(b"fil/3/verifiedregistry");
pub static ref CHAOS_ACTOR_CODE_ID: Cid = make_builtin(b"fil/3/chaos");
pub static ref CALLER_TYPES_SIGNABLE: [Cid; 2] =
[*ACCOUNT_ACTOR_CODE_ID, *MULTISIG_ACTOR_CODE_ID];
}
fn make_builtin(bz: &[u8]) -> Cid {
Cid::new_v1(RAW, Identity.digest(bz))
}
pub fn is_builtin_actor(code: &Cid) -> bool {
code == &*SYSTEM_ACTOR_CODE_ID
|| code == &*INIT_ACTOR_CODE_ID
|| code == &*CRON_ACTOR_CODE_ID
|| code == &*ACCOUNT_ACTOR_CODE_ID
|| code == &*POWER_ACTOR_CODE_ID
|| code == &*MINER_ACTOR_CODE_ID
|| code == &*MARKET_ACTOR_CODE_ID
|| code == &*PAYCH_ACTOR_CODE_ID
|| code == &*MULTISIG_ACTOR_CODE_ID
|| code == &*REWARD_ACTOR_CODE_ID
|| code == &*VERIFREG_ACTOR_CODE_ID
}
pub fn is_singleton_actor(code: &Cid) -> bool {
code == &*SYSTEM_ACTOR_CODE_ID
|| code == &*INIT_ACTOR_CODE_ID
|| code == &*REWARD_ACTOR_CODE_ID
|| code == &*CRON_ACTOR_CODE_ID
|| code == &*POWER_ACTOR_CODE_ID
|| code == &*MARKET_ACTOR_CODE_ID
|| code == &*VERIFREG_ACTOR_CODE_ID
}
pub fn is_account_actor(code: &Cid) -> bool {
code == &*ACCOUNT_ACTOR_CODE_ID
}
pub fn is_principal(code: &Cid) -> bool {
CALLER_TYPES_SIGNABLE.iter().any(|c| c == code)
}