Skip to content

Commit

Permalink
Merge pull request #56 from liuck8080/feat/support_ckb_0.108.0
Browse files Browse the repository at this point in the history
feat: 🎸 Bump ckb to 0.108.0
  • Loading branch information
quake authored Mar 16, 2023
2 parents f3f8626 + c436869 commit 5f7aa5a
Show file tree
Hide file tree
Showing 15 changed files with 32 additions and 30 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# 2.5.0
* Support indexer `exact` search mode.
* Add `get_block_with_cycles` and `get_block_by_number_with_cycles` to support `get_block` and `get_block_by_number` with parameter `with_cycles`.
* Support ckb 0.108.0

# 2.4.0
* Update ckb to 0.106.0
Expand Down
30 changes: 15 additions & 15 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ckb-sdk"
version = "2.4.1"
version = "2.5.0"
authors = ["Linfeng Qian <[email protected]>", "Nervos Core Dev <[email protected]>"]
edition = "2018"
license = "MIT"
Expand All @@ -18,7 +18,7 @@ bech32 = "0.8.1"
log = "0.4.6"
reqwest = { version = "0.11", features = ["json", "blocking"] }
secp256k1 = { version = "0.24", features = ["recovery"] }
tokio-util = { version = "0.6", features = ["codec"] }
tokio-util = { version = "0.7.7", features = ["codec"] }
tokio = { version = "1" }
bytes = "1"
futures = "0.3"
Expand All @@ -27,32 +27,32 @@ parking_lot = "0.12"
lru = "0.7.1"
dashmap = "5.4"

ckb-types = "=0.106.0"
ckb-dao-utils = "=0.106.0"
ckb-traits = "=0.106.0"
ckb-jsonrpc-types = "=0.106.0"
ckb-hash = "=0.106.0"
ckb-resource = "=0.106.0"
ckb-crypto = { version = "=0.106.0", features = ["secp"] }
ckb-script = { version = "=0.106.0"}
ckb-types = "=0.108.0"
ckb-dao-utils = "=0.108.0"
ckb-traits = "=0.108.0"
ckb-jsonrpc-types = "=0.108.0"
ckb-hash = "=0.108.0"
ckb-resource = "=0.108.0"
ckb-crypto = { version = "=0.108.0", features = ["secp"] }
ckb-script = { version = "=0.108.0"}
bitflags = "1.3.2"
sha3 = "0.10.1"
enum-repr-derive = "0.2.0"

# for feature test
rand = { version = "0.7.3", optional = true }
ckb-mock-tx-types = { version = "0.106.0", optional = true }
ckb-chain-spec = { version = "=0.106.0", optional = true }
ckb-mock-tx-types = { version = "0.108.0", optional = true }
ckb-chain-spec = { version = "0.108.0", optional = true }

sparse-merkle-tree = "0.5.4"
sparse-merkle-tree = "0.6.1"
lazy_static = "1.3.0"

[features]
default = []
test = []

[dev-dependencies]
clap = { version = "3.1.9", features = ["derive"] }
clap = { version = "4.1.8", features = ["derive"] }
httpmock = "0.6"
async-global-executor = "=2.0.4"
async-global-executor = "2.3.1"
hex = "0.4"
2 changes: 1 addition & 1 deletion examples/transfer_from_multisig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ fn main() -> Result<(), Box<dyn StdErr>> {
}
Commands::Send { tx_file, ckb_rpc } => {
// Send transaction
let tx_info: TxInfo = serde_json::from_slice(&fs::read(&tx_file)?)?;
let tx_info: TxInfo = serde_json::from_slice(&fs::read(tx_file)?)?;
println!(
"> tx: {}",
serde_json::to_string_pretty(&tx_info.tx).unwrap()
Expand Down
2 changes: 1 addition & 1 deletion examples/transfer_from_omnilock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ fn main() -> Result<(), Box<dyn StdErr>> {
}
Commands::Send { tx_file, ckb_rpc } => {
// Send transaction
let tx_info: TxInfo = serde_json::from_slice(&fs::read(&tx_file)?)?;
let tx_info: TxInfo = serde_json::from_slice(&fs::read(tx_file)?)?;
println!("> tx: {}", serde_json::to_string_pretty(&tx_info.tx)?);
let outputs_validator = Some(json_types::OutputsValidator::Passthrough);
let _tx_hash = CkbRpcClient::new(ckb_rpc.as_str())
Expand Down
2 changes: 1 addition & 1 deletion examples/transfer_from_omnilock_ethereum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ fn main() -> Result<(), Box<dyn StdErr>> {
}
Commands::Send { tx_file, ckb_rpc } => {
// Send transaction
let tx_info: TxInfo = serde_json::from_slice(&fs::read(&tx_file)?)?;
let tx_info: TxInfo = serde_json::from_slice(&fs::read(tx_file)?)?;
println!("> tx: {}", serde_json::to_string_pretty(&tx_info.tx)?);
let outputs_validator = Some(json_types::OutputsValidator::Passthrough);
let _tx_hash = CkbRpcClient::new(ckb_rpc.as_str())
Expand Down
2 changes: 1 addition & 1 deletion examples/transfer_from_omnilock_multisig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ fn main() -> Result<(), Box<dyn StdErr>> {
}
Commands::Send { tx_file, ckb_rpc } => {
// Send transaction
let tx_info: TxInfo = serde_json::from_slice(&fs::read(&tx_file)?)?;
let tx_info: TxInfo = serde_json::from_slice(&fs::read(tx_file)?)?;
println!("> tx: {}", serde_json::to_string_pretty(&tx_info.tx)?);
let outputs_validator = Some(json_types::OutputsValidator::Passthrough);
let _tx_hash = CkbRpcClient::new(ckb_rpc.as_str())
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.61.0
1.67.1
1 change: 1 addition & 0 deletions src/pubsub/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ where
}

/// if topic is empty, return Ok, else Err
#[allow(clippy::result_large_err)]
pub fn try_into(self) -> Result<Client<T>, Self> {
if self.topic_list.is_empty() {
Ok(Client {
Expand Down
6 changes: 3 additions & 3 deletions src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ macro_rules! jsonrpc {
$struct_name { url, id: 0, client: reqwest::blocking::Client::new(), }
}

pub fn post<PARAM, RET>(&mut self, method:&str, params: PARAM)->Result<RET, crate::rpc::RpcError>
pub fn post<PARAM, RET>(&mut self, method:&str, params: PARAM)->Result<RET, $crate::rpc::RpcError>
where
PARAM:serde::ser::Serialize,
RET: serde::de::DeserializeOwned,
Expand Down Expand Up @@ -74,9 +74,9 @@ macro_rules! jsonrpc {

$(
$(#[$attr])*
pub fn $method(&mut $selff $(, $arg_name: $arg_ty)*) -> Result<$return_ty, crate::rpc::RpcError> {
pub fn $method(&mut $selff $(, $arg_name: $arg_ty)*) -> Result<$return_ty, $crate::rpc::RpcError> {
let method = String::from(stringify!($method));
let params = crate::serialize_parameters!($($arg_name,)*);
let params = $crate::serialize_parameters!($($arg_name,)*);
$selff.id += 1;

let mut req_json = serde_json::Map::new();
Expand Down
4 changes: 2 additions & 2 deletions src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ fn test_transfer_to_acp() {
let account1_key = secp256k1::SecretKey::from_slice(ACCOUNT1_KEY.as_bytes()).unwrap();
let signer1 = SecpCkbRawKeySigner::new_with_secret_keys(vec![account1_key]);
let sighash_unlocker = AcpUnlocker::from(Box::new(signer1) as Box<_>);
let acp_unlocker = AcpUnlocker::from(Box::new(SecpCkbRawKeySigner::default()) as Box<_>);
let acp_unlocker = AcpUnlocker::from(Box::<SecpCkbRawKeySigner>::default() as Box<_>);
let mut unlockers: HashMap<ScriptId, Box<dyn ScriptUnlocker>> = HashMap::default();
unlockers.insert(
ScriptId::new_type(SIGHASH_TYPE_HASH),
Expand Down Expand Up @@ -1042,7 +1042,7 @@ fn test_udt_transfer() {
let account1_key = secp256k1::SecretKey::from_slice(ACCOUNT1_KEY.as_bytes()).unwrap();
let signer = SecpCkbRawKeySigner::new_with_secret_keys(vec![account1_key]);
let script_unlocker = SecpSighashUnlocker::from(Box::new(signer) as Box<_>);
let acp_unlocker = AcpUnlocker::from(Box::new(SecpCkbRawKeySigner::default()) as Box<_>);
let acp_unlocker = AcpUnlocker::from(Box::<SecpCkbRawKeySigner>::default() as Box<_>);
let mut unlockers: HashMap<ScriptId, Box<dyn ScriptUnlocker>> = HashMap::default();
unlockers.insert(
ScriptId::new_type(SIGHASH_TYPE_HASH.clone()),
Expand Down
2 changes: 1 addition & 1 deletion src/traits/default_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ impl CellCollector for DefaultCellCollector {
limit *= 2;
}
}
cells = ret_cells.into_iter().map(|(_k, v)| v).collect();
cells = ret_cells.into_values().collect();
}
if apply_changes {
self.offchain.live_cells = rest_cells;
Expand Down
2 changes: 1 addition & 1 deletion src/traits/light_client_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ impl CellCollector for LightClientCellCollector {
limit *= 2;
}
}
cells = ret_cells.into_iter().map(|(_k, v)| v).collect();
cells = ret_cells.into_values().collect();
}
if apply_changes {
self.offchain.live_cells = rest_cells;
Expand Down
2 changes: 1 addition & 1 deletion src/types/human_capacity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl FromStr for HumanCapacity {
let parts = input.trim().split('.').collect::<Vec<_>>();
let mut capacity = ONE_CKB
* parts
.get(0)
.first()
.ok_or_else(|| "Missing input".to_owned())?
.parse::<u64>()
.map_err(|err| err.to_string())?;
Expand Down
2 changes: 1 addition & 1 deletion src/unlock/omni_lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl Identity {
pub fn to_smt_key(&self) -> [u8; 32] {
let mut ret = [0u8; 32];
ret[0] = self.flag as u8;
(&mut ret[1..21]).copy_from_slice(self.auth_content.as_ref());
ret[1..21].copy_from_slice(self.auth_content.as_ref());
ret
}

Expand Down
2 changes: 1 addition & 1 deletion src/unlock/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl MultisigConfig {

pub fn hash160(&self) -> H160 {
let witness_data = self.to_witness_data();
let params_hash = blake2b_256(&witness_data);
let params_hash = blake2b_256(witness_data);
H160::from_slice(&params_hash[0..20]).unwrap()
}

Expand Down

0 comments on commit 5f7aa5a

Please sign in to comment.