feat: works

This commit is contained in:
2021-01-01 22:16:11 +08:00
parent 601f11efe6
commit 24150ca0f1
16 changed files with 555 additions and 82 deletions

View 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(())
}
}