Skip to content

Commit

Permalink
chore: Compatible to ckb develop branch
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWaWaR committed Jul 18, 2019
1 parent 7fc806f commit 0b7f2d6
Show file tree
Hide file tree
Showing 23 changed files with 180 additions and 402 deletions.
474 changes: 125 additions & 349 deletions Cargo.lock

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ edition = "2018"

[dependencies]
numext-fixed-hash = "~0.1"
jsonrpc-types = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.16" }
hash = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.16" }
crypto = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.16", features = ["secp", "bech32"] }
build-info = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.16" }
ckb-core = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.16" }
ckb-util = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.16" }
ckb-jsonrpc-types = { git = "https://github.com/nervosnetwork/ckb", branch = "develop" }
ckb-hash = { git = "https://github.com/nervosnetwork/ckb", branch = "develop" }
ckb-crypto = { git = "https://github.com/nervosnetwork/ckb", branch = "develop", features = ["secp", "bech32"] }
ckb-build-info = { git = "https://github.com/nervosnetwork/ckb", branch = "develop" }
ckb-core = { git = "https://github.com/nervosnetwork/ckb", branch = "develop" }
ckb-util = { git = "https://github.com/nervosnetwork/ckb", branch = "develop" }
ckb-sdk = { path = "ckb-sdk" }

jsonrpc-client-core = "0.5.0"
Expand Down Expand Up @@ -44,7 +44,7 @@ tui = "0.6.0"
termion = "1.5"

[build-dependencies]
build-info = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.16" }
ckb-build-info = { git = "https://github.com/nervosnetwork/ckb", branch = "develop" }

[workspace]
members = ["ckb-sdk"]
4 changes: 2 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ fn main() {
// forward git repo hashes we build at
println!(
"cargo:rustc-env=COMMIT_DESCRIBE={}",
build_info::get_commit_describe().unwrap_or_default()
ckb_build_info::get_commit_describe().unwrap_or_default()
);
println!(
"cargo:rustc-env=COMMIT_DATE={}",
build_info::get_commit_date().unwrap_or_default()
ckb_build_info::get_commit_date().unwrap_or_default()
);
}
10 changes: 5 additions & 5 deletions ckb-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ uuid = { version = "0.7.4", features = ["v4"] }
chrono = "0.4.6"
failure = "0.1.5"

ckb-core = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.16" }
ckb-script = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.16" }
jsonrpc-types = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.16" }
hash = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.16" }
crypto = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.16", features = ["secp", "bech32"] }
ckb-core = { git = "https://github.com/nervosnetwork/ckb", branch = "develop" }
ckb-script = { git = "https://github.com/nervosnetwork/ckb", branch = "develop" }
ckb-jsonrpc-types = { git = "https://github.com/nervosnetwork/ckb", branch = "develop" }
ckb-hash = { git = "https://github.com/nervosnetwork/ckb", branch = "develop" }
ckb-crypto = { git = "https://github.com/nervosnetwork/ckb", branch = "develop", features = ["secp", "bech32"] }
11 changes: 6 additions & 5 deletions ckb-sdk/src/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use std::str::FromStr;

use bech32::{convert_bits, Bech32, ToBase32};
use bytes::Bytes;
use ckb_core::script::Script as CoreScript;
use crypto::secp::Pubkey;
use hash::blake2b_256;
use ckb_core::script::{Script, ScriptHashType};
use ckb_crypto::secp::Pubkey;
use ckb_hash::blake2b_256;
use numext_fixed_hash::{H160, H256};
use serde_derive::{Deserialize, Serialize};

Expand Down Expand Up @@ -106,10 +106,11 @@ impl Address {
&self.hash
}

pub fn lock_script(&self, code_hash: H256) -> CoreScript {
CoreScript {
pub fn lock_script(&self, code_hash: H256) -> Script {
Script {
args: vec![Bytes::from(self.hash.as_bytes())],
code_hash,
hash_type: ScriptHashType::Data,
}
}

Expand Down
12 changes: 6 additions & 6 deletions ckb-sdk/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ use ckb_core::{
transaction::{CellOutPoint, CellOutput, OutPoint, TransactionBuilder},
Capacity,
};
use crypto::secp::SECP256K1;
use hash::blake2b_256;
use jsonrpc_types::Transaction as RpcTransaction;
use ckb_crypto::secp::SECP256K1;
use ckb_hash::blake2b_256;
use ckb_jsonrpc_types::Transaction as RpcTransaction;
use numext_fixed_hash::{h256, H256};

pub const ONE_CKB: u64 = 100_000_000;
// H256(secp code hash) + H160 (secp pubkey hash) + u64(capacity) = 32 + 20 + 8 = 60
pub const MIN_SECP_CELL_CAPACITY: u64 = 60 * ONE_CKB;
// H256(secp code hash) + H160 (secp pubkey hash) + 1 (ScriptHashType) + u64(capacity) = 32 + 20 + 1 + 8 = 61
pub const MIN_SECP_CELL_CAPACITY: u64 = (32 + 20 + 1 + 8) * ONE_CKB;

const SECP_CODE_HASH: H256 =
h256!("0x94334bdda40b69bae067d84937aa6bbccf8acd0df6626d4b9ac70d4612a11933");
h256!("0x54811ce986d5c3e57eaafab22cdd080e32209e39590e204a99b32935f835a13c");

#[derive(Debug, Clone)]
pub struct GenesisInfo {
Expand Down
6 changes: 3 additions & 3 deletions ckb-sdk/src/rpc/client.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use jsonrpc_client_core::{expand_params, jsonrpc_client};
use jsonrpc_client_http::{HttpHandle, HttpTransport};
use jsonrpc_types::{
use ckb_jsonrpc_types::{
BlockNumber, BlockView, CellOutputWithOutPoint, CellWithStatus, ChainInfo, EpochNumber,
EpochView, HeaderView, Node, OutPoint, Transaction, TransactionWithStatus, TxPoolInfo,
};
use jsonrpc_client_core::{expand_params, jsonrpc_client};
use jsonrpc_client_http::{HttpHandle, HttpTransport};
use serde_derive::{Deserialize, Serialize};

use numext_fixed_hash::H256;
Expand Down
8 changes: 4 additions & 4 deletions ckb-sdk/src/rpc/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
mod client;

pub use ckb_jsonrpc_types::{
BlockNumber, BlockView, CellOutputWithOutPoint, CellWithStatus, ChainInfo, EpochNumber,
EpochView, HeaderView, Node, OutPoint, Transaction, TransactionWithStatus, TxPoolInfo,
};
pub use client::{
CellOutputWithOutPoints, HttpRpcClient, Nodes, OptionBlockView, OptionEpochView, OptionH256,
OptionTransactionWithStatus, RpcClient,
};
pub use jsonrpc_types::{
BlockNumber, BlockView, CellOutputWithOutPoint, CellWithStatus, ChainInfo, EpochNumber,
EpochView, HeaderView, Node, OutPoint, Transaction, TransactionWithStatus, TxPoolInfo,
};
3 changes: 2 additions & 1 deletion ckb-sdk/src/transaction/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use ckb_core::{
transaction::{CellOutPoint, CellOutput, OutPoint, Transaction, TransactionBuilder, Witness},
Cycle,
};
use ckb_hash::blake2b_256;
use ckb_script::{DataLoader, ScriptConfig, TransactionScriptsVerifier};
use fnv::FnvHashSet;
use hash::blake2b_256;
use numext_fixed_hash::{H160, H256};
use rocksdb::{ColumnFamily, IteratorMode, Options, DB};
use serde_derive::{Deserialize, Serialize};
Expand Down Expand Up @@ -245,6 +245,7 @@ impl Resource {
block_info = Some(BlockInfo {
number: header.number(),
epoch: header.epoch(),
hash: header.hash().clone(),
});
required_headers.insert(hash.clone(), header);
out_point_blocks.insert(cell_out_point.clone(), hash.clone());
Expand Down
4 changes: 2 additions & 2 deletions ckb-sdk/src/wallet/keystore/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ use std::path::{Path, PathBuf};
use std::time::{Duration, Instant};

use chrono::{Datelike, Timelike, Utc};
use crypto::secp::SECP256K1;
use ckb_crypto::secp::SECP256K1;
use ckb_hash::blake2b_256;
use faster_hex::hex_decode;
use hash::blake2b_256;
use numext_fixed_hash::{H160, H256};
use rand::Rng;
use uuid::Uuid;
Expand Down
2 changes: 1 addition & 1 deletion src/interactive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::time::{Duration, Instant};

use ansi_term::Colour::Green;
use ckb_core::{block::Block, service::Request};
use jsonrpc_types::BlockNumber;
use ckb_jsonrpc_types::BlockNumber;
use regex::Regex;
use rustyline::config::Configurer;
use rustyline::error::ReadlineError;
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::iter::FromIterator;
use std::process;
use std::sync::Arc;

use build_info::Version;
use ckb_build_info::Version;
use ckb_sdk::HttpRpcClient;
use ckb_util::RwLock;
use clap::crate_version;
Expand Down
2 changes: 1 addition & 1 deletion src/subcommands/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use std::path::{Path, PathBuf};
use std::time::Duration;

use ckb_core::block::Block;
use ckb_jsonrpc_types::BlockNumber;
use ckb_sdk::{
wallet::{Key, KeyStore, MasterPrivKey},
Address, GenesisInfo, HttpRpcClient, NetworkType,
};
use clap::{App, Arg, ArgMatches, SubCommand};
use jsonrpc_types::BlockNumber;
use numext_fixed_hash::{H160, H256};

use super::CliSubCommand;
Expand Down
4 changes: 2 additions & 2 deletions src/subcommands/local/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ use ckb_core::{
transaction::{CellOutPoint, CellOutput},
Capacity,
};
use ckb_hash::blake2b_256;
use ckb_jsonrpc_types::{CellOutPoint as RpcCellOutPoint, CellOutput as RpcCellOutput};
use ckb_sdk::{
to_local_cell_out_point, with_rocksdb, CellAliasManager, CellManager, HttpRpcClient,
ScriptManager,
};
use clap::{App, Arg, ArgMatches, SubCommand};
use hash::blake2b_256;
use jsonrpc_types::{CellOutPoint as RpcCellOutPoint, CellOutput as RpcCellOutput};
use numext_fixed_hash::H256;

use super::super::CliSubCommand;
Expand Down
2 changes: 1 addition & 1 deletion src/subcommands/local/cell_input.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::path::PathBuf;

use ckb_core::transaction::{CellInput, CellOutPoint, OutPoint};
use ckb_jsonrpc_types::{BlockNumber as RpcBlockNumber, CellInput as RpcCellInput};
use ckb_sdk::{to_local_cell_out_point, with_rocksdb, CellInputManager, HttpRpcClient};
use clap::{App, Arg, ArgMatches, SubCommand};
use jsonrpc_types::{BlockNumber as RpcBlockNumber, CellInput as RpcCellInput};
use numext_fixed_hash::H256;

use super::super::CliSubCommand;
Expand Down
2 changes: 1 addition & 1 deletion src/subcommands/local/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ pub use tx::LocalTxSubCommand;
use std::path::PathBuf;

use ckb_core::block::Block;
use ckb_jsonrpc_types::BlockNumber;
use ckb_sdk::{wallet::KeyStore, GenesisInfo, HttpRpcClient};
use clap::{App, ArgMatches, SubCommand};
use jsonrpc_types::BlockNumber;

use super::CliSubCommand;
use crate::utils::printer::{OutputFormat, Printable};
Expand Down
6 changes: 3 additions & 3 deletions src/subcommands/local/script.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use std::path::PathBuf;

use bytes::Bytes;
use ckb_core::script::Script;
use ckb_core::script::{Script, ScriptHashType};
use ckb_jsonrpc_types::Script as RpcScript;
use ckb_sdk::{with_rocksdb, HttpRpcClient, ScriptManager};
use clap::{App, Arg, ArgMatches, SubCommand};
use faster_hex::hex_decode;
use jsonrpc_types::Script as RpcScript;
use numext_fixed_hash::H256;

use super::super::CliSubCommand;
Expand Down Expand Up @@ -103,7 +103,7 @@ impl<'a> CliSubCommand for LocalScriptSubCommand<'a> {
})
.collect();
let args = args_result?;
let script = Script::new(args, code_hash);
let script = Script::new(args, code_hash, ScriptHashType::Data);
let script_hash = script.hash();
with_rocksdb(&self.db_path, None, move |db| {
ScriptManager::new(db).add(script).map_err(Into::into)
Expand Down
2 changes: 1 addition & 1 deletion src/subcommands/local/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ use ckb_core::{
block::Block,
transaction::{CellInput, CellOutPoint, CellOutput, OutPoint, TransactionBuilder, Witness},
};
use ckb_jsonrpc_types::{BlockNumber, TransactionView};
use ckb_sdk::{
wallet::KeyStore, with_rocksdb, CellInputManager, CellManager, GenesisInfo, HttpRpcClient,
TransactionManager,
};
use clap::{App, Arg, ArgMatches, SubCommand};
use jsonrpc_types::{BlockNumber, TransactionView};
use numext_fixed_hash::H256;

use super::super::CliSubCommand;
Expand Down
2 changes: 1 addition & 1 deletion src/subcommands/rpc.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use ckb_jsonrpc_types::{BlockNumber, CellOutPoint, EpochNumber, OutPoint, Unsigned};
use ckb_sdk::HttpRpcClient;
use clap::{App, Arg, ArgMatches, SubCommand};
use jsonrpc_types::{BlockNumber, CellOutPoint, EpochNumber, OutPoint, Unsigned};
use numext_fixed_hash::H256;

use super::CliSubCommand;
Expand Down
2 changes: 1 addition & 1 deletion src/subcommands/tui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ use tui::widgets::{Block, Borders, Paragraph, SelectableList, Text, Widget};
use tui::{Frame, Terminal};
// use chrono::{Local, DateTime, TimeZone};
use ckb_core::service::Request;
use ckb_jsonrpc_types::BlockNumber;
use ckb_sdk::{with_index_db, GenesisInfo, HttpRpcClient, IndexDatabase, NetworkType, ONE_CKB};
use jsonrpc_types::BlockNumber;

use super::wallet::{IndexController, IndexRequest};
use state::{start_rpc_thread, State, SummaryInfo};
Expand Down
2 changes: 1 addition & 1 deletion src/subcommands/tui/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use std::thread;
use std::time::Duration;

use ckb_core::{header::Header, script::Script};
use ckb_jsonrpc_types::{BlockNumber, BlockView, ChainInfo, Node, TxPoolInfo};
use ckb_util::RwLock;
use jsonrpc_client_core::Error as RpcError;
use jsonrpc_types::{BlockNumber, BlockView, ChainInfo, Node, TxPoolInfo};

use super::util::ts_now;
use ckb_sdk::HttpRpcClient;
Expand Down
2 changes: 1 addition & 1 deletion src/subcommands/wallet/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use std::thread;
use std::time::{Duration, Instant};

use ckb_core::{block::Block, header::Header, service::Request};
use ckb_jsonrpc_types::BlockNumber;
use ckb_sdk::{GenesisInfo, NetworkType};
use ckb_util::RwLock;
use crossbeam_channel::{Receiver, Sender};
use jsonrpc_types::BlockNumber;
use numext_fixed_hash::H256;
use serde_derive::{Deserialize, Serialize};

Expand Down
6 changes: 3 additions & 3 deletions src/subcommands/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ use std::time::Duration;

use bytes::Bytes;
use ckb_core::{block::Block, service::Request};
use ckb_crypto::secp::SECP256K1;
use ckb_hash::blake2b_256;
use ckb_jsonrpc_types::BlockNumber;
use clap::{App, Arg, ArgMatches, SubCommand};
use crypto::secp::SECP256K1;
use faster_hex::hex_string;
use hash::blake2b_256;
use jsonrpc_types::BlockNumber;
use numext_fixed_hash::{H160, H256};
use serde_json::json;

Expand Down

0 comments on commit 0b7f2d6

Please sign in to comment.