Skip to content

Commit

Permalink
add Details type
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Jan 7, 2025
1 parent 6d2498d commit 87c027e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ mod types;
mod names;

pub use fungible::*;
pub use names::{AssetName, Ticker};
pub use names::{AssetName, Details, Ticker};
pub use types::{rgb_contract_stl, CommonTypes};

pub const LIB_NAME_RGB_CONTRACT: &str = "RGBContract";
8 changes: 8 additions & 0 deletions src/names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use std::hash::{Hash, Hasher};
use std::str::FromStr;

use amplify::confinement::TinyString;
use strict_encoding::stl::{Alpha, AlphaNum, AsciiPrintable};
use strict_encoding::RString;
use strict_types::StrictVal;
Expand Down Expand Up @@ -66,3 +67,10 @@ impl_ident_subtype!(AssetName);
impl AssetName {
pub fn from_strict_val_unchecked(value: &StrictVal) -> Self { Self::from_str(&value.unwrap_string()).unwrap() }
}

#[derive(Wrapper, Clone, Ord, PartialOrd, PartialEq, Eq, From)]
#[wrapper(Deref, Display, FromStr)]
#[derive(StrictDumb, StrictType, StrictEncode, StrictDecode)]
#[strict_type(lib = LIB_NAME_RGB_CONTRACT)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(transparent))]
pub struct Details(TinyString);
3 changes: 2 additions & 1 deletion src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
use strict_types::stl::std_stl;
use strict_types::{LibBuilder, SemId, SymbolicSys, SystemBuilder, TypeLib, TypeSystem};

use crate::{Amount, AssetName, Precision, Ticker, LIB_NAME_RGB_CONTRACT};
use crate::{Amount, AssetName, Details, Precision, Ticker, LIB_NAME_RGB_CONTRACT};

#[derive(Debug)]
pub struct CommonTypes(SymbolicSys);
Expand All @@ -38,6 +38,7 @@ pub fn rgb_contract_stl() -> TypeLib {
.transpile::<Precision>()
.transpile::<Ticker>()
.transpile::<AssetName>()
.transpile::<Details>()
.compile()
.expect("invalid common types library")
}
Expand Down

0 comments on commit 87c027e

Please sign in to comment.