From fe6b71bedc93b3a9576953ad066db37d6ce4200c Mon Sep 17 00:00:00 2001 From: Trubnikov Sergey Date: Wed, 27 Apr 2022 11:52:41 +0000 Subject: [PATCH] CORE-302 Fix shema => schema --- --- a/pallets/evm-collection/src/eth.rs +++ b/pallets/evm-collection/src/eth.rs @@ -130,20 +130,20 @@ Ok(()) } - fn set_offchain_shema( + fn set_offchain_schema( &self, caller: caller, collection_address: address, - shema: string, + schema: string, ) -> Result { let mut collection = collection_from_address(collection_address, &self.0)?; check_is_owner(caller, &collection)?; - let shema = shema + let schema = schema .into_bytes() .try_into() .map_err(|_| error_feild_too_long(stringify!(shema), OFFCHAIN_SCHEMA_LIMIT))?; - // collection.offchain_schema = shema; + // collection.offchain_schema = schema; collection.save().map_err(pallet_evm_coder_substrate::dispatch_to_evm::)?; Ok(()) } --- a/pallets/evm-collection/src/stubs/Collection.sol +++ b/pallets/evm-collection/src/stubs/Collection.sol @@ -21,7 +21,7 @@ } } -// Selector: 037b69c8 +// Selector: f83ad95b contract Collection is Dummy, ERC165 { // Selector: create721Collection(string,string,string) 951c0151 function create721Collection( @@ -55,8 +55,8 @@ dummy; } - // Selector: setOffchainShema(address,string) d7dc2de3 - function setOffchainShema(address collectionAddress, string memory shema) + // Selector: setOffchainSchema(address,string) 2c9d9d70 + function setOffchainSchema(address collectionAddress, string memory shema) public view { --- a/tests/src/eth/api/Collection.sol +++ b/tests/src/eth/api/Collection.sol @@ -12,7 +12,7 @@ function supportsInterface(bytes4 interfaceID) external view returns (bool); } -// Selector: 037b69c8 +// Selector: f83ad95b interface Collection is Dummy, ERC165 { // Selector: create721Collection(string,string,string) 951c0151 function create721Collection( @@ -29,8 +29,8 @@ // Selector: confirmSponsorship(address) abc00001 function confirmSponsorship(address collectionAddress) external view; - // Selector: setOffchainShema(address,string) d7dc2de3 - function setOffchainShema(address collectionAddress, string memory shema) + // Selector: setOffchainSchema(address,string) 2c9d9d70 + function setOffchainSchema(address collectionAddress, string memory shema) external view; --- a/tests/src/eth/collectionAbi.json +++ b/tests/src/eth/collectionAbi.json @@ -60,7 +60,7 @@ }, { "internalType": "string", "name": "shema", "type": "string" } ], - "name": "setOffchainShema", + "name": "setOffchainSchema", "outputs": [], "stateMutability": "view", "type": "function" --- a/tests/src/eth/createCollection.test.ts +++ b/tests/src/eth/createCollection.test.ts @@ -79,15 +79,15 @@ expect(collection.sponsorship.asConfirmed.toHuman()).to.be.eq(evmToAddress(sponsor)); }); - itWeb3('Set offchain shema', async ({api, web3}) => { + itWeb3('Set offchain schema', async ({api, web3}) => { const owner = await createEthAccountWithBalance(api, web3); const helper = collectionHelper(web3, owner); - let result = await helper.methods.create721Collection('Shema collection', '2', '2').send(); + let result = await helper.methods.create721Collection('Schema collection', '2', '2').send(); const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result); - const shema = 'Some shema'; - result = await helper.methods.setOffchainShema(collectionIdAddress, shema).send(); + const schema = 'Some schema'; + result = await helper.methods.setOffchainSchema(collectionIdAddress, schema).send(); const collection = (await getDetailedCollectionInfo(api, collectionId))!; - expect(collection.offchainSchema.toHuman()).to.be.eq(shema); + expect(collection.offchainSchema.toHuman()).to.be.eq(schema); }); itWeb3('Set variable on chain schema', async ({api, web3}) => { @@ -106,10 +106,10 @@ const helper = collectionHelper(web3, owner); let result = await helper.methods.create721Collection('Const collection', '4', '4').send(); const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result); - const constShema = 'Some const'; - result = await helper.methods.setConstOnChainSchema(collectionIdAddress, constShema).send(); + const constSchema = 'Some const'; + result = await helper.methods.setConstOnChainSchema(collectionIdAddress, constSchema).send(); const collection = (await getDetailedCollectionInfo(api, collectionId))!; - expect(collection.constOnChainSchema.toHuman()).to.be.eq(constShema); + expect(collection.constOnChainSchema.toHuman()).to.be.eq(constSchema); }); itWeb3('Set limits', async ({api, web3}) => { @@ -178,7 +178,7 @@ expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI'); // TODO: this wont work right now, need release 919000 first - // await helper.methods.setOffchainShema(collectionIdAddress, 'https://offchain-service.local/token-info/{id}').send(); + // await helper.methods.setOffchainSchema(collectionIdAddress, 'https://offchain-service.local/token-info/{id}').send(); // const tokenUri = await contract.methods.tokenURI(nextTokenId).call(); // expect(tokenUri).to.be.equal(`https://offchain-service.local/token-info/${nextTokenId}`); }); @@ -248,9 +248,9 @@ .call()).to.be.rejectedWith(EXPECTED_ERROR); } { - const shema = 'Some shema'; + const schema = 'Some schema'; await expect(helper.methods - .setOffchainShema(collectionAddressWithBadPrefix, shema) + .setOffchainSchema(collectionAddressWithBadPrefix, schema) .call()).to.be.rejectedWith(EXPECTED_ERROR); } { @@ -293,9 +293,9 @@ .call()).to.be.rejectedWith('Caller is not set as sponsor'); } { - const shema = 'Some shema'; + const schema = 'Some schema'; await expect(helperFromNotOwner.methods - .setOffchainShema(collectionIdAddress, shema) + .setOffchainSchema(collectionIdAddress, schema) .call()).to.be.rejectedWith(EXPECTED_ERROR); } { @@ -318,22 +318,22 @@ } }); - itWeb3('(!negative test!) Set offchain shema (length limit)', async ({api, web3}) => { + itWeb3('(!negative test!) Set offchain schema (length limit)', async ({api, web3}) => { const owner = await createEthAccountWithBalance(api, web3); const helper = collectionHelper(web3, owner); - const result = await helper.methods.create721Collection('Shema collection', 'A', 'A').send(); + const result = await helper.methods.create721Collection('Schema collection', 'A', 'A').send(); const {collectionIdAddress} = await getCollectionAddressFromResult(api, result); const OFFCHAIN_SCHEMA_LIMIT = 8192; - const shema = 'A'.repeat(OFFCHAIN_SCHEMA_LIMIT + 1); + const schema = 'A'.repeat(OFFCHAIN_SCHEMA_LIMIT + 1); await expect(helper.methods - .setOffchainShema(collectionIdAddress, shema) - .call()).to.be.rejectedWith('shema is too long. Max length is ' + OFFCHAIN_SCHEMA_LIMIT); + .setOffchainSchema(collectionIdAddress, schema) + .call()).to.be.rejectedWith('schema is too long. Max length is ' + OFFCHAIN_SCHEMA_LIMIT); }); itWeb3('(!negative test!) Set variable on chain schema (length limit)', async ({api, web3}) => { const owner = await createEthAccountWithBalance(api, web3); const helper = collectionHelper(web3, owner); - const result = await helper.methods.create721Collection('Shema collection', 'A', 'A').send(); + const result = await helper.methods.create721Collection('Schema collection', 'A', 'A').send(); const {collectionIdAddress} = await getCollectionAddressFromResult(api, result); const VARIABLE_ON_CHAIN_SCHEMA_LIMIT = 8192; const variable = 'A'.repeat(VARIABLE_ON_CHAIN_SCHEMA_LIMIT + 1); @@ -345,7 +345,7 @@ itWeb3('(!negative test!) Set const on chain schema (length limit)', async ({api, web3}) => { const owner = await createEthAccountWithBalance(api, web3); const helper = collectionHelper(web3, owner); - const result = await helper.methods.create721Collection('Shema collection', 'A', 'A').send(); + const result = await helper.methods.create721Collection('Schema collection', 'A', 'A').send(); const {collectionIdAddress} = await getCollectionAddressFromResult(api, result); const CONST_ON_CHAIN_SCHEMA_LIMIT = 32768; const constData = 'A'.repeat(CONST_ON_CHAIN_SCHEMA_LIMIT + 1); @@ -357,7 +357,7 @@ itWeb3('(!negative test!) Set limits', async ({api, web3}) => { const owner = await createEthAccountWithBalance(api, web3); const helper = collectionHelper(web3, owner); - const result = await helper.methods.create721Collection('Shema collection', 'A', 'A').send(); + const result = await helper.methods.create721Collection('Schema collection', 'A', 'A').send(); const {collectionIdAddress} = await getCollectionAddressFromResult(api, result); const badJson = '{accountTokenOwnershipLimit: 1000}'; await expect(helper.methods -- gitstuff