git.delta.rocks / unique-network / refs/commits / 06a1c73f4a1c

difftreelog

Combine collection sponsoring tests

Max Andreev2022-12-07parent: #15c7e8f.patch.diff
in: master

1 file changed

modifiedtests/src/eth/collectionSponsoring.test.tsdiffbeforeafterboth
81 // expect(bigIntToSub(api, BigInt(sponsorTuple[1]))).to.be.eq(sponsor.address);81 // expect(bigIntToSub(api, BigInt(sponsorTuple[1]))).to.be.eq(sponsor.address);
82 // });82 // });
8383
84 // Soft-deprecated84 [
85 'setCollectionSponsorCross',
86 'setCollectionSponsor', // Soft-deprecated
85 itEth('[eth] Remove sponsor', async ({helper}) => {87 ].map(testCase =>
88 itEth(`[${testCase}] can remove collection sponsor`, async ({helper}) => {
86 const owner = await helper.eth.createAccountWithBalance(donor);89 const owner = await helper.eth.createAccountWithBalance(donor);
87 const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);90 const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);
91
92 let result = await collectionHelpers.methods.createNFTCollection('Sponsor collection', '1', '1').send({value: Number(2n * nominal)});
93 const collectionIdAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);
94 const sponsor = await helper.eth.createAccountWithBalance(donor);
95 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);
96 const collectionEvm = helper.ethNativeContract.collection(collectionIdAddress, 'nft', owner, testCase === 'setCollectionSponsor');
97
98 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;
99 result = await collectionEvm.methods[testCase](testCase === 'setCollectionSponsor' ? sponsor : sponsorCross).send({from: owner});
100 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.true;
101
102 await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsor});
103 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;
104
105 await collectionEvm.methods.removeCollectionSponsor().send({from: owner});
106
107 const sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});
108 expect(sponsorTuple.field_0).to.be.eq('0x0000000000000000000000000000000000000000');
109 }));
88110
89 let result = await collectionHelpers.methods.createNFTCollection('Sponsor collection', '1', '1').send({value: Number(2n * nominal)});111 [
112 'setCollectionSponsorCross',
113 'setCollectionSponsor', // Soft-deprecated
114 ].map(testCase =>
115 itEth(`[${testCase}] Can sponsor from evm address via access list`, async ({helper}) => {
116 const owner = await helper.eth.createAccountWithBalance(donor);
117 const sponsorEth = await helper.eth.createAccountWithBalance(donor);
118 const sponsorCrossEth = helper.ethCrossAccount.fromAddress(sponsorEth);
119
120 const {collectionId, collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Sponsor collection', '1', '1', '');
121
122 const collectionSub = helper.nft.getCollectionObject(collectionId);
123 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, testCase === 'setCollectionSponsor');
124
125 // Set collection sponsor:
126 await collectionEvm.methods[testCase](testCase === 'setCollectionSponsor' ? sponsorEth : sponsorCrossEth).send({from: owner});
90 const collectionIdAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);127 let collectionData = (await collectionSub.getData())!;
128 expect(collectionData.raw.sponsorship.Unconfirmed).to.be.eq(helper.address.ethToSubstrate(sponsorEth, true));
129 // Account cannot confirm sponsorship if it is not set as a sponsor
130 await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');
91 const sponsor = await helper.eth.createAccountWithBalance(donor);131
132 // Sponsor can confirm sponsorship:
133 await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsorEth});
134 collectionData = (await collectionSub.getData())!;
135 expect(collectionData.raw.sponsorship.Confirmed).to.be.eq(helper.address.ethToSubstrate(sponsorEth, true));
136
137 // Create user with no balance:
138 const user = helper.eth.createAccount();
92 const collectionEvm = helper.ethNativeContract.collection(collectionIdAddress, 'nft', owner, true);139 const userCross = helper.ethCrossAccount.fromAddress(user);
140 const nextTokenId = await collectionEvm.methods.nextTokenId().call();
141 expect(nextTokenId).to.be.equal('1');
142
143 // Set collection permissions:
144 const oldPermissions = (await collectionSub.getData())!.raw.permissions; // (await getDetailedCollectionInfo(api, collectionId))!.permissions.toHuman();
145 expect(oldPermissions.mintMode).to.be.false;
146 expect(oldPermissions.access).to.be.equal('Normal');
93147
94 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;148 await collectionEvm.methods.setCollectionAccess(1 /*'AllowList'*/).send({from: owner});
95 result = await collectionEvm.methods.setCollectionSponsor(sponsor).send({from: owner});149 await collectionEvm.methods.addToCollectionAllowListCross(userCross).send({from: owner});
96 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.true;150 await collectionEvm.methods.setCollectionMintMode(true).send({from: owner});
151
152 const newPermissions = (await collectionSub.getData())!.raw.permissions; // (await getDetailedCollectionInfo(api, collectionId))!.permissions.toHuman();
153 expect(newPermissions.mintMode).to.be.true;
154 expect(newPermissions.access).to.be.equal('AllowList');
155
156 const ownerBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));
157 const sponsorBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsorEth));
97158
98 await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsor});159 // User can mint token without balance:
99 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;160 {
100161 const result = await collectionEvm.methods.mintWithTokenURI(user, 'Test URI').send({from: user});
101 await collectionEvm.methods.removeCollectionSponsor().send({from: owner});162 const events = helper.eth.normalizeEvents(result.events);
102163
103 const sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});164 expect(events).to.be.deep.equal([
104 expect(sponsorTuple.field_0).to.be.eq('0x0000000000000000000000000000000000000000');165 {
105 });166 address: collectionAddress,
106167 event: 'Transfer',
107 itEth('[cross] Remove sponsor', async ({helper}) => {168 args: {
108 const owner = await helper.eth.createAccountWithBalance(donor);169 from: '0x0000000000000000000000000000000000000000',
109 const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);170 to: user,
110171 tokenId: '1',
111 let result = await collectionHelpers.methods.createNFTCollection('Sponsor collection', '1', '1').send({value: Number(2n * nominal)});172 },
112 const collectionIdAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);
113 const sponsor = await helper.eth.createAccountWithBalance(donor);
114 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);
115 const collectionEvm = helper.ethNativeContract.collection(collectionIdAddress, 'nft', owner);
116
117 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;
118 result = await collectionEvm.methods.setCollectionSponsorCross(sponsorCross).send({from: owner});
119 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.true;
120
121 await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsor});
122 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;
123
124 await collectionEvm.methods.removeCollectionSponsor().send({from: owner});
125
126 const sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});
127 expect(sponsorTuple.field_0).to.be.eq('0x0000000000000000000000000000000000000000');
128 });
129
130 // Soft-deprecated
131 itEth('[eth] Sponsoring collection from evm address via access list', async ({helper}) => {
132 const owner = await helper.eth.createAccountWithBalance(donor);
133
134 const {collectionId, collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Sponsor collection', '1', '1', '');
135
136 const collection = helper.nft.getCollectionObject(collectionId);
137 const sponsor = await helper.eth.createAccountWithBalance(donor);
138 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);
139
140 await collectionEvm.methods.setCollectionSponsor(sponsor).send({from: owner});
141 let collectionData = (await collection.getData())!;
142 expect(collectionData.raw.sponsorship.Unconfirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));
143 await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');
144
145 await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsor});
146 collectionData = (await collection.getData())!;
147 expect(collectionData.raw.sponsorship.Confirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));
148
149 const user = helper.eth.createAccount();
150 const nextTokenId = await collectionEvm.methods.nextTokenId().call();
151 expect(nextTokenId).to.be.equal('1');
152
153 const oldPermissions = (await collection.getData())!.raw.permissions; // (await getDetailedCollectionInfo(api, collectionId))!.permissions.toHuman();
154 expect(oldPermissions.mintMode).to.be.false;
155 expect(oldPermissions.access).to.be.equal('Normal');
156
157 await collectionEvm.methods.setCollectionAccess(1 /*'AllowList'*/).send({from: owner});
158 await collectionEvm.methods.addToCollectionAllowList(user).send({from: owner});
159 await collectionEvm.methods.setCollectionMintMode(true).send({from: owner});
160
161 const newPermissions = (await collection.getData())!.raw.permissions; // (await getDetailedCollectionInfo(api, collectionId))!.permissions.toHuman();
162 expect(newPermissions.mintMode).to.be.true;
163 expect(newPermissions.access).to.be.equal('AllowList');
164
165 const ownerBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));
166 const sponsorBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsor));
167
168 {
169 const result = await collectionEvm.methods.mintWithTokenURI(user, 'Test URI').send({from: user});
170 const events = helper.eth.normalizeEvents(result.events);
171
172 expect(events).to.be.deep.equal([
173 {
174 address: collectionAddress,
175 event: 'Transfer',
176 args: {
177 from: '0x0000000000000000000000000000000000000000',
178 to: user,
179 tokenId: '1',
180 },173 },
181 },174 ]);
182 ]);175
176 const ownerBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));
177 const sponsorBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsorEth));
178 const userBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(user));
179
180 expect(await collectionEvm.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');
181 expect(ownerBalanceBefore).to.be.eq(ownerBalanceAfter);
182 expect(userBalanceAfter).to.be.eq(0n);
183 expect(sponsorBalanceBefore > sponsorBalanceAfter).to.be.true;
184 }
185 }));
183186
184 const ownerBalanceAfter = await helper.balance.getSubstrate(await helper.address.ethToSubstrate(owner));
185 const sponsorBalanceAfter = await helper.balance.getSubstrate(await helper.address.ethToSubstrate(sponsor));
186
187 expect(await collectionEvm.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');
188 expect(ownerBalanceBefore).to.be.eq(ownerBalanceAfter);
189 expect(sponsorBalanceBefore > sponsorBalanceAfter).to.be.true;
190 }
191 });
192
193 itEth('[cross] Sponsoring collection from evm address via access list', async ({helper}) => {
194 const owner = await helper.eth.createAccountWithBalance(donor);
195
196 const {collectionId, collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Sponsor collection', '1', '1', '');
197
198 const collection = helper.nft.getCollectionObject(collectionId);
199 const sponsor = await helper.eth.createAccountWithBalance(donor);
200 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);
201 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
202
203 await collectionEvm.methods.setCollectionSponsorCross(sponsorCross).send({from: owner});
204 let collectionData = (await collection.getData())!;
205 expect(collectionData.raw.sponsorship.Unconfirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));
206 await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');
207
208 await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsor});
209 collectionData = (await collection.getData())!;
210 expect(collectionData.raw.sponsorship.Confirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));
211
212 const user = helper.eth.createAccount();
213 const userCross = helper.ethCrossAccount.fromAddress(user);
214 const nextTokenId = await collectionEvm.methods.nextTokenId().call();
215 expect(nextTokenId).to.be.equal('1');
216
217 const oldPermissions = (await collection.getData())!.raw.permissions; // (await getDetailedCollectionInfo(api, collectionId))!.permissions.toHuman();
218 expect(oldPermissions.mintMode).to.be.false;
219 expect(oldPermissions.access).to.be.equal('Normal');
220
221 await collectionEvm.methods.setCollectionAccess(1 /*'AllowList'*/).send({from: owner});
222 await collectionEvm.methods.addToCollectionAllowListCross(userCross).send({from: owner});
223 await collectionEvm.methods.setCollectionMintMode(true).send({from: owner});
224
225 const newPermissions = (await collection.getData())!.raw.permissions; // (await getDetailedCollectionInfo(api, collectionId))!.permissions.toHuman();
226 expect(newPermissions.mintMode).to.be.true;
227 expect(newPermissions.access).to.be.equal('AllowList');
228
229 const ownerBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));
230 const sponsorBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsor));
231
232 {
233 const result = await collectionEvm.methods.mintWithTokenURI(user, 'Test URI').send({from: user});
234 const events = helper.eth.normalizeEvents(result.events);
235
236 expect(events).to.be.deep.equal([
237 {
238 address: collectionAddress,
239 event: 'Transfer',
240 args: {
241 from: '0x0000000000000000000000000000000000000000',
242 to: user,
243 tokenId: '1',
244 },
245 },
246 ]);
247
248 const ownerBalanceAfter = await helper.balance.getSubstrate(await helper.address.ethToSubstrate(owner));
249 const sponsorBalanceAfter = await helper.balance.getSubstrate(await helper.address.ethToSubstrate(sponsor));
250
251 expect(await collectionEvm.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');
252 expect(ownerBalanceBefore).to.be.eq(ownerBalanceAfter);
253 expect(sponsorBalanceBefore > sponsorBalanceAfter).to.be.true;
254 }
255 });
256
257 // TODO: Temprorary off. Need refactor187 // TODO: Temprorary off. Need refactor
258 // itWeb3('Sponsoring collection from substrate address via access list', async ({api, web3, privateKeyWrapper}) => {188 // itWeb3('Sponsoring collection from substrate address via access list', async ({api, web3, privateKeyWrapper}) => {
310 // }240 // }
311 // });241 // });
312242
313 // Soft-deprecated243 [
244 'setCollectionSponsorCross',
245 'setCollectionSponsor', // Soft-deprecated
314 itEth('[eth] Check that transaction via EVM spend money from sponsor address', async ({helper}) => {246 ].map(testCase =>
247 itEth(`[${testCase}] Check that transaction via EVM spend money from sponsor address`, async ({helper}) => {
315 const owner = await helper.eth.createAccountWithBalance(donor);248 const owner = await helper.eth.createAccountWithBalance(donor);
249 const sponsor = await helper.eth.createAccountWithBalance(donor);
250 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);
251
252 const {collectionAddress, collectionId} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner,'Sponsor collection', '1', '1', '');
316253
317 const {collectionAddress, collectionId} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner,'Sponsor collection', '1', '1', '');254 const collectionSub = helper.nft.getCollectionObject(collectionId);
318 const collection = helper.nft.getCollectionObject(collectionId);
319 const sponsor = await helper.eth.createAccountWithBalance(donor);255 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, testCase === 'setCollectionSponsor');
320 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);256 // Set collection sponsor:
321
322 await collectionEvm.methods.setCollectionSponsor(sponsor).send();257 await collectionEvm.methods[testCase](testCase === 'setCollectionSponsor' ? sponsor : sponsorCross).send();
323 let collectionData = (await collection.getData())!;258 let collectionData = (await collectionSub.getData())!;
324 expect(collectionData.raw.sponsorship.Unconfirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));259 expect(collectionData.raw.sponsorship.Unconfirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));
325 await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');260 await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');
326261
327 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor, true);262 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor);
328 await sponsorCollection.methods.confirmCollectionSponsorship().send();263 await sponsorCollection.methods.confirmCollectionSponsorship().send();
329 collectionData = (await collection.getData())!;264 collectionData = (await collectionSub.getData())!;
330 expect(collectionData.raw.sponsorship.Confirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));265 expect(collectionData.raw.sponsorship.Confirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));
331266
332 const user = helper.eth.createAccount();267 const user = helper.eth.createAccount();
333 await collectionEvm.methods.addCollectionAdmin(user).send();268 const userCross = helper.ethCrossAccount.fromAddress(user);
334269 await collectionEvm.methods.addCollectionAdminCross(userCross).send();
270
335 const ownerBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));271 const ownerBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));
336 const sponsorBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsor));272 const sponsorBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsor));
337273
338 const userCollectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', user, true);274 const userCollectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', user);
339275
340 const result = await userCollectionEvm.methods.mintWithTokenURI(user, 'Test URI').send();276 const result = await userCollectionEvm.methods.mintWithTokenURI(user, 'Test URI').send();
341 const tokenId = result.events.Transfer.returnValues.tokenId;277 const tokenId = result.events.Transfer.returnValues.tokenId;
342278
343 const events = helper.eth.normalizeEvents(result.events);279 const events = helper.eth.normalizeEvents(result.events);
344 const address = helper.ethAddress.fromCollectionId(collectionId);280 const address = helper.ethAddress.fromCollectionId(collectionId);
345281
346 expect(events).to.be.deep.equal([282 expect(events).to.be.deep.equal([
347 {283 {
348 address,284 address,
349 event: 'Transfer',285 event: 'Transfer',
350 args: {286 args: {
351 from: '0x0000000000000000000000000000000000000000',287 from: '0x0000000000000000000000000000000000000000',
352 to: user,288 to: user,
353 tokenId: '1',289 tokenId: '1',
290 },
354 },291 },
355 },292 ]);
356 ]);293 expect(await userCollectionEvm.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');
357 expect(await userCollectionEvm.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');294
358295 const ownerBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));
359 const ownerBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));296 expect(ownerBalanceAfter).to.be.eq(ownerBalanceBefore);
360 expect(ownerBalanceAfter).to.be.eq(ownerBalanceBefore);297 const sponsorBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsor));
361 const sponsorBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsor));298 expect(sponsorBalanceAfter < sponsorBalanceBefore).to.be.true;
362 expect(sponsorBalanceAfter < sponsorBalanceBefore).to.be.true;299 }));
363 });
364
365 itEth('[cross] Check that transaction via EVM spend money from sponsor address', async ({helper}) => {
366 const owner = await helper.eth.createAccountWithBalance(donor);
367
368 const {collectionAddress, collectionId} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner,'Sponsor collection', '1', '1', '');
369 const collection = helper.nft.getCollectionObject(collectionId);
370 const sponsor = await helper.eth.createAccountWithBalance(donor);
371 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);
372 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
373
374 await collectionEvm.methods.setCollectionSponsorCross(sponsorCross).send();
375 let collectionData = (await collection.getData())!;
376 expect(collectionData.raw.sponsorship.Unconfirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));
377 await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');
378
379 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor);
380 await sponsorCollection.methods.confirmCollectionSponsorship().send();
381 collectionData = (await collection.getData())!;
382 expect(collectionData.raw.sponsorship.Confirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));
383
384 const user = helper.eth.createAccount();
385 const userCross = helper.ethCrossAccount.fromAddress(user);
386 await collectionEvm.methods.addCollectionAdminCross(userCross).send();
387
388 const ownerBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));
389 const sponsorBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsor));
390
391 const userCollectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', user);
392
393 const result = await userCollectionEvm.methods.mintWithTokenURI(user, 'Test URI').send();
394 const tokenId = result.events.Transfer.returnValues.tokenId;
395
396 const events = helper.eth.normalizeEvents(result.events);
397 const address = helper.ethAddress.fromCollectionId(collectionId);
398
399 expect(events).to.be.deep.equal([
400 {
401 address,
402 event: 'Transfer',
403 args: {
404 from: '0x0000000000000000000000000000000000000000',
405 to: user,
406 tokenId: '1',
407 },
408 },
409 ]);
410 expect(await userCollectionEvm.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');
411
412 const ownerBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));
413 expect(ownerBalanceAfter).to.be.eq(ownerBalanceBefore);
414 const sponsorBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(sponsor));
415 expect(sponsorBalanceAfter < sponsorBalanceBefore).to.be.true;
416 });
417});300});
418301