Skip to content

Commit

Permalink
Simplified core mod.
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanYuan committed Jul 24, 2023
1 parent 524f5ff commit cd392ce
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 55 deletions.
57 changes: 55 additions & 2 deletions util/gen-types/src/core/mod.rs
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.
53 changes: 0 additions & 53 deletions util/gen-types/src/core/types/mod.rs

This file was deleted.

0 comments on commit cd392ce

Please sign in to comment.