Time in local TVM
use std::sync::Arc;
+use std::time::{SystemTime, UNIX_EPOCH};
use tvm::executor::Engine;
use tvm::block::{
BlockResult,
Message,
Serializable,
Deserializable,
+ SmartContractInfo
};
use tvm::block::error::*;
use tvm::stack::{CellData, IntegerData, SaveList, SliceData, Stack, StackItem};
@@ -30,6 +32,12 @@ pub fn local_contract_call(code: Arc<CellData>, data: Option<Arc<CellData>>, msg
.map_err(|err| BlockError::from(BlockErrorKind::Other(
format!("Cannot put data to register: {}", err))))?;
+ let mut sci = SmartContractInfo::default();
+ *sci.unix_time_mut() = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs() as u32;
+ ctrls.put(7, &mut sci.into_temp_data()?)
+ .map_err(|err| BlockError::from(BlockErrorKind::Other(
+ format!("Cannot put data to register: {}", err))))?;;
+
let mut engine = Engine::new().setup(SliceData::from(code), Some(ctrls), Some(stack), None);
let _result = engine.execute()?;
let mut slice = SliceData::from(engine.get_actions().as_cell()?.clone());
