1234567891011121314151617import {IKeyringPair} from '@polkadot/types/types';18import {expect, itSub, Pallets, usingPlaygrounds} from './util';1920const SPONSORING_TIMEOUT = 5;2122describe('Integration Test getNextSponsored(collection_id, owner, item_id):', () => {23 let alice: IKeyringPair;24 let bob: IKeyringPair;2526 before(async () => {27 await usingPlaygrounds(async (helper, privateKey) => {28 const donor = await privateKey({url: import.meta.url});29 [alice, bob] = await helper.arrange.createAccounts([20n, 10n], donor);30 });31 });3233 itSub('NFT', async ({helper}) => {34 35 expect(await helper.collection.getTokenNextSponsored(0, 0, {Substrate: alice.address})).to.be.null;3637 const collection = await helper.nft.mintCollection(alice, {});38 const token = await collection.mintToken(alice);3940 41 expect(await token.getNextSponsored({Substrate: alice.address})).to.be.null;4243 44 await collection.setSponsor(alice, bob.address);45 expect(await token.getNextSponsored({Substrate: alice.address})).to.be.null;4647 48 await collection.confirmSponsorship(bob);49 expect(await token.getNextSponsored({Substrate: alice.address})).to.be.equal(0);5051 52 await token.transfer(alice, {Substrate: bob.address});53 expect(await token.getNextSponsored({Substrate: alice.address})).to.be.lessThanOrEqual(SPONSORING_TIMEOUT);5455 56 expect(await collection.getTokenNextSponsored(0, {Substrate: alice.address})).to.be.null;57 });5859 itSub('Fungible', async ({helper}) => {60 const collection = await helper.ft.mintCollection(alice, {});61 await collection.mint(alice, 10n);6263 64 expect(await collection.getTokenNextSponsored(0, {Substrate: alice.address})).to.be.null;6566 await collection.setSponsor(alice, bob.address);67 await collection.confirmSponsorship(bob);6869 70 expect(await collection.getTokenNextSponsored(0, {Substrate: alice.address})).to.be.equal(0);7172 73 await collection.transfer(alice, {Substrate: bob.address});74 expect(await collection.getTokenNextSponsored(0, {Substrate: alice.address})).to.be.lessThanOrEqual(SPONSORING_TIMEOUT);75 });7677 itSub.ifWithPallets('ReFungible', [Pallets.ReFungible], async ({helper}) => {78 const collection = await helper.rft.mintCollection(alice, {});79 const token = await collection.mintToken(alice, 10n);8081 82 expect(await token.getNextSponsored({Substrate: alice.address})).to.be.null;8384 await collection.setSponsor(alice, bob.address);85 await collection.confirmSponsorship(bob);8687 88 expect(await token.getNextSponsored({Substrate: alice.address})).to.be.equal(0);8990 91 await token.transfer(alice, {Substrate: bob.address});92 expect(await token.getNextSponsored({Substrate: alice.address})).to.be.lessThanOrEqual(SPONSORING_TIMEOUT);9394 95 expect(await collection.getTokenNextSponsored(0, {Substrate: alice.address})).to.be.null;96 });97});