difftreelog
CORE-346 Fix recieving tokenURI
in: master
2 files changed
pallets/nonfungible/src/erc.rsdiffbeforeafterboth161 let key: string = "tokenURI".into(); //TODO: make static161 let key: string = "tokenURI".into(); //TODO: make static162 let key: up_data_structs::PropertyKey = key.into_bytes().try_into()162 let key: up_data_structs::PropertyKey = key.into_bytes().try_into()163 .map_err(|_| Error::Revert("".into()))?;163 .map_err(|_| Error::Revert("".into()))?;164 let permission = get_permission::<T>(self.id, &key)?;164 let permission = get_token_permission::<T>(self.id, &key)?;165 if !permission.collection_admin {165 if !permission.collection_admin {166 return Err("Operation is not allowed".into());166 return Err("Operation is not allowed".into());167 }167 }168168169 self.consume_store_reads(1)?;169 self.consume_store_reads(1)?;170 let _token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;170 let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;171172 let properties = <TokenProperties<T>>::try_get((self.id, token_id))173 .map_err(|_| Error::Revert("Token properties not found".into()))?;174 if let Some(property) = properties.get(&key) {171 Ok(string::from_utf8_lossy(175 return Ok(string::from_utf8_lossy(property).into());172 todo!()176 }173 )177174 .into())178 Err("Property tokenURI not found".into())175 }179 }176}180}177181361 let key: string = "tokenURI".into(); //TODO: make static365 let key: string = "tokenURI".into(); //TODO: make static362 let key: up_data_structs::PropertyKey = key.into_bytes().try_into()366 let key: up_data_structs::PropertyKey = key.into_bytes().try_into()363 .map_err(|_| Error::Revert("".into()))?;367 .map_err(|_| Error::Revert("".into()))?;364 let permission = get_permission::<T>(self.id, &key)?;368 let permission = get_token_permission::<T>(self.id, &key)?;365 if !permission.collection_admin {369 if !permission.collection_admin {366 return Err("Operation is not allowed".into());370 return Err("Operation is not allowed".into());367 }371 }407 }411 }408}412}409413410fn get_permission<T: Config>(collection_id: CollectionId, key: &PropertyKey) -> Result<PropertyPermission> {414fn get_token_permission<T: Config>(collection_id: CollectionId, key: &PropertyKey) -> Result<PropertyPermission> {411 let token_property_permissions = CollectionPropertyPermissions::<T>::try_get(collection_id)415 let token_property_permissions = CollectionPropertyPermissions::<T>::try_get(collection_id)412 .map_err(|_| Error::Revert("No permissions for collection".into()))?;416 .map_err(|_| Error::Revert("No permissions for collection".into()))?;413 Ok(token_property_permissions.get(key)417 let a = token_property_permissions.get(key)414 .map(|p| p.clone())418 .map(|p| p.clone())415 .ok_or_else(|| Error::Revert("No permission for tokenURI".into()))?)419 .ok_or_else(|| Error::Revert("No permission for tokenURI".into()))?;420 Ok(a)416}421}417422418#[solidity_interface(name = "ERC721UniqueExtensions")]423#[solidity_interface(name = "ERC721UniqueExtensions")]tests/src/eth/createCollection.test.tsdiffbeforeafterboth187 .isCollectionExist(collectionAddressForNonexistentCollection).call())187 .isCollectionExist(collectionAddressForNonexistentCollection).call())188 .to.be.false;188 .to.be.false;189 189 190 const result = await collectionHelper.methods.create721Collection('Const collection', '5', '5').send();190 const result = await collectionHelper.methods.create721Collection('Collection address exist', '7', '7').send();191 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);191 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);192 expect(await collectionHelper.methods192 expect(await collectionHelper.methods193 .isCollectionExist(collectionIdAddress).call())193 .isCollectionExist(collectionIdAddress).call())