difftreelog
fix properties have been moved in creation functions
in: master
5 files changed
tests/src/createItem.test.tsdiffbeforeafterboth24 addCollectionAdminExpectSuccess,24 addCollectionAdminExpectSuccess,25 createCollectionWithPropsExpectSuccess,25 createCollectionWithPropsExpectSuccess,26 createItemWithPropsExpectSuccess,26 createItemWithPropsExpectSuccess,27 createItemWithPropsExpectFailure,27} from './util/helpers';28} from './util/helpers';282929const expect = chai.expect;30const expect = chai.expect;129 const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode}, 130 const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode}, 130 propPerm: [{key: 'key1', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}]});131 propPerm: [{key: 'key1', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}]});131132 const token = await createItemExpectSuccess(alice, newCollectionID, 'NFT');133 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);132 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);134133135 await expect(executeTransaction(134 await createItemWithPropsExpectFailure(bob, newCollectionID, 'NFT', [{key: 'key1', value: 'v'}]);136 api, 137 alice, 138 api.tx.unique.setTokenProperties(newCollectionID, token, [{key: 'key1', value: 'v2'}]), 139 )).to.be.rejected;140 });135 });141 });136 });142137143 it('User doesnt have editing rights', async () => {138 it('User doesnt have editing rights', async () => {144 await usingApi(async api => {139 await usingApi(async api => {145 const newCollectionID = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});140 const newCollectionID = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});146 const token = await createItemExpectSuccess(alice, newCollectionID, 'NFT');147148 await expect(executeTransaction(141 await createItemWithPropsExpectFailure(bob, newCollectionID, 'NFT', [{key: 'key1', value: 'v'}]);149 api, 150 bob, 151 api.tx.unique.setTokenProperties(newCollectionID, token, [{key: 'key1', value: 'v2'}]), 152 )).to.be.rejected;153 });142 });154 });143 });155144156 it('Adding property without access rights', async () => {145 it('Adding property without access rights', async () => {157 await usingApi(async api => {146 await usingApi(async api => {158 const createMode = 'NFT';159 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});147 const newCollectionID = await createCollectionWithPropsExpectSuccess();160161 const token = await createItemExpectSuccess(alice, newCollectionID, 'NFT');162 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);148 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);163 149164 await expect(executeTransaction(150 await createItemWithPropsExpectFailure(bob, newCollectionID, 'NFT', [{key: 'k', value: 'v'}]);165 api, 166 bob, 167 api.tx.unique.setTokenProperties(newCollectionID, token, [{key: 'key1', value: 'v2'}]), 168 )).to.be.rejected;169 });151 });170 });152 });171153172 it('Adding more than 64 prps', async () => {154 it('Adding more than 64 prps', async () => {173 await usingApi(async api => {155 await usingApi(async api => {174 const createMode = 'NFT';175176 const prps = [];156 const prps = [];177157178 for (let i = 0; i < 65; i++) {158 for (let i = 0; i < 65; i++) {179 prps.push({key: `key${i}`, value: `value${i}`});159 prps.push({key: `key${i}`, value: `value${i}`});180 }160 }181161182 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});162 const newCollectionID = await createCollectionWithPropsExpectSuccess();183 163 184 await expect(executeTransaction(api, alice, api.tx.unique.setCollectionProperties(newCollectionID, prps))).to.be.rejectedWith(/common\.PropertyLimitReached/);164 createItemWithPropsExpectFailure(alice, newCollectionID, 'NFT', prps);185 });165 });186 });166 });187167188 it('Trying to add bigger property than allowed', async () => {168 it('Trying to add bigger property than allowed', async () => {189 await usingApi(async api => {169 await usingApi(async api => {190 const createMode = 'NFT';191 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});170 const newCollectionID = await createCollectionWithPropsExpectSuccess();192 171 193 await expect(executeTransaction(api, alice, api.tx.unique.setCollectionProperties(newCollectionID, [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]))).to.be.rejectedWith(/common\.NoSpaceForProperty/);172 createItemWithPropsExpectFailure(alice, newCollectionID, 'NFT', [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]);194 });173 });195 });174 });196});175});tests/src/createMultipleItems.test.tsdiffbeforeafterboth34 getCreatedCollectionCount,34 getCreatedCollectionCount,35 createCollectionWithPropsExpectSuccess,35 createCollectionWithPropsExpectSuccess,36 getCreateItemsResult,36 getCreateItemsResult,37 createMultipleItemsWithPropsExpectSuccess37 createMultipleItemsWithPropsExpectSuccess,38 createMultipleItemsWithPropsExpectFailure,38} from './util/helpers';39} from './util/helpers';394040chai.use(chaiAsPromised);41chai.use(chaiAsPromised);432 it('No editing rights', async () => {433 it('No editing rights', async () => {433 await usingApi(async (api: ApiPromise) => {434 await usingApi(async (api: ApiPromise) => {434 const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],435 const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],435 propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});436 propPerm: [{key: 'key1', permission: {mutable: false, collectionAdmin: false, tokenOwner: true}}]});436 const itemsListIndexBefore = await getLastTokenId(api, collectionId);437 const itemsListIndexBefore = await getLastTokenId(api, collectionId);437 expect(itemsListIndexBefore).to.be.equal(0);438 expect(itemsListIndexBefore).to.be.equal(0);438 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);439 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);439 const args = [{Nft: {const_data: '0x31'}},440 const args = [{Nft: {const_data: '0x31', properties: [{key: 'key1', value: 'v2'}]}},440 {Nft: {const_data: '0x32'}},441 {Nft: {const_data: '0x32'}},441 {Nft: {const_data: '0x33'}}];442 {Nft: {const_data: '0x33'}}];442443443 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);444445 const events = await submitTransactionAsync(alice, createMultipleItemsTx);446 const result = getCreateItemsResult(events);447448 for (const elem of result) {449 await expect(executeTransaction(444 await createMultipleItemsWithPropsExpectFailure(bob, collectionId, args);450 api,451 bob,452 api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]),453 )).to.be.rejected;454 }455456 // await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;457 });445 });458 });446 });459447460 it('User doesnt have editing rights', async () => {448 it('User doesnt have editing rights', async () => {461 await usingApi(async (api: ApiPromise) => {449 await usingApi(async (api: ApiPromise) => {462 const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],450 const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],463 propPerm: [{key: 'key1', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}]});451 propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});464 const itemsListIndexBefore = await getLastTokenId(api, collectionId);452 const itemsListIndexBefore = await getLastTokenId(api, collectionId);465 expect(itemsListIndexBefore).to.be.equal(0);453 expect(itemsListIndexBefore).to.be.equal(0);466 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);454 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);467 const args = [{Nft: {const_data: '0x31'}},455 const args = [{Nft: {const_data: '0x31', properties: [{key: 'key1', value: 'v2'}]}},468 {Nft: {const_data: '0x32'}},456 {Nft: {const_data: '0x32'}},469 {Nft: {const_data: '0x33'}}];457 {Nft: {const_data: '0x33'}}];470458471 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);472473 const events = await submitTransactionAsync(alice, createMultipleItemsTx);474 const result = getCreateItemsResult(events);475476 for (const elem of result) {477 await expect(executeTransaction(459 await createMultipleItemsWithPropsExpectFailure(bob, collectionId, args);478 api,479 bob,480 api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]),481 )).to.be.rejected;482 }483 });460 });484 });461 });485462486 it('Adding property without access rights', async () => {463 it('Adding property without access rights', async () => {487 await usingApi(async (api: ApiPromise) => {464 await usingApi(async (api: ApiPromise) => {488 const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}]});465 const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'k', value: 'v1'}]});489 const itemsListIndexBefore = await getLastTokenId(api, collectionId);466 const itemsListIndexBefore = await getLastTokenId(api, collectionId);490 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);467 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);491 expect(itemsListIndexBefore).to.be.equal(0);468 expect(itemsListIndexBefore).to.be.equal(0);492 const args = [{Nft: {const_data: '0x31'}},469 const args = [{Nft: {const_data: '0x31', properties: [{key: 'k', value: 'v'}]}},493 {Nft: {const_data: '0x32'}},470 {Nft: {const_data: '0x32'}},494 {Nft: {const_data: '0x33'}}];471 {Nft: {const_data: '0x33'}}];495472496 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);497498 const events = await submitTransactionAsync(alice, createMultipleItemsTx);499 const result = getCreateItemsResult(events);500501 for (const elem of result) {502 await expect(executeTransaction(473 await createMultipleItemsWithPropsExpectFailure(bob, collectionId, args);503 api,504 bob,505 api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]),506 )).to.be.rejected;507 }508 });474 });509 });475 });510476516 expect(itemsListIndexBefore).to.be.equal(0);482 expect(itemsListIndexBefore).to.be.equal(0);517 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);483 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);518519 const args = [{Nft: {const_data: '0x31'}},520 {Nft: {const_data: '0x32'}},521 {Nft: {const_data: '0x33'}}];522523 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);524 const events = await submitTransactionAsync(alice, createMultipleItemsTx);525526 const result = getCreateItemsResult(events);527484528 const prps = [];485 const prps = [];529486530 for (let i = 0; i < 65; i++) {487 for (let i = 0; i < 65; i++) {531 prps.push({key: `key${i}`, value: `value${i}`});488 prps.push({key: `key${i}`, value: `value${i}`});532 }489 }533490534 await expect(executeTransaction(api, bob, api.tx.unique.setCollectionProperties(collectionId, prps))).to.be.rejectedWith(/common\.PropertyLimitReached/);491 const args = [{Nft: {const_data: '0x31', properties: prps}},535492 {Nft: {const_data: '0x32', properties: prps}},536 for (const elem of result) {493 {Nft: {const_data: '0x33', properties: prps}}];494537 await expect(executeTransaction(495 createMultipleItemsWithPropsExpectFailure(alice, collectionId, args);538 api,539 bob,540 api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, prps),541 )).to.be.rejected;542 }543 });496 });544 });497 });545498546 it('Trying to add bigger property than allowed', async () => {499 it('Trying to add bigger property than allowed', async () => {547 await usingApi(async (api: ApiPromise) => {500 await usingApi(async (api: ApiPromise) => {548 const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],501 const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});549 propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});550 const itemsListIndexBefore = await getLastTokenId(api, collectionId);502 const itemsListIndexBefore = await getLastTokenId(api, collectionId);551 expect(itemsListIndexBefore).to.be.equal(0);503 expect(itemsListIndexBefore).to.be.equal(0);552 const args = [{Nft: {const_data: '0x31'}},504 const args = [{Nft: {const_data: '0x31', properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]}},553 {Nft: {const_data: '0x32'}},554 {Nft: {const_data: '0x33'}}];555556 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);557558 const events = await submitTransactionAsync(alice, createMultipleItemsTx);559 const result = getCreateItemsResult(events);560561562 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/);505 {Nft: {const_data: '0x32', properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]}},563506 {Nft: {const_data: '0x33', properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]}}];564 for (const elem of result) {507565 await expect(executeTransaction(508 createMultipleItemsWithPropsExpectFailure(alice, collectionId, args);566 api,567 bob,568 api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]),569 )).to.be.rejected;570 }571 });509 });572 });510 });573});511});tests/src/createMultipleItemsEx.test.tsdiffbeforeafterboth161617import {expect} from 'chai';17import {expect} from 'chai';18import privateKey from './substrate/privateKey';18import privateKey from './substrate/privateKey';19import usingApi, {executeTransaction, submitTransactionAsync} from './substrate/substrate-api';19import usingApi, {executeTransaction, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';20import {createCollectionExpectSuccess, createCollectionWithPropsExpectSuccess, addCollectionAdminExpectSuccess, getCreateItemsResult} from './util/helpers';20import {createCollectionExpectSuccess, createCollectionWithPropsExpectSuccess, addCollectionAdminExpectSuccess, getCreateItemsResult} from './util/helpers';212122describe('createMultipleItemsEx', () => {22describe('createMultipleItemsEx', () => {48 });48 });49 });49 });505051 it.only('createMultipleItemsEx with property Admin', async () => {51 it('createMultipleItemsEx with property Admin', async () => {52 const collection = await createCollectionWithPropsExpectSuccess({mode: {type: 'NFT'}, propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]});52 const collection = await createCollectionWithPropsExpectSuccess({mode: {type: 'NFT'}, propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]});53 const alice = privateKey('//Alice');53 const alice = privateKey('//Alice');54 const bob = privateKey('//Bob');54 const bob = privateKey('//Bob');152 const data = [152 const data = [153 {153 {154 owner: {substrate: alice.address},154 owner: {substrate: alice.address},155 properties: [{key: 'key1', value: 'v2'}],155 }, {156 }, {156 owner: {substrate: bob.address},157 owner: {substrate: alice.address},158 properties: [{key: 'key1', value: 'v2'}],157 }, {159 }, {158 owner: {substrate: charlie.address},160 owner: {substrate: alice.address},161 properties: [{key: 'key1', value: 'v2'}],159 },162 },160 ];163 ];161164162 const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});165 const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});163 await executeTransaction(api, alice, tx);166 // await executeTransaction(api, alice, tx);164167165 const events = await submitTransactionAsync(alice, tx);168 await submitTransactionExpectFailAsync(alice, tx);166 const result = getCreateItemsResult(events);167168 for (const elem of result) {169 await expect(executeTransaction(170 api,171 bob,172 api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]),173 )).to.be.rejected;174 }175 });169 });176 });170 });177171186 const data = [180 const data = [187 {181 {188 owner: {substrate: alice.address},182 owner: {substrate: alice.address},183 properties: [{key: 'key1', value: 'v2'}],189 }, {184 }, {190 owner: {substrate: bob.address},185 owner: {substrate: alice.address},186 properties: [{key: 'key1', value: 'v2'}],191 }, {187 }, {192 owner: {substrate: charlie.address},188 owner: {substrate: alice.address},189 properties: [{key: 'key1', value: 'v2'}],193 },190 },194 ];191 ];195192196 const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});193 const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});197 await executeTransaction(api, alice, tx);194 // await executeTransaction(api, alice, tx);198195199 const events = await submitTransactionAsync(alice, tx);196 await submitTransactionExpectFailAsync(alice, tx);200 const result = getCreateItemsResult(events);201202 for (const elem of result) {203 await expect(executeTransaction(204 api,205 bob,206 api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]),207 )).to.be.rejected;208 }209 });197 });210 });198 });211199219 const data = [207 const data = [220 {208 {221 owner: {substrate: alice.address},209 owner: {substrate: alice.address},210 properties: [{key: 'key1', value: 'v2'}],222 }, {211 }, {223 owner: {substrate: bob.address},212 owner: {substrate: bob.address},213 properties: [{key: 'key1', value: 'v2'}],224 }, {214 }, {225 owner: {substrate: charlie.address},215 owner: {substrate: charlie.address},216 properties: [{key: 'key1', value: 'v2'}],226 },217 },227 ];218 ];228219229 const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});220 const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});230 await executeTransaction(api, alice, tx);231221232 const events = await submitTransactionAsync(alice, tx);222 await submitTransactionExpectFailAsync(alice, tx);233 const result = getCreateItemsResult(events);234235 for (const elem of result) {236 await expect(executeTransaction(237 api,238 bob,239 api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]),240 )).to.be.rejected;241 }242 });223 });243 });224 });244225245 it('Adding more than 64 prps', async () => {226 it('Adding more than 64 prps', async () => {246 const collection = await createCollectionWithPropsExpectSuccess();227 const prps = [{key: 'key', value: 'v'}];228 const propPerm = [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}];229230 for (let i = 0; i < 65; i++) {231 prps.push({key: `key${i}`, value: `value${i}`});232 propPerm.push({key: `key${i}`, permission: {mutable: true, collectionAdmin: true, tokenOwner: true}});233 }234235 const collection = await createCollectionWithPropsExpectSuccess({propPerm: propPerm});247 const alice = privateKey('//Alice');236 const alice = privateKey('//Alice');248 const bob = privateKey('//Bob');237 const bob = privateKey('//Bob');249 const charlie = privateKey('//Charlie');238 const charlie = privateKey('//Charlie');252 const data = [241 const data = [253 {242 {254 owner: {substrate: alice.address},243 owner: {substrate: alice.address},244 properties: prps,255 }, {245 }, {256 owner: {substrate: bob.address},246 owner: {substrate: alice.address},247 properties: prps,257 }, {248 }, {258 owner: {substrate: charlie.address},249 owner: {substrate: alice.address},250 properties: prps,259 },251 },260 ];252 ];261253262 const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});254 const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});263 await executeTransaction(api, alice, tx);264255265 const events = await submitTransactionAsync(alice, tx);256 await submitTransactionExpectFailAsync(alice, tx);266 const result = getCreateItemsResult(events);267268 const prps = [];269270 for (let i = 0; i < 65; i++) {271 prps.push({key: `key${i}`, value: `value${i}`});272 }273274 await expect(executeTransaction(api, bob, api.tx.unique.setCollectionProperties(collection, prps))).to.be.rejectedWith(/common\.PropertyLimitReached/);275276277 for (const elem of result) {278 await expect(executeTransaction(279 api,280 bob,281 api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, prps),282 )).to.be.rejected;283 }284 });257 });285 });258 });286259287 it('Trying to add bigger property than allowed', async () => {260 it('Trying to add bigger property than allowed', async () => {288 const collection = await createCollectionWithPropsExpectSuccess();261 const collection = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});289 const alice = privateKey('//Alice');262 const alice = privateKey('//Alice');290 const bob = privateKey('//Bob');263 const bob = privateKey('//Bob');291 const charlie = privateKey('//Charlie');264 const charlie = privateKey('//Charlie');292 await addCollectionAdminExpectSuccess(alice, collection, bob.address);265 await addCollectionAdminExpectSuccess(alice, collection, bob.address);293 await usingApi(async (api) => {266 await usingApi(async (api) => {294 const data = [267 const data = [295 {268 {296 owner: {substrate: alice.address},269 owner: {substrate: alice.address}, properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}],297 }, {270 }, {298 owner: {substrate: bob.address},271 owner: {substrate: bob.address}, properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}],299 }, {272 }, {300 owner: {substrate: charlie.address},273 owner: {substrate: charlie.address}, properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}],301 },274 },302 ];275 ];303276304 const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});277 const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});305 await executeTransaction(api, alice, tx);306278307 const events = await submitTransactionAsync(alice, tx);279 await submitTransactionExpectFailAsync(alice, tx);308 const result = getCreateItemsResult(events);309310 const prps = [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}];311312 await expect(executeTransaction(api, bob, api.tx.unique.setCollectionProperties(collection, prps))).to.be.rejectedWith(/common\.NoSpaceForProperty/);313314315 for (const elem of result) {316 await expect(executeTransaction(317 api,318 bob,319 api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, prps),320 )).to.be.rejected;321 }322 });280 });323 });281 });324282tests/src/interfaces/rmrk/definitions.tsdiffbeforeafterbothno syntactic changes
tests/src/util/helpers.tsdiffbeforeafterboth1135 const events = await submitTransactionAsync(sender, tx);1135 const events = await submitTransactionAsync(sender, tx);1136 const result = getCreateItemsResult(events);1136 const result = getCreateItemsResult(events);113711371138 for (let res of result) {1138 for (const res of result) {1139 expect(await api.rpc.unique.tokenProperties(collectionId, res.itemId)).not.to.be.empty;1139 expect(await api.rpc.unique.tokenProperties(collectionId, res.itemId)).not.to.be.empty;1140 }1140 }1141 });1141 });1142}1142}11431144export async function createMultipleItemsWithPropsExpectFailure(sender: IKeyringPair, collectionId: number, itemsData: any, owner: CrossAccountId | string = sender.address) {1145 await usingApi(async (api) => {1146 const to = normalizeAccountId(owner);1147 const tx = api.tx.unique.createMultipleItems(collectionId, to, itemsData);11481149 const events = await expect(await submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1150 const result = getCreateItemsResult(events);11511152 expect(result).to.be.equal(false);1153 });1154}11551156export async function createMultipleItemsExWithPropsExpectSuccess(sender: IKeyringPair, collectionId: number, itemsData: any) {1157 await usingApi(async (api) => {1158 const tx = api.tx.unique.createMultipleItemsEx(collectionId, itemsData);11591160 const events = await submitTransactionAsync(sender, tx);1161 const result = getCreateItemsResult(events);11621163 for (const res of result) {1164 expect(await api.rpc.unique.tokenProperties(collectionId, res.itemId)).not.to.be.empty;1165 }1166 });1167}114311681144export async function createItemWithPropsExpectSuccess(sender: IKeyringPair, collectionId: number, createMode: string, props: Array<Property>, owner: CrossAccountId | string = sender.address) {1169export async function createItemWithPropsExpectSuccess(sender: IKeyringPair, collectionId: number, createMode: string, props: Array<Property>, owner: CrossAccountId | string = sender.address) {1145 let newItemId = 0;1170 let newItemId = 0;1186 return newItemId;1211 return newItemId;1187}1212}12131214export async function createItemWithPropsExpectFailure(sender: IKeyringPair, collectionId: number, createMode: string, props: Array<Property>, owner: CrossAccountId | string = sender.address) {1215 await usingApi(async (api) => {12161217 let tx;1218 if (createMode === 'NFT') {1219 const data = api.createType('UpDataStructsCreateItemData', {NFT: {constData: 'test', properties: props}});1220 tx = api.tx.unique.createItem(collectionId, normalizeAccountId(owner), data);1221 } else {1222 tx = api.tx.unique.createItem(collectionId, normalizeAccountId(owner), createMode);1223 }122412251226 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1227 const result = getCreateItemResult(events);12281229 expect(result.success).to.be.false;1230 });1231}118812321189export async function createItemExpectSuccess(sender: IKeyringPair, collectionId: number, createMode: string, owner: CrossAccountId | string = sender.address) {1233export async function createItemExpectSuccess(sender: IKeyringPair, collectionId: number, createMode: string, owner: CrossAccountId | string = sender.address) {1190 let newItemId = 0;1234 let newItemId = 0;