difftreelog
CORE-302 Fix shema => schema
in: master
6 files changed
pallets/evm-collection/src/eth.rsdiffbeforeafterboth130 Ok(())130 Ok(())131 }131 }132132133 fn set_offchain_shema(133 fn set_offchain_schema(134 &self,134 &self,135 caller: caller,135 caller: caller,136 collection_address: address,136 collection_address: address,137 shema: string,137 schema: string,138 ) -> Result<void> {138 ) -> Result<void> {139 let mut collection = collection_from_address(collection_address, &self.0)?;139 let mut collection = collection_from_address(collection_address, &self.0)?;140 check_is_owner(caller, &collection)?;140 check_is_owner(caller, &collection)?;141141142 let shema = shema142 let schema = schema143 .into_bytes()143 .into_bytes()144 .try_into()144 .try_into()145 .map_err(|_| error_feild_too_long(stringify!(shema), OFFCHAIN_SCHEMA_LIMIT))?;145 .map_err(|_| error_feild_too_long(stringify!(shema), OFFCHAIN_SCHEMA_LIMIT))?;146 // collection.offchain_schema = shema;146 // collection.offchain_schema = schema;147 collection.save().map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;147 collection.save().map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;148 Ok(())148 Ok(())149 }149 }pallets/evm-collection/src/stubs/Collection.rawdiffbeforeafterbothbinary blob — no preview
pallets/evm-collection/src/stubs/Collection.soldiffbeforeafterboth21 }21 }22}22}232324// Selector: 037b69c824// Selector: f83ad95b25contract Collection is Dummy, ERC165 {25contract Collection is Dummy, ERC165 {26 // Selector: create721Collection(string,string,string) 951c015126 // Selector: create721Collection(string,string,string) 951c015127 function create721Collection(27 function create721Collection(55 dummy;55 dummy;56 }56 }575758 // Selector: setOffchainShema(address,string) d7dc2de358 // Selector: setOffchainSchema(address,string) 2c9d9d7059 function setOffchainShema(address collectionAddress, string memory shema)59 function setOffchainSchema(address collectionAddress, string memory shema)60 public60 public61 view61 view62 {62 {tests/src/eth/api/Collection.soldiffbeforeafterboth12 function supportsInterface(bytes4 interfaceID) external view returns (bool);12 function supportsInterface(bytes4 interfaceID) external view returns (bool);13}13}141415// Selector: 037b69c815// Selector: f83ad95b16interface Collection is Dummy, ERC165 {16interface Collection is Dummy, ERC165 {17 // Selector: create721Collection(string,string,string) 951c015117 // Selector: create721Collection(string,string,string) 951c015118 function create721Collection(18 function create721Collection(29 // Selector: confirmSponsorship(address) abc0000129 // Selector: confirmSponsorship(address) abc0000130 function confirmSponsorship(address collectionAddress) external view;30 function confirmSponsorship(address collectionAddress) external view;313132 // Selector: setOffchainShema(address,string) d7dc2de332 // Selector: setOffchainSchema(address,string) 2c9d9d7033 function setOffchainShema(address collectionAddress, string memory shema)33 function setOffchainSchema(address collectionAddress, string memory shema)34 external34 external35 view;35 view;3636tests/src/eth/collectionAbi.jsondiffbeforeafterboth60 },60 },61 { "internalType": "string", "name": "shema", "type": "string" }61 { "internalType": "string", "name": "shema", "type": "string" }62 ],62 ],63 "name": "setOffchainShema",63 "name": "setOffchainSchema",64 "outputs": [],64 "outputs": [],65 "stateMutability": "view",65 "stateMutability": "view",66 "type": "function"66 "type": "function"tests/src/eth/createCollection.test.tsdiffbeforeafterboth79 expect(collection.sponsorship.asConfirmed.toHuman()).to.be.eq(evmToAddress(sponsor));79 expect(collection.sponsorship.asConfirmed.toHuman()).to.be.eq(evmToAddress(sponsor));80 });80 });81 81 82 itWeb3('Set offchain shema', async ({api, web3}) => {82 itWeb3('Set offchain schema', async ({api, web3}) => {83 const owner = await createEthAccountWithBalance(api, web3);83 const owner = await createEthAccountWithBalance(api, web3);84 const helper = collectionHelper(web3, owner);84 const helper = collectionHelper(web3, owner);85 let result = await helper.methods.create721Collection('Shema collection', '2', '2').send();85 let result = await helper.methods.create721Collection('Schema collection', '2', '2').send();86 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);86 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);87 const shema = 'Some shema';87 const schema = 'Some schema';88 result = await helper.methods.setOffchainShema(collectionIdAddress, shema).send();88 result = await helper.methods.setOffchainSchema(collectionIdAddress, schema).send();89 const collection = (await getDetailedCollectionInfo(api, collectionId))!;89 const collection = (await getDetailedCollectionInfo(api, collectionId))!;90 expect(collection.offchainSchema.toHuman()).to.be.eq(shema);90 expect(collection.offchainSchema.toHuman()).to.be.eq(schema);91 });91 });92 92 93 itWeb3('Set variable on chain schema', async ({api, web3}) => {93 itWeb3('Set variable on chain schema', async ({api, web3}) => {106 const helper = collectionHelper(web3, owner);106 const helper = collectionHelper(web3, owner);107 let result = await helper.methods.create721Collection('Const collection', '4', '4').send();107 let result = await helper.methods.create721Collection('Const collection', '4', '4').send();108 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);108 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);109 const constShema = 'Some const';109 const constSchema = 'Some const';110 result = await helper.methods.setConstOnChainSchema(collectionIdAddress, constShema).send();110 result = await helper.methods.setConstOnChainSchema(collectionIdAddress, constSchema).send();111 const collection = (await getDetailedCollectionInfo(api, collectionId))!;111 const collection = (await getDetailedCollectionInfo(api, collectionId))!;112 expect(collection.constOnChainSchema.toHuman()).to.be.eq(constShema);112 expect(collection.constOnChainSchema.toHuman()).to.be.eq(constSchema);113 });113 });114114115 itWeb3('Set limits', async ({api, web3}) => {115 itWeb3('Set limits', async ({api, web3}) => {178 expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');178 expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');179179180 // TODO: this wont work right now, need release 919000 first180 // TODO: this wont work right now, need release 919000 first181 // await helper.methods.setOffchainShema(collectionIdAddress, 'https://offchain-service.local/token-info/{id}').send();181 // await helper.methods.setOffchainSchema(collectionIdAddress, 'https://offchain-service.local/token-info/{id}').send();182 // const tokenUri = await contract.methods.tokenURI(nextTokenId).call();182 // const tokenUri = await contract.methods.tokenURI(nextTokenId).call();183 // expect(tokenUri).to.be.equal(`https://offchain-service.local/token-info/${nextTokenId}`);183 // expect(tokenUri).to.be.equal(`https://offchain-service.local/token-info/${nextTokenId}`);184 });184 });248 .call()).to.be.rejectedWith(EXPECTED_ERROR);248 .call()).to.be.rejectedWith(EXPECTED_ERROR);249 }249 }250 {250 {251 const shema = 'Some shema';251 const schema = 'Some schema';252 await expect(helper.methods252 await expect(helper.methods253 .setOffchainShema(collectionAddressWithBadPrefix, shema)253 .setOffchainSchema(collectionAddressWithBadPrefix, schema)254 .call()).to.be.rejectedWith(EXPECTED_ERROR);254 .call()).to.be.rejectedWith(EXPECTED_ERROR);255 }255 }256 {256 {293 .call()).to.be.rejectedWith('Caller is not set as sponsor');293 .call()).to.be.rejectedWith('Caller is not set as sponsor');294 }294 }295 {295 {296 const shema = 'Some shema';296 const schema = 'Some schema';297 await expect(helperFromNotOwner.methods297 await expect(helperFromNotOwner.methods298 .setOffchainShema(collectionIdAddress, shema)298 .setOffchainSchema(collectionIdAddress, schema)299 .call()).to.be.rejectedWith(EXPECTED_ERROR);299 .call()).to.be.rejectedWith(EXPECTED_ERROR);300 }300 }301 {301 {318 }318 }319 });319 });320320321 itWeb3('(!negative test!) Set offchain shema (length limit)', async ({api, web3}) => {321 itWeb3('(!negative test!) Set offchain schema (length limit)', async ({api, web3}) => {322 const owner = await createEthAccountWithBalance(api, web3);322 const owner = await createEthAccountWithBalance(api, web3);323 const helper = collectionHelper(web3, owner);323 const helper = collectionHelper(web3, owner);324 const result = await helper.methods.create721Collection('Shema collection', 'A', 'A').send();324 const result = await helper.methods.create721Collection('Schema collection', 'A', 'A').send();325 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);325 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);326 const OFFCHAIN_SCHEMA_LIMIT = 8192;326 const OFFCHAIN_SCHEMA_LIMIT = 8192;327 const shema = 'A'.repeat(OFFCHAIN_SCHEMA_LIMIT + 1);327 const schema = 'A'.repeat(OFFCHAIN_SCHEMA_LIMIT + 1);328 await expect(helper.methods328 await expect(helper.methods329 .setOffchainShema(collectionIdAddress, shema)329 .setOffchainSchema(collectionIdAddress, schema)330 .call()).to.be.rejectedWith('shema is too long. Max length is ' + OFFCHAIN_SCHEMA_LIMIT);330 .call()).to.be.rejectedWith('schema is too long. Max length is ' + OFFCHAIN_SCHEMA_LIMIT);331 });331 });332332333 itWeb3('(!negative test!) Set variable on chain schema (length limit)', async ({api, web3}) => {333 itWeb3('(!negative test!) Set variable on chain schema (length limit)', async ({api, web3}) => {334 const owner = await createEthAccountWithBalance(api, web3);334 const owner = await createEthAccountWithBalance(api, web3);335 const helper = collectionHelper(web3, owner);335 const helper = collectionHelper(web3, owner);336 const result = await helper.methods.create721Collection('Shema collection', 'A', 'A').send();336 const result = await helper.methods.create721Collection('Schema collection', 'A', 'A').send();337 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);337 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);338 const VARIABLE_ON_CHAIN_SCHEMA_LIMIT = 8192;338 const VARIABLE_ON_CHAIN_SCHEMA_LIMIT = 8192;339 const variable = 'A'.repeat(VARIABLE_ON_CHAIN_SCHEMA_LIMIT + 1);339 const variable = 'A'.repeat(VARIABLE_ON_CHAIN_SCHEMA_LIMIT + 1);345 itWeb3('(!negative test!) Set const on chain schema (length limit)', async ({api, web3}) => {345 itWeb3('(!negative test!) Set const on chain schema (length limit)', async ({api, web3}) => {346 const owner = await createEthAccountWithBalance(api, web3);346 const owner = await createEthAccountWithBalance(api, web3);347 const helper = collectionHelper(web3, owner);347 const helper = collectionHelper(web3, owner);348 const result = await helper.methods.create721Collection('Shema collection', 'A', 'A').send();348 const result = await helper.methods.create721Collection('Schema collection', 'A', 'A').send();349 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);349 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);350 const CONST_ON_CHAIN_SCHEMA_LIMIT = 32768;350 const CONST_ON_CHAIN_SCHEMA_LIMIT = 32768;351 const constData = 'A'.repeat(CONST_ON_CHAIN_SCHEMA_LIMIT + 1);351 const constData = 'A'.repeat(CONST_ON_CHAIN_SCHEMA_LIMIT + 1);357 itWeb3('(!negative test!) Set limits', async ({api, web3}) => {357 itWeb3('(!negative test!) Set limits', async ({api, web3}) => {358 const owner = await createEthAccountWithBalance(api, web3);358 const owner = await createEthAccountWithBalance(api, web3);359 const helper = collectionHelper(web3, owner);359 const helper = collectionHelper(web3, owner);360 const result = await helper.methods.create721Collection('Shema collection', 'A', 'A').send();360 const result = await helper.methods.create721Collection('Schema collection', 'A', 'A').send();361 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);361 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);362 const badJson = '{accountTokenOwnershipLimit: 1000}';362 const badJson = '{accountTokenOwnershipLimit: 1000}';363 await expect(helper.methods363 await expect(helper.methods