diff --git a/__crypto/simple_contract/src/cmd.rs b/__crypto/simple_contract/src/cmd.rs index 1d669fa..8cdc3f5 100644 --- a/__crypto/simple_contract/src/cmd.rs +++ b/__crypto/simple_contract/src/cmd.rs @@ -1,6 +1,7 @@ use clap::{ArgMatches, App}; use rust_util::XResult; pub type CommandError = XResult<()>; + pub trait Command { fn name(&self) -> &str; fn subcommand<'a>(&self) -> App<'a, 'a>; diff --git a/__crypto/simple_contract/src/cmd_credit_create.rs b/__crypto/simple_contract/src/cmd_credit_create.rs index ff45c93..e72df8d 100644 --- a/__crypto/simple_contract/src/cmd_credit_create.rs +++ b/__crypto/simple_contract/src/cmd_credit_create.rs @@ -1,10 +1,10 @@ use std::fs; use clap::{App, Arg, ArgMatches, SubCommand}; -use rust_util::information; -use crate::{cmd::{Command, CommandError}, engine_credit::CreditContractCreateParameters}; -use crate::engine::ContractEngine; -use crate::tx::{Transaction, TransactionBody}; +use crate::cmd::{Command, CommandError}; use crate::util::JsonKeyPair; +use crate::tx::{Transaction, TransactionBody}; +use crate::engine::ContractEngine; +use crate::engine_plugin_credit::CreditContractCreateParameters; pub struct CommandImpl; impl Command for CommandImpl { diff --git a/__crypto/simple_contract/src/cmd_credit_issue.rs b/__crypto/simple_contract/src/cmd_credit_issue.rs index 6260062..eff0fb0 100644 --- a/__crypto/simple_contract/src/cmd_credit_issue.rs +++ b/__crypto/simple_contract/src/cmd_credit_issue.rs @@ -1,10 +1,10 @@ use std::fs; use clap::{App, Arg, ArgMatches, SubCommand}; -use rust_util::information; -use crate::{cmd::{Command, CommandError}, engine_credit::CreditContractIssueParameters}; -use crate::engine::ContractEngine; -use crate::tx::{Transaction, TransactionBody}; +use crate::cmd::{Command, CommandError}; use crate::util::JsonKeyPair; +use crate::tx::{Transaction, TransactionBody}; +use crate::engine::ContractEngine; +use crate::engine_plugin_credit::CreditContractIssueParameters; pub struct CommandImpl; impl Command for CommandImpl { diff --git a/__crypto/simple_contract/src/cmd_credit_query.rs b/__crypto/simple_contract/src/cmd_credit_query.rs index 3636363..154993c 100644 --- a/__crypto/simple_contract/src/cmd_credit_query.rs +++ b/__crypto/simple_contract/src/cmd_credit_query.rs @@ -1,10 +1,10 @@ use std::fs; use clap::{App, Arg, ArgMatches, SubCommand}; -use rust_util::information; -use crate::{cmd::{Command, CommandError}, engine_credit::CreditContractQueryParameters}; -use crate::engine::ContractEngine; -use crate::tx::{Transaction, TransactionBody}; +use crate::cmd::{Command, CommandError}; use crate::util::JsonKeyPair; +use crate::tx::{Transaction, TransactionBody}; +use crate::engine::ContractEngine; +use crate::engine_plugin_credit::CreditContractQueryParameters; pub struct CommandImpl; impl Command for CommandImpl { diff --git a/__crypto/simple_contract/src/cmd_credit_queryall.rs b/__crypto/simple_contract/src/cmd_credit_queryall.rs index be7c6dd..c5ea074 100644 --- a/__crypto/simple_contract/src/cmd_credit_queryall.rs +++ b/__crypto/simple_contract/src/cmd_credit_queryall.rs @@ -1,10 +1,10 @@ use std::fs; use clap::{App, Arg, ArgMatches, SubCommand}; -use rust_util::information; -use crate::{cmd::{Command, CommandError}, engine_credit::CreditContractQueryAllParameters}; -use crate::engine::ContractEngine; -use crate::tx::{Transaction, TransactionBody}; +use crate::cmd::{Command, CommandError}; use crate::util::JsonKeyPair; +use crate::tx::{Transaction, TransactionBody}; +use crate::engine::ContractEngine; +use crate::engine_plugin_credit::CreditContractQueryAllParameters; pub struct CommandImpl; impl Command for CommandImpl { diff --git a/__crypto/simple_contract/src/cmd_credit_transfer.rs b/__crypto/simple_contract/src/cmd_credit_transfer.rs index edbf05b..1a995a7 100644 --- a/__crypto/simple_contract/src/cmd_credit_transfer.rs +++ b/__crypto/simple_contract/src/cmd_credit_transfer.rs @@ -1,10 +1,10 @@ use std::fs; use clap::{App, Arg, ArgMatches, SubCommand}; -use rust_util::information; -use crate::{cmd::{Command, CommandError}, engine_credit::CreditContractTransferParameters}; -use crate::engine::ContractEngine; -use crate::tx::{Transaction, TransactionBody}; +use crate::cmd::{Command, CommandError}; use crate::util::JsonKeyPair; +use crate::tx::{Transaction, TransactionBody}; +use crate::engine::ContractEngine; +use crate::engine_plugin_credit::CreditContractTransferParameters; pub struct CommandImpl; impl Command for CommandImpl { diff --git a/__crypto/simple_contract/src/cmd_default.rs b/__crypto/simple_contract/src/cmd_default.rs index a4c0c8e..6618764 100644 --- a/__crypto/simple_contract/src/cmd_default.rs +++ b/__crypto/simple_contract/src/cmd_default.rs @@ -1,6 +1,6 @@ use clap::{App, Arg, ArgMatches}; -use rust_util::information; use crate::cmd::CommandError; + pub struct CommandImpl; impl CommandImpl { pub fn process_command<'a>(app: App<'a, 'a>) -> App<'a, 'a> { diff --git a/__crypto/simple_contract/src/cmd_genkey.rs b/__crypto/simple_contract/src/cmd_genkey.rs index cc85267..f516dc9 100644 --- a/__crypto/simple_contract/src/cmd_genkey.rs +++ b/__crypto/simple_contract/src/cmd_genkey.rs @@ -1,8 +1,9 @@ use std::fs; use std::fs::File; use clap::{App, Arg, ArgMatches, SubCommand}; -use rust_util::failure; -use crate::{cmd::{Command, CommandError}, util::{JsonKeyPair, make_key_pair}}; +use crate::cmd::{Command, CommandError}; +use crate::util::{JsonKeyPair, make_key_pair}; + pub struct CommandImpl; impl Command for CommandImpl { fn name(&self) -> &str { "genkey" } diff --git a/__crypto/simple_contract/src/credit.rs b/__crypto/simple_contract/src/credit.rs index 2a299a6..91dcaf7 100644 --- a/__crypto/simple_contract/src/credit.rs +++ b/__crypto/simple_contract/src/credit.rs @@ -1,5 +1,5 @@ use std::{collections::HashMap, fs, fs::File}; -use rust_util::{XResult, information, simple_error}; +use rust_util::XResult; use serde::{Serialize, Deserialize}; use crate::tx::Transaction; diff --git a/__crypto/simple_contract/src/engine.rs b/__crypto/simple_contract/src/engine.rs index 103c468..e726e10 100644 --- a/__crypto/simple_contract/src/engine.rs +++ b/__crypto/simple_contract/src/engine.rs @@ -1,5 +1,6 @@ -use rust_util::{XResult, simple_error}; -use crate::{engine_credit::ContractEngineCredit, tx::Transaction}; +use rust_util::XResult; +use crate::tx::Transaction; +use crate::engine_plugin_credit::ContractEngineCredit; pub struct ContractEngine { } diff --git a/__crypto/simple_contract/src/engine_credit.rs b/__crypto/simple_contract/src/engine_plugin_credit.rs similarity index 95% rename from __crypto/simple_contract/src/engine_credit.rs rename to __crypto/simple_contract/src/engine_plugin_credit.rs index 1c5f0b7..db9f76c 100644 --- a/__crypto/simple_contract/src/engine_credit.rs +++ b/__crypto/simple_contract/src/engine_plugin_credit.rs @@ -1,7 +1,7 @@ use serde::{Serialize, Deserialize}; -use rust_util::{XResult, debugging, information, simple_error}; -use crate::{credit::CreditContract, tx::{Transaction, TransactionBody}}; - +use rust_util::XResult; +use crate::credit::CreditContract; +use crate::tx::{Transaction, TransactionBody}; #[derive(Debug, Serialize, Deserialize)] pub struct CreditContractCreateParameters { diff --git a/__crypto/simple_contract/src/main.rs b/__crypto/simple_contract/src/main.rs index 3eca7f2..340ef17 100644 --- a/__crypto/simple_contract/src/main.rs +++ b/__crypto/simple_contract/src/main.rs @@ -1,8 +1,10 @@ +#[macro_use] extern crate rust_util; + pub mod util; pub mod tx; pub mod credit; pub mod engine; -pub mod engine_credit; +pub mod engine_plugin_credit; mod cmd; mod cmd_default; diff --git a/__crypto/simple_contract/src/tx.rs b/__crypto/simple_contract/src/tx.rs index 87249e8..c51be5b 100644 --- a/__crypto/simple_contract/src/tx.rs +++ b/__crypto/simple_contract/src/tx.rs @@ -1,7 +1,7 @@ -use rust_util::{XResult, simple_error}; +use std::str::FromStr; +use rust_util::XResult; use secp256k1::{Message, PublicKey, Secp256k1, SecretKey, Signature}; use serde::{Serialize, Deserialize}; -use std::str::FromStr; use crate::util::{calc_sha256, make_btc_address}; #[derive(Debug, Serialize, Deserialize)] @@ -61,4 +61,4 @@ impl Transaction { fn get_body_message(body: &str) -> XResult { let digest= calc_sha256(body.as_bytes()); Message::from_slice(&digest).map_err(|e| e.into()) -} \ No newline at end of file +}