difftreelog
chore fix code review requests
in: master
2 files changed
runtime/common/ethereum/sponsoring/refungible.rsdiffbeforeafterboth233 | TokenContractAddress { .. } => None,233 | TokenContractAddress { .. } => None,234234235 // Not sponsored235 // Not sponsored236 BurnFrom { .. } | BurnFromCross { .. } => None,236 BurnFrom { .. } | BurnFromCross { .. } | MintBulk { .. } | MintBulkWithTokenUri { .. } => None,237237238 MintCross { .. } | MintBulk { .. } | MintBulkWithTokenUri { .. } => {238 MintCross { .. } => {239 withdraw_create_item::<T>(239 withdraw_create_item::<T>(240 &collection,240 &collection,241 &who,241 &who,tests/src/eth/collectionSponsoring.test.tsdiffbeforeafterboth161617import {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';18import {Pallets, requirePalletsOrSkip, usingPlaygrounds} from '../util/index';18import {Pallets, requirePalletsOrSkip, usingPlaygrounds} from '../util/index';19import { CrossAccountId } from '../util/playgrounds/unique';20import {itEth, expect} from './util';19import {itEth, expect} from './util';212022describe('evm nft collection sponsoring', () => {21describe('evm nft collection sponsoring', () => {102 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.true;101 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.true;103102104 await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsor});103 await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsor});105 let sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});104 let sponsorStruct = await collectionEvm.methods.collectionSponsor().call({from: owner});106 expect(helper.address.restoreCrossAccountFromBigInt(BigInt(sponsorTuple.sub))).to.be.eq(helper.address.ethToSubstrate(sponsor, true));105 expect(helper.address.restoreCrossAccountFromBigInt(BigInt(sponsorStruct.sub))).to.be.eq(helper.address.ethToSubstrate(sponsor, true));107 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;106 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;108107109 await collectionEvm.methods.removeCollectionSponsor().send({from: owner});108 await collectionEvm.methods.removeCollectionSponsor().send({from: owner});110109111 sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});110 sponsorStruct = await collectionEvm.methods.collectionSponsor().call({from: owner});112 expect(sponsorTuple.eth).to.be.eq('0x0000000000000000000000000000000000000000');111 expect(sponsorStruct.eth).to.be.eq('0x0000000000000000000000000000000000000000');113 }));112 }));114113115 [114 [337 [336 [338 'mintCross',337 'mintCross',339 'mintWithTokenURI',338 'mintWithTokenURI',340 'mintBulk',341 'mintBulkWithTokenUri',342 ].map(testCase => 339 ].map(testCase => 343 itEth(`[${testCase}] sponsors mint transactions`, async ({helper}) => {340 itEth(`[${testCase}] sponsors mint transactions`, async ({helper}) => {344 const collection = await helper.rft.mintCollection(alice, {tokenPrefix: 'spnr', permissions: {mintMode: true}, tokenPropertyPermissions: [341 const collection = await helper.rft.mintCollection(alice, {tokenPrefix: 'spnr', permissions: {mintMode: true}, tokenPropertyPermissions: [364361365 let mintingResult;362 let mintingResult;366 let tokenId;363 let tokenId;367 const nextTokenId = await contract.methods.nextTokenId().call();368 switch (testCase) {364 switch (testCase) {369 case 'mintCross':365 case 'mintCross':370 mintingResult = await contract.methods.mintCross(minterCross, []).send();366 mintingResult = await contract.methods.mintCross(minterCross, []).send();374 tokenId = mintingResult.events.Transfer.returnValues.tokenId;370 tokenId = mintingResult.events.Transfer.returnValues.tokenId;375 expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');371 expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');376 break;372 break;377 case 'mintBulk':378 mintingResult = await contract.methods.mintBulk(minter, [nextTokenId]).send();379 break;380 case 'mintBulkWithTokenUri':381 mintingResult = await contract.methods.mintBulkWithTokenURI(minter, [[nextTokenId, 'Test URI']]).send();382 tokenId = mintingResult.events.Transfer.returnValues.tokenId;383 expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');384 break;385 }373 }386374387 const events = helper.eth.normalizeEvents(mintingResult.events);375 const events = helper.eth.normalizeEvents(mintingResult.events);419 407 420 await collectionEvm.methods.removeCollectionSponsor().send({from: owner});408 await collectionEvm.methods.removeCollectionSponsor().send({from: owner});421 409 422 const sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});410 const sponsorStruct = await collectionEvm.methods.collectionSponsor().call({from: owner});423 expect(sponsorTuple.eth).to.be.eq('0x0000000000000000000000000000000000000000');411 expect(sponsorStruct.eth).to.be.eq('0x0000000000000000000000000000000000000000');424 }));412 }));425413426 [414 [524 collectionData = (await collectionSub.getData())!;512 collectionData = (await collectionSub.getData())!;525 expect(collectionData.raw.sponsorship.Confirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));513 expect(collectionData.raw.sponsorship.Confirmed).to.be.eq(helper.address.ethToSubstrate(sponsor, true));526 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call()).to.be.false;514 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call()).to.be.false;527 const sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});515 const sponsorStruct = await collectionEvm.methods.collectionSponsor().call({from: owner});528 const sponsorSubAddress = helper.address.normalizeSubstrateToChainFormat(helper.address.ethToSubstrate(sponsor));516 const sponsorSubAddress = helper.address.normalizeSubstrateToChainFormat(helper.address.ethToSubstrate(sponsor));529 const actualSubAddress = helper.address.normalizeSubstrateToChainFormat(helper.address.restoreCrossAccountFromBigInt(BigInt(sponsorTuple.sub)));517 const actualSubAddress = helper.address.normalizeSubstrateToChainFormat(helper.address.restoreCrossAccountFromBigInt(BigInt(sponsorStruct.sub)));530 expect(actualSubAddress).to.be.equal(sponsorSubAddress);518 expect(actualSubAddress).to.be.equal(sponsorSubAddress);531519532 const user = helper.eth.createAccount();520 const user = helper.eth.createAccount();580 collectionData = (await collectionSub.getData())!;568 collectionData = (await collectionSub.getData())!;581 expect(collectionData.raw.sponsorship.Confirmed).to.be.eq(sponsor.address);569 expect(collectionData.raw.sponsorship.Confirmed).to.be.eq(sponsor.address);582 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call()).to.be.false;570 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call()).to.be.false;583 const sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});571 const sponsorStruct = await collectionEvm.methods.collectionSponsor().call({from: owner});584 expect(BigInt(sponsorTuple.sub)).to.be.equal(BigInt('0x' + Buffer.from(sponsor.addressRaw).toString('hex')));572 expect(BigInt(sponsorStruct.sub)).to.be.equal(BigInt('0x' + Buffer.from(sponsor.addressRaw).toString('hex')));585573586 const user = helper.eth.createAccount();574 const user = helper.eth.createAccount();587 const userCross = helper.ethCrossAccount.fromAddress(user);575 const userCross = helper.ethCrossAccount.fromAddress(user);