123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- import { ApiPromise } from "@polkadot/api";
- import {
- CuratorGroup,
- CuratorGroupId,
- Channel,
- ChannelCategory,
- ChannelCategoryId,
- ChannelOwnershipTransferRequest,
- ChannelOwnershipTransferRequestId,
- Person,
- PersonId,
- Playlist,
- PlaylistId,
- Series,
- SeriesId,
- Video,
- VideoId,
- VideoCategory,
- VideoCategoryId,
- } from "@joystream/types/content";
- import { ChannelId } from "@joystream/types/storage";
- import { Hash } from "@polkadot/types/interfaces";
- export const getCuratorGroup = (
- api: ApiPromise,
- id: CuratorGroupId | number
- ): Promise<CuratorGroup> =>
- api.query.content.curatorGroupById(id) as Promise<CuratorGroup>;
- export const getChannel = (
- api: ApiPromise,
- id: ChannelId | number
- ): Promise<Channel> => api.query.content.channelById(id) as Promise<Channel>;
- export const getChannelCategory = (
- api: ApiPromise,
- id: ChannelCategoryId | number
- ): Promise<ChannelCategory> =>
- api.query.content.channelCategoryById(id) as Promise<ChannelCategory>;
- export const getVideo = (
- api: ApiPromise,
- id: VideoId | number
- ): Promise<Video> => api.query.content.videoById(id) as Promise<Video>;
- export const getVideoCategory = (
- api: ApiPromise,
- id: VideoId | number
- ): Promise<Video> => api.query.content.videoCategoryById(id) as Promise<Video>;
- export const getPerson = (
- api: ApiPromise,
- id: PersonId | number
- ): Promise<Person> => api.query.content.personById(id) as Promise<Person>;
- export const getPlaylist = (
- api: ApiPromise,
- id: PlaylistId | number
- ): Promise<Playlist> => api.query.content.playlistById(id) as Promise<Playlist>;
- export const getSeries = (
- api: ApiPromise,
- id: SeriesId | number
- ): Promise<Series> => api.query.content.seriesById(id) as Promise<Series>;
- export const getNextChannel = (
- api: ApiPromise,
- hash?: Hash
- ): Promise<ChannelId> =>
- hash
- ? (api.query.content.nextChannelId.at(hash) as Promise<ChannelId>)
- : (api.query.content.nextChannelId() as Promise<ChannelId>);
- export const getNextChannelCategory = (
- api: ApiPromise,
- hash?: Hash
- ): Promise<ChannelCategoryId> =>
- hash
- ? api.query.content.nextChannelCategoryId.at(hash)
- : (api.query.content.nextChannelCategoryId() as Promise<ChannelCategoryId>);
- export const getNextChannelOwnershipTransferRequestId = (
- api: ApiPromise,
- hash?: Hash
- ): Promise<ChannelOwnershipTransferRequestId> =>
- hash
- ? api.query.content.nextChannelOwnershipTransferRequestId.at(hash)
- : (api.query.content.nextChannelOwnershipTransferRequestId() as Promise<ChannelOwnershipTransferRequestId>);
- export const getNextCuratorGroup = (
- api: ApiPromise,
- hash?: Hash
- ): Promise<CuratorGroupId> =>
- hash
- ? api.query.content.nextCuratorGroupId.at(hash)
- : (api.query.content.nextCuratorGroupId() as Promise<CuratorGroupId>);
- export const getNextPerson = (api: ApiPromise, hash?: Hash): Promise<number> =>
- hash
- ? api.query.content.nextPersonId.at(hash)
- : api.query.content.nextPersonId();
- export const getNextPlaylist = (
- api: ApiPromise,
- hash?: Hash
- ): Promise<number> =>
- hash
- ? api.query.content.nextPlaylistId.at(hash)
- : api.query.content.nextPlaylistId();
- export const getNextSeries = (api: ApiPromise, hash?: Hash): Promise<number> =>
- hash
- ? api.query.content.nextSeriesId.at(hash)
- : api.query.content.nextSeriesId();
- export const getNextVideo = (api: ApiPromise, hash?: Hash): Promise<number> =>
- hash
- ? api.query.content.nextVideoId.at(hash)
- : api.query.content.nextVideoId();
- export const getNextVideoCategory = (
- api: ApiPromise,
- hash?: Hash
- ): Promise<number> =>
- hash
- ? api.query.content.nextVideoCategoryId.at(hash)
- : api.query.content.nextVideoCategoryId();
|