difftreelog
Fix rebase and uncomment rft sponsoring tests.
in: master
4 files changed
runtime/common/config/pallets/app_promotion.rsdiffbeforeafterboth22use frame_support::{parameter_types, PalletId};22use frame_support::{parameter_types, PalletId};23use sp_arithmetic::Perbill;23use sp_arithmetic::Perbill;24use up_common::{24use up_common::{25 constants::{UNIQUE, RELAY_DAYS},25 constants::{UNIQUE, RELAY_DAYS, DAYS},26 types::Balance,26 types::Balance,27};27};2828runtime/common/ethereum/sponsoring.rsdiffbeforeafterboth184 | IsOwnerOrAdminCross { .. }184 | IsOwnerOrAdminCross { .. }185 | CollectionOwner185 | CollectionOwner186 | CollectionAdmins186 | CollectionAdmins187 | CollectionLimits188 | CollectionNestingRestrictedIds189 | CollectionNestingPermissions187 | UniqueCollectionType => None,190 | UniqueCollectionType => None,188191189 // Not sponsored192 // Not sponsored207 | DeleteCollectionProperties { .. }210 | DeleteCollectionProperties { .. }208 | SetCollectionSponsor { .. }211 | SetCollectionSponsor { .. }209 | SetCollectionSponsorCross { .. }212 | SetCollectionSponsorCross { .. }210 | ConfirmCollectionSponsorship213 | SetCollectionLimit { .. }211 | RemoveCollectionSponsor214 | ConfirmCollectionSponsorship212 | SetIntLimit { .. } => None,215 | RemoveCollectionSponsor => None,213 }216 }214 }217 }215}218}runtime/common/ethereum/sponsoring/refungible.rsdiffbeforeafterboth797980 match call {80 match call {81 // Readonly81 // Readonly82 ERC165Call(_, _) | Property { .. } => None,82 ERC165Call(_, _) | Property { .. } | TokenPropertyPermissions => None,838384 // Not sponsored84 // Not sponsored85 SetTokenPropertyPermission { .. }85 SetTokenPropertyPermission { .. }86 | SetTokenPropertyPermissions { .. }86 | SetProperties { .. }87 | SetProperties { .. }87 | DeleteProperty { .. }88 | DeleteProperty { .. }88 | DeleteProperties { .. } => None,89 | DeleteProperties { .. } => None,236 | TransferFromCross { .. }237 | TransferFromCross { .. }237 | BurnFrom { .. }238 | BurnFrom { .. }238 | BurnFromCross { .. }239 | BurnFromCross { .. }240 | MintCross { .. }239 | MintBulk { .. }241 | MintBulk { .. }240 | MintBulkWithTokenUri { .. } => None,242 | MintBulkWithTokenUri { .. } => None,241243333335334 // Not sponsored336 // Not sponsored335 BurnFrom { .. } | Repartition { .. } => None,337 BurnFrom { .. }338 | BurnFromCross { .. }339 | ApproveCross { .. }340 | TransferCross { .. }341 | TransferFromCross { .. }342 | Repartition { .. } => None,336 }343 }337 }344 }tests/src/eth/collectionSponsoring.test.tsdiffbeforeafterboth359 });359 });360 });360 });361361362 // TODO: Temprorary off. Need refactor363 // itWeb3('Set substrate sponsor', async ({api, web3, privateKeyWrapper}) => {364 // const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);365 // const collectionHelpers = evmCollectionHelpers(web3, owner);366 // let result = await collectionHelpers.methods.createRFTCollection('Sponsor collection', '1', '1').send();367 // const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);368 // const sponsor = privateKeyWrapper('//Alice');369 // const collectionEvm = evmCollection(web3, owner, collectionIdAddress);370371 // expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;372 // result = await collectionEvm.methods.setCollectionSponsorSubstrate(sponsor.addressRaw).send({from: owner});373 // expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.true;374375 // const confirmTx = await api.tx.unique.confirmSponsorship(collectionId);376 // await submitTransactionAsync(sponsor, confirmTx);377 // expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;378379 // const sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});380 // expect(bigIntToSub(api, BigInt(sponsorTuple[1]))).to.be.eq(sponsor.address);381 // });382383 [362 [384 'setCollectionSponsorCross',363 'setCollectionSponsorCross',385 'setCollectionSponsor', // Soft-deprecated364 'setCollectionSponsor', // Soft-deprecated404 await collectionEvm.methods.removeCollectionSponsor().send({from: owner});383 await collectionEvm.methods.removeCollectionSponsor().send({from: owner});405 384 406 const sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});385 const sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});407 expect(sponsorTuple.field_0).to.be.eq('0x0000000000000000000000000000000000000000');386 expect(sponsorTuple.eth).to.be.eq('0x0000000000000000000000000000000000000000');408 }));387 }));409388410 [389 [426 let sponsorship = (await collectionSub.getData())!.raw.sponsorship;405 let sponsorship = (await collectionSub.getData())!.raw.sponsorship;427 expect(sponsorship.Unconfirmed).to.be.eq(helper.address.ethToSubstrate(sponsorEth, true));406 expect(sponsorship.Unconfirmed).to.be.eq(helper.address.ethToSubstrate(sponsorEth, true));428 // Account cannot confirm sponsorship if it is not set as a sponsor407 // Account cannot confirm sponsorship if it is not set as a sponsor429 await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');408 //await collectionEvm.methods.confirmCollectionSponsorship().call();409 await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');430 410 431 // Sponsor can confirm sponsorship:411 // Sponsor can confirm sponsorship:432 await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsorEth});412 await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsorEth});481 }461 }482 }));462 }));483463484 // TODO: Temprorary off. Need refactor485 // itWeb3('Sponsoring collection from substrate address via access list', async ({api, web3, privateKeyWrapper}) => {486 // const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);487 // const collectionHelpers = evmCollectionHelpers(web3, owner);488 // const result = await collectionHelpers.methods.createERC721MetadataCompatibleRFTCollection('Sponsor collection', '1', '1', '').send();489 // const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);490 // const sponsor = privateKeyWrapper('//Alice');491 // const collectionEvm = evmCollection(web3, owner, collectionIdAddress);492493 // await collectionEvm.methods.setCollectionSponsorSubstrate(sponsor.addressRaw).send({from: owner});494495 // const confirmTx = await api.tx.unique.confirmSponsorship(collectionId);496 // await submitTransactionAsync(sponsor, confirmTx);497498 // const user = createEthAccount(web3);499 // const nextTokenId = await collectionEvm.methods.nextTokenId().call();500 // expect(nextTokenId).to.be.equal('1');501502 // await collectionEvm.methods.setCollectionAccess(1 /*'AllowList'*/).send({from: owner});503 // await collectionEvm.methods.addToCollectionAllowList(user).send({from: owner});504 // await collectionEvm.methods.setCollectionMintMode(true).send({from: owner});505506 // const ownerBalanceBefore = await ethBalanceViaSub(api, owner);507 // const sponsorBalanceBefore = (await getBalance(api, [sponsor.address]))[0];508509 // {510 // const nextTokenId = await collectionEvm.methods.nextTokenId().call();511 // expect(nextTokenId).to.be.equal('1');512 // const result = await collectionEvm.methods.mintWithTokenURI(513 // user,514 // nextTokenId,515 // 'Test URI',516 // ).send({from: user});517 // const events = normalizeEvents(result.events);518519 // expect(events).to.be.deep.equal([520 // {521 // address: collectionIdAddress,522 // event: 'Transfer',523 // args: {524 // from: '0x0000000000000000000000000000000000000000',525 // to: user,526 // tokenId: nextTokenId,527 // },528 // },529 // ]);530531 // const ownerBalanceAfter = await ethBalanceViaSub(api, owner);532 // const sponsorBalanceAfter = (await getBalance(api, [sponsor.address]))[0];533534 // expect(await collectionEvm.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');535 // expect(ownerBalanceBefore).to.be.eq(ownerBalanceAfter);536 // expect(sponsorBalanceBefore > sponsorBalanceAfter).to.be.true;537 // }538 // });539540 [464 [541 'setCollectionSponsorCross',465 'setCollectionSponsorCross',554 await collectionEvm.methods[testCase](testCase === 'setCollectionSponsor' ? sponsor : sponsorCross).send();478 await collectionEvm.methods[testCase](testCase === 'setCollectionSponsor' ? sponsor : sponsorCross).send();555 let collectionData = (await collectionSub.getData())!;479 let collectionData = (await collectionSub.getData())!;556 expect(collectionData.raw.sponsorship.Unconfirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));480 expect(collectionData.raw.sponsorship.Unconfirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));557 await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');481 await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');558 482 559 await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsor});483 await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsor});560 collectionData = (await collectionSub.getData())!;484 collectionData = (await collectionSub.getData())!;600 const collectionSub = helper.rft.getCollectionObject(collectionId);524 const collectionSub = helper.rft.getCollectionObject(collectionId);601 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'rft', owner, false);525 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'rft', owner, false);602 // Set collection sponsor:526 // Set collection sponsor:527 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call()).to.be.false;603 await collectionEvm.methods.setCollectionSponsorCross(sponsorCross).send();528 await collectionEvm.methods.setCollectionSponsorCross(sponsorCross).send();529 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call()).to.be.true;604530605 await collectionSub.confirmSponsorship(sponsor);531 await collectionSub.confirmSponsorship(sponsor);532 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call()).to.be.false;606533607 const user = helper.eth.createAccount();534 const user = helper.eth.createAccount();608 const userCross = helper.ethCrossAccount.fromAddress(user);535 const userCross = helper.ethCrossAccount.fromAddress(user);615 const tokenId = mintingResult.events.Transfer.returnValues.tokenId;542 const tokenId = mintingResult.events.Transfer.returnValues.tokenId;616543617 const events = helper.eth.normalizeEvents(mintingResult.events);544 const events = helper.eth.normalizeEvents(mintingResult.events);618 const address = helper.ethAddress.fromCollectionId(collectionId);619545620 expect(events).to.deep.include({546 expect(events).to.deep.include({621 address,547 address: collectionAddress,622 event: 'Transfer',548 event: 'Transfer',623 args: {549 args: {624 from: '0x0000000000000000000000000000000000000000',550 from: '0x0000000000000000000000000000000000000000',632 expect(ownerBalanceAfter).to.be.eq(ownerBalanceBefore);558 expect(ownerBalanceAfter).to.be.eq(ownerBalanceBefore);633 const sponsorBalanceAfter = await helper.balance.getSubstrate(sponsor.address);559 const sponsorBalanceAfter = await helper.balance.getSubstrate(sponsor.address);634 expect(sponsorBalanceAfter < sponsorBalanceBefore).to.be.true;560 expect(sponsorBalanceAfter < sponsorBalanceBefore).to.be.true;561 });562563 itEth('Sponsoring collection from substrate address via access list', async ({helper}) => {564 const owner = await helper.eth.createAccountWithBalance(donor);565 const user = helper.eth.createAccount();566 const userCross = helper.ethCrossAccount.fromAddress(user);567 const sponsor = alice;568 const sponsorCross = helper.ethCrossAccount.fromKeyringPair(sponsor);569570 const {collectionAddress, collectionId} = await helper.eth.createERC721MetadataCompatibleRFTCollection(owner,'Sponsor collection', '1', '1', '');571 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'rft', owner, false);572573 await collectionEvm.methods.setCollectionSponsorCross(sponsorCross).send({from: owner});574575 const collectionSub = helper.rft.getCollectionObject(collectionId);576 await collectionSub.confirmSponsorship(sponsor);577578 const nextTokenId = await collectionEvm.methods.nextTokenId().call();579 expect(nextTokenId).to.be.equal('1');580581 await collectionEvm.methods.setCollectionAccess(1 /*'AllowList'*/).send({from: owner});582 583 await collectionEvm.methods.addToCollectionAllowListCross(userCross).send({from: owner});584 await collectionEvm.methods.setCollectionMintMode(true).send({from: owner});585586 const ownerBalanceBefore = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));587 const sponsorBalanceBefore = await helper.balance.getSubstrate(sponsor.address);588589 {590 const nextTokenId = await collectionEvm.methods.nextTokenId().call();591 expect(nextTokenId).to.be.equal('1');592 const mintingResult = await collectionEvm.methods.mintWithTokenURI(593 user,594 'Test URI',595 ).send({from: user});596597 const events = helper.eth.normalizeEvents(mintingResult.events);598 599600 expect(events).to.deep.include({601 address: collectionAddress,602 event: 'Transfer',603 args: {604 from: '0x0000000000000000000000000000000000000000',605 to: user,606 tokenId: nextTokenId,607 },608 });609610 const ownerBalanceAfter = await helper.balance.getSubstrate(helper.address.ethToSubstrate(owner));611 const sponsorBalanceAfter = await helper.balance.getSubstrate(sponsor.address);612613 expect(await collectionEvm.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');614 expect(ownerBalanceBefore).to.be.eq(ownerBalanceAfter);615 expect(sponsorBalanceBefore > sponsorBalanceAfter).to.be.true;616 }635 });617 });636618637 itEth('Can reassign collection sponsor', async ({helper}) => {619 itEth('Can reassign collection sponsor', async ({helper}) => {