Skip to main content

neo_runtime/
context.rs

1use neo_syscalls::NeoVMSyscall;
2use neo_types::*;
3
4/// Lightweight view of the runtime context.
5#[derive(Default)]
6pub struct NeoRuntimeContext;
7
8impl NeoRuntimeContext {
9    pub fn new() -> Self {
10        Self
11    }
12
13    pub fn trigger(&self) -> NeoResult<NeoInteger> {
14        NeoVMSyscall::get_trigger()
15    }
16
17    pub fn gas_left(&self) -> NeoResult<NeoInteger> {
18        NeoVMSyscall::get_gas_left()
19    }
20
21    pub fn invocation_counter(&self) -> NeoResult<NeoInteger> {
22        NeoVMSyscall::get_invocation_counter()
23    }
24
25    pub fn calling_script_hash(&self) -> NeoResult<NeoByteString> {
26        NeoVMSyscall::get_calling_script_hash()
27    }
28
29    pub fn entry_script_hash(&self) -> NeoResult<NeoByteString> {
30        NeoVMSyscall::get_entry_script_hash()
31    }
32
33    pub fn executing_script_hash(&self) -> NeoResult<NeoByteString> {
34        NeoVMSyscall::get_executing_script_hash()
35    }
36}