Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement missing mutations for account #1002

Merged
merged 3 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 113 additions & 2 deletions packages/client/src/actions/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,21 @@ import type {
AccountStatsRequest,
AccountsAvailableRequest,
AccountsBlockedRequest,
BlockRequest,
BlockResult,
CreateAccountWithUsernameRequest,
CreateAccountWithUsernameResult,
EnableSignlessResult,
MuteRequest,
RecommendAccountRequest,
RemoveSignlessResult,
ReportAccountRequest,
SearchAccountsRequest,
SetAccountMetadataRequest,
SetAccountMetadataResult,
UnblockRequest,
UnblockResult,
UndoRecommendAccountRequest,
UnmuteRequest,
} from '@lens-protocol/graphql';
import {
Expand All @@ -28,12 +35,17 @@ import {
AccountStatsQuery,
AccountsAvailableQuery,
AccountsBlockedQuery,
BlockMutation,
CreateAccountWithUsernameMutation,
EnableSignlessMutation,
MuteAccountMutation,
RecommendAccountMutation,
RemoveSignlessMutation,
ReportAccountMutation,
SearchAccountsQuery,
SetAccountMetadataMutation,
UnblockMutation,
UndoRecommendAccountMutation,
UnmuteAccountMutation,
} from '@lens-protocol/graphql';
import type { ResultAsync } from '@lens-protocol/types';
Expand Down Expand Up @@ -264,7 +276,7 @@ export function removeSignless(
*
* ```ts
* const result = await muteAccount(sessionClient, {
* account: evmAddress("0xe5439696f4057aF073c0FB2dc6e5e755392922e1");
* account: evmAddress("0xe5439696f4057aF073c0FB2dc6e5e755392922e1"),
* });
* ```
*
Expand All @@ -284,7 +296,7 @@ export function muteAccount(
*
* ```ts
* const result = await unmuteAccount(sessionClient, {
* account: evmAddress("0xe5439696f4057aF073c0FB2dc6e5e755392922e1");
* account: evmAddress("0xe5439696f4057aF073c0FB2dc6e5e755392922e1"),
* });
* ```
*
Expand All @@ -298,3 +310,102 @@ export function unmuteAccount(
): ResultAsync<void, UnexpectedError | UnauthenticatedError> {
return client.mutation(UnmuteAccountMutation, { request });
}

/**
* Report an account.
*
* ```ts
* const result = await reportAccount(sessionClient, {
* account: evmAddress("0xe5439696f4057aF073c0FB2dc6e5e755392922e1"),
* reason: "REPETITIVE_SPAM",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should create an enum in graphql package for these (see PageSize and the way it's bound to scalars).

* });
* ```
*
* @param client - The session client for the authenticated Account.
* @param request - The mutation request.
* @returns void.
*/
export function reportAccount(
client: SessionClient,
request: ReportAccountRequest,
): ResultAsync<void, UnexpectedError | UnauthenticatedError> {
return client.mutation(ReportAccountMutation, { request });
}

/**
* Block an account.
*
* ```ts
* const result = await blockAccount(sessionClient, {
* account: evmAddress("0xe5439696f4057aF073c0FB2dc6e5e755392922e1"),
* });
*
* @param client - The session client for the authenticated Account.
* @param request - The mutation request.
* @returns Tiered transaction result.
*/
export function blockAccount(
client: SessionClient,
request: BlockRequest,
): ResultAsync<BlockResult, UnexpectedError | UnauthenticatedError> {
return client.mutation(BlockMutation, { request });
}

/**
* Unblock an account.
*
* ```ts
* const result = await unblockAccount(sessionClient, {
* account: evmAddress("0xe5439696f4057aF073c0FB2dc6e5e755392922e1"),
* });
*
* @param client - The session client for the authenticated Account.
* @param request - The mutation request.
* @returns Tiered transaction result.
*/
export function unblockAccount(
client: SessionClient,
request: UnblockRequest,
): ResultAsync<UnblockResult, UnauthenticatedError | UnexpectedError> {
return client.mutation(UnblockMutation, { request });
}

/**
* Recommend an account.
*
* ```ts
* const result = await recommendAccount(sessionClient, {
* account: evmAddress("0xe5439696f4057aF073c0FB2dc6e5e755392922e1"),
* });
* ```
*
* @param client - The session client for the authenticated Account.
* @param request - The mutation request.
* @returns void.
*/
export function recommendAccount(
client: SessionClient,
request: RecommendAccountRequest,
): ResultAsync<void, UnexpectedError | UnauthenticatedError> {
return client.mutation(RecommendAccountMutation, { request });
}

/**
* Undo recommendation of an account.
*
* ```ts
* const result = await undoRecommendAccount(sessionClient, {
* account: evmAddress("0xe5439696f4057aF073c0FB2dc6e5e755392922e1"),
* });
* ```
*
* @param client - The session client for the authenticated Account.
* @param request - The mutation request.
* @returns void.
*/
export function undoRecommendAccount(
client: SessionClient,
request: UndoRecommendAccountRequest,
): ResultAsync<void, UnexpectedError | UnauthenticatedError> {
return client.mutation(UndoRecommendAccountMutation, { request });
}
23 changes: 23 additions & 0 deletions packages/client/src/actions/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ import type {
RefreshResult,
RevokeAuthenticationRequest,
RolloverRefreshRequest,
SwitchAccountRequest,
SwitchAccountResult,
} from '@lens-protocol/graphql';
import {
AuthenticatedSessionsQuery,
CurrentSessionQuery,
LegacyRolloverRefreshMutation,
RefreshMutation,
RevokeAuthenticationMutation,
SwitchAccountMutation,
} from '@lens-protocol/graphql';
import type { ResultAsync } from '@lens-protocol/types';

Expand Down Expand Up @@ -119,3 +122,23 @@ export function legacyRolloverRefresh(
): ResultAsync<RefreshResult, UnexpectedError | UnauthenticatedError> {
return client.mutation(LegacyRolloverRefreshMutation, { request });
}

/**
* Switch to account managed.
*
* ```ts
* const result = await switchAccount(sessionClient{
* account: evmAddress('0x90c8c68d0Abfb40D4fCD72316A65e42161520BC3'),
* });
* ```
*
* @param client - The session client for the authenticated Account.
* @param request - The query request.
* @returns The authenticated tokens for the switched account.
*/
export function switchAccount(
client: SessionClient,
request: SwitchAccountRequest,
): ResultAsync<SwitchAccountResult, UnauthenticatedError | UnexpectedError> {
return client.query(SwitchAccountMutation, { request });
}
Loading
Loading