1234567891011121314151617use up_data_structs::CollectionId;18use sp_core::H160;1920lazy_static::lazy_static! {21 pub static ref KEY_TOKEN_URI: up_data_structs::PropertyKey = {22 let key: evm_coder::types::string = "tokenURI".into(); 23 let key: up_data_structs::PropertyKey = key.into_bytes().try_into().expect("Can't create \"tokenURI\" key");24 key25 };26}27282930const ETH_COLLECTION_PREFIX: [u8; 16] = [31 0x17, 0xc4, 0xe6, 0x45, 0x3c, 0xc4, 0x9a, 0xaa, 0xae, 0xac, 0xa8, 0x94, 0xe6, 0xd9, 0x68, 0x3e,32];3334pub fn map_eth_to_id(eth: &H160) -> Option<CollectionId> {35 if eth[0..16] != ETH_COLLECTION_PREFIX {36 return None;37 }38 let mut id_bytes = [0; 4];39 id_bytes.copy_from_slice(ð[16..20]);40 Some(CollectionId(u32::from_be_bytes(id_bytes)))41}42pub fn collection_id_to_address(id: CollectionId) -> H160 {43 let mut out = [0; 20];44 out[0..16].copy_from_slice(Ð_COLLECTION_PREFIX);45 out[16..20].copy_from_slice(&u32::to_be_bytes(id.0));46 H160(out)47}4849pub fn is_collection(address: &H160) -> bool {50 address[0..16] == ETH_COLLECTION_PREFIX51}