git.delta.rocks / unique-network / refs/commits / 464a3c1ac005

difftreelog

fix properties have been moved in creation functions

kryadinskii2022-05-20parent: #fc4f875.patch.diff
in: master

5 files changed

modifiedtests/src/createItem.test.tsdiffbeforeafterboth
24 addCollectionAdminExpectSuccess,24 addCollectionAdminExpectSuccess,
25 createCollectionWithPropsExpectSuccess,25 createCollectionWithPropsExpectSuccess,
26 createItemWithPropsExpectSuccess,26 createItemWithPropsExpectSuccess,
27 createItemWithPropsExpectFailure,
27} from './util/helpers';28} from './util/helpers';
2829
29const 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}}]});
131
132 const token = await createItemExpectSuccess(alice, newCollectionID, 'NFT');
133 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);132 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);
134133
135 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 });
142137
143 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');
147
148 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 });
155144
156 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();
160
161 const token = await createItemExpectSuccess(alice, newCollectionID, 'NFT');
162 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);148 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);
163 149
164 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 });
171153
172 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';
175
176 const prps = [];156 const prps = [];
177157
178 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 }
181161
182 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 });
187167
188 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});
modifiedtests/src/createMultipleItems.test.tsdiffbeforeafterboth
34 getCreatedCollectionCount,34 getCreatedCollectionCount,
35 createCollectionWithPropsExpectSuccess,35 createCollectionWithPropsExpectSuccess,
36 getCreateItemsResult,36 getCreateItemsResult,
37 createMultipleItemsWithPropsExpectSuccess37 createMultipleItemsWithPropsExpectSuccess,
38 createMultipleItemsWithPropsExpectFailure,
38} from './util/helpers';39} from './util/helpers';
3940
40chai.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'}}];
442443
443 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
444
445 const events = await submitTransactionAsync(alice, createMultipleItemsTx);
446 const result = getCreateItemsResult(events);
447
448 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 }
455
456 // await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;
457 });445 });
458 });446 });
459447
460 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'}}];
470458
471 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
472
473 const events = await submitTransactionAsync(alice, createMultipleItemsTx);
474 const result = getCreateItemsResult(events);
475
476 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 });
485462
486 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'}}];
495472
496 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
497
498 const events = await submitTransactionAsync(alice, createMultipleItemsTx);
499 const result = getCreateItemsResult(events);
500
501 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 });
510476
516 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);
518
519 const args = [{Nft: {const_data: '0x31'}},
520 {Nft: {const_data: '0x32'}},
521 {Nft: {const_data: '0x33'}}];
522
523 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
524 const events = await submitTransactionAsync(alice, createMultipleItemsTx);
525
526 const result = getCreateItemsResult(events);
527484
528 const prps = [];485 const prps = [];
529486
530 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 }
533490
534 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}}];
494
537 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 });
545498
546 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'}}];
555
556 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
557
558 const events = await submitTransactionAsync(alice, createMultipleItemsTx);
559 const result = getCreateItemsResult(events);
560
561
562 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) {507
565 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});
modifiedtests/src/createMultipleItemsEx.test.tsdiffbeforeafterboth
1616
17import {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';
2121
22describe('createMultipleItemsEx', () => {22describe('createMultipleItemsEx', () => {
48 });48 });
49 });49 });
5050
51 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 ];
161164
162 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);
164167
165 const events = await submitTransactionAsync(alice, tx);168 await submitTransactionExpectFailAsync(alice, tx);
166 const result = getCreateItemsResult(events);
167
168 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 });
177171
186 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 ];
195192
196 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);
198195
199 const events = await submitTransactionAsync(alice, tx);196 await submitTransactionExpectFailAsync(alice, tx);
200 const result = getCreateItemsResult(events);
201
202 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 });
211199
219 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 ];
228219
229 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);
231221
232 const events = await submitTransactionAsync(alice, tx);222 await submitTransactionExpectFailAsync(alice, tx);
233 const result = getCreateItemsResult(events);
234
235 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 });
244225
245 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}}];
229
230 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 }
234
235 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 ];
261253
262 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);
264255
265 const events = await submitTransactionAsync(alice, tx);256 await submitTransactionExpectFailAsync(alice, tx);
266 const result = getCreateItemsResult(events);
267
268 const prps = [];
269
270 for (let i = 0; i < 65; i++) {
271 prps.push({key: `key${i}`, value: `value${i}`});
272 }
273
274 await expect(executeTransaction(api, bob, api.tx.unique.setCollectionProperties(collection, prps))).to.be.rejectedWith(/common\.PropertyLimitReached/);
275
276
277 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 });
286259
287 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 ];
303276
304 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);
306278
307 const events = await submitTransactionAsync(alice, tx);279 await submitTransactionExpectFailAsync(alice, tx);
308 const result = getCreateItemsResult(events);
309
310 const prps = [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}];
311
312 await expect(executeTransaction(api, bob, api.tx.unique.setCollectionProperties(collection, prps))).to.be.rejectedWith(/common\.NoSpaceForProperty/);
313
314
315 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 });
324282
modifiedtests/src/interfaces/rmrk/definitions.tsdiffbeforeafterboth

no syntactic changes

modifiedtests/src/util/helpers.tsdiffbeforeafterboth
1135 const events = await submitTransactionAsync(sender, tx);1135 const events = await submitTransactionAsync(sender, tx);
1136 const result = getCreateItemsResult(events);1136 const result = getCreateItemsResult(events);
11371137
1138 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}
1143
1144export 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);
1148
1149 const events = await expect(await submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;
1150 const result = getCreateItemsResult(events);
1151
1152 expect(result).to.be.equal(false);
1153 });
1154}
1155
1156export async function createMultipleItemsExWithPropsExpectSuccess(sender: IKeyringPair, collectionId: number, itemsData: any) {
1157 await usingApi(async (api) => {
1158 const tx = api.tx.unique.createMultipleItemsEx(collectionId, itemsData);
1159
1160 const events = await submitTransactionAsync(sender, tx);
1161 const result = getCreateItemsResult(events);
1162
1163 for (const res of result) {
1164 expect(await api.rpc.unique.tokenProperties(collectionId, res.itemId)).not.to.be.empty;
1165 }
1166 });
1167}
11431168
1144export 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}
1213
1214export async function createItemWithPropsExpectFailure(sender: IKeyringPair, collectionId: number, createMode: string, props: Array<Property>, owner: CrossAccountId | string = sender.address) {
1215 await usingApi(async (api) => {
1216
1217 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 }
1224
1225
1226 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;
1227 const result = getCreateItemResult(events);
1228
1229 expect(result.success).to.be.false;
1230 });
1231}
11881232
1189export 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;