@oap75/api
Version:
JavaScript API for Subsocial blockchain.
108 lines (107 loc) • 5.31 kB
TypeScript
import { ApiPromise as SubstrateApi } from '@polkadot/api';
import { AnyAccountId, AnySpaceId, AnyPostId, AnyReactionId, PalletName } from '@subsocial/types';
import { Space, SpaceId, Post, PostId, Reaction, ReactionId } from '@subsocial/types/substrate/interfaces';
import { SupportedSubstrateId, SupportedSubstrateResult } from '../utils';
import { FindSpaceQuery, FindSpacesQuery, FindPostsQuery, FindPostQuery } from '../filters';
import { SocialAccountWithId } from '@subsocial/types/dto';
import { SubsocialContext } from '../types';
declare type StorageItem = {
pallet: PalletName;
storage: string;
};
declare type SubstrateApiProps = SubsocialContext & {
api: SubstrateApi;
};
export declare class SubsocialSubstrateApi {
private _api;
constructor({ api }: SubstrateApiProps);
getPalletQuery: (pallet: PalletName) => Promise<import("@polkadot/api-base/types").QueryableModuleStorage<"promise">>;
get api(): Promise<SubstrateApi>;
private queryPallet;
private queryPosts;
private querySpaces;
private queryProfiles;
private queryPalletMulti;
private isBooleanByAccount;
private getReactionIdsByAccount;
findStructs<T extends SupportedSubstrateResult>(storageItem: StorageItem, ids: SupportedSubstrateId[]): Promise<T[]>;
/**
* Find and load an array of information about spaces from Subsocial blockchain by a given array of `ids` and
* `visibility` filter.
*
* @returns An array of data about desired spaces from Subsocial blockchain. If no corresponding spaces to given array
* of `ids` and `visibility`, an empty array is returned.
*/
findSpaces(params: FindSpacesQuery): Promise<Space[]>;
/**
* Find and load an array of information about posts from Subsocial blockchain by a given array of `ids` and
* `visibility` filter.
*
* @returns An array of data about desired posts from Subsocial blockchain. If no corresponding posts to given array
* of `ids` and `visibility`, an empty array is returned.
*/
findPosts(params: FindPostsQuery): Promise<Post[]>;
/**
* Find and load an array of information about social profiles from Subsocial blockchain by a given array of account
* `ids`.
*
* @param ids - An array of account ids of desired profiles.
*
* @returns An array of data about desired profiles from Subsocial blockchain. If no corresponding profiles to given
* array of `ids`, an empty array is returned.
*/
findSocialAccounts(ids: AnyAccountId[]): Promise<SocialAccountWithId[]>;
/**
* Find and load an array of information about reactions from Subsocial blockchain by a given array of `ids`.
*
* @param ids - An array of ids of desired reactions.
*
* @returns An array of data about desired reactions from Subsocial blockchain. If no corresponding reactions to given
* array of `ids`, an empty array is returned.
*/
findReactions(ids: AnyReactionId[]): Promise<Reaction[]>;
/**
* Find and load information about a space from Subsocial blockchain by a given `id` and `visibility` filter.
*
* @returns Data about desired space from Subsocial blockchain. If no corresponding space to given `id` and
* `visibility`, `undefined` is returned.
*/
findSpace(params: FindSpaceQuery): Promise<Space | undefined>;
/**
* Find and load information about a post from Subsocial blockchain by a given `id` and `visibility` filter.
*
* @returns Data about desired post from Subsocial blockchain. If no corresponding post to given `id` and
* `visibility`, `undefined` is returned.
*/
findPost(params: FindPostQuery): Promise<Post | undefined>;
/**
* Find and load information about a profile from Subsocial blockchain by a given `id`.
*
* @param id - Account id of desired profile.
*
* @returns Data about desired profile from Subsocial blockchain. If no corresponding profile to given `id`,
* `undefined` is returned.
*/
findSocialAccount(id: AnyAccountId): Promise<SocialAccountWithId | undefined>;
/**
* Find and load information about a reaction from Subsocial blockchain by a given `id`.
*
* @param id - Id of desired reaction.
*
* @returns Data about desired reaction from Subsocial blockchain. If no corresponding reaction to given `id`,
* `undefined` is returned.
*/
findReaction(id: AnyReactionId): Promise<Reaction | undefined>;
getPostReactionIdByAccount(accountId: AnyAccountId, postId: AnyPostId): Promise<ReactionId | undefined>;
getPostReactionIdsByAccount(accountId: AnyAccountId, postIds: AnyPostId[]): Promise<ReactionId[]>;
nextSpaceId(): Promise<SpaceId>;
nextPostId(): Promise<PostId>;
getSpaceIdByHandle(handle: string): Promise<SpaceId | undefined>;
getReplyIdsByPostId(id: AnyPostId): Promise<PostId[]>;
spaceIdsByOwner(id: AnyAccountId): Promise<SpaceId[]>;
spaceIdsFollowedByAccount(id: AnyAccountId): Promise<SpaceId[]>;
postIdsBySpaceId(id: AnySpaceId): Promise<PostId[]>;
isAccountFollower(myAddress: AnyAccountId, followedAddress: AnyAccountId): Promise<boolean>;
isSpaceFollower(myAddress: AnyAccountId, spaceId: AnySpaceId): Promise<boolean>;
}
export {};