Skip to content

Commit

Permalink
feat: add ckb2023 feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
quake committed Nov 21, 2023
1 parent cdc2c52 commit 0c92111
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 7 deletions.
8 changes: 7 additions & 1 deletion ckb-auth-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
default = []
ckb2023 = ["ckb-std/ckb2023"]

[dependencies]
ckb-std = "0.14.3"

[target.'cfg(target_arch = "riscv64")'.dependencies]
ckb-std = { version = "0.14.3", features = ["ckb2023"] }
log = { version = "0.4.17", default-features = false}
hex = { version = "0.4.3", default-features = false, features = ["alloc"]}
5 changes: 4 additions & 1 deletion ckb-auth-rs/src/ckb_auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ use alloc::vec::Vec;
use ckb_std::{
ckb_types::core::ScriptHashType,
dynamic_loading_c_impl::{CKBDLContext, Library, Symbol},
high_level::spawn_cell,
syscalls::SysError,
};
#[cfg(feature = "ckb2023")]
use ckb_std::high_level::spawn_cell;
use core::mem::size_of_val;
use hex::encode;
use log::info;
Expand Down Expand Up @@ -66,10 +67,12 @@ pub fn ckb_auth(
match entry.entry_category {
// EntryCategoryType::Exec => ckb_auth_exec(entry, id, signature, message),
EntryCategoryType::DynamicLinking => ckb_auth_dl(entry, id, signature, message),
#[cfg(feature = "ckb2023")]
EntryCategoryType::Spawn => ckb_auth_spawn(entry, id, signature, message),
}
}

#[cfg(feature = "ckb2023")]
fn ckb_auth_spawn(
entry: &CkbEntryType,
id: &CkbAuthType,
Expand Down
2 changes: 2 additions & 0 deletions ckb-auth-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ impl TryFrom<u8> for AuthAlgorithmIdType {
pub enum EntryCategoryType {
// Exec = 0,
DynamicLinking = 1,
#[cfg(feature = "ckb2023")]
Spawn = 2,
}

Expand All @@ -64,6 +65,7 @@ impl TryFrom<u8> for EntryCategoryType {
match value {
// 0 => Ok(Self::Exec),
1 => Ok(Self::DynamicLinking),
#[cfg(feature = "ckb2023")]
2 => Ok(Self::Spawn),
_ => Err(CkbAuthTypesError::EncodeArgs),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"

[dependencies]
ckb-std = "0.14.3"
ckb-auth-rs = { path = "../../../../ckb-auth-rs" }
ckb-auth-rs = { path = "../../../../ckb-auth-rs", features = ["ckb2023"] }
log = { version = "0.4.17", default-features = false }
hex = { version = "0.4.3", default-features = false, features = ["alloc"]}
blake2b-rs = "0.2.0"
2 changes: 1 addition & 1 deletion examples/auth-rust-demo/tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ edition = "2021"

[dependencies]
ckb-testtool = "0.10"
ckb-auth-rs = { path = "../../../ckb-auth-rs" }
ckb-auth-rs = { path = "../../../ckb-auth-rs", features = ["ckb2023"] }

rand = "0.6.5"
2 changes: 1 addition & 1 deletion tests/auth-c-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ckb-auth-rs = { path = "../../ckb-auth-rs" }
ckb-auth-rs = { path = "../../ckb-auth-rs", features = ["ckb2023"] }
ckb-crypto = "0.111.0"
ckb-error = "0.111.0"
ckb-hash = "0.111.0"
Expand Down
2 changes: 1 addition & 1 deletion tests/auth-spawn-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ckb-auth-rs = { path = "../../ckb-auth-rs" }
ckb-auth-rs = { path = "../../ckb-auth-rs", features = ["ckb2023"] }
ckb-debugger-api = { git = "https://github.com/nervosnetwork/ckb-standalone-debugger.git", rev="5077c6c" }
ckb-mock-tx-types = { git = "https://github.com/nervosnetwork/ckb-standalone-debugger.git", rev="5077c6c" }
molecule = { version = "0.7.3", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion tools/ckb-auth-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ckb-auth-rs = { path = "../../ckb-auth-rs" }
ckb-auth-rs = { path = "../../ckb-auth-rs", features = ["ckb2023"] }
ckb-vm = { version = "0.24.0", features = [ "asm" ] }
ckb-types = "=0.111.0-rc2"
ckb-hash = "=0.111.0-rc2"
Expand Down

0 comments on commit 0c92111

Please sign in to comment.