1234567891011121314151617import type {IKeyringPair} from '@polkadot/types/types';18import {usingPlaygrounds, itSub, expect} from './util/index.js';19import {ICrossAccountId} from '@unique/playgrounds/types.js';2021describe('integration test: RPC methods', () => {22 let donor: IKeyringPair;23 let alice: IKeyringPair;24 let bob: IKeyringPair;2526 before(async () => {27 await usingPlaygrounds(async (helper, privateKey) => {28 donor = await privateKey({url: import.meta.url});29 [alice, bob] = await helper.arrange.createAccounts([20n, 10n], donor);30 });31 });3233 itSub('returns None for fungible collection', async ({helper}) => {34 const collection = await helper.ft.mintCollection(alice, {name: 'RPC-1', tokenPrefix: 'RPC'});35 const owner = (await helper.callRpc('api.rpc.unique.tokenOwner', [collection.collectionId, 0])).toJSON() as any;36 expect(owner).to.be.null;37 });3839 itSub('RPC method tokenOwners for fungible collection and token', async ({helper}) => {40 41 const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};42 const facelessCrowd = (await helper.arrange.createAccounts([0n, 0n, 0n, 0n, 0n, 0n, 0n], donor))43 .map(i => ({Substrate: i.address}));4445 const collection = await helper.ft.mintCollection(alice, {name: 'RPC-2', tokenPrefix: 'RPC'});46 47 await collection.mint(alice, (1n << 128n) - 1n);4849 await collection.transfer(alice, {Substrate: bob.address}, 1000n);50 await collection.transfer(alice, ethAcc, 900n);5152 for(let i = 0; i < facelessCrowd.length; i++) {53 await collection.transfer(alice, facelessCrowd[i], 1n);54 }55 5657 const owners = await helper.callRpc('api.rpc.unique.tokenOwners', [collection.collectionId, 0]);58 const ids = owners.toHuman() as ICrossAccountId[];5960 expect(ids).to.have.deep.members([{Substrate: alice.address}, ethAcc, {Substrate: bob.address}, ...facelessCrowd]);61 expect(owners.length == 10).to.be.true;6263 64 const [eleven] = await helper.arrange.createAccounts([0n], donor);65 expect(await collection.transfer(alice, {Substrate: eleven.address}, 10n)).to.be.true;66 expect((await helper.callRpc('api.rpc.unique.tokenOwners', [collection.collectionId, 0])).length).to.be.equal(10);67 });68});