neo_solidity/ir/expressions/member_access/
native_calls.rs

1fn try_lower_native_contract_constant(
2    inner: &Expression,
3    member: &Identifier,
4    instructions: &mut Vec<Instruction>,
5) -> Option<bool> {
6    if let Expression::Variable(base) = inner {
7        if base.name == "NativeCalls" {
8            let bytes = match member.name.as_str() {
9                "NEO_CONTRACT" => Some(
10                    b"\xf5\x63\xea\x40\xbc\x28\x3d\x4d\x0e\x05\xc4\x8e\xa3\x05\xb3\xf2\xa0\x73\x40\xef".to_vec(),
11                ),
12                "GAS_CONTRACT" => Some(
13                    b"\xcf\x76\xe2\x8b\xd0\x06\x2c\x4a\x47\x8e\xe3\x55\x61\x01\x13\x19\xf3\xcf\xa4\xd2".to_vec(),
14                ),
15                "CONTRACT_MANAGEMENT" => Some(
16                    b"\xfd\xa3\xfa\x43\x46\xea\x53\x2a\x25\x8f\xc4\x97\xdd\xad\xdb\x64\x37\xc9\xfd\xff".to_vec(),
17                ),
18                "POLICY_CONTRACT" => Some(
19                    b"\x7b\xc6\x81\xc0\xa1\xf7\x1d\x54\x34\x57\xb6\x8b\xba\x8d\x5f\x9f\xdd\x4e\x5e\xcc".to_vec(),
20                ),
21                "ORACLE_CONTRACT" => Some(
22                    b"\x58\x87\x17\x11\x7e\x0a\xa8\x10\x72\xaf\xab\x71\xd2\xdd\x89\xfe\x7c\x4b\x92\xfe".to_vec(),
23                ),
24                "ROLE_MANAGEMENT" => Some(
25                    b"\xe2\x95\xe3\x91\x54\x4c\x17\x8a\xd9\x4f\x03\xec\x4d\xcd\xff\x78\x53\x4e\xcf\x49".to_vec(),
26                ),
27                "NOTARY_CONTRACT" => Some(
28                    b"\x3b\xec\x35\x31\x11\x9b\xba\xd7\x6d\xd0\x44\x92\x0b\x0d\xe6\xc3\x19\x4f\xe1\xc1".to_vec(),
29                ),
30                "TREASURY_CONTRACT" => Some(
31                    b"\xc1\x3a\x56\xc9\x83\x53\xa7\xea\x6a\x32\x4d\x9a\x83\x5d\x1b\x5b\xf2\x26\x63\x15".to_vec(),
32                ),
33                "LEDGER_CONTRACT" => Some(
34                    b"\xbe\xf2\x04\x31\x40\x36\x2a\x77\xc1\x50\x99\xc7\xe6\x4c\x12\xf7\x00\xb6\x65\xda".to_vec(),
35                ),
36                "CRYPTO_LIB" => Some(
37                    b"\x1b\xf5\x75\xab\x11\x89\x68\x84\x13\x61\x0a\x35\xa1\x28\x86\xcd\xe0\xb6\x6c\x72".to_vec(),
38                ),
39                "STD_LIB" => Some(
40                    b"\xc0\xef\x39\xce\xe0\xe4\xe9\x25\xc6\xc2\xa0\x6a\x79\xe1\x44\x0d\xd8\x6f\xce\xac".to_vec(),
41                ),
42                _ => None,
43            };
44
45            if let Some(bytes) = bytes {
46                instructions.push(Instruction::PushLiteral(LiteralValue::Address(bytes)));
47                return Some(true);
48            }
49        }
50    }
51
52    None
53}