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
--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -446,12 +446,12 @@
 		property_key_from_bytes(b"baseURI").expect(EXPECT_CONVERT_ERROR)
 	}
 
-	pub fn u_key() -> up_data_structs::PropertyKey {
-		property_key_from_bytes(b"u").expect(EXPECT_CONVERT_ERROR)
+	pub fn url_key() -> up_data_structs::PropertyKey {
+		property_key_from_bytes(b"url").expect(EXPECT_CONVERT_ERROR)
 	}
 
-	pub fn s_key() -> up_data_structs::PropertyKey {
-		property_key_from_bytes(b"s").expect(EXPECT_CONVERT_ERROR)
+	pub fn suffix_key() -> up_data_structs::PropertyKey {
+		property_key_from_bytes(b"suffix").expect(EXPECT_CONVERT_ERROR)
 	}
 
 	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
--- a/pallets/unique/src/eth/mod.rs
+++ b/pallets/unique/src/eth/mod.rs
@@ -97,7 +97,7 @@
 
 	token_property_permissions
 		.try_push(up_data_structs::PropertyKeyPermission {
-			key: u_key(),
+			key: url_key(),
 			permission: up_data_structs::PropertyPermission {
 				mutable: false,
 				collection_admin: true,
@@ -109,7 +109,7 @@
 	if add_properties {
 		token_property_permissions
 			.try_push(up_data_structs::PropertyKeyPermission {
-				key: s_key(),
+				key: suffix_key(),
 				permission: up_data_structs::PropertyPermission {
 					mutable: false,
 					collection_admin: true,
modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
--- a/tests/src/eth/nonFungible.test.ts
+++ b/tests/src/eth/nonFungible.test.ts
@@ -122,7 +122,7 @@
     ).send();
     
     // Set URL
-    await contract.methods.setProperty(nextTokenId, 'u', Buffer.from('Token URI')).send();
+    await contract.methods.setProperty(nextTokenId, 'url', Buffer.from('Token URI')).send();
       
     const events = normalizeEvents(result.events);
     const address = collectionIdToAddress(collectionId);
@@ -192,7 +192,7 @@
           
     // Set suffix
     const suffix = '/some/suffix';
-    await contract.methods.setProperty(nextTokenId, 's', Buffer.from(suffix)).send();
+    await contract.methods.setProperty(nextTokenId, 'suffix', Buffer.from(suffix)).send();
 
     const events = normalizeEvents(result.events);
     const address = collectionIdToAddress(collectionId);