difftreelog
CORE-302 Fix shema => schema
in: master
6 files changed
pallets/evm-collection/src/eth.rsdiffbeforeafterboth--- 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<void> {
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::<T>)?;
Ok(())
}
pallets/evm-collection/src/stubs/Collection.rawdiffbeforeafterbothbinary blob — no preview
pallets/evm-collection/src/stubs/Collection.soldiffbeforeafterboth--- 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
{
tests/src/eth/api/Collection.soldiffbeforeafterboth--- 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;
tests/src/eth/collectionAbi.jsondiffbeforeafterboth--- 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"
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