Skip to content

Commit

Permalink
Implement follow/unfollow (#983)
Browse files Browse the repository at this point in the history
Co-authored-by: Cesare Naldi <[email protected]>
  • Loading branch information
juangm and cesarenaldi authored Dec 3, 2024
1 parent e8ea090 commit 497d6ff
Show file tree
Hide file tree
Showing 6 changed files with 393 additions and 7 deletions.
51 changes: 51 additions & 0 deletions packages/client/src/actions/follow.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import type {
CreateFollowRequest,
CreateUnfollowRequest,
FollowResult,
UnfollowResult,
} from '@lens-protocol/graphql';
import { FollowMutation, UnfollowMutation } from '@lens-protocol/graphql';
import type { ResultAsync } from '@lens-protocol/types';

import type { SessionClient } from '../clients';
import type { UnauthenticatedError, UnexpectedError } from '../errors';

/**
* Follow an Account
*
* ```ts
* const result = await follow(sessionClient, {
* account: evmAddress('0x90c8c68d0Abfb40D4fCD72316A65e42161520BC3')
* });
* ```
*
* @param client - The session client for the authenticated Account.
* @param request - The mutation request.
* @returns Tiered transaction result.
*/
export function follow(
client: SessionClient,
request: CreateFollowRequest,
): ResultAsync<FollowResult, UnexpectedError | UnauthenticatedError> {
return client.mutation(FollowMutation, { request });
}

/**
* Unfollow an Account
*
* ```ts
* const result = await unfollow(sessionClient, {
* account: evmAddress('0x90c8c68d0Abfb40D4fCD72316A65e42161520BC3')
* });
* ```
*
* @param client - The session client for the authenticated Account.
* @param request - The mutation request.
* @returns Tiered transaction result.
*/
export function unfollow(
client: SessionClient,
request: CreateUnfollowRequest,
): ResultAsync<UnfollowResult, UnexpectedError | UnauthenticatedError> {
return client.mutation(UnfollowMutation, { request });
}
1 change: 1 addition & 0 deletions packages/client/src/actions/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export * from './account';
export * from './app';
export * from './authentication';
export * from './follow';
export * from './post';
export * from './posts';
export * from './transactions';
Loading

0 comments on commit 497d6ff

Please sign in to comment.