Skip to content

Commit

Permalink
ckb-auth-rs: pub ckb_auth move to root
Browse files Browse the repository at this point in the history
  • Loading branch information
joii2020 committed Nov 23, 2023
1 parent 3e4d606 commit 5d891a4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
8 changes: 1 addition & 7 deletions ckb-auth-rs/src/ckb_auth.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extern crate alloc;

use crate::{CkbAuthError, CkbAuthType, EntryCategoryType};
use crate::{CkbAuthError, CkbAuthType, CkbEntryType, EntryCategoryType};
use alloc::collections::BTreeMap;
use alloc::ffi::CString;
use alloc::format;
Expand All @@ -15,12 +15,6 @@ use core::mem::size_of_val;
use hex::encode;
use log::info;

pub struct CkbEntryType {
pub code_hash: [u8; 32],
pub hash_type: ScriptHashType,
pub entry_category: EntryCategoryType,
}

pub fn ckb_auth(
entry: &CkbEntryType,
id: &CkbAuthType,
Expand Down
13 changes: 11 additions & 2 deletions ckb-auth-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ extern crate alloc;
use core::mem::transmute;

#[cfg(target_arch = "riscv64")]
pub mod ckb_auth;
mod ckb_auth;

#[cfg(target_arch = "riscv64")]
pub use ckb_auth::ckb_auth;

#[cfg(target_arch = "riscv64")]
mod generate_sighash_all;
Expand All @@ -17,7 +20,7 @@ use alloc::ffi::NulError;
use log::info;

#[cfg(target_arch = "riscv64")]
use ckb_std::error::SysError;
use ckb_std::{ckb_types::core::ScriptHashType, error::SysError};
#[cfg(not(target_arch = "riscv64"))]
type SysError = u64;

Expand Down Expand Up @@ -116,3 +119,9 @@ pub struct CkbAuthType {
pub algorithm_id: AuthAlgorithmIdType,
pub pubkey_hash: [u8; 20],
}

pub struct CkbEntryType {
pub code_hash: [u8; 32],
pub hash_type: ScriptHashType,
pub entry_category: EntryCategoryType,
}
4 changes: 2 additions & 2 deletions examples/auth-rust-demo/contracts/auth-rust-demo/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use core::result::Result;
use crate::error::Error;

use ckb_auth_rs::{
ckb_auth::{ckb_auth, CkbEntryType},
generate_sighash_all, AuthAlgorithmIdType, CkbAuthError, CkbAuthType, EntryCategoryType,
ckb_auth, generate_sighash_all, AuthAlgorithmIdType, CkbAuthError, CkbAuthType, CkbEntryType,
EntryCategoryType,
};
use ckb_std::{
ckb_constants::Source,
Expand Down

0 comments on commit 5d891a4

Please sign in to comment.