git.delta.rocks / unique-network / refs/commits / 8a86ddfbe791

difftreelog

misk: Rename property keys

Trubnikov Sergey2022-07-20parent: #6ef230f.patch.diff
in: master

4 files changed

modifiedpallets/common/src/erc.rsdiffbeforeafterboth
446 property_key_from_bytes(b"baseURI").expect(EXPECT_CONVERT_ERROR)446 property_key_from_bytes(b"baseURI").expect(EXPECT_CONVERT_ERROR)
447 }447 }
448448
449 pub fn u_key() -> up_data_structs::PropertyKey {449 pub fn url_key() -> up_data_structs::PropertyKey {
450 property_key_from_bytes(b"u").expect(EXPECT_CONVERT_ERROR)450 property_key_from_bytes(b"url").expect(EXPECT_CONVERT_ERROR)
451 }451 }
452452
453 pub fn s_key() -> up_data_structs::PropertyKey {453 pub fn suffix_key() -> up_data_structs::PropertyKey {
454 property_key_from_bytes(b"s").expect(EXPECT_CONVERT_ERROR)454 property_key_from_bytes(b"suffix").expect(EXPECT_CONVERT_ERROR)
455 }455 }
456456
457 pub const ERC721_METADATA: &[u8] = b"ERC721Metadata";457 pub const ERC721_METADATA: &[u8] = b"ERC721Metadata";
modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
232232
233 let token_id_u32: u32 = token_id.try_into().map_err(|_| "token id overflow")?;233 let token_id_u32: u32 = token_id.try_into().map_err(|_| "token id overflow")?;
234234
235 if let Ok(url) = get_token_property(self, token_id_u32, &u_key()) {235 if let Ok(url) = get_token_property(self, token_id_u32, &url_key()) {
236 if !url.is_empty() {236 if !url.is_empty() {
237 return Ok(url);237 return Ok(url);
238 }238 }
250 e250 e
251 ))251 ))
252 })?;252 })?;
253 if let Ok(suffix) = get_token_property(self, token_id_u32, &s_key()) {253 if let Ok(suffix) = get_token_property(self, token_id_u32, &suffix_key()) {
254 if !suffix.is_empty() {254 if !suffix.is_empty() {
255 return Ok(base_uri + suffix.as_str());255 return Ok(base_uri + suffix.as_str());
256 }256 }
497 token_id: uint256,497 token_id: uint256,
498 token_uri: string,498 token_uri: string,
499 ) -> Result<bool> {499 ) -> Result<bool> {
500 let key = u_key();500 let key = url_key();
501 let permission = get_token_permission::<T>(self.id, &key)?;501 let permission = get_token_permission::<T>(self.id, &key)?;
502 if !permission.collection_admin {502 if !permission.collection_admin {
503 return Err("Operation is not allowed".into());503 return Err("Operation is not allowed".into());
702 to: address,702 to: address,
703 tokens: Vec<(uint256, string)>,703 tokens: Vec<(uint256, string)>,
704 ) -> Result<bool> {704 ) -> Result<bool> {
705 let key = u_key();705 let key = url_key();
706 let caller = T::CrossAccountId::from_eth(caller);706 let caller = T::CrossAccountId::from_eth(caller);
707 let to = T::CrossAccountId::from_eth(to);707 let to = T::CrossAccountId::from_eth(to);
708 let mut expected_index = <TokensMinted<T>>::get(self.id)708 let mut expected_index = <TokensMinted<T>>::get(self.id)
modifiedpallets/unique/src/eth/mod.rsdiffbeforeafterboth
9797
98 token_property_permissions98 token_property_permissions
99 .try_push(up_data_structs::PropertyKeyPermission {99 .try_push(up_data_structs::PropertyKeyPermission {
100 key: u_key(),100 key: url_key(),
101 permission: up_data_structs::PropertyPermission {101 permission: up_data_structs::PropertyPermission {
102 mutable: false,102 mutable: false,
103 collection_admin: true,103 collection_admin: true,
109 if add_properties {109 if add_properties {
110 token_property_permissions110 token_property_permissions
111 .try_push(up_data_structs::PropertyKeyPermission {111 .try_push(up_data_structs::PropertyKeyPermission {
112 key: s_key(),112 key: suffix_key(),
113 permission: up_data_structs::PropertyPermission {113 permission: up_data_structs::PropertyPermission {
114 mutable: false,114 mutable: false,
115 collection_admin: true,115 collection_admin: true,
modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
122 ).send();122 ).send();
123 123
124 // Set URL124 // Set URL
125 await contract.methods.setProperty(nextTokenId, 'u', Buffer.from('Token URI')).send();125 await contract.methods.setProperty(nextTokenId, 'url', Buffer.from('Token URI')).send();
126 126
127 const events = normalizeEvents(result.events);127 const events = normalizeEvents(result.events);
128 const address = collectionIdToAddress(collectionId);128 const address = collectionIdToAddress(collectionId);
192 192
193 // Set suffix193 // Set suffix
194 const suffix = '/some/suffix';194 const suffix = '/some/suffix';
195 await contract.methods.setProperty(nextTokenId, 's', Buffer.from(suffix)).send();195 await contract.methods.setProperty(nextTokenId, 'suffix', Buffer.from(suffix)).send();
196196
197 const events = normalizeEvents(result.events);197 const events = normalizeEvents(result.events);
198 const address = collectionIdToAddress(collectionId);198 const address = collectionIdToAddress(collectionId);