@@ -48,8 +48,6 @@ pub use rgb21::{rgb21, rgb21_stl, Rgb21, LIB_ID_RGB21, LIB_NAME_RGB21};
48
48
pub use rgb25:: { rgb25, rgb25_stl, Rgb25 , LIB_ID_RGB25 , LIB_NAME_RGB25 } ;
49
49
pub use suppl:: { ContractSuppl , OwnedStateSuppl , SupplId , TickerSuppl , VelocityHint } ;
50
50
51
- use crate :: stl:: Ticker ;
52
-
53
51
#[ derive( Copy , Clone , Ord , PartialOrd , Eq , PartialEq , Hash , Debug , Display , Default ) ]
54
52
#[ derive( StrictType , StrictEncode , StrictDecode ) ]
55
53
#[ strict_type( lib = crate :: LIB_NAME_RGB_STD , tags = repr, into_u8, try_from_u8) ]
@@ -66,46 +64,26 @@ pub enum VerNo {
66
64
V1 = 0 ,
67
65
}
68
66
67
+ // TODO: Move to RGB Core
69
68
mod asset_tag_ext {
70
69
use std:: time:: SystemTime ;
71
70
72
71
use amplify:: confinement:: U8 ;
73
72
use bp:: secp256k1:: rand:: { thread_rng, RngCore } ;
74
73
use commit_verify:: { DigestExt , Sha256 } ;
75
- use rgb:: AssetTag ;
76
- use strict_encoding:: TypeName ;
77
-
78
- use super :: * ;
74
+ use rgb:: { AssetTag , AssignmentType } ;
79
75
80
76
pub trait AssetTagExt : Sized {
81
- fn new_rgb20 ( issuer_domain : & str , ticker : & Ticker ) -> Self {
82
- Self :: new_custom ( "RGB20" , issuer_domain, ticker)
83
- }
84
- fn new_rgb21 ( issuer_domain : & str , ticker : & Ticker ) -> Self {
85
- Self :: new_custom ( "RGB21" , issuer_domain, ticker)
86
- }
87
- fn new_rgb25 ( issuer_domain : & str , ticker : & Ticker ) -> Self {
88
- Self :: new_custom ( "RGB25" , issuer_domain, ticker)
89
- }
90
- fn new_custom (
91
- iface_name : impl Into < TypeName > ,
92
- issuer_domain : impl AsRef < str > ,
93
- ticker : impl AsRef < str > ,
94
- ) -> Self ;
77
+ fn new_random ( contract_domain : impl AsRef < str > , assignment_type : AssignmentType ) -> Self ;
95
78
}
96
79
97
80
impl AssetTagExt for AssetTag {
98
- fn new_custom (
99
- iface_name : impl Into < TypeName > ,
100
- issuer_domain : impl AsRef < str > ,
101
- ticker : impl AsRef < str > ,
102
- ) -> Self {
81
+ fn new_random ( contract_domain : impl AsRef < str > , assignment_type : AssignmentType ) -> Self {
103
82
let rand = thread_rng ( ) . next_u64 ( ) ;
104
83
let timestamp = SystemTime :: now ( ) . elapsed ( ) . expect ( "system time error" ) ;
105
84
let mut hasher = Sha256 :: default ( ) ;
106
- hasher. input_with_len :: < U8 > ( iface_name. into ( ) . as_bytes ( ) ) ;
107
- hasher. input_with_len :: < U8 > ( issuer_domain. as_ref ( ) . as_bytes ( ) ) ;
108
- hasher. input_with_len :: < U8 > ( ticker. as_ref ( ) . as_bytes ( ) ) ;
85
+ hasher. input_with_len :: < U8 > ( contract_domain. as_ref ( ) . as_bytes ( ) ) ;
86
+ hasher. input_raw ( & assignment_type. to_le_bytes ( ) ) ;
109
87
hasher. input_raw ( & timestamp. as_nanos ( ) . to_le_bytes ( ) ) ;
110
88
hasher. input_raw ( & rand. to_le_bytes ( ) ) ;
111
89
AssetTag :: from ( hasher. finish ( ) )
0 commit comments