1234567891011121314151617import {ApiPromise} from '@polkadot/api';18import {IKeyringPair} from '@polkadot/types/types';19import chai from 'chai';20import chaiAsPromised from 'chai-as-promised';21import privateKey from './substrate/privateKey';22import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync, executeTransaction} from './substrate/substrate-api';23import {24 createCollectionExpectSuccess,25 destroyCollectionExpectSuccess,26 getGenericResult,27 normalizeAccountId,28 setCollectionLimitsExpectSuccess,29 addCollectionAdminExpectSuccess,30 getBalance,31 getTokenOwner,32 getLastTokenId,33 getConstMetadata,34 getCreatedCollectionCount,35 createCollectionWithPropsExpectSuccess,36 getCreateItemsResult,37} from './util/helpers';3839chai.use(chaiAsPromised);40const expect = chai.expect;4142describe('Integration Test createMultipleItems(collection_id, owner, items_data):', () => {43 it('Create 0x31, 0x32, 0x33 items in active NFT collection and verify tokens data in chain', async () => {44 await usingApi(async (api: ApiPromise) => {45 const collectionId = await createCollectionExpectSuccess();46 const itemsListIndexBefore = await getLastTokenId(api, collectionId);47 expect(itemsListIndexBefore).to.be.equal(0);48 const alice = privateKey('//Alice');49 const args = [{Nft: {const_data: '0x31'}},50 {Nft: {const_data: '0x32'}},51 {Nft: {const_data: '0x33'}}];52 const createMultipleItemsTx = api.tx.unique53 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);54 await submitTransactionAsync(alice, createMultipleItemsTx);55 const itemsListIndexAfter = await getLastTokenId(api, collectionId);56 expect(itemsListIndexAfter).to.be.equal(3);5758 expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(alice.address));59 expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));60 expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));6162 expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);63 expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);64 expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);65 });66 });6768 it('Create 0x01, 0x02, 0x03 items in active Fungible collection and verify tokens data in chain', async () => {69 await usingApi(async (api: ApiPromise) => {70 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});71 const itemsListIndexBefore = await getLastTokenId(api, collectionId);72 expect(itemsListIndexBefore).to.be.equal(0);73 const alice = privateKey('//Alice');74 const args = [75 {Fungible: {value: 1}},76 {Fungible: {value: 2}},77 {Fungible: {value: 3}},78 ];79 const createMultipleItemsTx = api.tx.unique80 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);81 await submitTransactionAsync(alice, createMultipleItemsTx);82 const token1Data = await getBalance(api, collectionId, alice.address, 0);8384 expect(token1Data).to.be.equal(6n); 85 });86 });8788 it('Create 0x31, 0x32, 0x33 items in active ReFungible collection and verify tokens data in chain', async () => {89 await usingApi(async (api: ApiPromise) => {90 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});91 const itemsListIndexBefore = await getLastTokenId(api, collectionId);92 expect(itemsListIndexBefore).to.be.equal(0);93 const alice = privateKey('//Alice');94 const args = [95 {ReFungible: {const_data: [0x31], pieces: 1}},96 {ReFungible: {const_data: [0x32], pieces: 1}},97 {ReFungible: {const_data: [0x33], pieces: 1}},98 ];99 const createMultipleItemsTx = api.tx.unique100 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);101 await submitTransactionAsync(alice, createMultipleItemsTx);102 const itemsListIndexAfter = await getLastTokenId(api, collectionId);103 expect(itemsListIndexAfter).to.be.equal(3);104105 expect(await getBalance(api, collectionId, alice.address, 1)).to.be.equal(1n);106 expect(await getBalance(api, collectionId, alice.address, 2)).to.be.equal(1n);107 expect(await getBalance(api, collectionId, alice.address, 3)).to.be.equal(1n);108109 expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);110 expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);111 expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);112 });113 });114115 it('Can mint amount of items equals to collection limits', async () => {116 await usingApi(async (api) => {117 const alice = privateKey('//Alice');118119 const collectionId = await createCollectionExpectSuccess();120 await setCollectionLimitsExpectSuccess(alice, collectionId, {121 tokenLimit: 2,122 });123 const args = [124 {NFT: {const_data: 'A'}},125 {NFT: {const_data: 'B'}},126 ];127 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);128 const events = await submitTransactionAsync(alice, createMultipleItemsTx);129 const result = getGenericResult(events);130 expect(result.success).to.be.true;131 });132 });133134 it('Create 0x31, 0x32, 0x33 items in active NFT with property Admin', async () => {135 await usingApi(async (api: ApiPromise) => {136 const collectionId = await createCollectionExpectSuccess();137 const itemsListIndexBefore = await getLastTokenId(api, collectionId);138 expect(itemsListIndexBefore).to.be.equal(0);139 const alice = privateKey('//Alice');140 const bob = privateKey('//Bob');141 const args = [{Nft: {const_data: '0x31'}},142 {Nft: {const_data: '0x32'}},143 {Nft: {const_data: '0x33'}}];144 const createMultipleItemsTx = api.tx.unique145 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);146 await submitTransactionAsync(alice, createMultipleItemsTx);147 const itemsListIndexAfter = await getLastTokenId(api, collectionId);148 expect(itemsListIndexAfter).to.be.equal(3);149150 await expect(executeTransaction(151 api,152 alice,153 api.tx.unique.setPropertyPermissions(collectionId, [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]),154 )).to.not.be.rejected;155156 expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(alice.address));157 expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));158 expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));159160 expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);161 expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);162 expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);163 });164 });165166 it('Create 0x31, 0x32, 0x33 items in active NFT with property AdminConst', async () => {167 await usingApi(async (api: ApiPromise) => {168 const collectionId = await createCollectionExpectSuccess();169 const itemsListIndexBefore = await getLastTokenId(api, collectionId);170 expect(itemsListIndexBefore).to.be.equal(0);171 const alice = privateKey('//Alice');172 const bob = privateKey('//Bob');173 const args = [{Nft: {const_data: '0x31'}},174 {Nft: {const_data: '0x32'}},175 {Nft: {const_data: '0x33'}}];176 const createMultipleItemsTx = api.tx.unique177 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);178 await submitTransactionAsync(alice, createMultipleItemsTx);179 const itemsListIndexAfter = await getLastTokenId(api, collectionId);180 expect(itemsListIndexAfter).to.be.equal(3);181182 await expect(executeTransaction(183 api,184 alice,185 api.tx.unique.setPropertyPermissions(collectionId, [{key: 'k', permission: {mutable: false, collectionAdmin: true, tokenOwner: false}}]),186 )).to.not.be.rejected;187188 expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(alice.address));189 expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));190 expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));191192 expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);193 expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);194 expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);195 });196 });197198 it('Create 0x31, 0x32, 0x33 items in active NFT with property itemOwnerOrAdmin', async () => {199 await usingApi(async (api: ApiPromise) => {200 const collectionId = await createCollectionExpectSuccess();201 const itemsListIndexBefore = await getLastTokenId(api, collectionId);202 expect(itemsListIndexBefore).to.be.equal(0);203 const alice = privateKey('//Alice');204 const bob = privateKey('//Bob');205 const args = [{Nft: {const_data: '0x31'}},206 {Nft: {const_data: '0x32'}},207 {Nft: {const_data: '0x33'}}];208 const createMultipleItemsTx = api.tx.unique209 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);210 await submitTransactionAsync(alice, createMultipleItemsTx);211 const itemsListIndexAfter = await getLastTokenId(api, collectionId);212 expect(itemsListIndexAfter).to.be.equal(3);213214 await expect(executeTransaction(215 api,216 alice,217 api.tx.unique.setPropertyPermissions(collectionId, [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]),218 )).to.not.be.rejected;219220 expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(alice.address));221 expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));222 expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));223224 expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);225 expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);226 expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);227 });228 });229});230231describe('Integration Test createMultipleItems(collection_id, owner, items_data) with collection admin permissions:', () => {232233 let alice: IKeyringPair;234 let bob: IKeyringPair;235236 before(async () => {237 await usingApi(async () => {238 alice = privateKey('//Alice');239 bob = privateKey('//Bob');240 });241 });242243 it('Create 0x31, 0x32, 0x33 items in active NFT collection and verify tokens data in chain', async () => {244 await usingApi(async (api: ApiPromise) => {245 const collectionId = await createCollectionExpectSuccess();246 const itemsListIndexBefore = await getLastTokenId(api, collectionId);247 expect(itemsListIndexBefore).to.be.equal(0);248 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);249 const args = [{Nft: {const_data: '0x31'}},250 {Nft: {const_data: '0x32'}},251 {Nft: {const_data: '0x33'}}];252 const createMultipleItemsTx = api.tx.unique253 .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);254 await submitTransactionAsync(bob, createMultipleItemsTx);255 const itemsListIndexAfter = await getLastTokenId(api, collectionId);256 expect(itemsListIndexAfter).to.be.equal(3);257258 expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(bob.address));259 expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(bob.address));260 expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(bob.address));261262 expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);263 expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);264 expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);265 });266 });267268 it('Create 0x01, 0x02, 0x03 items in active Fungible collection and verify tokens data in chain', async () => {269 await usingApi(async (api: ApiPromise) => {270 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});271 const itemsListIndexBefore = await getLastTokenId(api, collectionId);272 expect(itemsListIndexBefore).to.be.equal(0);273 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);274 const args = [275 {Fungible: {value: 1}},276 {Fungible: {value: 2}},277 {Fungible: {value: 3}},278 ];279 const createMultipleItemsTx = api.tx.unique280 .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);281 await submitTransactionAsync(bob, createMultipleItemsTx);282 const token1Data = await getBalance(api, collectionId, bob.address, 0);283284 expect(token1Data).to.be.equal(6n); 285 });286 });287288 it('Create 0x31, 0x32, 0x33 items in active ReFungible collection and verify tokens data in chain', async () => {289 await usingApi(async (api: ApiPromise) => {290 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});291 const itemsListIndexBefore = await getLastTokenId(api, collectionId);292 expect(itemsListIndexBefore).to.be.equal(0);293 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);294 const args = [295 {ReFungible: {const_data: [0x31], pieces: 1}},296 {ReFungible: {const_data: [0x32], pieces: 1}},297 {ReFungible: {const_data: [0x33], pieces: 1}},298 ];299 const createMultipleItemsTx = api.tx.unique300 .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);301 await submitTransactionAsync(bob, createMultipleItemsTx);302 const itemsListIndexAfter = await getLastTokenId(api, collectionId);303 expect(itemsListIndexAfter).to.be.equal(3);304305 expect(await getBalance(api, collectionId, bob.address, 1)).to.be.equal(1n);306 expect(await getBalance(api, collectionId, bob.address, 2)).to.be.equal(1n);307 expect(await getBalance(api, collectionId, bob.address, 3)).to.be.equal(1n);308309 expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);310 expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);311 expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);312 });313 });314});315316describe('Negative Integration Test createMultipleItems(collection_id, owner, items_data):', () => {317318 let alice: IKeyringPair;319 let bob: IKeyringPair;320321 before(async () => {322 await usingApi(async () => {323 alice = privateKey('//Alice');324 bob = privateKey('//Bob');325 });326 });327328 it('Regular user cannot create items in active NFT collection', async () => {329 await usingApi(async (api: ApiPromise) => {330 const collectionId = await createCollectionExpectSuccess();331 const itemsListIndexBefore = await getLastTokenId(api, collectionId);332 expect(itemsListIndexBefore).to.be.equal(0);333 const args = [{Nft: {const_data: '0x31'}},334 {Nft: {const_data: '0x32'}},335 {Nft: {const_data: '0x33'}}];336 const createMultipleItemsTx = api.tx.unique337 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);338 await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;339 });340 });341342 it('Regular user cannot create items in active Fungible collection', async () => {343 await usingApi(async (api: ApiPromise) => {344 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});345 const itemsListIndexBefore = await getLastTokenId(api, collectionId);346 expect(itemsListIndexBefore).to.be.equal(0);347 const args = [348 {Fungible: {value: 1}},349 {Fungible: {value: 2}},350 {Fungible: {value: 3}},351 ];352 const createMultipleItemsTx = api.tx.unique353 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);354 await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;355 });356 });357358 it('Regular user cannot create items in active ReFungible collection', async () => {359 await usingApi(async (api: ApiPromise) => {360 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});361 const itemsListIndexBefore = await getLastTokenId(api, collectionId);362 expect(itemsListIndexBefore).to.be.equal(0);363 const args = [364 {ReFungible: {const_data: [0x31], pieces: 1}},365 {ReFungible: {const_data: [0x32], pieces: 1}},366 {ReFungible: {const_data: [0x33], pieces: 1}},367 ];368 const createMultipleItemsTx = api.tx.unique369 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);370 await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;371 });372 });373374 it('Create token in not existing collection', async () => {375 await usingApi(async (api: ApiPromise) => {376 const collectionId = await getCreatedCollectionCount(api) + 1;377 const createMultipleItemsTx = api.tx.unique378 .createMultipleItems(collectionId, normalizeAccountId(alice.address), ['NFT', 'NFT', 'NFT']);379 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;380 });381 });382383 it('Create NFT and Re-fungible tokens that has reached the maximum data limit', async () => {384 await usingApi(async (api: ApiPromise) => {385 386 const collectionId = await createCollectionExpectSuccess();387 const alice = privateKey('//Alice');388 const args = [389 {NFT: {const_data: 'A'.repeat(2049)}},390 {NFT: {const_data: 'B'.repeat(2049)}},391 {NFT: {const_data: 'C'.repeat(2049)}},392 ];393 const createMultipleItemsTx = api.tx.unique394 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);395 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;396397 398 const collectionIdReFungible =399 await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});400 const argsReFungible = [401 {ReFungible: ['1'.repeat(2049), 10]},402 {ReFungible: ['2'.repeat(2049), 10]},403 {ReFungible: ['3'.repeat(2049), 10]},404 ];405 const createMultipleItemsTxFungible = api.tx.unique406 .createMultipleItems(collectionIdReFungible, normalizeAccountId(alice.address), argsReFungible);407 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTxFungible)).to.be.rejected;408 });409 });410411 it('Create tokens with different types', async () => {412 await usingApi(async (api: ApiPromise) => {413 const collectionId = await createCollectionExpectSuccess();414 const createMultipleItemsTx = api.tx.unique415 .createMultipleItems(collectionId, normalizeAccountId(alice.address), ['NFT', 'Fungible', 'ReFungible']);416 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;417 418 await destroyCollectionExpectSuccess(collectionId);419 });420 });421422 it('Create tokens with different data limits <> maximum data limit', async () => {423 await usingApi(async (api: ApiPromise) => {424 const collectionId = await createCollectionExpectSuccess();425 const args = [426 {NFT: {const_data: 'A'}},427 {NFT: {const_data: 'B'.repeat(2049)}},428 ];429 const createMultipleItemsTx = await api.tx.unique430 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);431 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;432 });433 });434435 it('Fails when minting tokens exceeds collectionLimits amount', async () => {436 await usingApi(async (api) => {437438 const collectionId = await createCollectionExpectSuccess();439 await setCollectionLimitsExpectSuccess(alice, collectionId, {440 tokenLimit: 1,441 });442 const args = [443 {NFT: {const_data: 'A'}},444 {NFT: {const_data: 'B'}},445 ];446 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);447 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;448 });449 });450451 it('No editing rights', async () => {452 await usingApi(async (api: ApiPromise) => {453 const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],454 propPerm: [{key: 'key1', mutable: true, collectionAdmin: false, tokenOwner: false}]});455 const itemsListIndexBefore = await getLastTokenId(api, collectionId);456 expect(itemsListIndexBefore).to.be.equal(0);457 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);458 const args = [{Nft: {const_data: '0x31'}},459 {Nft: {const_data: '0x32'}},460 {Nft: {const_data: '0x33'}}];461462 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);463464 const events = await submitTransactionAsync(alice, createMultipleItemsTx);465 const result = getCreateItemsResult(events);466467 for (const elem of result) {468 await expect(executeTransaction(469 api,470 bob,471 api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]),472 )).to.be.rejected;473 }474475 476 });477 });478479 it('User doesnt have editing rights', async () => {480 await usingApi(async (api: ApiPromise) => {481 const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],482 propPerm: [{key: 'key1', mutable: false, collectionAdmin: false, tokenOwner: false}]});483 const itemsListIndexBefore = await getLastTokenId(api, collectionId);484 expect(itemsListIndexBefore).to.be.equal(0);485 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);486 const args = [{Nft: {const_data: '0x31'}},487 {Nft: {const_data: '0x32'}},488 {Nft: {const_data: '0x33'}}];489490 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);491492 const events = await submitTransactionAsync(alice, createMultipleItemsTx);493 const result = getCreateItemsResult(events);494495 for (const elem of result) {496 await expect(executeTransaction(497 api,498 bob,499 api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]),500 )).to.be.rejected;501 }502 });503 });504505 it('Adding property without access rights', async () => {506 await usingApi(async (api: ApiPromise) => {507 const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}]});508 const itemsListIndexBefore = await getLastTokenId(api, collectionId);509 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);510 expect(itemsListIndexBefore).to.be.equal(0);511 const args = [{Nft: {const_data: '0x31'}},512 {Nft: {const_data: '0x32'}},513 {Nft: {const_data: '0x33'}}];514515 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);516517 const events = await submitTransactionAsync(alice, createMultipleItemsTx);518 const result = getCreateItemsResult(events);519520 for (const elem of result) {521 await expect(executeTransaction(522 api,523 bob,524 api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]),525 )).to.be.rejected;526 }527 });528 });529530 it('Adding more than 64 prps', async () => {531 await usingApi(async (api: ApiPromise) => {532 const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],533 propPerm: [{key: 'key1', mutable: true, collectionAdmin: true, tokenOwner: false}]});534 const itemsListIndexBefore = await getLastTokenId(api, collectionId);535 expect(itemsListIndexBefore).to.be.equal(0);536 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);537538 const args = [{Nft: {const_data: '0x31'}},539 {Nft: {const_data: '0x32'}},540 {Nft: {const_data: '0x33'}}];541542 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);543 const events = await submitTransactionAsync(alice, createMultipleItemsTx);544545 const result = getCreateItemsResult(events);546547 const prps = [];548549 for (let i = 0; i < 65; i++) {550 prps.push({key: `key${i}`, value: `value${i}`});551 }552553 await expect(executeTransaction(api, bob, api.tx.unique.setCollectionProperties(collectionId, prps))).to.be.rejectedWith(/common\.PropertyLimitReached/);554555 for (const elem of result) {556 await expect(executeTransaction(557 api,558 bob,559 api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, prps),560 )).to.be.rejected;561 }562 });563 });564565 it('Trying to add bigger property than allowed', async () => {566 await usingApi(async (api: ApiPromise) => {567 const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],568 propPerm: [{key: 'key1', mutable: true, collectionAdmin: false, tokenOwner: false}]});569 const itemsListIndexBefore = await getLastTokenId(api, collectionId);570 expect(itemsListIndexBefore).to.be.equal(0);571 const args = [{Nft: {const_data: '0x31'}},572 {Nft: {const_data: '0x32'}},573 {Nft: {const_data: '0x33'}}];574575 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);576577 const events = await submitTransactionAsync(alice, createMultipleItemsTx);578 const result = getCreateItemsResult(events);579580581 await expect(executeTransaction(api, alice, api.tx.unique.setCollectionProperties(collectionId, [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]))).to.be.rejectedWith(/common\.NoSpaceForProperty/);582583 for (const elem of result) {584 await expect(executeTransaction(585 api,586 bob,587 api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]),588 )).to.be.rejected;589 }590 });591 });592});