Skip to content

Commit

Permalink
Merge pull request #159 from keroro520/2-phase-dao
Browse files Browse the repository at this point in the history
feat: 2 phase dao
  • Loading branch information
keroro520 authored Jan 3, 2020
2 parents 8f5de71 + 45571b9 commit 68cbb44
Show file tree
Hide file tree
Showing 18 changed files with 1,265 additions and 41 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ ckb-util = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.26.1-rc1" }
ckb-sdk = { path = "ckb-sdk" }
ckb-index = { path = "ckb-index" }
ckb-resource = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.26.1-rc1" }
ckb-dao-utils = { git = "https://github.com/nervosnetwork/ckb", tag = "v0.26.1-rc1" }

jsonrpc-client-core = "0.5.0"
secp256k1 = {version = "0.15.0" }
Expand Down Expand Up @@ -42,6 +43,8 @@ chrono = "0.4"
rpassword = "3.0.2"
ipnetwork = "0.14"
multiaddr = { package = "parity-multiaddr", version = "0.4.0" }
byteorder = "1.3.2"
itertools = "0.8.0"

[target.'cfg(unix)'.dependencies]
tui = "0.6.0"
Expand Down
2 changes: 1 addition & 1 deletion ckb-sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub use transaction::{
MockCellDep, MockInfo, MockInput, MockResourceLoader, MockTransaction, MockTransactionHelper,
ReprMockCellDep, ReprMockInfo, ReprMockInput, ReprMockTransaction,
};
pub use tx_helper::{MultisigConfig, SignerFn, TxHelper};
pub use tx_helper::{build_signature, MultisigConfig, SignerFn, TxHelper};
pub use types::{
Address, AddressPayload, AddressType, CodeHashIndex, HumanCapacity, NetworkType, OldAddress,
OldAddressFormat, Since, SinceType,
Expand Down
17 changes: 15 additions & 2 deletions src/interactive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use rustyline::{Cmd, CompletionType, Config, EditMode, Editor, KeyPress};
use serde_json::json;

use crate::subcommands::{
AccountSubCommand, CliSubCommand, MockTxSubCommand, MoleculeSubCommand, RpcSubCommand,
TxSubCommand, UtilSubCommand, WalletSubCommand,
AccountSubCommand, CliSubCommand, DAOSubCommand, MockTxSubCommand, MoleculeSubCommand,
RpcSubCommand, TxSubCommand, UtilSubCommand, WalletSubCommand,
};
use crate::utils::{
completer::CkbCompleter,
Expand Down Expand Up @@ -364,6 +364,19 @@ impl InteractiveEnv {
println!("{}", output);
Ok(())
}
("dao", Some(sub_matches)) => {
let genesis_info = self.genesis_info()?;
let output = DAOSubCommand::new(
&mut self.rpc_client,
&mut self.key_store,
genesis_info,
self.index_dir.clone(),
self.index_controller.clone(),
)
.process(&sub_matches, format, color, debug)?;
println!("{}", output);
Ok(())
}
("exit", _) => {
return Ok(true);
}
Expand Down
21 changes: 19 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ use clap::{App, AppSettings, Arg, SubCommand};
#[cfg(unix)]
use subcommands::TuiSubCommand;

use crate::utils::other::get_genesis_info;
use interactive::InteractiveEnv;
use subcommands::{
start_index_thread, AccountSubCommand, CliSubCommand, MockTxSubCommand, MoleculeSubCommand,
RpcSubCommand, TxSubCommand, UtilSubCommand, WalletSubCommand,
start_index_thread, AccountSubCommand, CliSubCommand, DAOSubCommand, MockTxSubCommand,
MoleculeSubCommand, RpcSubCommand, TxSubCommand, UtilSubCommand, WalletSubCommand,
};
use utils::other::sync_to_tip;
use utils::{
Expand Down Expand Up @@ -157,6 +158,20 @@ fn main() -> Result<(), io::Error> {
)
.process(&sub_matches, output_format, color, debug)
}),
("dao", Some(sub_matches)) => {
get_genesis_info(&None, &mut rpc_client).and_then(|genesis_info| {
get_key_store(&ckb_cli_dir).and_then(|mut key_store| {
DAOSubCommand::new(
&mut rpc_client,
&mut key_store,
genesis_info,
index_dir.clone(),
index_controller.clone(),
)
.process(&sub_matches, output_format, color, debug)
})
})
}
_ => {
if let Err(err) =
InteractiveEnv::from_config(ckb_cli_dir, config, index_controller.clone())
Expand Down Expand Up @@ -232,6 +247,7 @@ pub fn build_cli<'a>(version_short: &'a str, version_long: &'a str) -> App<'a, '
.subcommand(UtilSubCommand::subcommand("util"))
.subcommand(MoleculeSubCommand::subcommand("molecule"))
.subcommand(WalletSubCommand::subcommand())
.subcommand(DAOSubCommand::subcommand())
.arg(
Arg::with_name("url")
.long("url")
Expand Down Expand Up @@ -334,4 +350,5 @@ pub fn build_interactive() -> App<'static, 'static> {
.subcommand(UtilSubCommand::subcommand("util"))
.subcommand(MoleculeSubCommand::subcommand("molecule"))
.subcommand(WalletSubCommand::subcommand())
.subcommand(DAOSubCommand::subcommand())
}
Loading

0 comments on commit 68cbb44

Please sign in to comment.