use near_primitives::hash::CryptoHash;
use near_primitives::types::TrieNodesCount;
use near_primitives_core::types::{AccountId, Balance};
use near_vm_errors::VMLogicError;
pub trait MemoryLike {
fn fits_memory(&self, offset: u64, len: u64) -> bool;
fn read_memory(&self, offset: u64, buffer: &mut [u8]);
fn read_memory_u8(&self, offset: u64) -> u8;
fn write_memory(&mut self, offset: u64, buffer: &[u8]);
}
pub type Result<T> = ::std::result::Result<T, VMLogicError>;
pub trait ValuePtr {
fn len(&self) -> u32;
fn deref(&self) -> Result<Vec<u8>>;
}
pub trait External {
fn storage_set(&mut self, key: &[u8], value: &[u8]) -> Result<()>;
fn storage_get<'a>(&'a self, key: &[u8]) -> Result<Option<Box<dyn ValuePtr + 'a>>>;
fn storage_remove(&mut self, key: &[u8]) -> Result<()>;
fn storage_remove_subtree(&mut self, prefix: &[u8]) -> Result<()>;
fn storage_has_key(&mut self, key: &[u8]) -> Result<bool>;
fn generate_data_id(&mut self) -> CryptoHash;
fn get_trie_nodes_count(&self) -> TrieNodesCount;
fn validator_stake(&self, account_id: &AccountId) -> Result<Option<Balance>>;
fn validator_total_stake(&self) -> Result<Balance>;
}