-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
55 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,55 @@ | ||
mod types; | ||
pub use types::*; | ||
#![allow(clippy::from_over_into)] | ||
|
||
#[cfg(feature = "std")] | ||
mod std_env; | ||
#[cfg(feature = "std")] | ||
pub use std_env::*; | ||
|
||
use crate::packed; | ||
|
||
pub(crate) type BlockNumber = u64; | ||
|
||
/// Specifies how the script `code_hash` is used to match the script code and how to run the code. | ||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] | ||
pub enum ScriptHashType { | ||
/// Type "data" matches script code via cell data hash, and run the script code in v0 CKB VM. | ||
Data = 0, | ||
/// Type "type" matches script code via cell type script hash. | ||
Type = 1, | ||
/// Type "data1" matches script code via cell data hash, and run the script code in v1 CKB VM. | ||
Data1 = 2, | ||
/// Type "data2" matches script code via cell data hash, and run the script code in v2 CKB VM. | ||
Data2 = 3, | ||
} | ||
|
||
impl Default for ScriptHashType { | ||
fn default() -> Self { | ||
ScriptHashType::Data | ||
} | ||
} | ||
|
||
impl ScriptHashType { | ||
#[inline] | ||
pub(crate) fn verify_value(v: u8) -> bool { | ||
v <= 3 | ||
} | ||
} | ||
|
||
impl Into<u8> for ScriptHashType { | ||
#[inline] | ||
fn into(self) -> u8 { | ||
match self { | ||
Self::Data => 0, | ||
Self::Type => 1, | ||
Self::Data1 => 2, | ||
Self::Data2 => 3, | ||
} | ||
} | ||
} | ||
|
||
impl Into<packed::Byte> for ScriptHashType { | ||
#[inline] | ||
fn into(self) -> packed::Byte { | ||
Into::<u8>::into(self).into() | ||
} | ||
} |
File renamed without changes.
This file was deleted.
Oops, something went wrong.