Skip to content

Commit

Permalink
Merge pull request #17 from KaoImin/patch-1
Browse files Browse the repository at this point in the history
chore: upgrade ckb related dependencies
  • Loading branch information
TheWaWaR authored Jul 20, 2022
2 parents f141d9f + 5935888 commit cc7701f
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 38 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ test/target
test/Cargo.lock
**/*.rs.bk
/devtools/ci/travis-secret.asc
/.vscode
26 changes: 13 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ckb-sdk"
version = "1.0.1"
version = "1.1.0"
authors = ["Linfeng Qian <[email protected]>", "Nervos Core Dev <[email protected]>"]
edition = "2018"
license = "MIT"
Expand All @@ -22,22 +22,22 @@ tokio = { version = "1" }
bytes = "1"
futures = "0.3"
jsonrpc-core = "18"
parking_lot = "0.11"
parking_lot = "0.12"
lru = "0.7.1"

ckb-types = "=0.103.0"
ckb-dao-utils = "=0.103.0"
ckb-traits = "=0.103.0"
ckb-jsonrpc-types = "=0.103.0"
ckb-hash = "=0.103.0"
ckb-resource = "=0.103.0"
ckb-crypto = { version = "=0.103.0", features = ["secp"] }
ckb-types = "=0.104.0"
ckb-dao-utils = "=0.104.0"
ckb-traits = "=0.104.0"
ckb-jsonrpc-types = "=0.104.0"
ckb-hash = "=0.104.0"
ckb-resource = "=0.104.0"
ckb-crypto = { version = "=0.104.0", features = ["secp"] }

# for feature test
rand = { version = "0.7.3", optional = true }
ckb-mock-tx-types = { version = "0.3.0", optional = true }
ckb-chain-spec = { version = "=0.103.0", optional = true }
ckb-script = { version = "=0.103.0", optional = true }
ckb-mock-tx-types = { version = "0.4.0", optional = true }
ckb-chain-spec = { version = "=0.104.0", optional = true }
ckb-script = { version = "=0.104.0", optional = true }

[features]
default = []
Expand All @@ -47,4 +47,4 @@ test = []
clap = { version = "3.1.9", features = ["derive"] }
httpmock = "0.6"
async-global-executor = "=2.0.4"
hex = "0.4"
hex = "0.4"
1 change: 1 addition & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ allow = [
"CC0-1.0",
"ISC",
"MIT",
"Unicode-DFS-2016",
]
copyleft = "deny"
default = "deny"
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.56.1
1.61
28 changes: 4 additions & 24 deletions src/test_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@ use crate::{
tx_builder::tx_fee,
ScriptId,
};
use ckb_chain_spec::consensus::ConsensusBuilder;
use ckb_hash::blake2b_256;
use ckb_mock_tx_types::{
MockCellDep, MockInfo, MockInput, MockResourceLoader, MockTransaction, Resource,
};
use ckb_script::{TransactionScriptsVerifier, TxVerifyEnv};
use ckb_script::TransactionScriptsVerifier;
use ckb_types::{
bytes::Bytes,
core::{
cell::resolve_transaction, hardfork::HardForkSwitch, BlockView, Capacity, Cycle, DepType,
EpochNumberWithFraction, FeeRate, HeaderView, ScriptHashType, TransactionView,
cell::resolve_transaction, BlockView, Capacity, Cycle, DepType, FeeRate, HeaderView,
ScriptHashType, TransactionView,
},
packed::{Byte32, CellDep, CellInput, CellOutput, OutPoint, OutPointVec, Script, Transaction},
prelude::*,
Expand Down Expand Up @@ -307,31 +306,12 @@ impl Context {

/// Run all scripts in the transaction in ckb-vm
pub fn verify_scripts(&self, tx: TransactionView) -> Result<Cycle, Error> {
let (consensus, tx_env) = {
let enable_epoch_number = 200;
let commit_epoch_number = 200 + 100;
let epoch = EpochNumberWithFraction::new(commit_epoch_number, 0, 1);
let header = HeaderView::new_advanced_builder()
.epoch(epoch.pack())
.build();
let tx_env = TxVerifyEnv::new_commit(&header);
let hardfork_switch = HardForkSwitch::new_without_any_enabled()
.as_builder()
.rfc_0032(enable_epoch_number)
.build()
.unwrap();
let consensus = ConsensusBuilder::default()
.hardfork_switch(hardfork_switch)
.build();
(consensus, tx_env)
};

let mock_tx = self.to_mock_tx(tx.data());
let resource = Resource::from_both(&mock_tx, DummyLoader).map_err(Error::VerifyScript)?;
let rtx = resolve_transaction(tx, &mut HashSet::new(), &resource, &resource)
.map_err(|err| Error::VerifyScript(format!("Resolve transaction error: {:?}", err)))?;

let mut verifier = TransactionScriptsVerifier::new(&rtx, &consensus, &resource, &tx_env);
let mut verifier = TransactionScriptsVerifier::new(&rtx, &resource);
verifier.set_debug_printer(|script_hash, message| {
println!("script: {:x}, debug: {}", script_hash, message);
});
Expand Down
1 change: 1 addition & 0 deletions src/tx_builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ pub enum TransactionFeeError {

/// Calculate the actual transaction fee of the transaction, include dao
/// withdraw capacity.
#[allow(clippy::unnecessary_lazy_evaluations)]
pub fn tx_fee(
tx: TransactionView,
tx_dep_provider: &dyn TransactionDependencyProvider,
Expand Down

0 comments on commit cc7701f

Please sign in to comment.