Hierarchy

  • SocialProtocol

Implements

  • SplingProtocol

Constructors

  • Constructor for Protocol class.

    Parameters

    • wallet: any

      The wallet (useWallet() function from solana wallet-adapter) or keypair of the user.

    • payer: Keypair = null
    • Optional options: ProtocolOptions

      Options for the Protocol instance (optional).

    Returns SocialProtocol

Group Properties

createGroup: ((name: string, bio: string, avatar: FileData | FileUriData, metadata?: any) => Promise<Group>) = createGroup

Type declaration

    • (name: string, bio: string, avatar: FileData | FileUriData, metadata?: any): Promise<Group>
    • Creates a new group.

      Returns

      A Promise that resolves with the newly created group.

      Parameters

      • name: string

        The name of the group.

      • bio: string

        An optional description of the group.

      • avatar: FileData | FileUriData

        An optional avatar for the group. Can be a FileData, FileUriData, or null.

      • metadata: any = null

        An json object containing any relevant metadata to be associated with the group.

      Returns Promise<Group>

deleteGroup: (() => Promise<void>) = deleteGroup

Type declaration

    • (): Promise<void>
    • Deletes own user group.

      Returns

      A promise that resolves when the group has been successfully deleted.

      Returns Promise<void>

getAllGroups: ((limit?: number, offset?: number, orderBy?: Order_By) => Promise<Group[]>) = getAllGroups

Type declaration

    • (limit?: number, offset?: number, orderBy?: Order_By): Promise<Group[]>
    • Get all groups.

      Returns

      • Promise resolving to an array of groups.

      Parameters

      • limit: number = null

        Maximum number of groups to return. (optional, requires useIndexer option to be enabled)

      • offset: number = null

        Offset to start returning groups from. (optional, requires useIndexer option to be enabled)

      • orderBy: Order_By = null

        The order to return groups by timestamp. (optional, requires useIndexer option to be enabled)

      Returns Promise<Group[]>

getGroup: ((groupId: number) => Promise<Group | null>) = getGroup

Type declaration

    • (groupId: number): Promise<Group | null>
    • Retrieves a group associated with the id.

      Returns

      • A promise that resolves to the group, or null if no group was found.

      Parameters

      • groupId: number

        The id of the group to retrieve.

      Returns Promise<Group | null>

getGroupByPublicKey: ((publicKey: PublicKey) => Promise<Group | null>) = getGroupByPublicKey

Type declaration

    • (publicKey: PublicKey): Promise<Group | null>
    • Retrieves a group associated with the specified public key.

      Returns

      A Promise that resolves to the group associated with the specified public key, or null if no group was found.

      Parameters

      • publicKey: PublicKey

        The public key of the group to be retrieved.

      Returns Promise<Group | null>

getUserGroup: ((publicKey: PublicKey) => Promise<Group | null>) = getUserGroup

Type declaration

    • (publicKey: PublicKey): Promise<Group | null>
    • Retrieves the group associated with a given user public key.

      Returns

      • A promise that resolves to the group, or null if no group was found.

      Parameters

      • publicKey: PublicKey

        The public key of the user to retrieve the group for.

      Returns Promise<Group | null>

joinGroup: ((groupId: number) => Promise<void>) = joinGroup

Type declaration

    • (groupId: number): Promise<void>
    • Join group with the given group id.

      Returns

      A promise that resolves when the user has joined the group.

      Parameters

      • groupId: number

        the id of the group.

      Returns Promise<void>

leaveGroup: ((groupId: number) => Promise<void>) = leaveGroup

Type declaration

    • (groupId: number): Promise<void>
    • Leave group with the given group id.

      Returns

      A promise that resolves when the user has left the group.

      Parameters

      • groupId: number

        the id of the group.

      Returns Promise<void>

updateGroup: ((name?: string, avatar?: FileData | FileUriData, biography?: string, metadata?: any) => Promise<Group>) = updateGroup

Type declaration

    • (name?: string, avatar?: FileData | FileUriData, biography?: string, metadata?: any): Promise<Group>
    • Update a user group with the given parameters.

      Returns

      A promise that resolves to the newly created user.

      Parameters

      • name: string = null

        The name of the group to be updated.

      • avatar: FileData | FileUriData = null

        The avatar of the group to be updated. Can be a FileData object, a FileUriData object, or null.

      • biography: string = null

        The biography for the group to be updated. Can be a string or null.

      • metadata: any = null

        An updated json object containing any relevant metadata to be associated with the group.

      Returns Promise<Group>

Post Properties

createPost: ((groupId: number, title?: string, text?: string, files?: FileData[] | FileUriData[], tag?: string, metadata?: any) => Promise<Post>) = createPost

Type declaration

    • (groupId: number, title?: string, text?: string, files?: FileData[] | FileUriData[], tag?: string, metadata?: any): Promise<Post>
    • Creates a new post in the specific group with the given parameters.

      Returns

      • A promise that resolves to the newly created post.

      Parameters

      • groupId: number

        The id of the group to post to.

      • title: string = null

        The title of the post

      • text: string = null

        The text (content) of the post

      • files: FileData[] | FileUriData[] = null

        The file(s) to be posted (e.g. image / gif / video).

      • tag: string = null

        The tag to be associated with the post.

      • metadata: any = null

        An json object containing any relevant metadata to be associated with the post.

      Returns Promise<Post>

createPostReply: ((postId: number, text: string, metadata?: any) => Promise<Reply>) = createPostReply

Type declaration

    • (postId: number, text: string, metadata?: any): Promise<Reply>
    • Creates a reply to the given post.

      Returns

      • A promise that resolves with the new created reply.

      Parameters

      • postId: number

        The id of the post to reply to.

      • text: string

        The content of the reply.

      • metadata: any = null

        An json object containing any relevant metadata to be associated with the reply.

      Returns Promise<Reply>

deletePost: ((publicKey: PublicKey) => Promise<void>) = deletePost

Type declaration

    • (publicKey: PublicKey): Promise<void>
    • Delete a post by the given public key.

      Returns

      A promise that resolves when the post has been deleted.

      Parameters

      • publicKey: PublicKey

        The public key of the post to be deleted.

      Returns Promise<void>

deletePostReply: ((publicKey: PublicKey) => Promise<void>) = deletePostReply

Type declaration

    • (publicKey: PublicKey): Promise<void>
    • Deletes a post reply associated with the given public key.

      Returns

      • A promise that resolves when the post reply was deleted.

      Parameters

      • publicKey: PublicKey

        The public key of the post reply to be deleted.

      Returns Promise<void>

getAllPostReplies: ((postId: number, limit?: number, offset?: number, orderBy?: Order_By) => Promise<Reply[]>) = getAllPostReplies

Type declaration

    • (postId: number, limit?: number, offset?: number, orderBy?: Order_By): Promise<Reply[]>
    • Returns

      • Promise resolving to an array of replies.

      Parameters

      • postId: number

        The post id where the post replies should be fetched.

      • limit: number = null

        Maximum number of replies to return. (optional, requires useIndexer option to be enabled)

      • offset: number = null

        Offset to start returning replies from. (optional, requires useIndexer option to be enabled)

      • orderBy: Order_By = null

        The order to return replies by timestamp. (optional, requires useIndexer option to be enabled)

      Returns Promise<Reply[]>

getAllPosts: ((groupId: number, limit?: number, offset?: number, orderBy?: Order_By) => Promise<Post[]>) = getAllPosts

Type declaration

    • (groupId: number, limit?: number, offset?: number, orderBy?: Order_By): Promise<Post[]>
    • Get all posts for a group.

      Returns

      • Promise resolving to an array of posts.

      Parameters

      • groupId: number

        The group id where the posts should be fetched.

      • limit: number = null

        Maximum number of posts to return. (optional, requires useIndexer option to be enabled)

      • offset: number = null

        Offset to start returning posts from. (optional, requires useIndexer option to be enabled)

      • orderBy: Order_By = null

        The order to return posts by timestamp. (optional, requires useIndexer option to be enabled)

      Returns Promise<Post[]>

getAllPostsByUserId: ((userId: number, limit?: number, offset?: number, orderBy?: Order_By) => Promise<Post[]>) = getAllPostsByUserId

Type declaration

    • (userId: number, limit?: number, offset?: number, orderBy?: Order_By): Promise<Post[]>
    • Get all posts for a user.

      Returns

      • Promise resolving to an array of posts.

      Parameters

      • userId: number

        The user id where the posts should be fetched.

      • limit: number = null

        Maximum number of posts to return. (optional, requires useIndexer option to be enabled)

      • offset: number = null

        Offset to start returning posts from. (optional, requires useIndexer option to be enabled)

      • orderBy: Order_By = null

        The order to return posts by timestamp. (optional, requires useIndexer option to be enabled)

      Returns Promise<Post[]>

getPost: ((postId: number) => Promise<Post | null>) = getPost

Type declaration

    • (postId: number): Promise<Post | null>
    • Retrieve a post by id.

      Returns

      • Returns a Promise that resolves with the post associated with the post id, or null if no post was found.

      Parameters

      • postId: number

        The id of the post to be retrieved.

      Returns Promise<Post | null>

getPostByPublicKey: ((publicKey: PublicKey) => Promise<Post | null>) = getPostByPublicKey

Type declaration

    • (publicKey: PublicKey): Promise<Post | null>
    • Retrieves a post by its public key.

      Returns

      • Returns a Promise that resolves with the post associated with the public key, or null if no post was found.

      Parameters

      • publicKey: PublicKey

        The public key of the post.

      Returns Promise<Post | null>

getPostReply: ((publicKey: PublicKey) => Promise<Reply | null>) = getPostReply

Type declaration

    • (publicKey: PublicKey): Promise<Reply | null>
    • Retrieves a reply associated with a given public key

      Returns

      • The retrieved reply or null if none exists.

      Parameters

      • publicKey: PublicKey

        The public key of the reply to be retrieved.

      Returns Promise<Reply | null>

likePost: ((publicKey: PublicKey) => Promise<void>) = likePost

Type declaration

    • (publicKey: PublicKey): Promise<void>
    • Parameters

      • publicKey: PublicKey

        The public key of the post.

      Returns Promise<void>

User Properties

createUser: ((nickname: string, avatar: FileData | FileUriData, biography: string, metadata?: any) => Promise<User>) = createUser

Type declaration

    • (nickname: string, avatar: FileData | FileUriData, biography: string, metadata?: any): Promise<User>
    • Creates a user with the given parameters.

      Returns

      A promise that resolves to the newly created user.

      Parameters

      • nickname: string

        The nickname of the user to be created.

      • avatar: FileData | FileUriData

        An avatar for the new user. Can be a FileData object, a FileUriData object, or null.

      • biography: string

        A biography for the new user. Can be a string or null.

      • metadata: any = null

        An json object containing any relevant metadata to be associated with the user.

      Returns Promise<User>

deleteUser: (() => Promise<void>) = deleteUser

Type declaration

    • (): Promise<void>
    • Deletes a user.

      Returns

      A promise that resolves when the user was successfully deleted.

      Returns Promise<void>

followUser: ((userId: number) => Promise<void>) = followUser

Type declaration

    • (userId: number): Promise<void>
    • Follows a user with the given user id.

      Returns

      • A promise that resolves when the user has been followed.

      Parameters

      • userId: number

        The id of the user to follow.

      Returns Promise<void>

getUser: ((userId: number) => Promise<User | null>) = getUser

Type declaration

    • (userId: number): Promise<User | null>
    • Retrieve a user by their id.

      Returns

      A promise that resolves to a User object or null if the user does not exist.

      Parameters

      • userId: number

        The id of the user to retrieve.

      Returns Promise<User | null>

getUserByPublicKey: ((publicKey: PublicKey) => Promise<User | null>) = getUserByPublicKey

Type declaration

    • (publicKey: PublicKey): Promise<User | null>
    • Retrieve a user by their public key.

      Returns

      A promise that resolves to a User object or null if the user does not exist.

      Parameters

      • publicKey: PublicKey

        The public key of the user to retrieve.

      Returns Promise<User | null>

unfollowUser: ((userId: number) => Promise<void>) = unfollowUser

Type declaration

    • (userId: number): Promise<void>
    • Unfollows the user specified by the given user id.

      Returns

      • A promise that resolves when the user has been unfollowed.

      Parameters

      • userId: number

        The id of the user to unfollow.

      Returns Promise<void>

updateUser: ((nickname?: string, avatar?: FileData | FileUriData, biography?: string, metadata?: any) => Promise<User>) = updateUser

Type declaration

    • (nickname?: string, avatar?: FileData | FileUriData, biography?: string, metadata?: any): Promise<User>
    • Update a user with the given parameters.

      Returns

      A promise that resolves to the newly created user.

      Parameters

      • nickname: string = null

        The nickname of the user to be updated.

      • avatar: FileData | FileUriData = null

        The avatar of the user to be updated. Can be a FileData object, a FileUriData object, or null.

      • biography: string = null

        The biography for the user to be updated. Can be a string or null.

      • metadata: any = null

        An updated json object containing any relevant metadata to be associated with the user.

      Returns Promise<User>

Methods

  • Returns Promise<void>

Generated using TypeDoc