Skip to main content

neo_devpack_solidity/runtime/spec/
syscalls.rs

1use super::*;
2
3// Syscall registry – the names are authoritative; IDs are derived via SHA-256.
4//
5// IMPORTANT: This list is aligned to Neo N3 `ApplicationEngine.Register(...)` syscall names.
6pub static SYSCALLS: Lazy<HashMap<[u8; 4], SyscallSpec>> = Lazy::new(|| {
7    let names = [
8        // Storage
9        "System.Storage.GetContext",
10        "System.Storage.GetReadOnlyContext",
11        "System.Storage.AsReadOnly",
12        "System.Storage.Get",
13        "System.Storage.Put",
14        "System.Storage.Delete",
15        "System.Storage.Find",
16        // Iterator
17        "System.Iterator.Next",
18        "System.Iterator.Value",
19        // Crypto
20        "System.Crypto.CheckSig",
21        "System.Crypto.CheckMultisig",
22        // Contract
23        "System.Contract.Call",
24        "System.Contract.GetCallFlags",
25        "System.Contract.CreateStandardAccount",
26        "System.Contract.CreateMultisigAccount",
27        // Runtime
28        "System.Runtime.GetTrigger",
29        "System.Runtime.Platform",
30        "System.Runtime.GetNetwork",
31        "System.Runtime.GetAddressVersion",
32        "System.Runtime.GetTime",
33        "System.Runtime.GetScriptContainer",
34        "System.Runtime.GetExecutingScriptHash",
35        "System.Runtime.GetCallingScriptHash",
36        "System.Runtime.GetEntryScriptHash",
37        "System.Runtime.LoadScript",
38        "System.Runtime.CheckWitness",
39        "System.Runtime.GetInvocationCounter",
40        "System.Runtime.GetRandom",
41        "System.Runtime.Log",
42        "System.Runtime.Notify",
43        "System.Runtime.GetNotifications",
44        "System.Runtime.GasLeft",
45        "System.Runtime.BurnGas",
46        "System.Runtime.CurrentSigners",
47        // Task #113 — Solidity `msg.value` host-injection slot. Neo N3 has
48        // no native attached-value concept, so this syscall reads the
49        // runtime-side override (`ExecutionOverrides::value` /
50        // `NeoRuntime::override_value`). Returns 0 when no override set.
51        "System.Runtime.GetMsgValue",
52    ];
53
54    let mut m = HashMap::new();
55    for name in names {
56        m.insert(
57            interop_id_bytes(name),
58            SyscallSpec {
59                id: interop_id_bytes(name),
60                name,
61            },
62        );
63    }
64    m
65});
66
67pub fn syscall_name(id: &[u8; 4]) -> Option<&'static str> {
68    SYSCALLS.get(id).map(|s| s.name)
69}