@oap75/api
Version:
JavaScript API for Subsocial blockchain.
42 lines (41 loc) • 2.01 kB
TypeScript
import { ApiPromise as SubstrateApi } from '@polkadot/api';
import { SpaceData, PostData, ProfileData } from '@subsocial/types/dto/sub';
import { AnyAccountId } from '@subsocial/types';
import { SubsocialIpfsApi } from '../ipfs';
import { SubsocialSubstrateApi } from '../substrate';
import { FindPostQuery, FindSpacesQuery, FindPostsQuery, FindSpaceQuery } from '../filters';
import { SubsocialContext } from '../types';
export declare type SubsocialApiProps = SubsocialContext & {
substrateApi: SubstrateApi;
ipfsNodeUrl: string;
offchainUrl: string;
};
/** Using this class, you can get all the data of posts, spaces and profiles from blockchain storages and ipfs */
export declare class BasicSubsocialApi {
/** Gives access to subsocial substrate api*/
private _substrate;
/** Gives access to subsocial ipfs api*/
private _ipfs;
constructor(props: SubsocialApiProps);
/** Accessors for privat field {@link _substrate}*/
get substrate(): SubsocialSubstrateApi;
/** Accessors for privat field {@link _ipfs}*/
get ipfs(): SubsocialIpfsApi;
/** Get an array of data from blockchain storages and ipfs that is passed in the parameters of the method
* @param findStructs gets an array of structures by ids
* @param findContents gets contents by cids
*/
private findDataArray;
/** Find and load an array of spaces */
findSpaces(filter: FindSpacesQuery): Promise<SpaceData[]>;
/** Find and load an array of posts */
findPosts(filter: FindPostsQuery): Promise<PostData[]>;
/** Find and load an array of profiles */
findProfiles(ids: AnyAccountId[]): Promise<ProfileData[]>;
/** Find and load single space */
findSpace({ id, visibility }: FindSpaceQuery): Promise<SpaceData | undefined>;
/** Find and load single post */
findPost({ id, visibility }: FindPostQuery): Promise<PostData | undefined>;
/** Find and load single profile */
findProfile(id: AnyAccountId): Promise<ProfileData | undefined>;
}