feat: works
This commit is contained in:
26
__crypto/simple_contract/src/engine.rs
Normal file
26
__crypto/simple_contract/src/engine.rs
Normal file
@@ -0,0 +1,26 @@
|
||||
use rust_util::{XResult, simple_error};
|
||||
use crate::{engine_credit::ContractEngineCredit, tx::Transaction};
|
||||
|
||||
pub struct ContractEngine {
|
||||
}
|
||||
|
||||
impl ContractEngine {
|
||||
pub fn new() -> Self {
|
||||
Self{}
|
||||
}
|
||||
|
||||
pub fn execute(&self, tx: &Transaction) -> XResult<()> {
|
||||
tx.verify()?;
|
||||
|
||||
let tx_body = tx.parse_body()?;
|
||||
|
||||
match tx_body.contract.as_str() {
|
||||
"credit" => {
|
||||
ContractEngineCredit::new().execute(tx, &tx_body)?;
|
||||
},
|
||||
c => return simple_error!("Unknown cotract: {}", c),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user