Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
doitian committed Oct 5, 2019
2 parents 15fba5d + 0ab8124 commit 62f09ae
Show file tree
Hide file tree
Showing 15 changed files with 277 additions and 258 deletions.
279 changes: 170 additions & 109 deletions Cargo.lock

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions Cargo.toml
@@ -1,20 +1,20 @@
[package]
name = "ckb-cli"
version = "0.21.1"
version = "0.22.0"
license = "MIT"
authors = ["Linfeng Qian <thewawar@gmail.com>", "Nervos Core Dev <dev@nervos.org>"]
edition = "2018"

[dependencies]
ckb-jsonrpc-types = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.21" }
ckb-hash = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.21" }
ckb-crypto = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.21", features = ["secp"] }
ckb-build-info = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.21" }
ckb-types = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.21" }
ckb-util = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.21" }
ckb-jsonrpc-types = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.22" }
ckb-hash = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.22" }
ckb-crypto = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.22", features = ["secp"] }
ckb-build-info = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.22" }
ckb-types = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.22" }
ckb-util = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.22" }
ckb-sdk = { path = "ckb-sdk" }
ckb-index = { path = "ckb-index" }
ckb-resource = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.21" }
ckb-resource = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.22" }

jsonrpc-client-core = "0.5.0"
secp256k1 = {version = "0.15.0" }
Expand Down Expand Up @@ -47,7 +47,7 @@ tui = "0.6.0"
termion = "1.5"

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

[workspace]
members = ["ckb-sdk", "ckb-index", "ckb-sdk-types"]
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -13,7 +13,7 @@ ci: fmt clippy test
git diff --exit-code Cargo.lock

integration:
bash devtools/ci/integration.sh rc/v0.21
bash devtools/ci/integration.sh develop

prod: ## Build binary with release profile.
cargo build --release
Expand Down
4 changes: 2 additions & 2 deletions ckb-index/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "ckb-index"
version = "0.21.0"
version = "0.22.0"
authors = ["Linfeng Qian <thewawar@gmail.com>", "Nervos Core Dev <dev@nervos.org>"]
edition = "2018"
license = "MIT"
Expand All @@ -11,7 +11,7 @@ serde_derive = "1.0"
bincode = "1.1.4"
log = "0.4.6"
failure = "0.1.5"
ckb-types = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.21" }
ckb-types = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.22" }
ckb-sdk = { path = "../ckb-sdk" }

[dependencies.rocksdb]
Expand Down
6 changes: 1 addition & 5 deletions ckb-index/src/index/mod.rs
Expand Up @@ -7,7 +7,6 @@ use std::io;

use ckb_sdk::{Address, GenesisInfo, NetworkType};
use ckb_types::{
bytes::Bytes,
core::{BlockView, HeaderView},
packed::{Byte32, Header, OutPoint, Script},
prelude::*,
Expand Down Expand Up @@ -166,10 +165,7 @@ impl<'a> IndexDatabase<'a> {
.get(&Key::LockScript(lock_hash.unpack()).to_bytes())
.and_then(|bytes| {
let script = Script::new_unchecked(bytes.into());
script.args().get(0).and_then(|arg| {
let arg: Bytes = arg.unpack();
Address::from_lock_arg(&arg).ok()
})
Address::from_lock_arg(&script.args().raw_data()).ok()
})
}

Expand Down
6 changes: 3 additions & 3 deletions ckb-index/src/index/types.rs
Expand Up @@ -227,7 +227,7 @@ impl BlockDeltaInfo {
let header_info = HeaderInfo {
header: block_header.data().as_slice().into(),
txs_size: block.transactions().len() as u32,
uncles_size: block.uncles_count() as u32,
uncles_size: block.uncle_hashes().len() as u32,
proposals_size: block.union_proposal_ids().len() as u32,
new_chain_capacity,
capacity_delta,
Expand Down Expand Up @@ -564,8 +564,8 @@ impl LockInfo {
let type_hash = script.calc_script_hash();
let address_opt = if &type_hash == secp_type_hash {
if script.args().len() == 1 {
let lock_arg = &script.args().get(0).unwrap();
match Address::from_lock_arg(lock_arg.as_slice()) {
let lock_arg = script.args().raw_data();
match Address::from_lock_arg(&lock_arg) {
Ok(address) => Some(address),
Err(err) => {
log::info!("Invalid secp arg: {:?} => {}", lock_arg, err);
Expand Down
14 changes: 7 additions & 7 deletions ckb-sdk-types/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "ckb-sdk-types"
version = "0.21.0"
version = "0.22.0"
authors = ["Linfeng Qian <thewawar@gmail.com>", "Nervos Core Dev <dev@nervos.org>"]
edition = "2018"
license = "MIT"
Expand All @@ -9,14 +9,14 @@ license = "MIT"
serde = { version = "1.0", features = ["rc"] }
serde_derive = "1.0"

ckb-types = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.21" }
ckb-script = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.21", default-features = false }
ckb-jsonrpc-types = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.21" }
ckb-hash = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.21" }
ckb-error = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.21" }
ckb-types = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.22" }
ckb-script = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.22", default-features = false }
ckb-jsonrpc-types = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.22" }
ckb-hash = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.22" }
ckb-error = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.22" }

[dev-dependencies]
ckb-crypto = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.21", features = ["secp"] }
ckb-crypto = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.22", features = ["secp"] }

[features]
default = ["ckb-script/default"]
Expand Down
14 changes: 7 additions & 7 deletions ckb-sdk/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "ckb-sdk"
version = "0.21.0"
version = "0.22.0"
authors = ["Linfeng Qian <thewawar@gmail.com>", "Nervos Core Dev <dev@nervos.org>"]
edition = "2018"
license = "MIT"
Expand All @@ -27,10 +27,10 @@ chrono = "0.4.6"
failure = "0.1.5"
lazy_static = "1.4.0"

ckb-types = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.21" }
ckb-script = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.21" }
ckb-jsonrpc-types = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.21" }
ckb-hash = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.21" }
ckb-resource = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.21" }
ckb-crypto = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.21", features = ["secp"] }
ckb-types = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.22" }
ckb-script = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.22" }
ckb-jsonrpc-types = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.22" }
ckb-hash = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.22" }
ckb-resource = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.22" }
ckb-crypto = { git = "https://github.com/nervosnetwork/ckb", branch = "rc/v0.22", features = ["secp"] }
ckb-sdk-types = { path = "../ckb-sdk-types" }
7 changes: 3 additions & 4 deletions ckb-sdk/src/basic.rs
Expand Up @@ -4,7 +4,6 @@ use std::str::FromStr;
use bech32::{convert_bits, Bech32, ToBase32};
use ckb_hash::blake2b_256;
use ckb_types::{
bytes::Bytes,
core::ScriptHashType,
packed::{Byte32, Script},
prelude::*,
Expand Down Expand Up @@ -103,7 +102,7 @@ impl Address {

pub fn lock_script(&self, type_hash: Byte32) -> Script {
Script::new_builder()
.args(vec![Bytes::from(self.hash.as_bytes()).pack()].pack())
.args(self.hash.as_bytes().pack())
.code_hash(type_hash)
.hash_type(ScriptHashType::Type.pack())
.build()
Expand Down Expand Up @@ -153,7 +152,7 @@ impl Address {

mod old_addr {
use super::{
blake2b_256, convert_bits, Bech32, Bytes, Deserialize, FromStr, NetworkType, Script,
blake2b_256, convert_bits, Bech32, Deserialize, FromStr, NetworkType, Script,
ScriptHashType, Serialize, ToBase32, H160, H256,
};
use ckb_crypto::secp::Pubkey;
Expand Down Expand Up @@ -217,7 +216,7 @@ mod old_addr {

pub fn lock_script(&self, code_hash: H256) -> Script {
Script::new_builder()
.args(vec![Bytes::from(self.hash.as_bytes()).pack()].pack())
.args(self.hash.as_bytes().pack())
.code_hash(code_hash.pack())
.hash_type(ScriptHashType::Data.pack())
.build()
Expand Down
18 changes: 11 additions & 7 deletions ckb-sdk/src/chain.rs
Expand Up @@ -8,7 +8,7 @@ use ckb_types::{
BlockView, Capacity, DepType, HeaderView, ScriptHashType, TransactionBuilder,
TransactionView,
},
packed::{Byte32, CellDep, CellInput, CellOutput, OutPoint, Script, ScriptOpt, Witness},
packed::{Byte32, CellDep, CellInput, CellOutput, OutPoint, Script, ScriptOpt},
prelude::*,
H160, H256,
};
Expand All @@ -22,7 +22,7 @@ lazy_static::lazy_static! {
CellOutput::new_builder()
.lock(
Script::new_builder()
.args(vec![H160::default().as_bytes().pack()].pack())
.args(H160::default().as_bytes().pack())
.build()
)
.build()
Expand Down Expand Up @@ -344,14 +344,18 @@ impl<'a> TransferTransactionBuilder<'a> {
fn build_transaction(&self) -> TransactionView {
let (outputs, outputs_data): (Vec<_>, Vec<_>) = self.outputs.iter().cloned().unzip();
let (changes, changes_data): (Vec<_>, Vec<_>) = self.changes.iter().cloned().unzip();
let witnesses: Vec<Witness> = self
let witnesses: Vec<Bytes> = self
.witnesses
.iter()
.cloned()
.map(|witness| {
Witness::new_builder()
.extend(witness.into_iter().map(|w| w.pack()))
.build()
witness
.into_iter()
.fold(Vec::new(), |mut data, part| {
data.extend_from_slice(&part);
data
})
.into()
})
.collect();
TransactionBuilder::default()
Expand All @@ -362,7 +366,7 @@ impl<'a> TransferTransactionBuilder<'a> {
.outputs_data(changes_data.iter().map(Pack::pack))
.cell_deps(self.cell_deps.clone())
.header_deps(self.header_deps.clone())
.witnesses(witnesses)
.witnesses(witnesses.pack())
.build()
}
}
Expand Down

0 comments on commit 62f09ae

Please sign in to comment.