git.delta.rocks / unique-network / refs/commits / 790d2f0e58ad

difftreelog

CORE-325 Fix PR

Trubnikov Sergey2022-04-11parent: #2baf5e9.patch.diff
in: master

2 files changed

modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
94 /// Returns token's const_metadata94 /// Returns token's const_metadata
95 #[solidity(rename_selector = "tokenURI")]95 #[solidity(rename_selector = "tokenURI")]
96 fn token_uri(&self, token_id: uint256) -> Result<string> {96 fn token_uri(&self, token_id: uint256) -> Result<string> {
97 if let SchemaVersion::ImageURL = self.schema_version {97 if !matches!(self.schema_version, SchemaVersion::ImageURL) {
98 return Err(error_unsupported_shema_version());
99 }
100
98 self.consume_store_reads(1)?;101 self.consume_store_reads(1)?;
99 let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;102 let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;
103 .const_data,106 .const_data,
104 )107 )
105 .into())108 .into())
106 } else {
107 Err(error_unsupported_shema_version())
108 }
109 }109 }
110}110}
111111
285 token_id: uint256,285 token_id: uint256,
286 token_uri: string,286 token_uri: string,
287 ) -> Result<bool> {287 ) -> Result<bool> {
288 if let SchemaVersion::ImageURL = self.schema_version {288 if !matches!(self.schema_version, SchemaVersion::ImageURL) {
289 return Err(error_unsupported_shema_version());
290 }
291
289 let caller = T::CrossAccountId::from_eth(caller);292 let caller = T::CrossAccountId::from_eth(caller);
290 let to = T::CrossAccountId::from_eth(to);293 let to = T::CrossAccountId::from_eth(to);
310 )313 )
311 .map_err(dispatch_to_evm::<T>)?;314 .map_err(dispatch_to_evm::<T>)?;
312 Ok(true)315 Ok(true)
313 } else {
314 Err(error_unsupported_shema_version())
315 }
316 }316 }
317317
318 /// Not implemented318 /// Not implemented
430 to: address,430 to: address,
431 tokens: Vec<(uint256, string)>,431 tokens: Vec<(uint256, string)>,
432 ) -> Result<bool> {432 ) -> Result<bool> {
433 if let SchemaVersion::ImageURL = self.schema_version {433 if !matches!(self.schema_version, SchemaVersion::ImageURL) {
434 return Err(error_unsupported_shema_version());
435 }
436
434 let caller = T::CrossAccountId::from_eth(caller);437 let caller = T::CrossAccountId::from_eth(caller);
435 let to = T::CrossAccountId::from_eth(to);438 let to = T::CrossAccountId::from_eth(to);
457 <Pallet<T>>::create_multiple_items(self, &caller, data)460 <Pallet<T>>::create_multiple_items(self, &caller, data)
458 .map_err(dispatch_to_evm::<T>)?;461 .map_err(dispatch_to_evm::<T>)?;
459 Ok(true)462 Ok(true)
460 } else {
461 Err(error_unsupported_shema_version())
462 }
463 }463 }
464}464}
465465
modifiedtests/src/eth/metadata.test.tsdiffbeforeafterboth
98 receiver,98 receiver,
99 nextTokenId,99 nextTokenId,
100 'Test URI',100 'Test URI',
101 ).send({from: caller})).to.be.rejected;101 ).call({from: caller})).to.be.rejectedWith('Unsupported shema version! Support only ImageURL');
102102
103 await expect(contract.methods.mintBulkWithTokenURI(103 await expect(contract.methods.mintBulkWithTokenURI(
104 receiver,104 receiver,
107 [+nextTokenId + 1, 'Test URI 1'],107 [+nextTokenId + 1, 'Test URI 1'],
108 [+nextTokenId + 2, 'Test URI 2'],108 [+nextTokenId + 2, 'Test URI 2'],
109 ],109 ],
110 ).send({from: caller})).to.be.rejected;110 ).call({from: caller})).to.be.rejectedWith('Unsupported shema version! Support only ImageURL');
111 });111 });
112112
113 itWeb3('Check support ERC721Metadata for ShemaVersion::ImageURL', async ({web3, api}) => {113 itWeb3('Check support ERC721Metadata for ShemaVersion::ImageURL', async ({web3, api}) => {