UNPKG

@towns-protocol/react-sdk

Version:

React Hooks for Towns Protocol SDK

82 lines 3.33 kB
import type { Member, Myself } from '@towns-protocol/sdk'; import { type ActionConfig } from './internals/useAction'; import { type ObservableConfig } from './useObservable'; /** * Hook to get the data of the current user in a stream. * @param streamId - The id of the stream to get the current user of. * @param config - Configuration options for the observable. * @returns The MemberModel of the current user. */ export declare const useMyMember: (streamId: string, config?: ObservableConfig.FromObservable<Member>) => { id: string; userId: string; streamId: string; initialized: boolean; username: string; isUsernameConfirmed: boolean; isUsernameEncrypted: boolean; displayName: string; isDisplayNameEncrypted?: boolean; ensAddress?: string; nft?: import("@towns-protocol/sdk").NftModel; membership?: import("@towns-protocol/proto").MembershipOp; }; /** * Hook to set the ENS address of the current user in a stream. * You should be validating if the ENS address belongs to the user before setting it. * @param streamId - The id of the stream to set the ENS address of. * @param config - Configuration options for the action. * @returns The `setEnsAddress` action and its loading state. */ export declare const useSetEnsAddress: (streamId: string, config?: ActionConfig<Myself["setEnsAddress"]>) => { data: void | undefined; error: Error | undefined; isPending: boolean; isSuccess: boolean; isError: boolean; setEnsAddress: (ensAddress: `0x${string}`) => Promise<void>; }; /** * Hook to set the username of the current user in a stream. * @param streamId - The id of the stream to set the username of. * @param config - Configuration options for the action. * @returns The `setUsername` action and its loading state. */ export declare const useSetUsername: (streamId: string, config?: ActionConfig<Myself["setUsername"]>) => { data: void | undefined; error: Error | undefined; isPending: boolean; isSuccess: boolean; isError: boolean; setUsername: (username: string) => Promise<void>; }; /** * Hook to set the display name of the current user in a stream. * @param streamId - The id of the stream to set the display name of. * @param config - Configuration options for the action. * @returns The `setDisplayName` action and its loading state. */ export declare const useSetDisplayName: (streamId: string, config?: ActionConfig<Myself["setDisplayName"]>) => { data: void | undefined; error: Error | undefined; isPending: boolean; isSuccess: boolean; isError: boolean; setDisplayName: (displayName: string) => Promise<void>; }; /** * Hook to set the NFT of the current user in a stream. * You should be validating if the NFT belongs to the user before setting it. * @param streamId - The id of the stream to set the NFT of. * @param config - Configuration options for the action. * @returns The `setNft` action and its loading state. */ export declare const useSetNft: (streamId: string, config?: ActionConfig<Myself["setNft"]>) => { data: void | undefined; error: Error | undefined; isPending: boolean; isSuccess: boolean; isError: boolean; setNft: (nft: import("@towns-protocol/sdk").NftModel) => Promise<void>; }; //# sourceMappingURL=useMyMember.d.ts.map