UNPKG

@subsocial/api

Version:
28 lines (27 loc) 1.75 kB
import { PostId, ReactionId, Reaction, Post, Content } from '@subsocial/definitions/interfaces'; import { GenericAccountId } from '@polkadot/types'; import { SubmittableResult } from '@polkadot/api'; import BN from 'bn.js'; import { AnyAccountId, CommonStruct, IpfsCid, SubstrateId } from '../types'; import { CID } from 'ipfs-http-client'; export declare type SupportedSubstrateId = SubstrateId | AnyAccountId | ReactionId; export declare type SupportedSubstrateResult = CommonStruct | Reaction; declare type AnyId = SupportedSubstrateId | IpfsCid; export declare const getUniqueIds: <ID extends AnyId>(ids: (ID | undefined)[]) => ID[]; export declare function asAccountId(id: AnyAccountId): GenericAccountId | undefined; export declare function isAccountId(id: AnyAccountId): boolean; export declare const getSharedPostId: (postData: any) => PostId | undefined; declare type HasPostStruct = { struct: Post; }; /** Return original post id from shared post or root post id if this post is a comment. */ export declare const getPostIdFromExtension: (postData?: HasPostStruct | undefined) => PostId | undefined; export declare const isIpfs: (content?: Content | undefined) => any; /** Validate whether given string is a cid or not. Returns undefined if empty, and throws error if not a cid */ export declare const asIpfsCid: (cid: IpfsCid) => CID | undefined; /** Check whether given string is a cid or not. */ export declare const isValidIpfsCid: (cid: IpfsCid) => boolean; export declare const resolveCidOfContent: (content?: Content | undefined) => string | undefined; export declare type ResultEventType = 'Created' | 'Updated'; export declare function getNewIdsFromEvent(txResult: SubmittableResult, eventType?: ResultEventType): BN[]; export {};