From 8a86ddfbe791fe6c31f82d7b5092e60d613ef6b0 Mon Sep 17 00:00:00 2001 From: Trubnikov Sergey Date: Wed, 20 Jul 2022 07:50:24 +0000 Subject: [PATCH] misk: Rename property keys --- --- 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"; --- a/pallets/nonfungible/src/erc.rs +++ b/pallets/nonfungible/src/erc.rs @@ -232,7 +232,7 @@ let token_id_u32: u32 = token_id.try_into().map_err(|_| "token id overflow")?; - if let Ok(url) = get_token_property(self, token_id_u32, &u_key()) { + if let Ok(url) = get_token_property(self, token_id_u32, &url_key()) { if !url.is_empty() { return Ok(url); } @@ -250,7 +250,7 @@ e )) })?; - if let Ok(suffix) = get_token_property(self, token_id_u32, &s_key()) { + if let Ok(suffix) = get_token_property(self, token_id_u32, &suffix_key()) { if !suffix.is_empty() { return Ok(base_uri + suffix.as_str()); } @@ -497,7 +497,7 @@ token_id: uint256, token_uri: string, ) -> Result { - let key = u_key(); + let key = url_key(); let permission = get_token_permission::(self.id, &key)?; if !permission.collection_admin { return Err("Operation is not allowed".into()); @@ -702,7 +702,7 @@ to: address, tokens: Vec<(uint256, string)>, ) -> Result { - let key = u_key(); + let key = url_key(); let caller = T::CrossAccountId::from_eth(caller); let to = T::CrossAccountId::from_eth(to); let mut expected_index = >::get(self.id) --- 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, --- 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); -- gitstuff