use once_cell::sync::Lazy;
use std::collections::HashMap;
use crate::interop::interop_id_bytes;
#[derive(Debug, Clone, Copy)]
pub struct OpcodeSpec {
pub code: u8,
pub name: &'static str,
pub gas: u64,
}
impl OpcodeSpec {
pub fn is_push(&self) -> bool {
self.code <= 0x20 || (self.code >= 0x0C && self.code <= 0x0E)
}
pub fn is_jump(&self) -> bool {
self.code >= 0x22 && self.code <= 0x33
}
pub fn is_call(&self) -> bool {
self.code >= 0x34 && self.code <= 0x37
}
}
#[derive(Debug, Clone, Copy)]
pub struct SyscallSpec {
pub id: [u8; 4],
pub name: &'static str,
}
impl SyscallSpec {
pub fn id_hex(&self) -> String {
hex::encode(self.id)
}
}
#[derive(Debug, Clone, Copy)]
pub struct NativeContractSpec {
pub hash: [u8; 20],
pub name: &'static str,
}
impl NativeContractSpec {
pub fn hash_hex(&self) -> String {
hex::encode(self.hash)
}
}
mod gas;
mod native_contracts;
mod opcodes;
mod syscalls;
pub use gas::*;
pub use native_contracts::*;
pub use opcodes::*;
pub use syscalls::*;
#[cfg(test)]
mod tests;