1import { IKeyringPair } from '@polkadot/types/types';2import chai from 'chai';3import chaiAsPromised from 'chai-as-promised';4import privateKey from '../substrate/privateKey';5import usingApi from '../substrate/substrate-api';6import {7 createCollectionExpectSuccess, setCollectionSponsorExpectSuccess,8} from '../util/helpers';910chai.use(chaiAsPromised);11const expect = chai.expect;12let Alice: IKeyringPair;13let Bob: IKeyringPair;14let Ferdie: IKeyringPair;1516before(async () => {17 await usingApi(async () => {18 Alice = privateKey('//Alice');19 Bob = privateKey('//Bob');20 Ferdie = privateKey('//Ferdie');21 });22});2324describe('Sponsored with new owner ', () => {25 26 it('Confirmation of sponsorship of a collection in a block with a change in the owner of the collection: ', async () => {27 await usingApi(async (api) => {28 const collectionId = await createCollectionExpectSuccess();29 await setCollectionSponsorExpectSuccess(collectionId, Bob.address);30 const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));31 await timeoutPromise(10000);32 const confirmSponsorship = api.tx.nft.confirmSponsorship(collectionId);33 const changeCollectionOwner = api.tx.nft.changeCollectionOwner(collectionId, Ferdie.address);34 await Promise.all([35 confirmSponsorship.signAndSend(Bob),36 changeCollectionOwner.signAndSend(Alice),37 ]);38 await timeoutPromise(10000);39 const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();40 expect(collection.Sponsorship.Confirmed).to.be.eq(Bob.address);41 expect(collection.Owner).to.be.eq(Ferdie.address);42 await timeoutPromise(20000);43 });44 });45});