--- a/pallets/nft/src/lib.rs +++ b/pallets/nft/src/lib.rs @@ -2356,6 +2356,7 @@ let mut sponsor_transfer = false; if >::get(collection_id).sponsor_confirmed { + let collection_limits = >::get(collection_id).limits; let collection_mode = >::get(collection_id).mode; --- a/tests/src/confirmSponsorship.test.ts +++ b/tests/src/confirmSponsorship.test.ts @@ -58,33 +58,41 @@ await setCollectionSponsorExpectSuccess(collectionId, charlie.address); }); - it.only('Transfer fees are paid by the sponsor after confirmation', async () => { + it('NFT: Transfer fees are paid by the sponsor after confirmation', async () => { const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'NFT'); await setCollectionSponsorExpectSuccess(collectionId, bob.address); await confirmSponsorshipExpectSuccess(collectionId, '//Bob'); - const itemId = await createItemExpectSuccess(collectionId, 'NFT', '//Alice'); await usingApi(async (api) => { - const AsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).toString()); + const AsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString()); // Find unused address const zeroBalance = await findUnusedAddress(api); - - const aliceToZero = api.tx.nft.transfer(zeroBalance.address, collectionId, itemId, 0); - await submitTransactionAsync(alice, aliceToZero); + // Mint token for unused address + const itemId = await createItemExpectSuccess(collectionId, 'NFT', zeroBalance.address, '//Alice'); + + // Transfer this token from unused address to Alice const zeroToAlice = api.tx.nft.transfer(zeroBalance.address, collectionId, itemId, 0); const events = await submitTransactionAsync(zeroBalance, zeroToAlice); const result = getGenericResult(events); - const BsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).toString()); + const BsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString()); expect(result.success).to.be.true; - expect(BsponsorBalance.toNumber()).to.be.lessThan(AsponsorBalance.toNumber()); + expect(BsponsorBalance.lt(AsponsorBalance)).to.be.true; }); }); + it('Fungible: Transfer fees are paid by the sponsor after confirmation', async () => { + expect(false).to.be.true; + }); + + it('ReFungible: Transfer fees are paid by the sponsor after confirmation', async () => { + expect(false).to.be.true; + }); + it.skip('CreateItem fees are paid by the sponsor after confirmation', async () => { // const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'NFT'); // await setCollectionSponsorExpectSuccess(collectionId, bob.address); @@ -92,6 +100,18 @@ expect(false).to.be.true; }); + it('NFT: Sponsoring is rate limited', async () => { + expect(false).to.be.true; + }); + + it('Fungible: Sponsoring is rate limited', async () => { + expect(false).to.be.true; + }); + + it('ReFungible: Sponsoring is rate limited', async () => { + expect(false).to.be.true; + }); + }); describe('(!negative test!) integration test: ext. setCollectionSponsor():', () => { --- a/tests/src/createItem.test.ts +++ b/tests/src/createItem.test.ts @@ -12,16 +12,16 @@ it('Create new item in NFT collection', async () => { const createMode = 'NFT'; const newCollectionID = await createCollectionExpectSuccess('0', '0', '0', createMode); - await createItemExpectSuccess(newCollectionID, createMode, '//Alice'); + await createItemExpectSuccess(newCollectionID, createMode); }); it('Create new item in Fungible collection', async () => { const createMode = 'Fungible'; const newCollectionID = await createCollectionExpectSuccess('0', '0', '0', createMode); - await createItemExpectSuccess(newCollectionID, createMode, '//Alice'); + await createItemExpectSuccess(newCollectionID, createMode); }); it('Create new item in ReFungible collection', async () => { const createMode = 'ReFungible'; const newCollectionID = await createCollectionExpectSuccess('0', '0', '0', createMode); - await createItemExpectSuccess(newCollectionID, createMode, '//Alice'); + await createItemExpectSuccess(newCollectionID, createMode); }); }); --- a/tests/src/util/helpers.ts +++ b/tests/src/util/helpers.ts @@ -258,13 +258,14 @@ }); } -export async function createItemExpectSuccess(collectionId: number, createMode: string, senderSeed: string = '//Alice') { +export async function createItemExpectSuccess(collectionId: number, createMode: string, owner: string = '', senderSeed: string = '//Alice') { let newItemId: number = 0; await usingApi(async (api) => { const AItemCount = parseInt((await api.query.nft.itemListIndex(collectionId)).toString()); const sender = privateKey(senderSeed); - const tx = api.tx.nft.createItem(collectionId, sender.address, createMode); + if (owner === '') owner = sender.address; + const tx = api.tx.nft.createItem(collectionId, owner, createMode); const events = await submitTransactionAsync(sender, tx); const result = getCreateItemResult(events);