difftreelog
fix misprints
in: master
3 files changed
pallets/nonfungible/src/erc.rsdiffbeforeafterboth36 SelfWeightOf, weights::WeightInfo,36 SelfWeightOf, weights::WeightInfo,37};37};383839fn error_unsupported_shema_version() -> Error {39fn error_unsupported_schema_version() -> Error {40 alloc::format!(40 alloc::format!(41 "Unsupported shema version! Support only {:?}",41 "Unsupported schema version! Support only {:?}",42 SchemaVersion::ImageURL42 SchemaVersion::ImageURL43 )43 )44 .as_str()44 .as_str()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 !matches!(self.schema_version, SchemaVersion::ImageURL) {97 if !matches!(self.schema_version, SchemaVersion::ImageURL) {98 return Err(error_unsupported_shema_version());98 return Err(error_unsupported_schema_version());99 }99 }100100101 self.consume_store_reads(1)?;101 self.consume_store_reads(1)?;286 token_uri: string,286 token_uri: string,287 ) -> Result<bool> {287 ) -> Result<bool> {288 if !matches!(self.schema_version, SchemaVersion::ImageURL) {288 if !matches!(self.schema_version, SchemaVersion::ImageURL) {289 return Err(error_unsupported_shema_version());289 return Err(error_unsupported_schema_version());290 }290 }291291292 let caller = T::CrossAccountId::from_eth(caller);292 let caller = T::CrossAccountId::from_eth(caller);431 tokens: Vec<(uint256, string)>,431 tokens: Vec<(uint256, string)>,432 ) -> Result<bool> {432 ) -> Result<bool> {433 if !matches!(self.schema_version, SchemaVersion::ImageURL) {433 if !matches!(self.schema_version, SchemaVersion::ImageURL) {434 return Err(error_unsupported_shema_version());434 return Err(error_unsupported_schema_version());435 }435 }436436437 let caller = T::CrossAccountId::from_eth(caller);437 let caller = T::CrossAccountId::from_eth(caller);tests/src/eth/metadata.test.tsdiffbeforeafterboth68});68});696970describe('Support ERC721Metadata', () => {70describe('Support ERC721Metadata', () => {71 itWeb3('Check unsupport ERC721Metadata ShemaVersion::Unique', async ({web3, api}) => {71 itWeb3('Check unsupport ERC721Metadata SchemaVersion::Unique', async ({web3, api}) => {72 const collectionId = await createCollectionExpectSuccess({72 const collectionId = await createCollectionExpectSuccess({73 mode: {type: 'NFT'},73 mode: {type: 'NFT'},74 shemaVersion: 'Unique',74 schemaVersion: 'Unique',75 name: 'some_name',75 name: 'some_name',76 tokenPrefix: 'some_prefix',76 tokenPrefix: 'some_prefix',77 });77 });98 receiver,98 receiver,99 nextTokenId,99 nextTokenId,100 'Test URI',100 'Test URI',101 ).call({from: caller})).to.be.rejectedWith('Unsupported shema version! Support only ImageURL');101 ).call({from: caller})).to.be.rejectedWith('Unsupported schema version! Support only ImageURL');102102103 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 ).call({from: caller})).to.be.rejectedWith('Unsupported shema version! Support only ImageURL');110 ).call({from: caller})).to.be.rejectedWith('Unsupported schema version! Support only ImageURL');111 });111 });112112113 itWeb3('Check support ERC721Metadata for ShemaVersion::ImageURL', async ({web3, api}) => {113 itWeb3('Check support ERC721Metadata for SchemaVersion::ImageURL', async ({web3, api}) => {114 const collectionId = await createCollectionExpectSuccess({114 const collectionId = await createCollectionExpectSuccess({115 mode: {type: 'NFT'},115 mode: {type: 'NFT'},116 name: 'some_name',116 name: 'some_name',tests/src/setConstOnChainSchema.test.tsdiffbeforeafterboth323233let alice: IKeyringPair;33let alice: IKeyringPair;34let bob: IKeyringPair;34let bob: IKeyringPair;35let shema: any;35let schema: any;36let largeShema: any;36let largeSchema: any;373738before(async () => {38before(async () => {39 await usingApi(async () => {39 await usingApi(async () => {40 const keyring = new Keyring({type: 'sr25519'});40 const keyring = new Keyring({type: 'sr25519'});41 alice = keyring.addFromUri('//Alice');41 alice = keyring.addFromUri('//Alice');42 bob = keyring.addFromUri('//Bob');42 bob = keyring.addFromUri('//Bob');43 shema = '0x31';43 schema = '0x31';44 largeShema = new Array(1024 * 1024 + 10).fill(0xff);44 largeSchema = new Array(1024 * 1024 + 10).fill(0xff);45 });45 });46});46});47describe('Integration Test ext. setConstOnChainSchema()', () => {47describe('Integration Test ext. setConstOnChainSchema()', () => {51 const collectionId = await createCollectionExpectSuccess();51 const collectionId = await createCollectionExpectSuccess();52 const collection = await queryCollectionExpectSuccess(api, collectionId);52 const collection = await queryCollectionExpectSuccess(api, collectionId);53 expect(collection.owner.toString()).to.be.eq(alice.address);53 expect(collection.owner.toString()).to.be.eq(alice.address);54 const setShema = api.tx.unique.setConstOnChainSchema(collectionId, shema);54 const setSchema = api.tx.unique.setConstOnChainSchema(collectionId, schema);55 await submitTransactionAsync(alice, setShema);55 await submitTransactionAsync(alice, setSchema);56 });56 });57 });57 });585862 const collection = await queryCollectionExpectSuccess(api, collectionId);62 const collection = await queryCollectionExpectSuccess(api, collectionId);63 expect(collection.owner.toString()).to.be.eq(alice.address);63 expect(collection.owner.toString()).to.be.eq(alice.address);64 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);64 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);65 const setShema = api.tx.unique.setConstOnChainSchema(collectionId, shema);65 const setSchema = api.tx.unique.setConstOnChainSchema(collectionId, schema);66 await submitTransactionAsync(bob, setShema);66 await submitTransactionAsync(bob, setSchema);67 });67 });68 });68 });696970 it('Checking collection data using the ConstOnChainSchema parameter', async () => {70 it('Checking collection data using the ConstOnChainSchema parameter', async () => {71 await usingApi(async (api) => {71 await usingApi(async (api) => {72 const collectionId = await createCollectionExpectSuccess();72 const collectionId = await createCollectionExpectSuccess();73 const setShema = api.tx.unique.setConstOnChainSchema(collectionId, shema);73 const setSchema = api.tx.unique.setConstOnChainSchema(collectionId, schema);74 await submitTransactionAsync(alice, setShema);74 await submitTransactionAsync(alice, setSchema);75 const collection = await queryCollectionExpectSuccess(api, collectionId);75 const collection = await queryCollectionExpectSuccess(api, collectionId);76 expect(collection.constOnChainSchema.toString()).to.be.eq(shema);76 expect(collection.constOnChainSchema.toString()).to.be.eq(schema);77 });77 });78 });78 });79});79});84 await usingApi(async (api) => {84 await usingApi(async (api) => {85 // tslint:disable-next-line: radix85 // tslint:disable-next-line: radix86 const collectionId = await getCreatedCollectionCount(api) + 1;86 const collectionId = await getCreatedCollectionCount(api) + 1;87 const setShema = api.tx.unique.setConstOnChainSchema(collectionId, shema);87 const setSchema = api.tx.unique.setConstOnChainSchema(collectionId, schema);88 await expect(submitTransactionExpectFailAsync(alice, setShema)).to.be.rejected;88 await expect(submitTransactionExpectFailAsync(alice, setSchema)).to.be.rejected;89 });89 });90 });90 });919192 it('Set a previously deleted collection', async () => {92 it('Set a previously deleted collection', async () => {93 await usingApi(async (api) => {93 await usingApi(async (api) => {94 const collectionId = await createCollectionExpectSuccess();94 const collectionId = await createCollectionExpectSuccess();95 await destroyCollectionExpectSuccess(collectionId);95 await destroyCollectionExpectSuccess(collectionId);96 const setShema = api.tx.unique.setConstOnChainSchema(collectionId, shema);96 const setSchema = api.tx.unique.setConstOnChainSchema(collectionId, schema);97 await expect(submitTransactionExpectFailAsync(alice, setShema)).to.be.rejected;97 await expect(submitTransactionExpectFailAsync(alice, setSchema)).to.be.rejected;98 });98 });99 });99 });100100101 it('Set invalid data in schema (size too large:> 1MB)', async () => {101 it('Set invalid data in schema (size too large:> 1MB)', async () => {102 await usingApi(async (api) => {102 await usingApi(async (api) => {103 const collectionId = await createCollectionExpectSuccess();103 const collectionId = await createCollectionExpectSuccess();104 const setShema = api.tx.unique.setConstOnChainSchema(collectionId, largeShema);104 const setSchema = api.tx.unique.setConstOnChainSchema(collectionId, largeSchema);105 await expect(submitTransactionExpectFailAsync(alice, setShema)).to.be.rejected;105 await expect(submitTransactionExpectFailAsync(alice, setSchema)).to.be.rejected;106 });106 });107 });107 });108108111 const collectionId = await createCollectionExpectSuccess();111 const collectionId = await createCollectionExpectSuccess();112 const collection = await queryCollectionExpectSuccess(api, collectionId);112 const collection = await queryCollectionExpectSuccess(api, collectionId);113 expect(collection.owner.toString()).to.be.eq(alice.address);113 expect(collection.owner.toString()).to.be.eq(alice.address);114 const setShema = api.tx.unique.setConstOnChainSchema(collectionId, shema);114 const setSchema = api.tx.unique.setConstOnChainSchema(collectionId, schema);115 await expect(submitTransactionExpectFailAsync(bob, setShema)).to.be.rejected;115 await expect(submitTransactionExpectFailAsync(bob, setSchema)).to.be.rejected;116 });116 });117 });117 });118118