pub mod clarity {
pub mod runtime {
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
#[derive(Debug)]
pub struct ContractContext {
contract_id: String,
}
impl ContractContext {
pub fn new(contract_id: &str) -> Self {
Self {
contract_id: contract_id.to_string(),
}
}
}
#[derive(Debug)]
pub struct SimulatedRuntime {
contracts: HashMap<String, ContractContext>,
}
impl SimulatedRuntime {
pub fn new() -> Self {
Self {
contracts: HashMap::new(),
}
}
pub fn deploy_contract(&mut self, contract_id: &str, _contract_content: &str) -> Result<(), String> {
self.contracts.insert(contract_id.to_string(), ContractContext::new(contract_id));
Ok(())
}
}
}
pub mod value {
#[derive(Debug, Clone)]
pub enum Value {
Bool(bool),
Int(i128),
UInt(u128),
String(String),
None,
}
impl Value {
pub fn bool(value: bool) -> Self {
Self::Bool(value)
}
pub fn uint(value: u128) -> Self {
Self::UInt(value)
}
pub fn string(value: &str) -> Self {
Self::String(value.to_string())
}
}
}
}
pub mod repl {
use super::clarity::runtime::SimulatedRuntime;
use super::clarity::value::Value;
#[derive(Debug)]
pub struct Session {
runtime: SimulatedRuntime,
}
impl Session {
pub fn new() -> Self {
Self {
runtime: SimulatedRuntime::new(),
}
}
pub fn eval(&mut self, _code: &str) -> Result<Value, String> {
Ok(Value::Bool(true))
}
}
}
pub use clarity::runtime;
pub use clarity::value;
pub use repl::Session;