1234567891011121314151617import {IKeyringPair} from '@polkadot/types/types';18import {itSub, Pallets, requirePalletsOrSkip, usingPlaygrounds, expect} from '../../util';1920describe('Refungible transfer tests', () => {21 let donor: IKeyringPair;22 let alice: IKeyringPair;23 let bob: IKeyringPair;24 let charlie: IKeyringPair;2526 before(async function() {27 await usingPlaygrounds(async (helper, privateKey) => {28 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);2930 donor = await privateKey({url: import.meta.url});31 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);32 });33 });3435 itSub('Can transfer token pieces', async ({helper}) => {36 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});37 const token = await collection.mintToken(alice, 100n);3839 expect(await token.transfer(alice, {Substrate: bob.address}, 60n)).to.be.true;40 41 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(40n);42 expect(await token.getBalance({Substrate: bob.address})).to.be.equal(60n);43 });4445 itSub('Cannot transfer incorrect amount of token pieces', async ({helper}) => {46 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});47 const tokenAlice = await collection.mintToken(alice, 10n, {Substrate: alice.address});48 const tokenBob = await collection.mintToken(alice, 10n, {Substrate: bob.address});4950 51 await expect(tokenBob.transfer(alice, {Substrate: charlie.address}, 0n)).to.be.rejectedWith('common.TokenValueTooLow');52 await expect(tokenBob.transfer(alice, {Substrate: charlie.address}, 1n)).to.be.rejectedWith('common.TokenValueTooLow');53 await expect(tokenBob.transfer(alice, {Substrate: charlie.address}, 10n)).to.be.rejectedWith('common.TokenValueTooLow');54 await expect(tokenBob.transfer(alice, {Substrate: charlie.address}, 100n)).to.be.rejectedWith('common.TokenValueTooLow');5556 57 await expect(collection.transferToken(alice, 100, {Substrate: charlie.address}, 0n)).to.be.rejectedWith('common.TokenValueTooLow');58 await expect(collection.transferToken(alice, 100, {Substrate: charlie.address}, 1n)).to.be.rejectedWith('common.TokenValueTooLow');5960 61 await expect(tokenAlice.transfer(alice, {Substrate: bob.address}, 11n))62 .to.eventually.be.rejectedWith(/common\.TokenValueTooLow/);6364 65 await tokenAlice.transfer(alice, {Substrate: charlie.address}, 0n);6667 expect(await tokenAlice.getTop10Owners()).to.deep.eq([{Substrate: alice.address}]);68 expect(await tokenBob.getTop10Owners()).to.deep.eq([{Substrate: bob.address}]);69 expect(await tokenAlice.getBalance({Substrate: alice.address})).to.eq(10n);70 expect(await tokenBob.getBalance({Substrate: bob.address})).to.eq(10n);71 expect(await tokenBob.getBalance({Substrate: charlie.address})).to.eq(0n);72 });73});