git.delta.rocks / unique-network / refs/commits / 49890775239a

difftreelog

test changed the privateKeyWrapper parameter from optional to mandatory

h3lpkey2022-06-03parent: #b1d3841.patch.diff
in: master

63 files changed

modifiedtests/src/addCollectionAdmin.test.tsdiffbeforeafterboth
27 it('Add collection admin.', async () => {27 it('Add collection admin.', async () => {
28 await usingApi(async (api, privateKeyWrapper) => {28 await usingApi(async (api, privateKeyWrapper) => {
29 const collectionId = await createCollectionExpectSuccess();29 const collectionId = await createCollectionExpectSuccess();
30 const alice = privateKeyWrapper!('//Alice');30 const alice = privateKeyWrapper('//Alice');
31 const bob = privateKeyWrapper!('//Bob');31 const bob = privateKeyWrapper('//Bob');
3232
33 const collection = await queryCollectionExpectSuccess(api, collectionId);33 const collection = await queryCollectionExpectSuccess(api, collectionId);
34 expect(collection.owner.toString()).to.be.equal(alice.address);34 expect(collection.owner.toString()).to.be.equal(alice.address);
44 it('Add admin using added collection admin.', async () => {44 it('Add admin using added collection admin.', async () => {
45 await usingApi(async (api, privateKeyWrapper) => {45 await usingApi(async (api, privateKeyWrapper) => {
46 const collectionId = await createCollectionExpectSuccess();46 const collectionId = await createCollectionExpectSuccess();
47 const alice = privateKeyWrapper!('//Alice');47 const alice = privateKeyWrapper('//Alice');
48 const bob = privateKeyWrapper!('//Bob');48 const bob = privateKeyWrapper('//Bob');
49 const charlie = privateKeyWrapper!('//CHARLIE');49 const charlie = privateKeyWrapper('//CHARLIE');
5050
51 const collection = await queryCollectionExpectSuccess(api, collectionId);51 const collection = await queryCollectionExpectSuccess(api, collectionId);
52 expect(collection.owner.toString()).to.be.equal(alice.address);52 expect(collection.owner.toString()).to.be.equal(alice.address);
70 it("Not owner can't add collection admin.", async () => {70 it("Not owner can't add collection admin.", async () => {
71 await usingApi(async (api, privateKeyWrapper) => {71 await usingApi(async (api, privateKeyWrapper) => {
72 const collectionId = await createCollectionExpectSuccess();72 const collectionId = await createCollectionExpectSuccess();
73 const alice = privateKeyWrapper!('//Alice');73 const alice = privateKeyWrapper('//Alice');
74 const nonOwner = privateKeyWrapper!('//Bob_stash');74 const nonOwner = privateKeyWrapper('//Bob_stash');
7575
76 const changeAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(alice.address));76 const changeAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(alice.address));
77 await expect(submitTransactionExpectFailAsync(nonOwner, changeAdminTx)).to.be.rejected;77 await expect(submitTransactionExpectFailAsync(nonOwner, changeAdminTx)).to.be.rejected;
87 await usingApi(async (api, privateKeyWrapper) => {87 await usingApi(async (api, privateKeyWrapper) => {
88 // tslint:disable-next-line: no-bitwise88 // tslint:disable-next-line: no-bitwise
89 const collectionId = (1 << 32) - 1;89 const collectionId = (1 << 32) - 1;
90 const alice = privateKeyWrapper!('//Alice');90 const alice = privateKeyWrapper('//Alice');
91 const bob = privateKeyWrapper!('//Bob');91 const bob = privateKeyWrapper('//Bob');
9292
93 const changeOwnerTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));93 const changeOwnerTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));
94 await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;94 await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;
101 it("Can't add an admin to a destroyed collection.", async () => {101 it("Can't add an admin to a destroyed collection.", async () => {
102 await usingApi(async (api, privateKeyWrapper) => {102 await usingApi(async (api, privateKeyWrapper) => {
103 const collectionId = await createCollectionExpectSuccess();103 const collectionId = await createCollectionExpectSuccess();
104 const alice = privateKeyWrapper!('//Alice');104 const alice = privateKeyWrapper('//Alice');
105 const bob = privateKeyWrapper!('//Bob');105 const bob = privateKeyWrapper('//Bob');
106 await destroyCollectionExpectSuccess(collectionId);106 await destroyCollectionExpectSuccess(collectionId);
107 const changeOwnerTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));107 const changeOwnerTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));
108 await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;108 await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;
114114
115 it('Add an admin to a collection that has reached the maximum number of admins limit', async () => {115 it('Add an admin to a collection that has reached the maximum number of admins limit', async () => {
116 await usingApi(async (api: ApiPromise, privateKeyWrapper) => {116 await usingApi(async (api: ApiPromise, privateKeyWrapper) => {
117 const alice = privateKeyWrapper!('//Alice');117 const alice = privateKeyWrapper('//Alice');
118 const accounts = [118 const accounts = [
119 privateKeyWrapper!('//AdminTest/1').address,119 privateKeyWrapper('//AdminTest/1').address,
120 privateKeyWrapper!('//AdminTest/2').address,120 privateKeyWrapper('//AdminTest/2').address,
121 privateKeyWrapper!('//AdminTest/3').address,121 privateKeyWrapper('//AdminTest/3').address,
122 privateKeyWrapper!('//AdminTest/4').address,122 privateKeyWrapper('//AdminTest/4').address,
123 privateKeyWrapper!('//AdminTest/5').address,123 privateKeyWrapper('//AdminTest/5').address,
124 privateKeyWrapper!('//AdminTest/6').address,124 privateKeyWrapper('//AdminTest/6').address,
125 privateKeyWrapper!('//AdminTest/7').address,125 privateKeyWrapper('//AdminTest/7').address,
126 ];126 ];
127 const collectionId = await createCollectionExpectSuccess();127 const collectionId = await createCollectionExpectSuccess();
128128
modifiedtests/src/addToAllowList.test.tsdiffbeforeafterboth
4242
43 before(async () => {43 before(async () => {
44 await usingApi(async (api, privateKeyWrapper) => {44 await usingApi(async (api, privateKeyWrapper) => {
45 alice = privateKeyWrapper!('//Alice');45 alice = privateKeyWrapper('//Alice');
46 bob = privateKeyWrapper!('//Bob');46 bob = privateKeyWrapper('//Bob');
47 });47 });
48 });48 });
4949
67 await usingApi(async (api, privateKeyWrapper) => {67 await usingApi(async (api, privateKeyWrapper) => {
68 // tslint:disable-next-line: no-bitwise68 // tslint:disable-next-line: no-bitwise
69 const collectionId = await getCreatedCollectionCount(api) + 1;69 const collectionId = await getCreatedCollectionCount(api) + 1;
70 const bob = privateKeyWrapper!('//Bob');70 const bob = privateKeyWrapper('//Bob');
7171
72 const tx = api.tx.unique.addToAllowList(collectionId, normalizeAccountId(bob.address));72 const tx = api.tx.unique.addToAllowList(collectionId, normalizeAccountId(bob.address));
73 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;73 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;
7676
77 it('Allow list an address in the collection that was destroyed', async () => {77 it('Allow list an address in the collection that was destroyed', async () => {
78 await usingApi(async (api, privateKeyWrapper) => {78 await usingApi(async (api, privateKeyWrapper) => {
79 const alice = privateKeyWrapper!('//Alice');79 const alice = privateKeyWrapper('//Alice');
80 const bob = privateKeyWrapper!('//Bob');80 const bob = privateKeyWrapper('//Bob');
81 // tslint:disable-next-line: no-bitwise81 // tslint:disable-next-line: no-bitwise
82 const collectionId = await createCollectionExpectSuccess();82 const collectionId = await createCollectionExpectSuccess();
83 await destroyCollectionExpectSuccess(collectionId);83 await destroyCollectionExpectSuccess(collectionId);
8888
89 it('Allow list an address in the collection that does not have allow list access enabled', async () => {89 it('Allow list an address in the collection that does not have allow list access enabled', async () => {
90 await usingApi(async (api, privateKeyWrapper) => {90 await usingApi(async (api, privateKeyWrapper) => {
91 const alice = privateKeyWrapper!('//Alice');91 const alice = privateKeyWrapper('//Alice');
92 const ferdie = privateKeyWrapper!('//Ferdie');92 const ferdie = privateKeyWrapper('//Ferdie');
93 const collectionId = await createCollectionExpectSuccess();93 const collectionId = await createCollectionExpectSuccess();
94 await enableAllowListExpectSuccess(alice, collectionId);94 await enableAllowListExpectSuccess(alice, collectionId);
95 await enablePublicMintingExpectSuccess(alice, collectionId);95 await enablePublicMintingExpectSuccess(alice, collectionId);
104104
105 before(async () => {105 before(async () => {
106 await usingApi(async (api, privateKeyWrapper) => {106 await usingApi(async (api, privateKeyWrapper) => {
107 alice = privateKeyWrapper!('//Alice');107 alice = privateKeyWrapper('//Alice');
108 bob = privateKeyWrapper!('//Bob');108 bob = privateKeyWrapper('//Bob');
109 charlie = privateKeyWrapper!('//Charlie');109 charlie = privateKeyWrapper('//Charlie');
110 });110 });
111 });111 });
112112
modifiedtests/src/addToContractAllowList.test.tsdiffbeforeafterboth
3131
32 it('Add an address to a contract allow list', async () => {32 it('Add an address to a contract allow list', async () => {
33 await usingApi(async (api, privateKeyWrapper) => {33 await usingApi(async (api, privateKeyWrapper) => {
34 const bob = privateKeyWrapper!('//Bob');34 const bob = privateKeyWrapper('//Bob');
35 const [contract, deployer] = await deployFlipper(api);35 const [contract, deployer] = await deployFlipper(api);
3636
37 const allowListedBefore = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();37 const allowListedBefore = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();
4747
48 it('Adding same address to allow list repeatedly should not produce errors', async () => {48 it('Adding same address to allow list repeatedly should not produce errors', async () => {
49 await usingApi(async (api, privateKeyWrapper) => {49 await usingApi(async (api, privateKeyWrapper) => {
50 const bob = privateKeyWrapper!('//Bob');50 const bob = privateKeyWrapper('//Bob');
51 const [contract, deployer] = await deployFlipper(api);51 const [contract, deployer] = await deployFlipper(api);
5252
53 const allowListedBefore = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();53 const allowListedBefore = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();
7070
71 it('Add an address to a allow list of a non-contract', async () => {71 it('Add an address to a allow list of a non-contract', async () => {
72 await usingApi(async (api, privateKeyWrapper) => {72 await usingApi(async (api, privateKeyWrapper) => {
73 const alice = privateKeyWrapper!('//Bob');73 const alice = privateKeyWrapper('//Bob');
74 const bob = privateKeyWrapper!('//Bob');74 const bob = privateKeyWrapper('//Bob');
75 const charlieGuineaPig = privateKeyWrapper!('//Charlie');75 const charlieGuineaPig = privateKeyWrapper('//Charlie');
7676
77 const allowListedBefore = (await api.query.unique.contractAllowList(charlieGuineaPig.address, bob.address)).toJSON();77 const allowListedBefore = (await api.query.unique.contractAllowList(charlieGuineaPig.address, bob.address)).toJSON();
78 const addTx = api.tx.unique.addToContractAllowList(charlieGuineaPig.address, bob.address);78 const addTx = api.tx.unique.addToContractAllowList(charlieGuineaPig.address, bob.address);
8686
87 it('Add to a contract allow list using a non-owner address', async () => {87 it('Add to a contract allow list using a non-owner address', async () => {
88 await usingApi(async (api, privateKeyWrapper) => {88 await usingApi(async (api, privateKeyWrapper) => {
89 const bob = privateKeyWrapper!('//Bob');89 const bob = privateKeyWrapper('//Bob');
90 const [contract] = await deployFlipper(api);90 const [contract] = await deployFlipper(api);
9191
92 const allowListedBefore = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();92 const allowListedBefore = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();
modifiedtests/src/allowLists.test.tsdiffbeforeafterboth
5050
51 before(async () => {51 before(async () => {
52 await usingApi(async (api, privateKeyWrapper) => {52 await usingApi(async (api, privateKeyWrapper) => {
53 alice = privateKeyWrapper!('//Alice');53 alice = privateKeyWrapper('//Alice');
54 bob = privateKeyWrapper!('//Bob');54 bob = privateKeyWrapper('//Bob');
55 charlie = privateKeyWrapper!('//Charlie');55 charlie = privateKeyWrapper('//Charlie');
56 });56 });
57 });57 });
5858
modifiedtests/src/approve.test.tsdiffbeforeafterboth
4343
44 before(async () => {44 before(async () => {
45 await usingApi(async (api, privateKeyWrapper) => {45 await usingApi(async (api, privateKeyWrapper) => {
46 alice = privateKeyWrapper!('//Alice');46 alice = privateKeyWrapper('//Alice');
47 bob = privateKeyWrapper!('//Bob');47 bob = privateKeyWrapper('//Bob');
48 charlie = privateKeyWrapper!('//Charlie');48 charlie = privateKeyWrapper('//Charlie');
49 });49 });
50 });50 });
5151
9999
100 before(async () => {100 before(async () => {
101 await usingApi(async (api, privateKeyWrapper) => {101 await usingApi(async (api, privateKeyWrapper) => {
102 alice = privateKeyWrapper!('//Alice');102 alice = privateKeyWrapper('//Alice');
103 bob = privateKeyWrapper!('//Bob');103 bob = privateKeyWrapper('//Bob');
104 charlie = privateKeyWrapper!('//Charlie');104 charlie = privateKeyWrapper('//Charlie');
105 });105 });
106 }); 106 });
107107
131131
132 before(async () => {132 before(async () => {
133 await usingApi(async (api, privateKeyWrapper) => {133 await usingApi(async (api, privateKeyWrapper) => {
134 alice = privateKeyWrapper!('//Alice');134 alice = privateKeyWrapper('//Alice');
135 bob = privateKeyWrapper!('//Bob');135 bob = privateKeyWrapper('//Bob');
136 charlie = privateKeyWrapper!('//Charlie');136 charlie = privateKeyWrapper('//Charlie');
137 });137 });
138 }); 138 });
139139
166166
167 before(async () => {167 before(async () => {
168 await usingApi(async (api, privateKeyWrapper) => {168 await usingApi(async (api, privateKeyWrapper) => {
169 alice = privateKeyWrapper!('//Alice');169 alice = privateKeyWrapper('//Alice');
170 bob = privateKeyWrapper!('//Bob');170 bob = privateKeyWrapper('//Bob');
171 charlie = privateKeyWrapper!('//Charlie');171 charlie = privateKeyWrapper('//Charlie');
172 });172 });
173 }); 173 });
174174
205205
206 before(async () => {206 before(async () => {
207 await usingApi(async (api, privateKeyWrapper) => {207 await usingApi(async (api, privateKeyWrapper) => {
208 alice = privateKeyWrapper!('//Alice');208 alice = privateKeyWrapper('//Alice');
209 bob = privateKeyWrapper!('//Bob');209 bob = privateKeyWrapper('//Bob');
210 charlie = privateKeyWrapper!('//Charlie');210 charlie = privateKeyWrapper('//Charlie');
211 dave = privateKeyWrapper!('//Dave');211 dave = privateKeyWrapper('//Dave');
212 });212 });
213 }); 213 });
214214
228228
229 before(async () => {229 before(async () => {
230 await usingApi(async (api, privateKeyWrapper) => {230 await usingApi(async (api, privateKeyWrapper) => {
231 alice = privateKeyWrapper!('//Alice');231 alice = privateKeyWrapper('//Alice');
232 bob = privateKeyWrapper!('//Bob');232 bob = privateKeyWrapper('//Bob');
233 charlie = privateKeyWrapper!('//Charlie');233 charlie = privateKeyWrapper('//Charlie');
234 });234 });
235 });235 });
236236
267267
268 before(async () => {268 before(async () => {
269 await usingApi(async (api, privateKeyWrapper) => {269 await usingApi(async (api, privateKeyWrapper) => {
270 alice = privateKeyWrapper!('//Alice');270 alice = privateKeyWrapper('//Alice');
271 bob = privateKeyWrapper!('//Bob');271 bob = privateKeyWrapper('//Bob');
272 charlie = privateKeyWrapper!('//Charlie');272 charlie = privateKeyWrapper('//Charlie');
273 });273 });
274 });274 });
275275
300300
301 before(async () => {301 before(async () => {
302 await usingApi(async (api, privateKeyWrapper) => {302 await usingApi(async (api, privateKeyWrapper) => {
303 alice = privateKeyWrapper!('//Alice');303 alice = privateKeyWrapper('//Alice');
304 bob = privateKeyWrapper!('//Bob');304 bob = privateKeyWrapper('//Bob');
305 charlie = privateKeyWrapper!('//Charlie');305 charlie = privateKeyWrapper('//Charlie');
306 dave = privateKeyWrapper!('//Dave');306 dave = privateKeyWrapper('//Dave');
307 });307 });
308 }); 308 });
309309
340340
341 before(async () => {341 before(async () => {
342 await usingApi(async (api, privateKeyWrapper) => {342 await usingApi(async (api, privateKeyWrapper) => {
343 alice = privateKeyWrapper!('//Alice');343 alice = privateKeyWrapper('//Alice');
344 bob = privateKeyWrapper!('//Bob');344 bob = privateKeyWrapper('//Bob');
345 charlie = privateKeyWrapper!('//Charlie');345 charlie = privateKeyWrapper('//Charlie');
346 dave = privateKeyWrapper!('//Dave');346 dave = privateKeyWrapper('//Dave');
347 });347 });
348 }); 348 });
349349
391391
392 before(async () => {392 before(async () => {
393 await usingApi(async (api, privateKeyWrapper) => {393 await usingApi(async (api, privateKeyWrapper) => {
394 alice = privateKeyWrapper!('//Alice');394 alice = privateKeyWrapper('//Alice');
395 bob = privateKeyWrapper!('//Bob');395 bob = privateKeyWrapper('//Bob');
396 charlie = privateKeyWrapper!('//Charlie');396 charlie = privateKeyWrapper('//Charlie');
397 });397 });
398 });398 });
399399
413413
414 before(async () => {414 before(async () => {
415 await usingApi(async (api, privateKeyWrapper) => {415 await usingApi(async (api, privateKeyWrapper) => {
416 alice = privateKeyWrapper!('//Alice');416 alice = privateKeyWrapper('//Alice');
417 bob = privateKeyWrapper!('//Bob');417 bob = privateKeyWrapper('//Bob');
418 charlie = privateKeyWrapper!('//Charlie');418 charlie = privateKeyWrapper('//Charlie');
419 });419 });
420 });420 });
421421
modifiedtests/src/change-collection-owner.test.tsdiffbeforeafterboth
42 it('Changing owner changes owner address', async () => {42 it('Changing owner changes owner address', async () => {
43 await usingApi(async (api, privateKeyWrapper) => {43 await usingApi(async (api, privateKeyWrapper) => {
44 const collectionId = await createCollectionExpectSuccess();44 const collectionId = await createCollectionExpectSuccess();
45 const alice = privateKeyWrapper!('//Alice');45 const alice = privateKeyWrapper('//Alice');
46 const bob = privateKeyWrapper!('//Bob');46 const bob = privateKeyWrapper('//Bob');
4747
48 const collection =await queryCollectionExpectSuccess(api, collectionId);48 const collection =await queryCollectionExpectSuccess(api, collectionId);
49 expect(collection.owner.toString()).to.be.deep.eq(alice.address);49 expect(collection.owner.toString()).to.be.deep.eq(alice.address);
61 it('Changing the owner of the collection is not allowed for the former owner', async () => {61 it('Changing the owner of the collection is not allowed for the former owner', async () => {
62 await usingApi(async (api, privateKeyWrapper) => {62 await usingApi(async (api, privateKeyWrapper) => {
63 const collectionId = await createCollectionExpectSuccess();63 const collectionId = await createCollectionExpectSuccess();
64 const alice = privateKeyWrapper!('//Alice');64 const alice = privateKeyWrapper('//Alice');
65 const bob = privateKeyWrapper!('//Bob');65 const bob = privateKeyWrapper('//Bob');
6666
67 const collection = await queryCollectionExpectSuccess(api, collectionId);67 const collection = await queryCollectionExpectSuccess(api, collectionId);
68 expect(collection.owner.toString()).to.be.deep.eq(alice.address);68 expect(collection.owner.toString()).to.be.deep.eq(alice.address);
81 it('New collectionOwner has access to sponsorship management operations in the collection', async () => {81 it('New collectionOwner has access to sponsorship management operations in the collection', async () => {
82 await usingApi(async (api, privateKeyWrapper) => {82 await usingApi(async (api, privateKeyWrapper) => {
83 const collectionId = await createCollectionExpectSuccess();83 const collectionId = await createCollectionExpectSuccess();
84 const alice = privateKeyWrapper!('//Alice');84 const alice = privateKeyWrapper('//Alice');
85 const bob = privateKeyWrapper!('//Bob');85 const bob = privateKeyWrapper('//Bob');
86 const charlie = privateKeyWrapper!('//Charlie');86 const charlie = privateKeyWrapper('//Charlie');
8787
88 const collection = await queryCollectionExpectSuccess(api, collectionId);88 const collection = await queryCollectionExpectSuccess(api, collectionId);
89 expect(collection.owner.toString()).to.be.deep.eq(alice.address);89 expect(collection.owner.toString()).to.be.deep.eq(alice.address);
125 it('New collectionOwner has access to changeCollectionOwner', async () => {125 it('New collectionOwner has access to changeCollectionOwner', async () => {
126 await usingApi(async (api, privateKeyWrapper) => {126 await usingApi(async (api, privateKeyWrapper) => {
127 const collectionId = await createCollectionExpectSuccess();127 const collectionId = await createCollectionExpectSuccess();
128 const alice = privateKeyWrapper!('//Alice');128 const alice = privateKeyWrapper('//Alice');
129 const bob = privateKeyWrapper!('//Bob');129 const bob = privateKeyWrapper('//Bob');
130 const charlie = privateKeyWrapper!('//Charlie');130 const charlie = privateKeyWrapper('//Charlie');
131131
132 const collection = await queryCollectionExpectSuccess(api, collectionId);132 const collection = await queryCollectionExpectSuccess(api, collectionId);
133 expect(collection.owner.toString()).to.be.deep.eq(alice.address);133 expect(collection.owner.toString()).to.be.deep.eq(alice.address);
152 it('Not owner can\'t change owner.', async () => {152 it('Not owner can\'t change owner.', async () => {
153 await usingApi(async (api, privateKeyWrapper) => {153 await usingApi(async (api, privateKeyWrapper) => {
154 const collectionId = await createCollectionExpectSuccess();154 const collectionId = await createCollectionExpectSuccess();
155 const alice = privateKeyWrapper!('//Alice');155 const alice = privateKeyWrapper('//Alice');
156 const bob = privateKeyWrapper!('//Bob');156 const bob = privateKeyWrapper('//Bob');
157157
158 const changeOwnerTx = api.tx.unique.changeCollectionOwner(collectionId, bob.address);158 const changeOwnerTx = api.tx.unique.changeCollectionOwner(collectionId, bob.address);
159 await expect(submitTransactionExpectFailAsync(bob, changeOwnerTx)).to.be.rejected;159 await expect(submitTransactionExpectFailAsync(bob, changeOwnerTx)).to.be.rejected;
169 it('Collection admin can\'t change owner.', async () => {169 it('Collection admin can\'t change owner.', async () => {
170 await usingApi(async (api, privateKeyWrapper) => {170 await usingApi(async (api, privateKeyWrapper) => {
171 const collectionId = await createCollectionExpectSuccess();171 const collectionId = await createCollectionExpectSuccess();
172 const alice = privateKeyWrapper!('//Alice');172 const alice = privateKeyWrapper('//Alice');
173 const bob = privateKeyWrapper!('//Bob');173 const bob = privateKeyWrapper('//Bob');
174174
175 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);175 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
176176
188 it('Can\'t change owner of a non-existing collection.', async () => {188 it('Can\'t change owner of a non-existing collection.', async () => {
189 await usingApi(async (api, privateKeyWrapper) => {189 await usingApi(async (api, privateKeyWrapper) => {
190 const collectionId = (1<<32) - 1;190 const collectionId = (1<<32) - 1;
191 const alice = privateKeyWrapper!('//Alice');191 const alice = privateKeyWrapper('//Alice');
192 const bob = privateKeyWrapper!('//Bob');192 const bob = privateKeyWrapper('//Bob');
193193
194 const changeOwnerTx = api.tx.unique.changeCollectionOwner(collectionId, bob.address);194 const changeOwnerTx = api.tx.unique.changeCollectionOwner(collectionId, bob.address);
195 await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;195 await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;
202 it('Former collectionOwner not allowed to sponsorship management operations in the collection', async () => {202 it('Former collectionOwner not allowed to sponsorship management operations in the collection', async () => {
203 await usingApi(async (api, privateKeyWrapper) => {203 await usingApi(async (api, privateKeyWrapper) => {
204 const collectionId = await createCollectionExpectSuccess();204 const collectionId = await createCollectionExpectSuccess();
205 const alice = privateKeyWrapper!('//Alice');205 const alice = privateKeyWrapper('//Alice');
206 const bob = privateKeyWrapper!('//Bob');206 const bob = privateKeyWrapper('//Bob');
207 const charlie = privateKeyWrapper!('//Charlie');207 const charlie = privateKeyWrapper('//Charlie');
208208
209 const collection = await queryCollectionExpectSuccess(api, collectionId);209 const collection = await queryCollectionExpectSuccess(api, collectionId);
210 expect(collection.owner.toString()).to.be.deep.eq(alice.address);210 expect(collection.owner.toString()).to.be.deep.eq(alice.address);
modifiedtests/src/check-event/burnItemEvent.test.tsdiffbeforeafterboth
32 const checkSystem = 'ExtrinsicSuccess';32 const checkSystem = 'ExtrinsicSuccess';
33 before(async () => {33 before(async () => {
34 await usingApi(async (api, privateKeyWrapper) => {34 await usingApi(async (api, privateKeyWrapper) => {
35 alice = privateKeyWrapper!('//Alice');35 alice = privateKeyWrapper('//Alice');
36 });36 });
37 });37 });
38 it('Check event from burnItem(): ', async () => {38 it('Check event from burnItem(): ', async () => {
modifiedtests/src/check-event/createCollectionEvent.test.tsdiffbeforeafterboth
32 const checkSystem = 'ExtrinsicSuccess';32 const checkSystem = 'ExtrinsicSuccess';
33 before(async () => {33 before(async () => {
34 await usingApi(async (api, privateKeyWrapper) => {34 await usingApi(async (api, privateKeyWrapper) => {
35 alice = privateKeyWrapper!('//Alice');35 alice = privateKeyWrapper('//Alice');
36 });36 });
37 });37 });
38 it('Check event from createCollection(): ', async () => {38 it('Check event from createCollection(): ', async () => {
modifiedtests/src/check-event/createItemEvent.test.tsdiffbeforeafterboth
32 const checkSystem = 'ExtrinsicSuccess';32 const checkSystem = 'ExtrinsicSuccess';
33 before(async () => {33 before(async () => {
34 await usingApi(async (api, privateKeyWrapper) => {34 await usingApi(async (api, privateKeyWrapper) => {
35 alice = privateKeyWrapper!('//Alice');35 alice = privateKeyWrapper('//Alice');
36 });36 });
37 });37 });
38 it('Check event from createItem(): ', async () => {38 it('Check event from createItem(): ', async () => {
modifiedtests/src/check-event/createMultipleItemsEvent.test.tsdiffbeforeafterboth
32 const checkSystem = 'ExtrinsicSuccess';32 const checkSystem = 'ExtrinsicSuccess';
33 before(async () => {33 before(async () => {
34 await usingApi(async (api, privateKeyWrapper) => {34 await usingApi(async (api, privateKeyWrapper) => {
35 alice = privateKeyWrapper!('//Alice');35 alice = privateKeyWrapper('//Alice');
36 });36 });
37 });37 });
38 it('Check event from createMultipleItems(): ', async () => {38 it('Check event from createMultipleItems(): ', async () => {
modifiedtests/src/check-event/destroyCollectionEvent.test.tsdiffbeforeafterboth
31 const checkSystem = 'ExtrinsicSuccess';31 const checkSystem = 'ExtrinsicSuccess';
32 before(async () => {32 before(async () => {
33 await usingApi(async (api, privateKeyWrapper) => {33 await usingApi(async (api, privateKeyWrapper) => {
34 alice = privateKeyWrapper!('//Alice');34 alice = privateKeyWrapper('//Alice');
35 });35 });
36 });36 });
37 it('Check event from destroyCollection(): ', async () => {37 it('Check event from destroyCollection(): ', async () => {
modifiedtests/src/check-event/transferEvent.test.tsdiffbeforeafterboth
33 const checkSystem = 'ExtrinsicSuccess';33 const checkSystem = 'ExtrinsicSuccess';
34 before(async () => {34 before(async () => {
35 await usingApi(async (api, privateKeyWrapper) => {35 await usingApi(async (api, privateKeyWrapper) => {
36 alice = privateKeyWrapper!('//Alice');36 alice = privateKeyWrapper('//Alice');
37 bob = privateKeyWrapper!('//Bob');37 bob = privateKeyWrapper('//Bob');
38 });38 });
39 });39 });
40 it('Check event from transfer(): ', async () => {40 it('Check event from transfer(): ', async () => {
modifiedtests/src/check-event/transferFromEvent.test.tsdiffbeforeafterboth
33 const checkSystem = 'ExtrinsicSuccess';33 const checkSystem = 'ExtrinsicSuccess';
34 before(async () => {34 before(async () => {
35 await usingApi(async (api, privateKeyWrapper) => {35 await usingApi(async (api, privateKeyWrapper) => {
36 alice = privateKeyWrapper!('//Alice');36 alice = privateKeyWrapper('//Alice');
37 bob = privateKeyWrapper!('//Bob');37 bob = privateKeyWrapper('//Bob');
38 });38 });
39 });39 });
40 it('Check event from transferFrom(): ', async () => {40 it('Check event from transferFrom(): ', async () => {
modifiedtests/src/contracts.test.tsdiffbeforeafterboth
19import usingApi, {submitTransactionAsync} from './substrate/substrate-api';19import usingApi, {submitTransactionAsync} from './substrate/substrate-api';
20import fs from 'fs';20import fs from 'fs';
21import {Abi, ContractPromise as Contract} from '@polkadot/api-contract';21import {Abi, ContractPromise as Contract} from '@polkadot/api-contract';
22import privateKey from './substrate/privateKey';
23import {22import {
24 deployFlipper,23 deployFlipper,
25 getFlipValue,24 getFlipValue,
54 const [contract, deployer] = await deployFlipper(api);53 const [contract, deployer] = await deployFlipper(api);
55 const initialGetResponse = await getFlipValue(contract, deployer);54 const initialGetResponse = await getFlipValue(contract, deployer);
5655
57 const bob = privateKeyWrapper!('//Bob');56 const bob = privateKeyWrapper('//Bob');
58 const flip = contract.tx.flip(value, gasLimit);57 const flip = contract.tx.flip(value, gasLimit);
59 await submitTransactionAsync(bob, flip);58 await submitTransactionAsync(bob, flip);
6059
77describe.skip('Chain extensions', () => {76describe.skip('Chain extensions', () => {
78 it('Transfer CE', async () => {77 it('Transfer CE', async () => {
79 await usingApi(async (api, privateKeyWrapper) => {78 await usingApi(async (api, privateKeyWrapper) => {
80 const alice = privateKeyWrapper!('//Alice');79 const alice = privateKeyWrapper('//Alice');
81 const bob = privateKeyWrapper!('//Bob');80 const bob = privateKeyWrapper('//Bob');
8281
83 // Prep work82 // Prep work
84 const collectionId = await createCollectionExpectSuccess();83 const collectionId = await createCollectionExpectSuccess();
101100
102 it('Mint CE', async () => {101 it('Mint CE', async () => {
103 await usingApi(async (api, privateKeyWrapper) => {102 await usingApi(async (api, privateKeyWrapper) => {
104 const alice = privateKeyWrapper!('//Alice');103 const alice = privateKeyWrapper('//Alice');
105 const bob = privateKeyWrapper!('//Bob');104 const bob = privateKeyWrapper('//Bob');
106105
107 const collectionId = await createCollectionExpectSuccess();106 const collectionId = await createCollectionExpectSuccess();
108 const [contract] = await deployTransferContract(api);107 const [contract] = await deployTransferContract(api);
128127
129 it('Bulk mint CE', async () => {128 it('Bulk mint CE', async () => {
130 await usingApi(async (api, privateKeyWrapper) => {129 await usingApi(async (api, privateKeyWrapper) => {
131 const alice = privateKeyWrapper!('//Alice');130 const alice = privateKeyWrapper('//Alice');
132 const bob = privateKeyWrapper!('//Bob');131 const bob = privateKeyWrapper('//Bob');
133132
134 const collectionId = await createCollectionExpectSuccess();133 const collectionId = await createCollectionExpectSuccess();
135 const [contract] = await deployTransferContract(api);134 const [contract] = await deployTransferContract(api);
169168
170 it('Approve CE', async () => {169 it('Approve CE', async () => {
171 await usingApi(async (api, privateKeyWrapper) => {170 await usingApi(async (api, privateKeyWrapper) => {
172 const alice = privateKeyWrapper!('//Alice');171 const alice = privateKeyWrapper('//Alice');
173 const bob = privateKeyWrapper!('//Bob');172 const bob = privateKeyWrapper('//Bob');
174 const charlie = privateKeyWrapper!('//Charlie');173 const charlie = privateKeyWrapper('//Charlie');
175174
176 const collectionId = await createCollectionExpectSuccess();175 const collectionId = await createCollectionExpectSuccess();
177 const [contract] = await deployTransferContract(api);176 const [contract] = await deployTransferContract(api);
188187
189 it('TransferFrom CE', async () => {188 it('TransferFrom CE', async () => {
190 await usingApi(async (api, privateKeyWrapper) => {189 await usingApi(async (api, privateKeyWrapper) => {
191 const alice = privateKeyWrapper!('//Alice');190 const alice = privateKeyWrapper('//Alice');
192 const bob = privateKeyWrapper!('//Bob');191 const bob = privateKeyWrapper('//Bob');
193 const charlie = privateKeyWrapper!('//Charlie');192 const charlie = privateKeyWrapper('//Charlie');
194193
195 const collectionId = await createCollectionExpectSuccess();194 const collectionId = await createCollectionExpectSuccess();
196 const [contract] = await deployTransferContract(api);195 const [contract] = await deployTransferContract(api);
209208
210 it('ToggleAllowList CE', async () => {209 it('ToggleAllowList CE', async () => {
211 await usingApi(async (api, privateKeyWrapper) => {210 await usingApi(async (api, privateKeyWrapper) => {
212 const alice = privateKeyWrapper!('//Alice');211 const alice = privateKeyWrapper('//Alice');
213 const bob = privateKeyWrapper!('//Bob');212 const bob = privateKeyWrapper('//Bob');
214213
215 const collectionId = await createCollectionExpectSuccess();214 const collectionId = await createCollectionExpectSuccess();
216 const [contract] = await deployTransferContract(api);215 const [contract] = await deployTransferContract(api);
modifiedtests/src/createCollection.test.tsdiffbeforeafterboth
5858
59 it('Create new collection with extra fields', async () => {59 it('Create new collection with extra fields', async () => {
60 await usingApi(async (api, privateKeyWrapper) => {60 await usingApi(async (api, privateKeyWrapper) => {
61 const alice = privateKeyWrapper!('//Alice');61 const alice = privateKeyWrapper('//Alice');
62 const bob = privateKeyWrapper!('//Bob');62 const bob = privateKeyWrapper('//Bob');
63 const tx = api.tx.unique.createCollectionEx({63 const tx = api.tx.unique.createCollectionEx({
64 mode: {Fungible: 8},64 mode: {Fungible: 8},
65 permissions: {65 permissions: {
101 });101 });
102 it('fails when bad limits are set', async () => {102 it('fails when bad limits are set', async () => {
103 await usingApi(async (api, privateKeyWrapper) => {103 await usingApi(async (api, privateKeyWrapper) => {
104 const alice = privateKeyWrapper!('//Alice');104 const alice = privateKeyWrapper('//Alice');
105 const tx = api.tx.unique.createCollectionEx({mode: 'NFT', limits: {tokenLimit: 0}});105 const tx = api.tx.unique.createCollectionEx({mode: 'NFT', limits: {tokenLimit: 0}});
106 await expect(executeTransaction(api, alice, tx)).to.be.rejectedWith(/^common.CollectionTokenLimitExceeded$/);106 await expect(executeTransaction(api, alice, tx)).to.be.rejectedWith(/^common.CollectionTokenLimitExceeded$/);
107 });107 });
modifiedtests/src/createMultipleItems.test.tsdiffbeforeafterboth
45 const itemsListIndexBefore = await getLastTokenId(api, collectionId);45 const itemsListIndexBefore = await getLastTokenId(api, collectionId);
46 expect(itemsListIndexBefore).to.be.equal(0);46 expect(itemsListIndexBefore).to.be.equal(0);
4747
48 const alice = privateKeyWrapper!('//Alice');48 const alice = privateKeyWrapper('//Alice');
49 await submitTransactionAsync(49 await submitTransactionAsync(
50 alice, 50 alice,
51 api.tx.unique.setPropertyPermissions(collectionId, [{key: 'data', permission: {tokenOwner: true}}]),51 api.tx.unique.setPropertyPermissions(collectionId, [{key: 'data', permission: {tokenOwner: true}}]),
76 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});76 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
77 const itemsListIndexBefore = await getLastTokenId(api, collectionId);77 const itemsListIndexBefore = await getLastTokenId(api, collectionId);
78 expect(itemsListIndexBefore).to.be.equal(0);78 expect(itemsListIndexBefore).to.be.equal(0);
79 const alice = privateKeyWrapper!('//Alice');79 const alice = privateKeyWrapper('//Alice');
80 const args = [80 const args = [
81 {Fungible: {value: 1}},81 {Fungible: {value: 1}},
82 {Fungible: {value: 2}},82 {Fungible: {value: 2}},
96 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});96 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
97 const itemsListIndexBefore = await getLastTokenId(api, collectionId);97 const itemsListIndexBefore = await getLastTokenId(api, collectionId);
98 expect(itemsListIndexBefore).to.be.equal(0);98 expect(itemsListIndexBefore).to.be.equal(0);
99 const alice = privateKeyWrapper!('//Alice');99 const alice = privateKeyWrapper('//Alice');
100 const args = [100 const args = [
101 {ReFungible: {pieces: 1}},101 {ReFungible: {pieces: 1}},
102 {ReFungible: {pieces: 2}},102 {ReFungible: {pieces: 2}},
116116
117 it('Can mint amount of items equals to collection limits', async () => {117 it('Can mint amount of items equals to collection limits', async () => {
118 await usingApi(async (api, privateKeyWrapper) => {118 await usingApi(async (api, privateKeyWrapper) => {
119 const alice = privateKeyWrapper!('//Alice');119 const alice = privateKeyWrapper('//Alice');
120120
121 const collectionId = await createCollectionExpectSuccess();121 const collectionId = await createCollectionExpectSuccess();
122 await setCollectionLimitsExpectSuccess(alice, collectionId, {122 await setCollectionLimitsExpectSuccess(alice, collectionId, {
138 const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]});138 const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]});
139 const itemsListIndexBefore = await getLastTokenId(api, collectionId);139 const itemsListIndexBefore = await getLastTokenId(api, collectionId);
140 expect(itemsListIndexBefore).to.be.equal(0);140 expect(itemsListIndexBefore).to.be.equal(0);
141 const alice = privateKeyWrapper!('//Alice');141 const alice = privateKeyWrapper('//Alice');
142 const args = [142 const args = [
143 {NFT: {properties: [{key: 'k', value: 'v1'}]}},143 {NFT: {properties: [{key: 'k', value: 'v1'}]}},
144 {NFT: {properties: [{key: 'k', value: 'v2'}]}},144 {NFT: {properties: [{key: 'k', value: 'v2'}]}},
164 const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: false, collectionAdmin: true, tokenOwner: false}}]});164 const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: false, collectionAdmin: true, tokenOwner: false}}]});
165 const itemsListIndexBefore = await getLastTokenId(api, collectionId);165 const itemsListIndexBefore = await getLastTokenId(api, collectionId);
166 expect(itemsListIndexBefore).to.be.equal(0);166 expect(itemsListIndexBefore).to.be.equal(0);
167 const alice = privateKeyWrapper!('//Alice');167 const alice = privateKeyWrapper('//Alice');
168 const bob = privateKeyWrapper!('//Bob');168 const bob = privateKeyWrapper('//Bob');
169 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);169 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
170 const args = [170 const args = [
171 {NFT: {properties: [{key: 'k', value: 'v1'}]}},171 {NFT: {properties: [{key: 'k', value: 'v1'}]}},
192 const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});192 const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});
193 const itemsListIndexBefore = await getLastTokenId(api, collectionId);193 const itemsListIndexBefore = await getLastTokenId(api, collectionId);
194 expect(itemsListIndexBefore).to.be.equal(0);194 expect(itemsListIndexBefore).to.be.equal(0);
195 const alice = privateKeyWrapper!('//Alice');195 const alice = privateKeyWrapper('//Alice');
196 const args = [196 const args = [
197 {NFT: {properties: [{key: 'k', value: 'v1'}]}},197 {NFT: {properties: [{key: 'k', value: 'v1'}]}},
198 {NFT: {properties: [{key: 'k', value: 'v2'}]}},198 {NFT: {properties: [{key: 'k', value: 'v2'}]}},
220220
221 before(async () => {221 before(async () => {
222 await usingApi(async (api, privateKeyWrapper) => {222 await usingApi(async (api, privateKeyWrapper) => {
223 alice = privateKeyWrapper!('//Alice');223 alice = privateKeyWrapper('//Alice');
224 bob = privateKeyWrapper!('//Bob');224 bob = privateKeyWrapper('//Bob');
225 });225 });
226 });226 });
227227
302302
303 before(async () => {303 before(async () => {
304 await usingApi(async (api, privateKeyWrapper) => {304 await usingApi(async (api, privateKeyWrapper) => {
305 alice = privateKeyWrapper!('//Alice');305 alice = privateKeyWrapper('//Alice');
306 bob = privateKeyWrapper!('//Bob');306 bob = privateKeyWrapper('//Bob');
307 });307 });
308 });308 });
309309
364 const collectionId = await createCollectionWithPropsExpectSuccess({364 const collectionId = await createCollectionWithPropsExpectSuccess({
365 propPerm: [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}],365 propPerm: [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}],
366 });366 });
367 const alice = privateKeyWrapper!('//Alice');367 const alice = privateKeyWrapper('//Alice');
368 const args = [368 const args = [
369 {NFT: {properties: [{key: 'key', value: 'A'.repeat(32769)}]}},369 {NFT: {properties: [{key: 'key', value: 'A'.repeat(32769)}]}},
370 {NFT: {properties: [{key: 'key', value: 'B'.repeat(32769)}]}},370 {NFT: {properties: [{key: 'key', value: 'B'.repeat(32769)}]}},
modifiedtests/src/createMultipleItemsEx.test.tsdiffbeforeafterboth
22 it('can initialize multiple NFT with different owners', async () => {22 it('can initialize multiple NFT with different owners', async () => {
23 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});23 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
24 await usingApi(async (api, privateKeyWrapper) => {24 await usingApi(async (api, privateKeyWrapper) => {
25 const alice = privateKeyWrapper!('//Alice');25 const alice = privateKeyWrapper('//Alice');
26 const bob = privateKeyWrapper!('//Bob');26 const bob = privateKeyWrapper('//Bob');
27 const charlie = privateKeyWrapper!('//Charlie');27 const charlie = privateKeyWrapper('//Charlie');
28 const data = [28 const data = [
29 {29 {
30 owner: {substrate: alice.address},30 owner: {substrate: alice.address},
47 it('createMultipleItemsEx with property Admin', async () => {47 it('createMultipleItemsEx with property Admin', async () => {
48 const collection = await createCollectionWithPropsExpectSuccess({mode: {type: 'NFT'}, propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]});48 const collection = await createCollectionWithPropsExpectSuccess({mode: {type: 'NFT'}, propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]});
49 await usingApi(async (api, privateKeyWrapper) => {49 await usingApi(async (api, privateKeyWrapper) => {
50 const alice = privateKeyWrapper!('//Alice');50 const alice = privateKeyWrapper('//Alice');
51 const bob = privateKeyWrapper!('//Bob');51 const bob = privateKeyWrapper('//Bob');
52 const charlie = privateKeyWrapper!('//Charlie');52 const charlie = privateKeyWrapper('//Charlie');
53 const data = [53 const data = [
54 {54 {
55 owner: {substrate: alice.address},55 owner: {substrate: alice.address},
75 it('createMultipleItemsEx with property AdminConst', async () => {75 it('createMultipleItemsEx with property AdminConst', async () => {
76 const collection = await createCollectionWithPropsExpectSuccess({mode: {type: 'NFT'}, propPerm: [{key: 'k', permission: {mutable: false, collectionAdmin: true, tokenOwner: false}}]});76 const collection = await createCollectionWithPropsExpectSuccess({mode: {type: 'NFT'}, propPerm: [{key: 'k', permission: {mutable: false, collectionAdmin: true, tokenOwner: false}}]});
77 await usingApi(async (api, privateKeyWrapper) => {77 await usingApi(async (api, privateKeyWrapper) => {
78 const alice = privateKeyWrapper!('//Alice');78 const alice = privateKeyWrapper('//Alice');
79 const bob = privateKeyWrapper!('//Bob');79 const bob = privateKeyWrapper('//Bob');
80 const charlie = privateKeyWrapper!('//Charlie');80 const charlie = privateKeyWrapper('//Charlie');
81 const data = [81 const data = [
82 {82 {
83 owner: {substrate: alice.address},83 owner: {substrate: alice.address},
103 it('createMultipleItemsEx with property itemOwnerOrAdmin', async () => {103 it('createMultipleItemsEx with property itemOwnerOrAdmin', async () => {
104 const collection = await createCollectionWithPropsExpectSuccess({mode: {type: 'NFT'}, propPerm: [{key: 'k', permission: {mutable: false, collectionAdmin: true, tokenOwner: true}}]});104 const collection = await createCollectionWithPropsExpectSuccess({mode: {type: 'NFT'}, propPerm: [{key: 'k', permission: {mutable: false, collectionAdmin: true, tokenOwner: true}}]});
105 await usingApi(async (api, privateKeyWrapper) => {105 await usingApi(async (api, privateKeyWrapper) => {
106 const alice = privateKeyWrapper!('//Alice');106 const alice = privateKeyWrapper('//Alice');
107 const bob = privateKeyWrapper!('//Bob');107 const bob = privateKeyWrapper('//Bob');
108 const charlie = privateKeyWrapper!('//Charlie');108 const charlie = privateKeyWrapper('//Charlie');
109 const data = [109 const data = [
110 {110 {
111 owner: {substrate: alice.address},111 owner: {substrate: alice.address},
132 const collection = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],132 const collection = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],
133 propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});133 propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});
134 await usingApi(async (api, privateKeyWrapper) => {134 await usingApi(async (api, privateKeyWrapper) => {
135 const alice = privateKeyWrapper!('//Alice');135 const alice = privateKeyWrapper('//Alice');
136 const bob = privateKeyWrapper!('//Bob');136 const bob = privateKeyWrapper('//Bob');
137 const charlie = privateKeyWrapper!('//Charlie');137 const charlie = privateKeyWrapper('//Charlie');
138 await addCollectionAdminExpectSuccess(alice, collection, bob.address);138 await addCollectionAdminExpectSuccess(alice, collection, bob.address);
139 const data = [139 const data = [
140 {140 {
161 const collection = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],161 const collection = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],
162 propPerm: [{key: 'key1', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}]});162 propPerm: [{key: 'key1', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}]});
163 await usingApi(async (api, privateKeyWrapper) => {163 await usingApi(async (api, privateKeyWrapper) => {
164 const alice = privateKeyWrapper!('//Alice');164 const alice = privateKeyWrapper('//Alice');
165 const bob = privateKeyWrapper!('//Bob');165 const bob = privateKeyWrapper('//Bob');
166 await addCollectionAdminExpectSuccess(alice, collection, bob.address);166 await addCollectionAdminExpectSuccess(alice, collection, bob.address);
167 const data = [167 const data = [
168 {168 {
188 it('Adding property without access rights', async () => {188 it('Adding property without access rights', async () => {
189 const collection = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}]});189 const collection = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}]});
190 await usingApi(async (api, privateKeyWrapper) => {190 await usingApi(async (api, privateKeyWrapper) => {
191 const alice = privateKeyWrapper!('//Alice');191 const alice = privateKeyWrapper('//Alice');
192 const bob = privateKeyWrapper!('//Bob');192 const bob = privateKeyWrapper('//Bob');
193 const charlie = privateKeyWrapper!('//Charlie');193 const charlie = privateKeyWrapper('//Charlie');
194 await addCollectionAdminExpectSuccess(alice, collection, bob.address);194 await addCollectionAdminExpectSuccess(alice, collection, bob.address);
195 const data = [195 const data = [
196 {196 {
221221
222 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});222 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
223 await usingApi(async (api, privateKeyWrapper) => {223 await usingApi(async (api, privateKeyWrapper) => {
224 const alice = privateKeyWrapper!('//Alice');224 const alice = privateKeyWrapper('//Alice');
225 await expect(executeTransaction(api, alice, api.tx.unique.setPropertyPermissions(collection, propPerms))).to.be.rejectedWith(/common\.PropertyLimitReached/);225 await expect(executeTransaction(api, alice, api.tx.unique.setPropertyPermissions(collection, propPerms))).to.be.rejectedWith(/common\.PropertyLimitReached/);
226 });226 });
227 });227 });
228228
229 it('Trying to add bigger property than allowed', async () => {229 it('Trying to add bigger property than allowed', async () => {
230 const collection = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});230 const collection = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});
231 await usingApi(async (api, privateKeyWrapper) => {231 await usingApi(async (api, privateKeyWrapper) => {
232 const alice = privateKeyWrapper!('//Alice');232 const alice = privateKeyWrapper('//Alice');
233 const bob = privateKeyWrapper!('//Bob');233 const bob = privateKeyWrapper('//Bob');
234 const charlie = privateKeyWrapper!('//Charlie');234 const charlie = privateKeyWrapper('//Charlie');
235 await addCollectionAdminExpectSuccess(alice, collection, bob.address);235 await addCollectionAdminExpectSuccess(alice, collection, bob.address);
236 const data = [236 const data = [
237 {237 {
253 it('can initialize multiple NFT with different owners', async () => {253 it('can initialize multiple NFT with different owners', async () => {
254 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});254 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
255 await usingApi(async (api, privateKeyWrapper) => {255 await usingApi(async (api, privateKeyWrapper) => {
256 const alice = privateKeyWrapper!('//Alice');256 const alice = privateKeyWrapper('//Alice');
257 const bob = privateKeyWrapper!('//Bob');257 const bob = privateKeyWrapper('//Bob');
258 const charlie = privateKeyWrapper!('//Charlie');258 const charlie = privateKeyWrapper('//Charlie');
259 const data = [259 const data = [
260 {260 {
261 owner: {substrate: alice.address},261 owner: {substrate: alice.address},
278 it('can initialize multiple NFT with different owners', async () => {278 it('can initialize multiple NFT with different owners', async () => {
279 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});279 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
280 await usingApi(async (api, privateKeyWrapper) => {280 await usingApi(async (api, privateKeyWrapper) => {
281 const alice = privateKeyWrapper!('//Alice');281 const alice = privateKeyWrapper('//Alice');
282 const bob = privateKeyWrapper!('//Bob');282 const bob = privateKeyWrapper('//Bob');
283 const charlie = privateKeyWrapper!('//Charlie');283 const charlie = privateKeyWrapper('//Charlie');
284 const data = [284 const data = [
285 {285 {
286 owner: {substrate: alice.address},286 owner: {substrate: alice.address},
304 const collection = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});304 const collection = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
305 305
306 await usingApi(async (api, privateKeyWrapper) => {306 await usingApi(async (api, privateKeyWrapper) => {
307 const alice = privateKeyWrapper!('//Alice');307 const alice = privateKeyWrapper('//Alice');
308 const bob = privateKeyWrapper!('//Bob');308 const bob = privateKeyWrapper('//Bob');
309 // Polkadot requires map, and yet requires keys to be JSON encoded309 // Polkadot requires map, and yet requires keys to be JSON encoded
310 const users = new Map();310 const users = new Map();
311 users.set(JSON.stringify({substrate: alice.address}), 1);311 users.set(JSON.stringify({substrate: alice.address}), 1);
modifiedtests/src/creditFeesToTreasury.test.tsdiffbeforeafterboth
65describe('integration test: Fees must be credited to Treasury:', () => {65describe('integration test: Fees must be credited to Treasury:', () => {
66 before(async () => {66 before(async () => {
67 await usingApi(async (api, privateKeyWrapper) => {67 await usingApi(async (api, privateKeyWrapper) => {
68 alice = privateKeyWrapper!('//Alice');68 alice = privateKeyWrapper('//Alice');
69 bob = privateKeyWrapper!('//Bob');69 bob = privateKeyWrapper('//Bob');
70 });70 });
71 });71 });
7272
7777
78 const totalBefore = (await api.query.balances.totalIssuance()).toBigInt();78 const totalBefore = (await api.query.balances.totalIssuance()).toBigInt();
7979
80 const alicePrivateKey = privateKeyWrapper!('//Alice');80 const alicePrivateKey = privateKeyWrapper('//Alice');
81 const amount = 1n;81 const amount = 1n;
82 const transfer = api.tx.balances.transfer(bobsPublicKey, amount);82 const transfer = api.tx.balances.transfer(bobsPublicKey, amount);
8383
95 await skipInflationBlock(api);95 await skipInflationBlock(api);
96 await waitNewBlocks(api, 1);96 await waitNewBlocks(api, 1);
9797
98 const alicePrivateKey = privateKeyWrapper!('//Alice');98 const alicePrivateKey = privateKeyWrapper('//Alice');
99 const treasuryBalanceBefore: bigint = (await api.query.system.account(TREASURY)).data.free.toBigInt();99 const treasuryBalanceBefore: bigint = (await api.query.system.account(TREASURY)).data.free.toBigInt();
100 const aliceBalanceBefore: bigint = (await api.query.system.account(alicesPublicKey)).data.free.toBigInt();100 const aliceBalanceBefore: bigint = (await api.query.system.account(alicesPublicKey)).data.free.toBigInt();
101101
118 //await skipInflationBlock(api);118 //await skipInflationBlock(api);
119 await waitNewBlocks(api, 1);119 await waitNewBlocks(api, 1);
120120
121 const bobPrivateKey = privateKeyWrapper!('//Bob');121 const bobPrivateKey = privateKeyWrapper('//Bob');
122 const treasuryBalanceBefore = (await api.query.system.account(TREASURY)).data.free.toBigInt();122 const treasuryBalanceBefore = (await api.query.system.account(TREASURY)).data.free.toBigInt();
123 const bobBalanceBefore = (await api.query.system.account(bobsPublicKey)).data.free.toBigInt();123 const bobBalanceBefore = (await api.query.system.account(bobsPublicKey)).data.free.toBigInt();
124124
modifiedtests/src/destroyCollection.test.tsdiffbeforeafterboth
5050
51 before(async () => {51 before(async () => {
52 await usingApi(async (api, privateKeyWrapper) => {52 await usingApi(async (api, privateKeyWrapper) => {
53 alice = privateKeyWrapper!('//Alice');53 alice = privateKeyWrapper('//Alice');
54 bob = privateKeyWrapper!('//Bob');54 bob = privateKeyWrapper('//Bob');
55 });55 });
56 });56 });
5757
modifiedtests/src/enableContractSponsoring.test.tsdiffbeforeafterboth
7979
80 before(async () => {80 before(async () => {
81 await usingApi(async (api, privateKeyWrapper) => {81 await usingApi(async (api, privateKeyWrapper) => {
82 alice = privateKeyWrapper!('//Alice');82 alice = privateKeyWrapper('//Alice');
83 });83 });
84 });84 });
8585
modifiedtests/src/enableDisableTransfer.test.tsdiffbeforeafterboth
31describe('Enable/Disable Transfers', () => {31describe('Enable/Disable Transfers', () => {
32 it('User can transfer token with enabled transfer flag', async () => {32 it('User can transfer token with enabled transfer flag', async () => {
33 await usingApi(async (api, privateKeyWrapper) => {33 await usingApi(async (api, privateKeyWrapper) => {
34 const alice = privateKeyWrapper!('//Alice');34 const alice = privateKeyWrapper('//Alice');
35 const bob = privateKeyWrapper!('//Bob');35 const bob = privateKeyWrapper('//Bob');
36 // nft36 // nft
37 const nftCollectionId = await createCollectionExpectSuccess();37 const nftCollectionId = await createCollectionExpectSuccess();
38 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');38 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
4646
47 it('User can\'n transfer token with disabled transfer flag', async () => {47 it('User can\'n transfer token with disabled transfer flag', async () => {
48 await usingApi(async (api, privateKeyWrapper) => {48 await usingApi(async (api, privateKeyWrapper) => {
49 const alice = privateKeyWrapper!('//Alice');49 const alice = privateKeyWrapper('//Alice');
50 const bob = privateKeyWrapper!('//Bob');50 const bob = privateKeyWrapper('//Bob');
51 // nft51 // nft
52 const nftCollectionId = await createCollectionExpectSuccess();52 const nftCollectionId = await createCollectionExpectSuccess();
53 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');53 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
63describe('Negative Enable/Disable Transfers', () => {63describe('Negative Enable/Disable Transfers', () => {
64 it('Non-owner cannot change transfer flag', async () => {64 it('Non-owner cannot change transfer flag', async () => {
65 await usingApi(async (api, privateKeyWrapper) => {65 await usingApi(async (api, privateKeyWrapper) => {
66 const bob = privateKeyWrapper!('//Bob');66 const bob = privateKeyWrapper('//Bob');
67 // nft67 // nft
68 const nftCollectionId = await createCollectionExpectSuccess();68 const nftCollectionId = await createCollectionExpectSuccess();
6969
modifiedtests/src/eth/base.test.tsdiffbeforeafterboth
53 const caller = await createEthAccountWithBalance(api, web3);53 const caller = await createEthAccountWithBalance(api, web3);
54 const receiver = createEthAccount(web3);54 const receiver = createEthAccount(web3);
5555
56 const alice = privateKeyWrapper!('//Alice');56 const alice = privateKeyWrapper('//Alice');
57 const collection = await createCollectionExpectSuccess({57 const collection = await createCollectionExpectSuccess({
58 mode: {type: 'NFT'},58 mode: {type: 'NFT'},
59 });59 });
modifiedtests/src/eth/collectionProperties.test.tsdiffbeforeafterboth
66
7describe('EVM collection properties', () => {7describe('EVM collection properties', () => {
8 itWeb3('Can be set', async({web3, api, privateKeyWrapper}) => {8 itWeb3('Can be set', async({web3, api, privateKeyWrapper}) => {
9 const alice = privateKeyWrapper!('//Alice');9 const alice = privateKeyWrapper('//Alice');
10 const caller = await createEthAccountWithBalance(api, web3);10 const caller = await createEthAccountWithBalance(api, web3);
11 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});11 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
1212
21 expect(value).to.equal('testValue');21 expect(value).to.equal('testValue');
22 });22 });
23 itWeb3('Can be deleted', async({web3, api, privateKeyWrapper}) => {23 itWeb3('Can be deleted', async({web3, api, privateKeyWrapper}) => {
24 const alice = privateKeyWrapper!('//Alice');24 const alice = privateKeyWrapper('//Alice');
25 const caller = await createEthAccountWithBalance(api, web3);25 const caller = await createEthAccountWithBalance(api, web3);
26 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});26 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
2727
38 expect(result.length).to.equal(0);38 expect(result.length).to.equal(0);
39 });39 });
40 itWeb3('Can be read', async({web3, api, privateKeyWrapper}) => {40 itWeb3('Can be read', async({web3, api, privateKeyWrapper}) => {
41 const alice = privateKeyWrapper!('//Alice');41 const alice = privateKeyWrapper('//Alice');
42 const caller = createEthAccount(web3);42 const caller = createEthAccount(web3);
43 const collection = await createCollectionExpectSuccess({mode: {type:'NFT'}});43 const collection = await createCollectionExpectSuccess({mode: {type:'NFT'}});
4444
modifiedtests/src/eth/collectionSponsoring.test.tsdiffbeforeafterboth
55
6describe('evm collection sponsoring', () => {6describe('evm collection sponsoring', () => {
7 itWeb3('sponsors mint transactions', async ({web3, privateKeyWrapper}) => {7 itWeb3('sponsors mint transactions', async ({web3, privateKeyWrapper}) => {
8 const alice = privateKeyWrapper!('//Alice');8 const alice = privateKeyWrapper('//Alice');
99
10 const collection = await createCollectionExpectSuccess();10 const collection = await createCollectionExpectSuccess();
11 await setCollectionSponsorExpectSuccess(collection, alice.address);11 await setCollectionSponsorExpectSuccess(collection, alice.address);
modifiedtests/src/eth/contractSponsoring.test.tsdiffbeforeafterboth
63 });63 });
6464
65 itWeb3('In generous mode, non-allowlisted user transaction will be sponsored', async ({api, web3, privateKeyWrapper}) => {65 itWeb3('In generous mode, non-allowlisted user transaction will be sponsored', async ({api, web3, privateKeyWrapper}) => {
66 const alice = privateKeyWrapper!('//Alice');66 const alice = privateKeyWrapper('//Alice');
6767
68 const owner = await createEthAccountWithBalance(api, web3);68 const owner = await createEthAccountWithBalance(api, web3);
69 const caller = await createEthAccountWithBalance(api, web3);69 const caller = await createEthAccountWithBalance(api, web3);
91 });91 });
9292
93 itWeb3('Sponsoring is set, an address that has no UNQ can send a transaction and it works. Sponsor balance should decrease (allowlisted)', async ({api, web3, privateKeyWrapper}) => {93 itWeb3('Sponsoring is set, an address that has no UNQ can send a transaction and it works. Sponsor balance should decrease (allowlisted)', async ({api, web3, privateKeyWrapper}) => {
94 const alice = privateKeyWrapper!('//Alice');94 const alice = privateKeyWrapper('//Alice');
9595
96 const owner = await createEthAccountWithBalance(api, web3);96 const owner = await createEthAccountWithBalance(api, web3);
97 const caller = createEthAccount(web3);97 const caller = createEthAccount(web3);
121 });121 });
122122
123 itWeb3('Sponsoring is set, an address that has no UNQ can send a transaction and it works. Sponsor balance should not decrease (non-allowlisted)', async ({api, web3, privateKeyWrapper}) => {123 itWeb3('Sponsoring is set, an address that has no UNQ can send a transaction and it works. Sponsor balance should not decrease (non-allowlisted)', async ({api, web3, privateKeyWrapper}) => {
124 const alice = privateKeyWrapper!('//Alice');124 const alice = privateKeyWrapper('//Alice');
125125
126 const owner = await createEthAccountWithBalance(api, web3);126 const owner = await createEthAccountWithBalance(api, web3);
127 const caller = createEthAccount(web3);127 const caller = createEthAccount(web3);
149 });149 });
150150
151 itWeb3('Sponsoring is set, an address that has UNQ can send a transaction and it works. User balance should not change', async ({api, web3, privateKeyWrapper}) => {151 itWeb3('Sponsoring is set, an address that has UNQ can send a transaction and it works. User balance should not change', async ({api, web3, privateKeyWrapper}) => {
152 const alice = privateKeyWrapper!('//Alice');152 const alice = privateKeyWrapper('//Alice');
153153
154 const owner = await createEthAccountWithBalance(api, web3);154 const owner = await createEthAccountWithBalance(api, web3);
155 const caller = await createEthAccountWithBalance(api, web3);155 const caller = await createEthAccountWithBalance(api, web3);
178 });178 });
179179
180 itWeb3('Sponsoring is limited, with setContractRateLimit. The limitation is working if transactions are sent more often, the sender pays the commission.', async ({api, web3, privateKeyWrapper}) => {180 itWeb3('Sponsoring is limited, with setContractRateLimit. The limitation is working if transactions are sent more often, the sender pays the commission.', async ({api, web3, privateKeyWrapper}) => {
181 const alice = privateKeyWrapper!('//Alice');181 const alice = privateKeyWrapper('//Alice');
182182
183 const owner = await createEthAccountWithBalance(api, web3);183 const owner = await createEthAccountWithBalance(api, web3);
184 const caller = await createEthAccountWithBalance(api, web3);184 const caller = await createEthAccountWithBalance(api, web3);
301301
302 //TODO: CORE-302 add eth methods302 //TODO: CORE-302 add eth methods
303 itWeb3.skip('Check that transaction via EVM spend money from substrate address', async ({api, web3, privateKeyWrapper}) => {303 itWeb3.skip('Check that transaction via EVM spend money from substrate address', async ({api, web3, privateKeyWrapper}) => {
304 const owner = privateKeyWrapper!('//Alice');304 const owner = privateKeyWrapper('//Alice');
305 const user = privateKeyWrapper!(`//User/${Date.now()}`);305 const user = privateKeyWrapper(`//User/${Date.now()}`);
306 const userEth = subToEth(user.address);306 const userEth = subToEth(user.address);
307 const collectionId = await createCollectionExpectSuccess();307 const collectionId = await createCollectionExpectSuccess();
308 await addCollectionAdminExpectSuccess(owner, collectionId, {Ethereum: userEth});308 await addCollectionAdminExpectSuccess(owner, collectionId, {Ethereum: userEth});
modifiedtests/src/eth/crossTransfer.test.tsdiffbeforeafterboth
32 name: 'token name',32 name: 'token name',
33 mode: {type: 'Fungible', decimalPoints: 0},33 mode: {type: 'Fungible', decimalPoints: 0},
34 });34 });
35 const alice = privateKeyWrapper!('//Alice');35 const alice = privateKeyWrapper('//Alice');
36 const bob = privateKeyWrapper!('//Bob');36 const bob = privateKeyWrapper('//Bob');
37 const charlie = privateKeyWrapper!('//Charlie');37 const charlie = privateKeyWrapper('//Charlie');
38 await createFungibleItemExpectSuccess(alice, collection, {Value: 200n}, {Substrate: alice.address});38 await createFungibleItemExpectSuccess(alice, collection, {Value: 200n}, {Substrate: alice.address});
39 await transferExpectSuccess(collection, 0, alice, {Ethereum: subToEth(charlie.address)} , 200, 'Fungible');39 await transferExpectSuccess(collection, 0, alice, {Ethereum: subToEth(charlie.address)} , 200, 'Fungible');
40 await transferFromExpectSuccess(collection, 0, alice, {Ethereum: subToEth(charlie.address)}, charlie, 50, 'Fungible');40 await transferFromExpectSuccess(collection, 0, alice, {Ethereum: subToEth(charlie.address)}, charlie, 50, 'Fungible');
46 name: 'token name',46 name: 'token name',
47 mode: {type: 'Fungible', decimalPoints: 0},47 mode: {type: 'Fungible', decimalPoints: 0},
48 });48 });
49 const alice = privateKeyWrapper!('//Alice');49 const alice = privateKeyWrapper('//Alice');
50 const bob = privateKeyWrapper!('//Bob');50 const bob = privateKeyWrapper('//Bob');
51 const bobProxy = await createEthAccountWithBalance(api, web3);51 const bobProxy = await createEthAccountWithBalance(api, web3);
52 const aliceProxy = await createEthAccountWithBalance(api, web3);52 const aliceProxy = await createEthAccountWithBalance(api, web3);
5353
68 name: 'token name',68 name: 'token name',
69 mode: {type: 'NFT'},69 mode: {type: 'NFT'},
70 });70 });
71 const alice = privateKeyWrapper!('//Alice');71 const alice = privateKeyWrapper('//Alice');
72 const bob = privateKeyWrapper!('//Bob');72 const bob = privateKeyWrapper('//Bob');
73 const charlie = privateKeyWrapper!('//Charlie');73 const charlie = privateKeyWrapper('//Charlie');
74 const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Substrate: alice.address});74 const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Substrate: alice.address});
75 await transferExpectSuccess(collection, tokenId, alice, {Ethereum: subToEth(charlie.address)}, 1, 'NFT');75 await transferExpectSuccess(collection, tokenId, alice, {Ethereum: subToEth(charlie.address)}, 1, 'NFT');
76 await transferFromExpectSuccess(collection, tokenId, alice, {Ethereum: subToEth(charlie.address)}, charlie, 1, 'NFT');76 await transferFromExpectSuccess(collection, tokenId, alice, {Ethereum: subToEth(charlie.address)}, charlie, 1, 'NFT');
82 name: 'token name',82 name: 'token name',
83 mode: {type: 'NFT'},83 mode: {type: 'NFT'},
84 });84 });
85 const alice = privateKeyWrapper!('//Alice');85 const alice = privateKeyWrapper('//Alice');
86 const bob = privateKeyWrapper!('//Bob');86 const bob = privateKeyWrapper('//Bob');
87 const charlie = privateKeyWrapper!('//Charlie');87 const charlie = privateKeyWrapper('//Charlie');
88 const bobProxy = await createEthAccountWithBalance(api, web3);88 const bobProxy = await createEthAccountWithBalance(api, web3);
89 const aliceProxy = await createEthAccountWithBalance(api, web3);89 const aliceProxy = await createEthAccountWithBalance(api, web3);
90 const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Substrate: alice.address});90 const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Substrate: alice.address});
modifiedtests/src/eth/fungible.test.tsdiffbeforeafterboth
25 name: 'token name',25 name: 'token name',
26 mode: {type: 'Fungible', decimalPoints: 0},26 mode: {type: 'Fungible', decimalPoints: 0},
27 });27 });
28 const alice = privateKeyWrapper!('//Alice');28 const alice = privateKeyWrapper('//Alice');
2929
30 const caller = await createEthAccountWithBalance(api, web3);30 const caller = await createEthAccountWithBalance(api, web3);
3131
43 name: 'token name',43 name: 'token name',
44 mode: {type: 'Fungible', decimalPoints: 0},44 mode: {type: 'Fungible', decimalPoints: 0},
45 });45 });
46 const alice = privateKeyWrapper!('//Alice');46 const alice = privateKeyWrapper('//Alice');
4747
48 const caller = await createEthAccountWithBalance(api, web3);48 const caller = await createEthAccountWithBalance(api, web3);
4949
63 name: 'token name',63 name: 'token name',
64 mode: {type: 'Fungible', decimalPoints: 0},64 mode: {type: 'Fungible', decimalPoints: 0},
65 });65 });
66 const alice = privateKeyWrapper!('//Alice');66 const alice = privateKeyWrapper('//Alice');
6767
68 const owner = await createEthAccountWithBalance(api, web3);68 const owner = await createEthAccountWithBalance(api, web3);
6969
102 name: 'token name',102 name: 'token name',
103 mode: {type: 'Fungible', decimalPoints: 0},103 mode: {type: 'Fungible', decimalPoints: 0},
104 });104 });
105 const alice = privateKeyWrapper!('//Alice');105 const alice = privateKeyWrapper('//Alice');
106106
107 const owner = createEthAccount(web3);107 const owner = createEthAccount(web3);
108 await transferBalanceToEth(api, alice, owner);108 await transferBalanceToEth(api, alice, owner);
160 name: 'token name',160 name: 'token name',
161 mode: {type: 'Fungible', decimalPoints: 0},161 mode: {type: 'Fungible', decimalPoints: 0},
162 });162 });
163 const alice = privateKeyWrapper!('//Alice');163 const alice = privateKeyWrapper('//Alice');
164164
165 const owner = createEthAccount(web3);165 const owner = createEthAccount(web3);
166 await transferBalanceToEth(api, alice, owner);166 await transferBalanceToEth(api, alice, owner);
206 const collection = await createCollectionExpectSuccess({206 const collection = await createCollectionExpectSuccess({
207 mode: {type: 'Fungible', decimalPoints: 0},207 mode: {type: 'Fungible', decimalPoints: 0},
208 });208 });
209 const alice = privateKeyWrapper!('//Alice');209 const alice = privateKeyWrapper('//Alice');
210210
211 const owner = await createEthAccountWithBalance(api, web3);211 const owner = await createEthAccountWithBalance(api, web3);
212 const spender = createEthAccount(web3);212 const spender = createEthAccount(web3);
224 const collection = await createCollectionExpectSuccess({224 const collection = await createCollectionExpectSuccess({
225 mode: {type: 'Fungible', decimalPoints: 0},225 mode: {type: 'Fungible', decimalPoints: 0},
226 });226 });
227 const alice = privateKeyWrapper!('//Alice');227 const alice = privateKeyWrapper('//Alice');
228228
229 const owner = await createEthAccountWithBalance(api, web3);229 const owner = await createEthAccountWithBalance(api, web3);
230 const spender = await createEthAccountWithBalance(api, web3);230 const spender = await createEthAccountWithBalance(api, web3);
244 const collection = await createCollectionExpectSuccess({244 const collection = await createCollectionExpectSuccess({
245 mode: {type: 'Fungible', decimalPoints: 0},245 mode: {type: 'Fungible', decimalPoints: 0},
246 });246 });
247 const alice = privateKeyWrapper!('//Alice');247 const alice = privateKeyWrapper('//Alice');
248248
249 const owner = await createEthAccountWithBalance(api, web3);249 const owner = await createEthAccountWithBalance(api, web3);
250 const receiver = createEthAccount(web3);250 const receiver = createEthAccount(web3);
264 const collection = await createCollectionExpectSuccess({264 const collection = await createCollectionExpectSuccess({
265 mode: {type: 'Fungible', decimalPoints: 0},265 mode: {type: 'Fungible', decimalPoints: 0},
266 });266 });
267 const alice = privateKeyWrapper!('//Alice');267 const alice = privateKeyWrapper('//Alice');
268268
269 const receiver = createEthAccount(web3);269 const receiver = createEthAccount(web3);
270270
294 const collection = await createCollectionExpectSuccess({294 const collection = await createCollectionExpectSuccess({
295 mode: {type: 'Fungible', decimalPoints: 0},295 mode: {type: 'Fungible', decimalPoints: 0},
296 });296 });
297 const alice = privateKeyWrapper!('//Alice');297 const alice = privateKeyWrapper('//Alice');
298 const bob = privateKeyWrapper!('//Bob');298 const bob = privateKeyWrapper('//Bob');
299299
300 const receiver = createEthAccount(web3);300 const receiver = createEthAccount(web3);
301301
335 const collection = await createCollectionExpectSuccess({335 const collection = await createCollectionExpectSuccess({
336 mode: {type: 'Fungible', decimalPoints: 0},336 mode: {type: 'Fungible', decimalPoints: 0},
337 });337 });
338 const alice = privateKeyWrapper!('//Alice');338 const alice = privateKeyWrapper('//Alice');
339339
340 const receiver = createEthAccount(web3);340 const receiver = createEthAccount(web3);
341341
modifiedtests/src/eth/marketplace/marketplace.test.tsdiffbeforeafterboth
3838
39describe('Matcher contract usage', () => {39describe('Matcher contract usage', () => {
40 itWeb3('With UNQ', async ({api, web3, privateKeyWrapper}) => {40 itWeb3('With UNQ', async ({api, web3, privateKeyWrapper}) => {
41 const alice = privateKeyWrapper!('//Alice');41 const alice = privateKeyWrapper('//Alice');
42 const matcherOwner = await createEthAccountWithBalance(api, web3);42 const matcherOwner = await createEthAccountWithBalance(api, web3);
43 const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {43 const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {
44 from: matcherOwner,44 from: matcherOwner,
60 await helpers.methods.toggleAllowed(matcher.options.address, subToEth(alice.address), true).send({from: matcherOwner});60 await helpers.methods.toggleAllowed(matcher.options.address, subToEth(alice.address), true).send({from: matcherOwner});
61 await addToAllowListExpectSuccess(alice, collectionId, evmToAddress(subToEth(alice.address)));61 await addToAllowListExpectSuccess(alice, collectionId, evmToAddress(subToEth(alice.address)));
6262
63 const seller = privateKeyWrapper!(`//Seller/${Date.now()}`);63 const seller = privateKeyWrapper(`//Seller/${Date.now()}`);
64 await helpers.methods.toggleAllowed(matcher.options.address, subToEth(seller.address), true).send({from: matcherOwner});64 await helpers.methods.toggleAllowed(matcher.options.address, subToEth(seller.address), true).send({from: matcherOwner});
6565
66 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);66 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);
9999
100100
101 itWeb3('With escrow', async ({api, web3, privateKeyWrapper}) => {101 itWeb3('With escrow', async ({api, web3, privateKeyWrapper}) => {
102 const alice = privateKeyWrapper!('//Alice');102 const alice = privateKeyWrapper('//Alice');
103 const matcherOwner = await createEthAccountWithBalance(api, web3);103 const matcherOwner = await createEthAccountWithBalance(api, web3);
104 const escrow = await createEthAccountWithBalance(api, web3);104 const escrow = await createEthAccountWithBalance(api, web3);
105 const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {105 const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {
123 await helpers.methods.toggleAllowed(matcher.options.address, subToEth(alice.address), true).send({from: matcherOwner});123 await helpers.methods.toggleAllowed(matcher.options.address, subToEth(alice.address), true).send({from: matcherOwner});
124 await addToAllowListExpectSuccess(alice, collectionId, evmToAddress(subToEth(alice.address)));124 await addToAllowListExpectSuccess(alice, collectionId, evmToAddress(subToEth(alice.address)));
125125
126 const seller = privateKeyWrapper!(`//Seller/${Date.now()}`);126 const seller = privateKeyWrapper(`//Seller/${Date.now()}`);
127 await helpers.methods.toggleAllowed(matcher.options.address, subToEth(seller.address), true).send({from: matcherOwner});127 await helpers.methods.toggleAllowed(matcher.options.address, subToEth(seller.address), true).send({from: matcherOwner});
128128
129 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);129 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);
170170
171171
172 itWeb3('Sell tokens from substrate user via EVM contract', async ({api, web3, privateKeyWrapper}) => {172 itWeb3('Sell tokens from substrate user via EVM contract', async ({api, web3, privateKeyWrapper}) => {
173 const alice = privateKeyWrapper!('//Alice');173 const alice = privateKeyWrapper('//Alice');
174 const matcherOwner = await createEthAccountWithBalance(api, web3);174 const matcherOwner = await createEthAccountWithBalance(api, web3);
175 const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {175 const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {
176 from: matcherOwner,176 from: matcherOwner,
183 await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorApproveTimeout: 1});183 await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorApproveTimeout: 1});
184 const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collectionId), {from: matcherOwner});184 const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collectionId), {from: matcherOwner});
185185
186 const seller = privateKeyWrapper!(`//Seller/${Date.now()}`);186 const seller = privateKeyWrapper(`//Seller/${Date.now()}`);
187 await transferBalanceTo(api, alice, seller.address);187 await transferBalanceTo(api, alice, seller.address);
188 188
189 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);189 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);
modifiedtests/src/eth/migration.test.tsdiffbeforeafterboth
53 ['0xedc95719e9a3b28dd8e80877cb5880a9be7de1a13fc8b05e7999683b6b567643', '0x0000000000000000000000000000000000000000000000000000000000000004'],53 ['0xedc95719e9a3b28dd8e80877cb5880a9be7de1a13fc8b05e7999683b6b567643', '0x0000000000000000000000000000000000000000000000000000000000000004'],
54 ];54 ];
5555
56 const alice = privateKeyWrapper!('//Alice');56 const alice = privateKeyWrapper('//Alice');
57 const caller = await createEthAccountWithBalance(api, web3);57 const caller = await createEthAccountWithBalance(api, web3);
5858
59 await submitTransactionAsync(alice, api.tx.sudo.sudo(api.tx.evmMigration.begin(ADDRESS) as any));59 await submitTransactionAsync(alice, api.tx.sudo.sudo(api.tx.evmMigration.begin(ADDRESS) as any));
modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
25 const collection = await createCollectionExpectSuccess({25 const collection = await createCollectionExpectSuccess({
26 mode: {type: 'NFT'},26 mode: {type: 'NFT'},
27 });27 });
28 const alice = privateKeyWrapper!('//Alice');28 const alice = privateKeyWrapper('//Alice');
29 const caller = await createEthAccountWithBalance(api, web3);29 const caller = await createEthAccountWithBalance(api, web3);
3030
31 await createItemExpectSuccess(alice, collection, 'NFT', {Substrate: alice.address});31 await createItemExpectSuccess(alice, collection, 'NFT', {Substrate: alice.address});
41 const collection = await createCollectionExpectSuccess({41 const collection = await createCollectionExpectSuccess({
42 mode: {type: 'NFT'},42 mode: {type: 'NFT'},
43 });43 });
44 const alice = privateKeyWrapper!('//Alice');44 const alice = privateKeyWrapper('//Alice');
4545
46 const caller = await createEthAccountWithBalance(api, web3);46 const caller = await createEthAccountWithBalance(api, web3);
47 await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum:caller});47 await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum:caller});
59 const collection = await createCollectionExpectSuccess({59 const collection = await createCollectionExpectSuccess({
60 mode: {type: 'NFT'},60 mode: {type: 'NFT'},
61 });61 });
62 const alice = privateKeyWrapper!('//Alice');62 const alice = privateKeyWrapper('//Alice');
6363
64 const caller = await createEthAccountWithBalance(api, web3);64 const caller = await createEthAccountWithBalance(api, web3);
65 const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: caller});65 const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: caller});
117 const collection = await createCollectionExpectSuccess({117 const collection = await createCollectionExpectSuccess({
118 mode: {type: 'NFT'},118 mode: {type: 'NFT'},
119 });119 });
120 const alice = privateKeyWrapper!('//Alice');120 const alice = privateKeyWrapper('//Alice');
121121
122 const caller = await createEthAccountWithBalance(api, web3);122 const caller = await createEthAccountWithBalance(api, web3);
123 const changeAdminTx = api.tx.unique.addCollectionAdmin(collection, {Ethereum: caller});123 const changeAdminTx = api.tx.unique.addCollectionAdmin(collection, {Ethereum: caller});
180 const collection = await createCollectionExpectSuccess({180 const collection = await createCollectionExpectSuccess({
181 mode: {type: 'NFT'},181 mode: {type: 'NFT'},
182 });182 });
183 const alice = privateKeyWrapper!('//Alice');183 const alice = privateKeyWrapper('//Alice');
184184
185 const owner = await createEthAccountWithBalance(api, web3);185 const owner = await createEthAccountWithBalance(api, web3);
186186
211 const collection = await createCollectionExpectSuccess({211 const collection = await createCollectionExpectSuccess({
212 mode: {type: 'NFT'},212 mode: {type: 'NFT'},
213 });213 });
214 const alice = privateKeyWrapper!('//Alice');214 const alice = privateKeyWrapper('//Alice');
215215
216 const owner = createEthAccount(web3);216 const owner = createEthAccount(web3);
217 await transferBalanceToEth(api, alice, owner);217 await transferBalanceToEth(api, alice, owner);
245 const collection = await createCollectionExpectSuccess({245 const collection = await createCollectionExpectSuccess({
246 mode: {type: 'NFT'},246 mode: {type: 'NFT'},
247 });247 });
248 const alice = privateKeyWrapper!('//Alice');248 const alice = privateKeyWrapper('//Alice');
249249
250 const owner = createEthAccount(web3);250 const owner = createEthAccount(web3);
251 await transferBalanceToEth(api, alice, owner);251 await transferBalanceToEth(api, alice, owner);
293 const collection = await createCollectionExpectSuccess({293 const collection = await createCollectionExpectSuccess({
294 mode: {type: 'NFT'},294 mode: {type: 'NFT'},
295 });295 });
296 const alice = privateKeyWrapper!('//Alice');296 const alice = privateKeyWrapper('//Alice');
297297
298 const owner = createEthAccount(web3);298 const owner = createEthAccount(web3);
299 await transferBalanceToEth(api, alice, owner);299 await transferBalanceToEth(api, alice, owner);
339 const collection = await createCollectionExpectSuccess({339 const collection = await createCollectionExpectSuccess({
340 mode: {type: 'NFT'},340 mode: {type: 'NFT'},
341 });341 });
342 const alice = privateKeyWrapper!('//Alice');342 const alice = privateKeyWrapper('//Alice');
343343
344 const owner = await createEthAccountWithBalance(api, web3);344 const owner = await createEthAccountWithBalance(api, web3);
345 const spender = createEthAccount(web3);345 const spender = createEthAccount(web3);
357 const collection = await createCollectionExpectSuccess({357 const collection = await createCollectionExpectSuccess({
358 mode: {type: 'NFT'},358 mode: {type: 'NFT'},
359 });359 });
360 const alice = privateKeyWrapper!('//Alice');360 const alice = privateKeyWrapper('//Alice');
361361
362 const owner = await createEthAccountWithBalance(api, web3);362 const owner = await createEthAccountWithBalance(api, web3);
363 const spender = await createEthAccountWithBalance(api, web3);363 const spender = await createEthAccountWithBalance(api, web3);
377 const collection = await createCollectionExpectSuccess({377 const collection = await createCollectionExpectSuccess({
378 mode: {type: 'NFT'},378 mode: {type: 'NFT'},
379 });379 });
380 const alice = privateKeyWrapper!('//Alice');380 const alice = privateKeyWrapper('//Alice');
381381
382 const owner = await createEthAccountWithBalance(api, web3);382 const owner = await createEthAccountWithBalance(api, web3);
383 const receiver = createEthAccount(web3);383 const receiver = createEthAccount(web3);
397 const collection = await createCollectionExpectSuccess({397 const collection = await createCollectionExpectSuccess({
398 mode: {type: 'NFT'},398 mode: {type: 'NFT'},
399 });399 });
400 const alice = privateKeyWrapper!('//Alice');400 const alice = privateKeyWrapper('//Alice');
401401
402 const address = collectionIdToAddress(collection);402 const address = collectionIdToAddress(collection);
403 const contract = new web3.eth.Contract(nonFungibleAbi as any, address);403 const contract = new web3.eth.Contract(nonFungibleAbi as any, address);
424 const collection = await createCollectionExpectSuccess({424 const collection = await createCollectionExpectSuccess({
425 mode: {type: 'NFT'},425 mode: {type: 'NFT'},
426 });426 });
427 const alice = privateKeyWrapper!('//Alice');427 const alice = privateKeyWrapper('//Alice');
428428
429 const address = collectionIdToAddress(collection);429 const address = collectionIdToAddress(collection);
430 const contract = new web3.eth.Contract(nonFungibleAbi as any, address);430 const contract = new web3.eth.Contract(nonFungibleAbi as any, address);
451 const collection = await createCollectionExpectSuccess({451 const collection = await createCollectionExpectSuccess({
452 mode: {type: 'NFT'},452 mode: {type: 'NFT'},
453 });453 });
454 const alice = privateKeyWrapper!('//Alice');454 const alice = privateKeyWrapper('//Alice');
455455
456 const receiver = createEthAccount(web3);456 const receiver = createEthAccount(web3);
457457
481 const collection = await createCollectionExpectSuccess({481 const collection = await createCollectionExpectSuccess({
482 mode: {type: 'NFT'},482 mode: {type: 'NFT'},
483 });483 });
484 const alice = privateKeyWrapper!('//Alice');484 const alice = privateKeyWrapper('//Alice');
485 const bob = privateKeyWrapper!('//Bob');485 const bob = privateKeyWrapper('//Bob');
486486
487 const receiver = createEthAccount(web3);487 const receiver = createEthAccount(web3);
488488
513 const collection = await createCollectionExpectSuccess({513 const collection = await createCollectionExpectSuccess({
514 mode: {type: 'NFT'},514 mode: {type: 'NFT'},
515 });515 });
516 const alice = privateKeyWrapper!('//Alice');516 const alice = privateKeyWrapper('//Alice');
517517
518 const receiver = createEthAccount(web3);518 const receiver = createEthAccount(web3);
519519
modifiedtests/src/eth/payable.test.tsdiffbeforeafterboth
34 itWeb3('Evm contract can receive wei from substrate account', async ({api, web3, privateKeyWrapper}) => {34 itWeb3('Evm contract can receive wei from substrate account', async ({api, web3, privateKeyWrapper}) => {
35 const deployer = await createEthAccountWithBalance(api, web3);35 const deployer = await createEthAccountWithBalance(api, web3);
36 const contract = await deployCollector(web3, deployer);36 const contract = await deployCollector(web3, deployer);
37 const alice = privateKeyWrapper!('//Alice');37 const alice = privateKeyWrapper('//Alice');
3838
39 // Transaction fee/value will be payed from subToEth(sender) evm balance,39 // Transaction fee/value will be payed from subToEth(sender) evm balance,
40 // which is backed by evmToAddress(subToEth(sender)) substrate balance40 // which is backed by evmToAddress(subToEth(sender)) substrate balance
64 itWeb3('Wei sent directly to backing storage of evm contract balance is unaccounted', async({api, web3, privateKeyWrapper}) => {64 itWeb3('Wei sent directly to backing storage of evm contract balance is unaccounted', async({api, web3, privateKeyWrapper}) => {
65 const deployer = await createEthAccountWithBalance(api, web3);65 const deployer = await createEthAccountWithBalance(api, web3);
66 const contract = await deployCollector(web3, deployer);66 const contract = await deployCollector(web3, deployer);
67 const alice = privateKeyWrapper!('//Alice');67 const alice = privateKeyWrapper('//Alice');
6868
69 await transferBalanceExpectSuccess(api, alice, evmToAddress(contract.options.address), '10000');69 await transferBalanceExpectSuccess(api, alice, evmToAddress(contract.options.address), '10000');
7070
7777
78 const deployer = await createEthAccountWithBalance(api, web3);78 const deployer = await createEthAccountWithBalance(api, web3);
79 const contract = await deployCollector(web3, deployer);79 const contract = await deployCollector(web3, deployer);
80 const alice = privateKeyWrapper!('//Alice');80 const alice = privateKeyWrapper('//Alice');
8181
82 await web3.eth.sendTransaction({from: deployer, to: contract.options.address, value: CONTRACT_BALANCE.toString(), ...GAS_ARGS});82 await web3.eth.sendTransaction({from: deployer, to: contract.options.address, value: CONTRACT_BALANCE.toString(), ...GAS_ARGS});
8383
84 const receiver = privateKeyWrapper!(`//Receiver${Date.now()}`);84 const receiver = privateKeyWrapper(`//Receiver${Date.now()}`);
8585
86 // First receive balance on eth balance of bob86 // First receive balance on eth balance of bob
87 {87 {
modifiedtests/src/eth/proxy/fungibleProxy.test.tsdiffbeforeafterboth
39 name: 'token name',39 name: 'token name',
40 mode: {type: 'Fungible', decimalPoints: 0},40 mode: {type: 'Fungible', decimalPoints: 0},
41 });41 });
42 const alice = privateKeyWrapper!('//Alice');42 const alice = privateKeyWrapper('//Alice');
43 const caller = await createEthAccountWithBalance(api, web3);43 const caller = await createEthAccountWithBalance(api, web3);
4444
45 await createFungibleItemExpectSuccess(alice, collection, {Value: 200n}, {Substrate: alice.address});45 await createFungibleItemExpectSuccess(alice, collection, {Value: 200n}, {Substrate: alice.address});
56 name: 'token name',56 name: 'token name',
57 mode: {type: 'Fungible', decimalPoints: 0},57 mode: {type: 'Fungible', decimalPoints: 0},
58 });58 });
59 const alice = privateKeyWrapper!('//Alice');59 const alice = privateKeyWrapper('//Alice');
60 const caller = await createEthAccountWithBalance(api, web3);60 const caller = await createEthAccountWithBalance(api, web3);
6161
62 await createFungibleItemExpectSuccess(alice, collection, {Value: 200n}, {Ethereum: caller});62 await createFungibleItemExpectSuccess(alice, collection, {Value: 200n}, {Ethereum: caller});
75 name: 'token name',75 name: 'token name',
76 mode: {type: 'Fungible', decimalPoints: 0},76 mode: {type: 'Fungible', decimalPoints: 0},
77 });77 });
78 const alice = privateKeyWrapper!('//Alice');78 const alice = privateKeyWrapper('//Alice');
79 const caller = await createEthAccountWithBalance(api, web3);79 const caller = await createEthAccountWithBalance(api, web3);
80 const spender = createEthAccount(web3);80 const spender = createEthAccount(web3);
8181
111 name: 'token name',111 name: 'token name',
112 mode: {type: 'Fungible', decimalPoints: 0},112 mode: {type: 'Fungible', decimalPoints: 0},
113 });113 });
114 const alice = privateKeyWrapper!('//Alice');114 const alice = privateKeyWrapper('//Alice');
115 const caller = await createEthAccountWithBalance(api, web3);115 const caller = await createEthAccountWithBalance(api, web3);
116 const owner = await createEthAccountWithBalance(api, web3);116 const owner = await createEthAccountWithBalance(api, web3);
117117
166 name: 'token name',166 name: 'token name',
167 mode: {type: 'Fungible', decimalPoints: 0},167 mode: {type: 'Fungible', decimalPoints: 0},
168 });168 });
169 const alice = privateKeyWrapper!('//Alice');169 const alice = privateKeyWrapper('//Alice');
170 const caller = await createEthAccountWithBalance(api, web3);170 const caller = await createEthAccountWithBalance(api, web3);
171 const receiver = await createEthAccountWithBalance(api, web3);171 const receiver = await createEthAccountWithBalance(api, web3);
172172
modifiedtests/src/eth/proxy/nonFungibleProxy.test.tsdiffbeforeafterboth
39 const collection = await createCollectionExpectSuccess({39 const collection = await createCollectionExpectSuccess({
40 mode: {type: 'NFT'},40 mode: {type: 'NFT'},
41 });41 });
42 const alice = privateKeyWrapper!('//Alice');42 const alice = privateKeyWrapper('//Alice');
43 const caller = await createEthAccountWithBalance(api, web3);43 const caller = await createEthAccountWithBalance(api, web3);
4444
45 await createItemExpectSuccess(alice, collection, 'NFT', {Substrate: alice.address});45 await createItemExpectSuccess(alice, collection, 'NFT', {Substrate: alice.address});
55 const collection = await createCollectionExpectSuccess({55 const collection = await createCollectionExpectSuccess({
56 mode: {type: 'NFT'},56 mode: {type: 'NFT'},
57 });57 });
58 const alice = privateKeyWrapper!('//Alice');58 const alice = privateKeyWrapper('//Alice');
5959
60 const caller = await createEthAccountWithBalance(api, web3);60 const caller = await createEthAccountWithBalance(api, web3);
61 await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: caller});61 await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: caller});
73 const collection = await createCollectionExpectSuccess({73 const collection = await createCollectionExpectSuccess({
74 mode: {type: 'NFT'},74 mode: {type: 'NFT'},
75 });75 });
76 const alice = privateKeyWrapper!('//Alice');76 const alice = privateKeyWrapper('//Alice');
7777
78 const caller = await createEthAccountWithBalance(api, web3);78 const caller = await createEthAccountWithBalance(api, web3);
79 const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: caller});79 const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: caller});
92 const collection = await createCollectionExpectSuccess({92 const collection = await createCollectionExpectSuccess({
93 mode: {type: 'NFT'},93 mode: {type: 'NFT'},
94 });94 });
95 const alice = privateKeyWrapper!('//Alice');95 const alice = privateKeyWrapper('//Alice');
96 const caller = await createEthAccountWithBalance(api, web3);96 const caller = await createEthAccountWithBalance(api, web3);
97 const receiver = createEthAccount(web3);97 const receiver = createEthAccount(web3);
9898
133 const collection = await createCollectionExpectSuccess({133 const collection = await createCollectionExpectSuccess({
134 mode: {type: 'NFT'},134 mode: {type: 'NFT'},
135 });135 });
136 const alice = privateKeyWrapper!('//Alice');136 const alice = privateKeyWrapper('//Alice');
137137
138 const caller = await createEthAccountWithBalance(api, web3);138 const caller = await createEthAccountWithBalance(api, web3);
139 const receiver = createEthAccount(web3);139 const receiver = createEthAccount(web3);
196 const collection = await createCollectionExpectSuccess({196 const collection = await createCollectionExpectSuccess({
197 mode: {type: 'NFT'},197 mode: {type: 'NFT'},
198 });198 });
199 const alice = privateKeyWrapper!('//Alice');199 const alice = privateKeyWrapper('//Alice');
200 const caller = await createEthAccountWithBalance(api, web3);200 const caller = await createEthAccountWithBalance(api, web3);
201201
202 const address = collectionIdToAddress(collection);202 const address = collectionIdToAddress(collection);
228 const collection = await createCollectionExpectSuccess({228 const collection = await createCollectionExpectSuccess({
229 mode: {type: 'NFT'},229 mode: {type: 'NFT'},
230 });230 });
231 const alice = privateKeyWrapper!('//Alice');231 const alice = privateKeyWrapper('//Alice');
232 const caller = await createEthAccountWithBalance(api, web3);232 const caller = await createEthAccountWithBalance(api, web3);
233 const spender = createEthAccount(web3);233 const spender = createEthAccount(web3);
234234
258 const collection = await createCollectionExpectSuccess({258 const collection = await createCollectionExpectSuccess({
259 mode: {type: 'NFT'},259 mode: {type: 'NFT'},
260 });260 });
261 const alice = privateKeyWrapper!('//Alice');261 const alice = privateKeyWrapper('//Alice');
262 const caller = await createEthAccountWithBalance(api, web3);262 const caller = await createEthAccountWithBalance(api, web3);
263 const owner = await createEthAccountWithBalance(api, web3);263 const owner = await createEthAccountWithBalance(api, web3);
264264
302 const collection = await createCollectionExpectSuccess({302 const collection = await createCollectionExpectSuccess({
303 mode: {type: 'NFT'},303 mode: {type: 'NFT'},
304 });304 });
305 const alice = privateKeyWrapper!('//Alice');305 const alice = privateKeyWrapper('//Alice');
306 const caller = await createEthAccountWithBalance(api, web3);306 const caller = await createEthAccountWithBalance(api, web3);
307 const receiver = createEthAccount(web3);307 const receiver = createEthAccount(web3);
308308
modifiedtests/src/eth/sponsoring.test.tsdiffbeforeafterboth
1919
20describe('EVM sponsoring', () => {20describe('EVM sponsoring', () => {
21 itWeb3('Fee is deducted from contract if sponsoring is enabled', async ({api, web3, privateKeyWrapper}) => {21 itWeb3('Fee is deducted from contract if sponsoring is enabled', async ({api, web3, privateKeyWrapper}) => {
22 const alice = privateKeyWrapper!('//Alice');22 const alice = privateKeyWrapper('//Alice');
2323
24 const owner = await createEthAccountWithBalance(api, web3);24 const owner = await createEthAccountWithBalance(api, web3);
25 const caller = createEthAccount(web3);25 const caller = createEthAccount(web3);
50 expect(await web3.eth.getBalance(flipper.options.address)).to.be.not.equals(originalFlipperBalance);50 expect(await web3.eth.getBalance(flipper.options.address)).to.be.not.equals(originalFlipperBalance);
51 });51 });
52 itWeb3('...but this doesn\'t applies to payable value', async ({api, web3, privateKeyWrapper}) => {52 itWeb3('...but this doesn\'t applies to payable value', async ({api, web3, privateKeyWrapper}) => {
53 const alice = privateKeyWrapper!('//Alice');53 const alice = privateKeyWrapper('//Alice');
5454
55 const owner = await createEthAccountWithBalance(api, web3);55 const owner = await createEthAccountWithBalance(api, web3);
56 const caller = await createEthAccountWithBalance(api, web3);56 const caller = await createEthAccountWithBalance(api, web3);
modifiedtests/src/eth/tokenProperties.test.tsdiffbeforeafterboth
66
7describe('EVM token properties', () => {7describe('EVM token properties', () => {
8 itWeb3('Can be reconfigured', async({web3, api, privateKeyWrapper}) => {8 itWeb3('Can be reconfigured', async({web3, api, privateKeyWrapper}) => {
9 const alice = privateKeyWrapper!('//Alice');9 const alice = privateKeyWrapper('//Alice');
10 const caller = await createEthAccountWithBalance(api, web3);10 const caller = await createEthAccountWithBalance(api, web3);
11 for(const [mutable,collectionAdmin, tokenOwner] of cartesian([], [false, true], [false, true], [false, true])) {11 for(const [mutable,collectionAdmin, tokenOwner] of cartesian([], [false, true], [false, true], [false, true])) {
12 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});12 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
24 }24 }
25 });25 });
26 itWeb3('Can be set', async({web3, api, privateKeyWrapper}) => {26 itWeb3('Can be set', async({web3, api, privateKeyWrapper}) => {
27 const alice = privateKeyWrapper!('//Alice');27 const alice = privateKeyWrapper('//Alice');
28 const caller = await createEthAccountWithBalance(api, web3);28 const caller = await createEthAccountWithBalance(api, web3);
29 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});29 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
30 const token = await createItemExpectSuccess(alice, collection, 'NFT');30 const token = await createItemExpectSuccess(alice, collection, 'NFT');
47 expect(value).to.equal('testValue');47 expect(value).to.equal('testValue');
48 });48 });
49 itWeb3('Can be deleted', async({web3, api, privateKeyWrapper}) => {49 itWeb3('Can be deleted', async({web3, api, privateKeyWrapper}) => {
50 const alice = privateKeyWrapper!('//Alice');50 const alice = privateKeyWrapper('//Alice');
51 const caller = await createEthAccountWithBalance(api, web3);51 const caller = await createEthAccountWithBalance(api, web3);
52 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});52 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
53 const token = await createItemExpectSuccess(alice, collection, 'NFT');53 const token = await createItemExpectSuccess(alice, collection, 'NFT');
72 expect(result.length).to.equal(0);72 expect(result.length).to.equal(0);
73 });73 });
74 itWeb3('Can be read', async({web3, api, privateKeyWrapper}) => {74 itWeb3('Can be read', async({web3, api, privateKeyWrapper}) => {
75 const alice = privateKeyWrapper!('//Alice');75 const alice = privateKeyWrapper('//Alice');
76 const caller = createEthAccount(web3);76 const caller = createEthAccount(web3);
77 const collection = await createCollectionExpectSuccess({mode: {type:'NFT'}});77 const collection = await createCollectionExpectSuccess({mode: {type:'NFT'}});
78 const token = await createItemExpectSuccess(alice, collection, 'NFT');78 const token = await createItemExpectSuccess(alice, collection, 'NFT');
modifiedtests/src/eth/util/helpers.tsdiffbeforeafterboth
127 expect(result.success).to.be.true;127 expect(result.success).to.be.true;
128}128}
129129
130export async function itWeb3(name: string, cb: (apis: { web3: Web3, api: ApiPromise, privateKeyWrapper?: (account: string) => IKeyringPair }) => any, opts: { only?: boolean, skip?: boolean } = {}) {130export async function itWeb3(name: string, cb: (apis: { web3: Web3, api: ApiPromise, privateKeyWrapper: (account: string) => IKeyringPair }) => any, opts: { only?: boolean, skip?: boolean } = {}) {
131 let i: any = it;131 let i: any = it;
132 if (opts.only) i = i.only;132 if (opts.only) i = i.only;
133 else if (opts.skip) i = i.skip;133 else if (opts.skip) i = i.skip;
139 });139 });
140 });140 });
141}141}
142itWeb3.only = (name: string, cb: (apis: { web3: Web3, api: ApiPromise, privateKeyWrapper?: (account: string) => IKeyringPair }) => any) => itWeb3(name, cb, {only: true});142itWeb3.only = (name: string, cb: (apis: { web3: Web3, api: ApiPromise, privateKeyWrapper: (account: string) => IKeyringPair }) => any) => itWeb3(name, cb, {only: true});
143itWeb3.skip = (name: string, cb: (apis: { web3: Web3, api: ApiPromise, privateKeyWrapper?: (account: string) => IKeyringPair }) => any) => itWeb3(name, cb, {skip: true});143itWeb3.skip = (name: string, cb: (apis: { web3: Web3, api: ApiPromise, privateKeyWrapper: (account: string) => IKeyringPair }) => any) => itWeb3(name, cb, {skip: true});
144144
145export async function generateSubstrateEthPair(web3: Web3) {145export async function generateSubstrateEthPair(web3: Web3) {
146 const account = web3.eth.accounts.create();146 const account = web3.eth.accounts.create();
modifiedtests/src/inflation.test.tsdiffbeforeafterboth
2727
28 // Make sure non-sudo can't start inflation28 // Make sure non-sudo can't start inflation
29 const tx = api.tx.inflation.startInflation(1);29 const tx = api.tx.inflation.startInflation(1);
30 const bob = privateKeyWrapper!('//Bob');30 const bob = privateKeyWrapper('//Bob');
31 await expect(submitTransactionExpectFailAsync(bob, tx)).to.be.rejected;31 await expect(submitTransactionExpectFailAsync(bob, tx)).to.be.rejected;
3232
33 // Start inflation on relay block 1 (Alice is sudo)33 // Start inflation on relay block 1 (Alice is sudo)
34 const alice = privateKeyWrapper!('//Alice');34 const alice = privateKeyWrapper('//Alice');
35 const sudoTx = api.tx.sudo.sudo(tx as any);35 const sudoTx = api.tx.sudo.sudo(tx as any);
36 await submitTransactionAsync(alice, sudoTx);36 await submitTransactionAsync(alice, sudoTx);
3737
modifiedtests/src/limits.test.tsdiffbeforeafterboth
3535
36 before(async () => {36 before(async () => {
37 await usingApi(async (api, privateKeyWrapper) => {37 await usingApi(async (api, privateKeyWrapper) => {
38 alice = privateKeyWrapper!('//Alice');38 alice = privateKeyWrapper('//Alice');
39 });39 });
40 });40 });
4141
6969
70 before(async () => {70 before(async () => {
71 await usingApi(async (api, privateKeyWrapper) => {71 await usingApi(async (api, privateKeyWrapper) => {
72 alice = privateKeyWrapper!('//Alice');72 alice = privateKeyWrapper('//Alice');
73 });73 });
74 });74 });
7575
103103
104 before(async () => {104 before(async () => {
105 await usingApi(async (api, privateKeyWrapper) => {105 await usingApi(async (api, privateKeyWrapper) => {
106 alice = privateKeyWrapper!('//Alice');106 alice = privateKeyWrapper('//Alice');
107 bob = privateKeyWrapper!('//Bob');107 bob = privateKeyWrapper('//Bob');
108 charlie = privateKeyWrapper!('//Charlie');108 charlie = privateKeyWrapper('//Charlie');
109 });109 });
110 });110 });
111111
166166
167 before(async () => {167 before(async () => {
168 await usingApi(async (api, privateKeyWrapper) => {168 await usingApi(async (api, privateKeyWrapper) => {
169 alice = privateKeyWrapper!('//Alice');169 alice = privateKeyWrapper('//Alice');
170 bob = privateKeyWrapper!('//Bob');170 bob = privateKeyWrapper('//Bob');
171 charlie = privateKeyWrapper!('//Charlie');171 charlie = privateKeyWrapper('//Charlie');
172 });172 });
173 });173 });
174174
233233
234 before(async () => {234 before(async () => {
235 await usingApi(async (api, privateKeyWrapper) => {235 await usingApi(async (api, privateKeyWrapper) => {
236 alice = privateKeyWrapper!('//Alice');236 alice = privateKeyWrapper('//Alice');
237 bob = privateKeyWrapper!('//Bob');237 bob = privateKeyWrapper('//Bob');
238 charlie = privateKeyWrapper!('//Charlie');238 charlie = privateKeyWrapper('//Charlie');
239 });239 });
240 });240 });
241241
296296
297 before(async () => {297 before(async () => {
298 await usingApi(async (api, privateKeyWrapper) => {298 await usingApi(async (api, privateKeyWrapper) => {
299 alice = privateKeyWrapper!('//Alice');299 alice = privateKeyWrapper('//Alice');
300 bob = privateKeyWrapper!('//Bob');300 bob = privateKeyWrapper('//Bob');
301 charlie = privateKeyWrapper!('//Charlie');301 charlie = privateKeyWrapper('//Charlie');
302 });302 });
303 });303 });
304304
337337
338 before(async () => {338 before(async () => {
339 await usingApi(async (api, privateKeyWrapper) => {339 await usingApi(async (api, privateKeyWrapper) => {
340 alice = privateKeyWrapper!('//Alice');340 alice = privateKeyWrapper('//Alice');
341 bob = privateKeyWrapper!('//Bob');341 bob = privateKeyWrapper('//Bob');
342 charlie = privateKeyWrapper!('//Charlie');342 charlie = privateKeyWrapper('//Charlie');
343 });343 });
344 });344 });
345345
369369
370 before(async () => {370 before(async () => {
371 await usingApi(async (api, privateKeyWrapper) => {371 await usingApi(async (api, privateKeyWrapper) => {
372 alice = privateKeyWrapper!('//Alice');372 alice = privateKeyWrapper('//Alice');
373 bob = privateKeyWrapper!('//Bob');373 bob = privateKeyWrapper('//Bob');
374 charlie = privateKeyWrapper!('//Charlie');374 charlie = privateKeyWrapper('//Charlie');
375 });375 });
376 });376 });
377377
modifiedtests/src/mintModes.test.tsdiffbeforeafterboth
3333
34 before(async () => {34 before(async () => {
35 await usingApi(async (api, privateKeyWrapper) => {35 await usingApi(async (api, privateKeyWrapper) => {
36 alice = privateKeyWrapper!('//Alice');36 alice = privateKeyWrapper('//Alice');
37 bob = privateKeyWrapper!('//Bob');37 bob = privateKeyWrapper('//Bob');
38 });38 });
39 });39 });
4040
112112
113 before(async () => {113 before(async () => {
114 await usingApi(async (api, privateKeyWrapper) => {114 await usingApi(async (api, privateKeyWrapper) => {
115 alice = privateKeyWrapper!('//Alice');115 alice = privateKeyWrapper('//Alice');
116 bob = privateKeyWrapper!('//Bob');116 bob = privateKeyWrapper('//Bob');
117 });117 });
118 });118 });
119119
modifiedtests/src/nesting/graphs.test.tsdiffbeforeafterboth
34describe('Graphs', () => {34describe('Graphs', () => {
35 it('Ouroboros can\'t be created in a complex graph', async () => {35 it('Ouroboros can\'t be created in a complex graph', async () => {
36 await usingApi(async (api, privateKeyWrapper) => {36 await usingApi(async (api, privateKeyWrapper) => {
37 const alice = privateKeyWrapper!('//Alice');37 const alice = privateKeyWrapper('//Alice');
38 const collection = await buildComplexObjectGraph(api, alice);38 const collection = await buildComplexObjectGraph(api, alice);
3939
40 // to self40 // to self
modifiedtests/src/nesting/migration-check.test.tsdiffbeforeafterboth
1313
14 before(async() => {14 before(async() => {
15 await usingApi(async (api, privateKeyWrapper) => {15 await usingApi(async (api, privateKeyWrapper) => {
16 alice = privateKeyWrapper!('//Alice');16 alice = privateKeyWrapper('//Alice');
17 });17 });
18 });18 });
1919
modifiedtests/src/nesting/nest.test.tsdiffbeforeafterboth
23describe('Integration Test: Nesting', () => {23describe('Integration Test: Nesting', () => {
24 before(async () => {24 before(async () => {
25 await usingApi(async (api, privateKeyWrapper) => {25 await usingApi(async (api, privateKeyWrapper) => {
26 alice = privateKeyWrapper!('//Alice');26 alice = privateKeyWrapper('//Alice');
27 bob = privateKeyWrapper!('//Bob');27 bob = privateKeyWrapper('//Bob');
28 });28 });
29 });29 });
3030
226describe('Negative Test: Nesting', async() => {226describe('Negative Test: Nesting', async() => {
227 before(async () => {227 before(async () => {
228 await usingApi(async (api, privateKeyWrapper) => {228 await usingApi(async (api, privateKeyWrapper) => {
229 alice = privateKeyWrapper!('//Alice');229 alice = privateKeyWrapper('//Alice');
230 bob = privateKeyWrapper!('//Bob');230 bob = privateKeyWrapper('//Bob');
231 });231 });
232 });232 });
233233
modifiedtests/src/nesting/properties.test.tsdiffbeforeafterboth
16describe('Composite Properties Test', () => {16describe('Composite Properties Test', () => {
17 before(async () => {17 before(async () => {
18 await usingApi(async (api, privateKeyWrapper) => {18 await usingApi(async (api, privateKeyWrapper) => {
19 alice = privateKeyWrapper!('//Alice');19 alice = privateKeyWrapper('//Alice');
20 bob = privateKeyWrapper!('//Bob');20 bob = privateKeyWrapper('//Bob');
21 });21 });
22 });22 });
2323
63describe('Integration Test: Collection Properties', () => {63describe('Integration Test: Collection Properties', () => {
64 before(async () => {64 before(async () => {
65 await usingApi(async (api, privateKeyWrapper) => {65 await usingApi(async (api, privateKeyWrapper) => {
66 alice = privateKeyWrapper!('//Alice');66 alice = privateKeyWrapper('//Alice');
67 bob = privateKeyWrapper!('//Bob');67 bob = privateKeyWrapper('//Bob');
68 });68 });
69 });69 });
7070
158describe('Negative Integration Test: Collection Properties', () => {158describe('Negative Integration Test: Collection Properties', () => {
159 before(async () => {159 before(async () => {
160 await usingApi(async (api, privateKeyWrapper) => {160 await usingApi(async (api, privateKeyWrapper) => {
161 alice = privateKeyWrapper!('//Alice');161 alice = privateKeyWrapper('//Alice');
162 bob = privateKeyWrapper!('//Bob');162 bob = privateKeyWrapper('//Bob');
163 });163 });
164 });164 });
165 165
290describe('Integration Test: Access Rights to Token Properties', () => {290describe('Integration Test: Access Rights to Token Properties', () => {
291 before(async () => {291 before(async () => {
292 await usingApi(async (api, privateKeyWrapper) => {292 await usingApi(async (api, privateKeyWrapper) => {
293 alice = privateKeyWrapper!('//Alice');293 alice = privateKeyWrapper('//Alice');
294 bob = privateKeyWrapper!('//Bob');294 bob = privateKeyWrapper('//Bob');
295 });295 });
296 });296 });
297 297
356describe('Negative Integration Test: Access Rights to Token Properties', () => {356describe('Negative Integration Test: Access Rights to Token Properties', () => {
357 before(async () => {357 before(async () => {
358 await usingApi(async (api, privateKeyWrapper) => {358 await usingApi(async (api, privateKeyWrapper) => {
359 alice = privateKeyWrapper!('//Alice');359 alice = privateKeyWrapper('//Alice');
360 bob = privateKeyWrapper!('//Bob');360 bob = privateKeyWrapper('//Bob');
361 });361 });
362 });362 });
363363
474474
475 before(async () => {475 before(async () => {
476 await usingApi(async (api, privateKeyWrapper) => {476 await usingApi(async (api, privateKeyWrapper) => {
477 alice = privateKeyWrapper!('//Alice');477 alice = privateKeyWrapper('//Alice');
478 bob = privateKeyWrapper!('//Bob');478 bob = privateKeyWrapper('//Bob');
479 charlie = privateKeyWrapper!('//Charlie');479 charlie = privateKeyWrapper('//Charlie');
480480
481 permissions = [481 permissions = [
482 {permission: {mutable: true, collectionAdmin: true}, signers: [alice, bob]},482 {permission: {mutable: true, collectionAdmin: true}, signers: [alice, bob]},
639639
640 before(async () => {640 before(async () => {
641 await usingApi(async (api, privateKeyWrapper) => {641 await usingApi(async (api, privateKeyWrapper) => {
642 alice = privateKeyWrapper!('//Alice');642 alice = privateKeyWrapper('//Alice');
643 bob = privateKeyWrapper!('//Bob');643 bob = privateKeyWrapper('//Bob');
644 charlie = privateKeyWrapper!('//Charlie');644 charlie = privateKeyWrapper('//Charlie');
645 const dave = privateKeyWrapper!('//Dave');645 const dave = privateKeyWrapper('//Dave');
646646
647 constitution = [647 constitution = [
648 {permission: {mutable: true, collectionAdmin: true}, signers: [alice, bob], sinner: charlie},648 {permission: {mutable: true, collectionAdmin: true}, signers: [alice, bob], sinner: charlie},
modifiedtests/src/nesting/rules-smoke.test.tsdiffbeforeafterboth
9 let nestTarget!: CrossAccountId;9 let nestTarget!: CrossAccountId;
10 before(async() => {10 before(async() => {
11 await usingApi(async (api, privateKeyWrapper) => {11 await usingApi(async (api, privateKeyWrapper) => {
12 alice = privateKeyWrapper!('//Alice');12 alice = privateKeyWrapper('//Alice');
13 const bob = privateKeyWrapper!('//Bob');13 const bob = privateKeyWrapper('//Bob');
14 const events = await executeTransaction(api, alice, api.tx.unique.createCollectionEx({14 const events = await executeTransaction(api, alice, api.tx.unique.createCollectionEx({
15 mode: 'NFT',15 mode: 'NFT',
16 permissions: {16 permissions: {
modifiedtests/src/nesting/unnest.test.tsdiffbeforeafterboth
19describe('Integration Test: Unnesting', () => {19describe('Integration Test: Unnesting', () => {
20 before(async () => {20 before(async () => {
21 await usingApi(async (api, privateKeyWrapper) => {21 await usingApi(async (api, privateKeyWrapper) => {
22 alice = privateKeyWrapper!('//Alice');22 alice = privateKeyWrapper('//Alice');
23 bob = privateKeyWrapper!('//Bob');23 bob = privateKeyWrapper('//Bob');
24 });24 });
25 });25 });
2626
110describe('Negative Test: Unnesting', () => {110describe('Negative Test: Unnesting', () => {
111 before(async () => {111 before(async () => {
112 await usingApi(async (api, privateKeyWrapper) => {112 await usingApi(async (api, privateKeyWrapper) => {
113 alice = privateKeyWrapper!('//Alice');113 alice = privateKeyWrapper('//Alice');
114 bob = privateKeyWrapper!('//Bob');114 bob = privateKeyWrapper('//Bob');
115 });115 });
116 });116 });
117117
modifiedtests/src/nextSponsoring.test.tsdiffbeforeafterboth
4040
41 before(async () => {41 before(async () => {
42 await usingApi(async (api, privateKeyWrapper) => {42 await usingApi(async (api, privateKeyWrapper) => {
43 alice = privateKeyWrapper!('//Alice');43 alice = privateKeyWrapper('//Alice');
44 bob = privateKeyWrapper!('//Bob');44 bob = privateKeyWrapper('//Bob');
45 });45 });
46 });46 });
4747
modifiedtests/src/overflow.test.tsdiffbeforeafterboth
3030
31 before(async () => {31 before(async () => {
32 await usingApi(async (api, privateKeyWrapper) => {32 await usingApi(async (api, privateKeyWrapper) => {
33 alice = privateKeyWrapper!('//Alice');33 alice = privateKeyWrapper('//Alice');
34 bob = privateKeyWrapper!('//Bob');34 bob = privateKeyWrapper('//Bob');
35 charlie = privateKeyWrapper!('//Charlie');35 charlie = privateKeyWrapper('//Charlie');
36 });36 });
37 });37 });
3838
modifiedtests/src/removeCollectionAdmin.test.tsdiffbeforeafterboth
26 it('Remove collection admin.', async () => {26 it('Remove collection admin.', async () => {
27 await usingApi(async (api, privateKeyWrapper) => {27 await usingApi(async (api, privateKeyWrapper) => {
28 const collectionId = await createCollectionExpectSuccess();28 const collectionId = await createCollectionExpectSuccess();
29 const alice = privateKeyWrapper!('//Alice');29 const alice = privateKeyWrapper('//Alice');
30 const bob = privateKeyWrapper!('//Bob');30 const bob = privateKeyWrapper('//Bob');
31 const collection = await queryCollectionExpectSuccess(api, collectionId);31 const collection = await queryCollectionExpectSuccess(api, collectionId);
32 expect(collection.owner.toString()).to.be.deep.eq(alice.address);32 expect(collection.owner.toString()).to.be.deep.eq(alice.address);
33 // first - add collection admin Bob33 // first - add collection admin Bob
49 it('Remove collection admin by admin.', async () => {49 it('Remove collection admin by admin.', async () => {
50 await usingApi(async (api, privateKeyWrapper) => {50 await usingApi(async (api, privateKeyWrapper) => {
51 const collectionId = await createCollectionExpectSuccess();51 const collectionId = await createCollectionExpectSuccess();
52 const alice = privateKeyWrapper!('//Alice');52 const alice = privateKeyWrapper('//Alice');
53 const bob = privateKeyWrapper!('//Bob');53 const bob = privateKeyWrapper('//Bob');
54 const charlie = privateKeyWrapper!('//Charlie');54 const charlie = privateKeyWrapper('//Charlie');
55 const collection = await queryCollectionExpectSuccess(api, collectionId);55 const collection = await queryCollectionExpectSuccess(api, collectionId);
56 expect(collection.owner.toString()).to.be.eq(alice.address);56 expect(collection.owner.toString()).to.be.eq(alice.address);
57 // first - add collection admin Bob57 // first - add collection admin Bob
7575
76 it('Remove admin from collection that has no admins', async () => {76 it('Remove admin from collection that has no admins', async () => {
77 await usingApi(async (api, privateKeyWrapper) => {77 await usingApi(async (api, privateKeyWrapper) => {
78 const alice = privateKeyWrapper!('//Alice');78 const alice = privateKeyWrapper('//Alice');
79 const collectionId = await createCollectionExpectSuccess();79 const collectionId = await createCollectionExpectSuccess();
8080
81 const adminListBeforeAddAdmin = await getAdminList(api, collectionId);81 const adminListBeforeAddAdmin = await getAdminList(api, collectionId);
92 await usingApi(async (api, privateKeyWrapper) => {92 await usingApi(async (api, privateKeyWrapper) => {
93 // tslint:disable-next-line: no-bitwise93 // tslint:disable-next-line: no-bitwise
94 const collectionId = (1 << 32) - 1;94 const collectionId = (1 << 32) - 1;
95 const alice = privateKeyWrapper!('//Alice');95 const alice = privateKeyWrapper('//Alice');
96 const bob = privateKeyWrapper!('//Bob');96 const bob = privateKeyWrapper('//Bob');
9797
98 const changeOwnerTx = api.tx.unique.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));98 const changeOwnerTx = api.tx.unique.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));
99 await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;99 await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;
107 await usingApi(async (api, privateKeyWrapper) => {107 await usingApi(async (api, privateKeyWrapper) => {
108 // tslint:disable-next-line: no-bitwise108 // tslint:disable-next-line: no-bitwise
109 const collectionId = await createCollectionExpectSuccess();109 const collectionId = await createCollectionExpectSuccess();
110 const alice = privateKeyWrapper!('//Alice');110 const alice = privateKeyWrapper('//Alice');
111 const bob = privateKeyWrapper!('//Bob');111 const bob = privateKeyWrapper('//Bob');
112112
113 await destroyCollectionExpectSuccess(collectionId);113 await destroyCollectionExpectSuccess(collectionId);
114114
123 it('Regular user Can\'t remove collection admin', async () => {123 it('Regular user Can\'t remove collection admin', async () => {
124 await usingApi(async (api, privateKeyWrapper) => {124 await usingApi(async (api, privateKeyWrapper) => {
125 const collectionId = await createCollectionExpectSuccess();125 const collectionId = await createCollectionExpectSuccess();
126 const alice = privateKeyWrapper!('//Alice');126 const alice = privateKeyWrapper('//Alice');
127 const bob = privateKeyWrapper!('//Bob');127 const bob = privateKeyWrapper('//Bob');
128 const charlie = privateKeyWrapper!('//Charlie');128 const charlie = privateKeyWrapper('//Charlie');
129129
130 const addAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));130 const addAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));
131 await submitTransactionAsync(alice, addAdminTx);131 await submitTransactionAsync(alice, addAdminTx);
modifiedtests/src/removeFromAllowList.test.tsdiffbeforeafterboth
4141
42 before(async () => {42 before(async () => {
43 await usingApi(async (api, privateKeyWrapper) => {43 await usingApi(async (api, privateKeyWrapper) => {
44 alice = privateKeyWrapper!('//Alice');44 alice = privateKeyWrapper('//Alice');
45 bob = privateKeyWrapper!('//Bob');45 bob = privateKeyWrapper('//Bob');
46 });46 });
47 });47 });
4848
7575
76 before(async () => {76 before(async () => {
77 await usingApi(async (api, privateKeyWrapper) => {77 await usingApi(async (api, privateKeyWrapper) => {
78 alice = privateKeyWrapper!('//Alice');78 alice = privateKeyWrapper('//Alice');
79 bob = privateKeyWrapper!('//Bob');79 bob = privateKeyWrapper('//Bob');
80 });80 });
81 });81 });
8282
107107
108 before(async () => {108 before(async () => {
109 await usingApi(async (api, privateKeyWrapper) => {109 await usingApi(async (api, privateKeyWrapper) => {
110 alice = privateKeyWrapper!('//Alice');110 alice = privateKeyWrapper('//Alice');
111 bob = privateKeyWrapper!('//Bob');111 bob = privateKeyWrapper('//Bob');
112 charlie = privateKeyWrapper!('//Charlie');112 charlie = privateKeyWrapper('//Charlie');
113 });113 });
114 });114 });
115115
modifiedtests/src/removeFromContractAllowList.test.tsdiffbeforeafterboth
2525
26 before(async () => {26 before(async () => {
27 await usingApi(async (api, privateKeyWrapper) => {27 await usingApi(async (api, privateKeyWrapper) => {
28 bob = privateKeyWrapper!('//Bob');28 bob = privateKeyWrapper('//Bob');
29 });29 });
30 });30 });
3131
7070
71 before(async () => {71 before(async () => {
72 await usingApi(async (api, privateKeyWrapper) => {72 await usingApi(async (api, privateKeyWrapper) => {
73 alice = privateKeyWrapper!('//Alice');73 alice = privateKeyWrapper('//Alice');
74 bob = privateKeyWrapper!('//Bob');74 bob = privateKeyWrapper('//Bob');
75 });75 });
76 });76 });
7777
modifiedtests/src/rpc.load.tsdiffbeforeafterboth
126 const [contract, deployer] = await deployLoadTester(api);126 const [contract, deployer] = await deployLoadTester(api);
127127
128 // Fill smart contract up with data128 // Fill smart contract up with data
129 const bob = privateKeyWrapper!('//Bob');129 const bob = privateKeyWrapper('//Bob');
130 const tx = contract.tx.bloat(value, gasLimit, 200);130 const tx = contract.tx.bloat(value, gasLimit, 200);
131 await submitTransactionAsync(bob, tx);131 await submitTransactionAsync(bob, tx);
132132
modifiedtests/src/scheduler.test.tsdiffbeforeafterboth
30describe.skip('Integration Test scheduler base transaction', () => {30describe.skip('Integration Test scheduler base transaction', () => {
31 it('User can transfer owned token with delay (scheduler)', async () => {31 it('User can transfer owned token with delay (scheduler)', async () => {
32 await usingApi(async (api, privateKeyWrapper) => {32 await usingApi(async (api, privateKeyWrapper) => {
33 const alice = privateKeyWrapper!('//Alice');33 const alice = privateKeyWrapper('//Alice');
34 const bob = privateKeyWrapper!('//Bob');34 const bob = privateKeyWrapper('//Bob');
35 // nft35 // nft
36 const nftCollectionId = await createCollectionExpectSuccess();36 const nftCollectionId = await createCollectionExpectSuccess();
37 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');37 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
modifiedtests/src/setChainLimits.test.tsdiffbeforeafterboth
3131
32 before(async () => {32 before(async () => {
33 await usingApi(async (api, privateKeyWrapper) => {33 await usingApi(async (api, privateKeyWrapper) => {
34 alice = privateKeyWrapper!('//Alice');34 alice = privateKeyWrapper('//Alice');
35 bob = privateKeyWrapper!('//Bob');35 bob = privateKeyWrapper('//Bob');
36 dave = privateKeyWrapper!('//Dave');36 dave = privateKeyWrapper('//Dave');
37 limits = {37 limits = {
38 collectionNumbersLimit : 1,38 collectionNumbersLimit : 1,
39 accountTokenOwnershipLimit: 1,39 accountTokenOwnershipLimit: 1,
modifiedtests/src/setContractSponsoringRateLimit.test.tsdiffbeforeafterboth
5757
58 before(async () => {58 before(async () => {
59 await usingApi(async (api, privateKeyWrapper) => {59 await usingApi(async (api, privateKeyWrapper) => {
60 alice = privateKeyWrapper!('//Alice');60 alice = privateKeyWrapper('//Alice');
61 });61 });
62 });62 });
6363
modifiedtests/src/setMintPermission.test.tsdiffbeforeafterboth
3535
36 before(async () => {36 before(async () => {
37 await usingApi(async (api, privateKeyWrapper) => {37 await usingApi(async (api, privateKeyWrapper) => {
38 alice = privateKeyWrapper!('//Alice');38 alice = privateKeyWrapper('//Alice');
39 bob = privateKeyWrapper!('//Bob');39 bob = privateKeyWrapper('//Bob');
40 });40 });
41 });41 });
4242
7575
76 before(async () => {76 before(async () => {
77 await usingApi(async (api, privateKeyWrapper) => {77 await usingApi(async (api, privateKeyWrapper) => {
78 alice = privateKeyWrapper!('//Alice');78 alice = privateKeyWrapper('//Alice');
79 bob = privateKeyWrapper!('//Bob');79 bob = privateKeyWrapper('//Bob');
80 });80 });
81 });81 });
8282
modifiedtests/src/setPublicAccessMode.test.tsdiffbeforeafterboth
41describe('Integration Test setPublicAccessMode(): ', () => {41describe('Integration Test setPublicAccessMode(): ', () => {
42 before(async () => {42 before(async () => {
43 await usingApi(async (api, privateKeyWrapper) => {43 await usingApi(async (api, privateKeyWrapper) => {
44 alice = privateKeyWrapper!('//Alice');44 alice = privateKeyWrapper('//Alice');
45 bob = privateKeyWrapper!('//Bob');45 bob = privateKeyWrapper('//Bob');
46 });46 });
47 });47 });
4848
108describe('Negative Integration Test ext. collection admin setPublicAccessMode(): ', () => {108describe('Negative Integration Test ext. collection admin setPublicAccessMode(): ', () => {
109 before(async () => {109 before(async () => {
110 await usingApi(async (api, privateKeyWrapper) => {110 await usingApi(async (api, privateKeyWrapper) => {
111 alice = privateKeyWrapper!('//Alice');111 alice = privateKeyWrapper('//Alice');
112 bob = privateKeyWrapper!('//Bob');112 bob = privateKeyWrapper('//Bob');
113 });113 });
114 });114 });
115 it('setPublicAccessMode by collection admin', async () => {115 it('setPublicAccessMode by collection admin', async () => {
modifiedtests/src/substrate/substrate-api.tsdiffbeforeafterboth
59 };59 };
60}60}
6161
62export default async function usingApi<T = void>(action: (api: ApiPromise, privateKeyWrapper?: (account: string) => IKeyringPair) => Promise<T>, settings: ApiOptions | undefined = undefined): Promise<T> {62export default async function usingApi<T = void>(action: (api: ApiPromise, privateKeyWrapper: (account: string) => IKeyringPair) => Promise<T>, settings: ApiOptions | undefined = undefined): Promise<T> {
63 settings = settings || defaultApiOptions();63 settings = settings || defaultApiOptions();
64 const api: ApiPromise = new ApiPromise(settings);64 const api: ApiPromise = new ApiPromise(settings);
65 let result: T = null as unknown as T;65 let result: T = null as unknown as T;
modifiedtests/src/toggleContractAllowList.test.tsdiffbeforeafterboth
5050
51 it('Only allowlisted account can call contract', async () => {51 it('Only allowlisted account can call contract', async () => {
52 await usingApi(async (api, privateKeyWrapper) => {52 await usingApi(async (api, privateKeyWrapper) => {
53 const bob = privateKeyWrapper!('//Bob');53 const bob = privateKeyWrapper('//Bob');
5454
55 const [contract, deployer] = await deployFlipper(api);55 const [contract, deployer] = await deployFlipper(api);
5656
135135
136 it('Enable allow list for a non-contract', async () => {136 it('Enable allow list for a non-contract', async () => {
137 await usingApi(async (api, privateKeyWrapper) => {137 await usingApi(async (api, privateKeyWrapper) => {
138 const alice = privateKeyWrapper!('//Alice');138 const alice = privateKeyWrapper('//Alice');
139 const bobGuineaPig = privateKeyWrapper!('//Bob');139 const bobGuineaPig = privateKeyWrapper('//Bob');
140140
141 const enabledBefore = (await api.query.unique.contractAllowListEnabled(bobGuineaPig.address)).toJSON();141 const enabledBefore = (await api.query.unique.contractAllowListEnabled(bobGuineaPig.address)).toJSON();
142 const enableAllowListTx = api.tx.unique.toggleContractAllowList(bobGuineaPig.address, true);142 const enableAllowListTx = api.tx.unique.toggleContractAllowList(bobGuineaPig.address, true);
150150
151 it('Enable allow list using a non-owner address', async () => {151 it('Enable allow list using a non-owner address', async () => {
152 await usingApi(async (api, privateKeyWrapper) => {152 await usingApi(async (api, privateKeyWrapper) => {
153 const bob = privateKeyWrapper!('//Bob');153 const bob = privateKeyWrapper('//Bob');
154 const [contract] = await deployFlipper(api);154 const [contract] = await deployFlipper(api);
155155
156 const enabledBefore = (await api.query.unique.contractAllowListEnabled(contract.address)).toJSON();156 const enabledBefore = (await api.query.unique.contractAllowListEnabled(contract.address)).toJSON();
modifiedtests/src/transfer.nload.tsdiffbeforeafterboth
95 const waiting: Promise<void>[] = [];95 const waiting: Promise<void>[] = [];
96 console.log(`Starting ${os.cpus().length} workers`);96 console.log(`Starting ${os.cpus().length} workers`);
97 usingApi(async (api, privateKeyWrapper) => {97 usingApi(async (api, privateKeyWrapper) => {
98 const alice = privateKeyWrapper!('//Alice');98 const alice = privateKeyWrapper('//Alice');
99 for (const id in os.cpus()) {99 for (const id in os.cpus()) {
100 const WORKER_NAME = `//LoadWorker${id}_${Date.now()}`;100 const WORKER_NAME = `//LoadWorker${id}_${Date.now()}`;
101 const workerAccount = privateKeyWrapper!(WORKER_NAME);101 const workerAccount = privateKeyWrapper(WORKER_NAME);
102 const tx = api.tx.balances.transfer(workerAccount.address, 400n * 10n ** 23n);102 const tx = api.tx.balances.transfer(workerAccount.address, 400n * 10n ** 23n);
103 await submitTransactionAsync(alice, tx);103 await submitTransactionAsync(alice, tx);
104104
119} else {119} else {
120 increaseCounter('startedWorkers', 1);120 increaseCounter('startedWorkers', 1);
121 usingApi(async (api, privateKeyWrapper) => {121 usingApi(async (api, privateKeyWrapper) => {
122 await distributeBalance(privateKeyWrapper!(process.env.WORKER_NAME as string), api, 400n * 10n ** 22n, 10);122 await distributeBalance(privateKeyWrapper(process.env.WORKER_NAME as string), api, 400n * 10n ** 22n, 10);
123 });123 });
124 const interval = setInterval(() => {124 const interval = setInterval(() => {
125 flushCounterToMaster();125 flushCounterToMaster();
modifiedtests/src/transfer.test.tsdiffbeforeafterboth
51 await usingApi(async (api, privateKeyWrapper) => {51 await usingApi(async (api, privateKeyWrapper) => {
52 const [alicesBalanceBefore, bobsBalanceBefore] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);52 const [alicesBalanceBefore, bobsBalanceBefore] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);
5353
54 const alicePrivateKey = privateKeyWrapper!('//Alice');54 const alicePrivateKey = privateKeyWrapper('//Alice');
5555
56 const transfer = api.tx.balances.transfer(bobsPublicKey, 1n);56 const transfer = api.tx.balances.transfer(bobsPublicKey, 1n);
57 const events = await submitTransactionAsync(alicePrivateKey, transfer);57 const events = await submitTransactionAsync(alicePrivateKey, transfer);
8787
88 it('User can transfer owned token', async () => {88 it('User can transfer owned token', async () => {
89 await usingApi(async (api, privateKeyWrapper) => {89 await usingApi(async (api, privateKeyWrapper) => {
90 const alice = privateKeyWrapper!('//Alice');90 const alice = privateKeyWrapper('//Alice');
91 const bob = privateKeyWrapper!('//Bob');91 const bob = privateKeyWrapper('//Bob');
92 // nft92 // nft
93 const nftCollectionId = await createCollectionExpectSuccess();93 const nftCollectionId = await createCollectionExpectSuccess();
94 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');94 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
114114
115 it('Collection admin can transfer owned token', async () => {115 it('Collection admin can transfer owned token', async () => {
116 await usingApi(async (api, privateKeyWrapper) => {116 await usingApi(async (api, privateKeyWrapper) => {
117 const alice = privateKeyWrapper!('//Alice');117 const alice = privateKeyWrapper('//Alice');
118 const bob = privateKeyWrapper!('//Bob');118 const bob = privateKeyWrapper('//Bob');
119 // nft119 // nft
120 const nftCollectionId = await createCollectionExpectSuccess();120 const nftCollectionId = await createCollectionExpectSuccess();
121 await addCollectionAdminExpectSuccess(alice, nftCollectionId, bob.address);121 await addCollectionAdminExpectSuccess(alice, nftCollectionId, bob.address);
145describe('Negative Integration Test Transfer(recipient, collection_id, item_id, value)', () => {145describe('Negative Integration Test Transfer(recipient, collection_id, item_id, value)', () => {
146 before(async () => {146 before(async () => {
147 await usingApi(async (api, privateKeyWrapper) => {147 await usingApi(async (api, privateKeyWrapper) => {
148 alice = privateKeyWrapper!('//Alice');148 alice = privateKeyWrapper('//Alice');
149 bob = privateKeyWrapper!('//Bob');149 bob = privateKeyWrapper('//Bob');
150 charlie = privateKeyWrapper!('//Charlie');150 charlie = privateKeyWrapper('//Charlie');
151 });151 });
152 });152 });
153 it('Transfer with not existed collection_id', async () => {153 it('Transfer with not existed collection_id', async () => {
258describe('Zero value transfer(From)', () => {258describe('Zero value transfer(From)', () => {
259 before(async () => {259 before(async () => {
260 await usingApi(async (api, privateKeyWrapper) => {260 await usingApi(async (api, privateKeyWrapper) => {
261 alice = privateKeyWrapper!('//Alice');261 alice = privateKeyWrapper('//Alice');
262 bob = privateKeyWrapper!('//Bob');262 bob = privateKeyWrapper('//Bob');
263 });263 });
264 });264 });
265265
316describe('Transfers to self (potentially over substrate-evm boundary)', () => {316describe('Transfers to self (potentially over substrate-evm boundary)', () => {
317 itWeb3('Transfers to self. In case of same frontend', async ({api, privateKeyWrapper}) => {317 itWeb3('Transfers to self. In case of same frontend', async ({api, privateKeyWrapper}) => {
318 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});318 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
319 const alice = privateKeyWrapper!('//Alice');319 const alice = privateKeyWrapper('//Alice');
320 const aliceProxy = subToEth(alice.address);320 const aliceProxy = subToEth(alice.address);
321 const tokenId = await createItemExpectSuccess(alice, collectionId, 'Fungible', {Substrate: alice.address});321 const tokenId = await createItemExpectSuccess(alice, collectionId, 'Fungible', {Substrate: alice.address});
322 await transferExpectSuccess(collectionId, tokenId, alice, {Ethereum: aliceProxy}, 10, 'Fungible');322 await transferExpectSuccess(collectionId, tokenId, alice, {Ethereum: aliceProxy}, 10, 'Fungible');
328328
329 itWeb3('Transfers to self. In case of substrate-evm boundary', async ({api, privateKeyWrapper}) => {329 itWeb3('Transfers to self. In case of substrate-evm boundary', async ({api, privateKeyWrapper}) => {
330 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});330 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
331 const alice = privateKeyWrapper!('//Alice');331 const alice = privateKeyWrapper('//Alice');
332 const aliceProxy = subToEth(alice.address);332 const aliceProxy = subToEth(alice.address);
333 const tokenId = await createItemExpectSuccess(alice, collectionId, 'Fungible', {Substrate: alice.address});333 const tokenId = await createItemExpectSuccess(alice, collectionId, 'Fungible', {Substrate: alice.address});
334 const balanceAliceBefore = await getTokenBalance(api, collectionId, normalizeAccountId(alice), tokenId);334 const balanceAliceBefore = await getTokenBalance(api, collectionId, normalizeAccountId(alice), tokenId);
340340
341 itWeb3('Transfers to self. In case of inside substrate-evm', async ({api, privateKeyWrapper}) => {341 itWeb3('Transfers to self. In case of inside substrate-evm', async ({api, privateKeyWrapper}) => {
342 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});342 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
343 const alice = privateKeyWrapper!('//Alice');343 const alice = privateKeyWrapper('//Alice');
344 const tokenId = await createItemExpectSuccess(alice, collectionId, 'Fungible', {Substrate: alice.address});344 const tokenId = await createItemExpectSuccess(alice, collectionId, 'Fungible', {Substrate: alice.address});
345 const balanceAliceBefore = await getTokenBalance(api, collectionId, normalizeAccountId(alice), tokenId);345 const balanceAliceBefore = await getTokenBalance(api, collectionId, normalizeAccountId(alice), tokenId);
346 await transferExpectSuccess(collectionId, tokenId, alice, alice , 10, 'Fungible');346 await transferExpectSuccess(collectionId, tokenId, alice, alice , 10, 'Fungible');
351351
352 itWeb3('Transfers to self. In case of inside substrate-evm when not enought "Fungibles"', async ({api, privateKeyWrapper}) => {352 itWeb3('Transfers to self. In case of inside substrate-evm when not enought "Fungibles"', async ({api, privateKeyWrapper}) => {
353 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});353 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
354 const alice = privateKeyWrapper!('//Alice');354 const alice = privateKeyWrapper('//Alice');
355 const tokenId = await createItemExpectSuccess(alice, collectionId, 'Fungible', {Substrate: alice.address});355 const tokenId = await createItemExpectSuccess(alice, collectionId, 'Fungible', {Substrate: alice.address});
356 const balanceAliceBefore = await getTokenBalance(api, collectionId, normalizeAccountId(alice), tokenId);356 const balanceAliceBefore = await getTokenBalance(api, collectionId, normalizeAccountId(alice), tokenId);
357 await transferExpectFailure(collectionId, tokenId, alice, alice , 11);357 await transferExpectFailure(collectionId, tokenId, alice, alice , 11);
modifiedtests/src/transferFrom.test.tsdiffbeforeafterboth
4343
44 before(async () => {44 before(async () => {
45 await usingApi(async (api, privateKeyWrapper) => {45 await usingApi(async (api, privateKeyWrapper) => {
46 alice = privateKeyWrapper!('//Alice');46 alice = privateKeyWrapper('//Alice');
47 bob = privateKeyWrapper!('//Bob');47 bob = privateKeyWrapper('//Bob');
48 charlie = privateKeyWrapper!('//Charlie');48 charlie = privateKeyWrapper('//Charlie');
49 });49 });
50 });50 });
5151
8383
84 it('Should reduce allowance if value is big', async () => {84 it('Should reduce allowance if value is big', async () => {
85 await usingApi(async (api, privateKeyWrapper) => {85 await usingApi(async (api, privateKeyWrapper) => {
86 const alice = privateKeyWrapper!('//Alice');86 const alice = privateKeyWrapper('//Alice');
87 const bob = privateKeyWrapper!('//Bob');87 const bob = privateKeyWrapper('//Bob');
88 const charlie = privateKeyWrapper!('//Charlie');88 const charlie = privateKeyWrapper('//Charlie');
8989
90 // fungible90 // fungible
91 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});91 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
112112
113 before(async () => {113 before(async () => {
114 await usingApi(async (api, privateKeyWrapper) => {114 await usingApi(async (api, privateKeyWrapper) => {
115 alice = privateKeyWrapper!('//Alice');115 alice = privateKeyWrapper('//Alice');
116 bob = privateKeyWrapper!('//Bob');116 bob = privateKeyWrapper('//Bob');
117 charlie = privateKeyWrapper!('//Charlie');117 charlie = privateKeyWrapper('//Charlie');
118 });118 });
119 });119 });
120120
216216
217 it('execute transferFrom from account that is not owner of collection', async () => {217 it('execute transferFrom from account that is not owner of collection', async () => {
218 await usingApi(async (api, privateKeyWrapper) => {218 await usingApi(async (api, privateKeyWrapper) => {
219 const dave = privateKeyWrapper!('//Dave');219 const dave = privateKeyWrapper('//Dave');
220 // nft220 // nft
221 const nftCollectionId = await createCollectionExpectSuccess();221 const nftCollectionId = await createCollectionExpectSuccess();
222 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');222 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
modifiedtests/src/util/helpers.tsdiffbeforeafterboth
329 const collectionCountBefore = await getCreatedCollectionCount(api);329 const collectionCountBefore = await getCreatedCollectionCount(api);
330330
331 // Run the CreateCollection transaction331 // Run the CreateCollection transaction
332 const alicePrivateKey = privateKeyWrapper!('//Alice');332 const alicePrivateKey = privateKeyWrapper('//Alice');
333333
334 let modeprm = {};334 let modeprm = {};
335 if (mode.type === 'NFT') {335 if (mode.type === 'NFT') {
382 const collectionCountBefore = await getCreatedCollectionCount(api);382 const collectionCountBefore = await getCreatedCollectionCount(api);
383383
384 // Run the CreateCollection transaction384 // Run the CreateCollection transaction
385 const alicePrivateKey = privateKeyWrapper!('//Alice');385 const alicePrivateKey = privateKeyWrapper('//Alice');
386386
387 let modeprm = {};387 let modeprm = {};
388 if (mode.type === 'NFT') {388 if (mode.type === 'NFT') {
430 const collectionCountBefore = await getCreatedCollectionCount(api);430 const collectionCountBefore = await getCreatedCollectionCount(api);
431431
432 // Run the CreateCollection transaction432 // Run the CreateCollection transaction
433 const alicePrivateKey = privateKeyWrapper!('//Alice');433 const alicePrivateKey = privateKeyWrapper('//Alice');
434434
435 let modeprm = {};435 let modeprm = {};
436 if (mode.type === 'NFT') {436 if (mode.type === 'NFT') {
469 const collectionCountBefore = await getCreatedCollectionCount(api);469 const collectionCountBefore = await getCreatedCollectionCount(api);
470470
471 // Run the CreateCollection transaction471 // Run the CreateCollection transaction
472 const alicePrivateKey = privateKeyWrapper!('//Alice');472 const alicePrivateKey = privateKeyWrapper('//Alice');
473 const tx = api.tx.unique.createCollectionEx({name: strToUTF16(name), description: strToUTF16(description), tokenPrefix: strToUTF16(tokenPrefix), mode: modeprm as any});473 const tx = api.tx.unique.createCollectionEx({name: strToUTF16(name), description: strToUTF16(description), tokenPrefix: strToUTF16(tokenPrefix), mode: modeprm as any});
474 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;474 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;
475475
520export async function destroyCollectionExpectFailure(collectionId: number, senderSeed = '//Alice') {520export async function destroyCollectionExpectFailure(collectionId: number, senderSeed = '//Alice') {
521 await usingApi(async (api, privateKeyWrapper) => {521 await usingApi(async (api, privateKeyWrapper) => {
522 // Run the DestroyCollection transaction522 // Run the DestroyCollection transaction
523 const alicePrivateKey = privateKeyWrapper!(senderSeed);523 const alicePrivateKey = privateKeyWrapper(senderSeed);
524 const tx = api.tx.unique.destroyCollection(collectionId);524 const tx = api.tx.unique.destroyCollection(collectionId);
525 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;525 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;
526 });526 });
529export async function destroyCollectionExpectSuccess(collectionId: number, senderSeed = '//Alice') {529export async function destroyCollectionExpectSuccess(collectionId: number, senderSeed = '//Alice') {
530 await usingApi(async (api, privateKeyWrapper) => {530 await usingApi(async (api, privateKeyWrapper) => {
531 // Run the DestroyCollection transaction531 // Run the DestroyCollection transaction
532 const alicePrivateKey = privateKeyWrapper!(senderSeed);532 const alicePrivateKey = privateKeyWrapper(senderSeed);
533 const tx = api.tx.unique.destroyCollection(collectionId);533 const tx = api.tx.unique.destroyCollection(collectionId);
534 const events = await submitTransactionAsync(alicePrivateKey, tx);534 const events = await submitTransactionAsync(alicePrivateKey, tx);
535 const result = getDestroyResult(events);535 const result = getDestroyResult(events);
574 await usingApi(async (api, privateKeyWrapper) => {574 await usingApi(async (api, privateKeyWrapper) => {
575575
576 // Run the transaction576 // Run the transaction
577 const senderPrivateKey = privateKeyWrapper!(sender);577 const senderPrivateKey = privateKeyWrapper(sender);
578 const tx = api.tx.unique.setCollectionSponsor(collectionId, sponsor);578 const tx = api.tx.unique.setCollectionSponsor(collectionId, sponsor);
579 const events = await submitTransactionAsync(senderPrivateKey, tx);579 const events = await submitTransactionAsync(senderPrivateKey, tx);
580 const result = getGenericResult(events);580 const result = getGenericResult(events);
594 await usingApi(async (api, privateKeyWrapper) => {594 await usingApi(async (api, privateKeyWrapper) => {
595595
596 // Run the transaction596 // Run the transaction
597 const alicePrivateKey = privateKeyWrapper!(sender);597 const alicePrivateKey = privateKeyWrapper(sender);
598 const tx = api.tx.unique.removeCollectionSponsor(collectionId);598 const tx = api.tx.unique.removeCollectionSponsor(collectionId);
599 const events = await submitTransactionAsync(alicePrivateKey, tx);599 const events = await submitTransactionAsync(alicePrivateKey, tx);
600 const result = getGenericResult(events);600 const result = getGenericResult(events);
612 await usingApi(async (api, privateKeyWrapper) => {612 await usingApi(async (api, privateKeyWrapper) => {
613613
614 // Run the transaction614 // Run the transaction
615 const alicePrivateKey = privateKeyWrapper!(senderSeed);615 const alicePrivateKey = privateKeyWrapper(senderSeed);
616 const tx = api.tx.unique.removeCollectionSponsor(collectionId);616 const tx = api.tx.unique.removeCollectionSponsor(collectionId);
617 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;617 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;
618 });618 });
622 await usingApi(async (api, privateKeyWrapper) => {622 await usingApi(async (api, privateKeyWrapper) => {
623623
624 // Run the transaction624 // Run the transaction
625 const alicePrivateKey = privateKeyWrapper!(senderSeed);625 const alicePrivateKey = privateKeyWrapper(senderSeed);
626 const tx = api.tx.unique.setCollectionSponsor(collectionId, sponsor);626 const tx = api.tx.unique.setCollectionSponsor(collectionId, sponsor);
627 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;627 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;
628 });628 });
632 await usingApi(async (api, privateKeyWrapper) => {632 await usingApi(async (api, privateKeyWrapper) => {
633633
634 // Run the transaction634 // Run the transaction
635 const sender = privateKeyWrapper!(senderSeed);635 const sender = privateKeyWrapper(senderSeed);
636 const tx = api.tx.unique.confirmSponsorship(collectionId);636 const tx = api.tx.unique.confirmSponsorship(collectionId);
637 const events = await submitTransactionAsync(sender, tx);637 const events = await submitTransactionAsync(sender, tx);
638 const result = getGenericResult(events);638 const result = getGenericResult(events);
653 await usingApi(async (api, privateKeyWrapper) => {653 await usingApi(async (api, privateKeyWrapper) => {
654654
655 // Run the transaction655 // Run the transaction
656 const sender = privateKeyWrapper!(senderSeed);656 const sender = privateKeyWrapper(senderSeed);
657 const tx = api.tx.unique.confirmSponsorship(collectionId);657 const tx = api.tx.unique.confirmSponsorship(collectionId);
658 await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;658 await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;
659 });659 });
modifiedtests/src/xcmTransfer.test.tsdiffbeforeafterboth
38 38
39 before(async () => {39 before(async () => {
40 await usingApi(async (api, privateKeyWrapper) => {40 await usingApi(async (api, privateKeyWrapper) => {
41 alice = privateKeyWrapper!('//Alice');41 alice = privateKeyWrapper('//Alice');
42 });42 });
4343
44 const karuraApiOptions: ApiOptions = {44 const karuraApiOptions: ApiOptions = {