Skip to content

Commit

Permalink
Merge branch 'next' into T-23223/js-action-app-creation-setting-mutat…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
juangm committed Dec 6, 2024
2 parents f23bbf2 + 1049987 commit 555a22a
Show file tree
Hide file tree
Showing 14 changed files with 700 additions and 24 deletions.
88 changes: 88 additions & 0 deletions packages/client/src/actions/account.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,40 @@
import type {
Account,
AccountAvailable,
AccountBlocked,
AccountFeedsStats,
AccountFeedsStatsRequest,
AccountGraphsFollowStats,
AccountGraphsStatsRequest,
AccountRequest,
AccountStats,
AccountStatsRequest,
AccountsAvailableRequest,
AccountsBlockedRequest,
CreateAccountWithUsernameRequest,
CreateAccountWithUsernameResult,
EnableSignlessResult,
MuteRequest,
RemoveSignlessResult,
SearchAccountsRequest,
SetAccountMetadataRequest,
SetAccountMetadataResult,
UnmuteRequest,
} from '@lens-protocol/graphql';
import {
AccountFeedsStatsQuery,
AccountGraphsStatsQuery,
AccountQuery,
AccountStatsQuery,
AccountsAvailableQuery,
AccountsBlockedQuery,
CreateAccountWithUsernameMutation,
EnableSignlessMutation,
MuteAccountMutation,
RemoveSignlessMutation,
SearchAccountsQuery,
SetAccountMetadataMutation,
UnmuteAccountMutation,
} from '@lens-protocol/graphql';
import type { ResultAsync } from '@lens-protocol/types';

Expand Down Expand Up @@ -114,6 +124,44 @@ export function fetchAccountGraphStats(
return client.query(AccountGraphsStatsQuery, { request });
}

/**
* Fetch Accounts Available.
*
* ```ts
* const result = await fetchAccountsAvailable(anyClient, {
* managedBy: evmAddress('0xe2f2a5C287993345a840db3B0845fbc70f5935a5'),
* });
* ```
*
* @param client - Any Lens client.
* @param request - The query request.
* @returns The list of available accounts.
*/
export function fetchAccountsAvailable(
client: AnyClient,
request: AccountsAvailableRequest,
): ResultAsync<Paginated<AccountAvailable> | null, UnexpectedError> {
return client.query(AccountsAvailableQuery, { request });
}

/**
* Fetch Blocked Accounts.
*
* ```ts
* const result = await fetchAccountsBlocked(sessionClient);
* ```
*
* @param client - The session client for the authenticated Account.
* @param request - The query request.
* @returns The list of blocked accounts.
*/
export function fetchAccountsBlocked(
client: SessionClient,
request: AccountsBlockedRequest,
): ResultAsync<Paginated<AccountBlocked> | null, UnexpectedError> {
return client.query(AccountsBlockedQuery, { request });
}

/**
* Search accounts.
*
Expand Down Expand Up @@ -210,3 +258,43 @@ export function removeSignless(
): ResultAsync<RemoveSignlessResult, UnexpectedError | UnauthenticatedError> {
return client.mutation(RemoveSignlessMutation, {});
}

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

/**
* Unmute an account.
*
* ```ts
* const result = await unmuteAccount(sessionClient, {
* account: evmAddress("0xe5439696f4057aF073c0FB2dc6e5e755392922e1");
* });
* ```
*
* @param client - The session client for the authenticated Account.
* @param request - The mutation request.
* @returns void.
*/
export function unmuteAccount(
client: SessionClient,
request: UnmuteRequest,
): ResultAsync<void, UnexpectedError | UnauthenticatedError> {
return client.mutation(UnmuteAccountMutation, { request });
}
29 changes: 29 additions & 0 deletions packages/client/src/actions/accountManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ import type {
AddAccountManagerResult,
RemoveAccountManagerRequest,
RemoveAccountManagerResult,
UpdateAccountManagerRequest,
UpdateAccountManagerResult,
} from '@lens-protocol/graphql';
import {
AccountManagersQuery,
AddAccountManagerMutation,
RemoveAccountManagerMutation,
UpdateAccountManagerMutation,
} from '@lens-protocol/graphql';
import type { ResultAsync } from '@lens-protocol/types';

Expand Down Expand Up @@ -74,3 +77,29 @@ export function removeAccountManager(
): ResultAsync<RemoveAccountManagerResult, UnexpectedError | UnauthenticatedError> {
return client.mutation(RemoveAccountManagerMutation, { request });
}

/**
* Update permissions for an account manager.
*
* ```ts
* const result = await updateAccountManager(sessionClient, {
* permissions: {
* canSetMetadataUri: true;
* canTransferNative: false;
* canTransferTokens: true;
* canExecuteTransactions: false;
* },
* manager: evmAddress("0xe5439696f4057aF073c0FB2dc6e5e755392922e1");
* });
* ```
*
* @param client - Lens SessionClient.
* @param request - The mutation request.
* @returns Tiered transaction result.
*/
export function updateAccountManager(
client: SessionClient,
request: UpdateAccountManagerRequest,
): ResultAsync<UpdateAccountManagerResult, UnexpectedError | UnauthenticatedError> {
return client.mutation(UpdateAccountManagerMutation, { request });
}
101 changes: 99 additions & 2 deletions packages/client/src/actions/follow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,26 @@ import type {
FollowResult,
UnfollowResult,
} from '@lens-protocol/graphql';
import { FollowMutation, UnfollowMutation } from '@lens-protocol/graphql';
import {
FollowMutation,
FollowStatusQuery,
FollowersQuery,
FollowersYouKnowQuery,
FollowingQuery,
UnfollowMutation,
} from '@lens-protocol/graphql';
import type { ResultAsync } from '@lens-protocol/types';

import type { SessionClient } from '../clients';
import type { FollowersRequest } from '@lens-protocol/graphql';
import type { Follower } from '@lens-protocol/graphql';
import type { FollowingRequest } from '@lens-protocol/graphql';
import type { Following } from '@lens-protocol/graphql';
import type { FollowersYouKnowRequest } from '@lens-protocol/graphql';
import type { FollowStatusRequest } from '@lens-protocol/graphql';
import type { FollowStatusResult } from '@lens-protocol/graphql';
import type { AnyClient, SessionClient } from '../clients';
import type { UnauthenticatedError, UnexpectedError } from '../errors';
import type { Paginated } from '../types';

/**
* Follow an Account
Expand Down Expand Up @@ -49,3 +64,85 @@ export function unfollow(
): ResultAsync<UnfollowResult, UnexpectedError | UnauthenticatedError> {
return client.mutation(UnfollowMutation, { request });
}

/**
* Fetch followers accounts.
*
* ```ts
* const result = await fetchFollowers(anyClient, {
* account: evmAddress('0xe2f2a5C287993345a840db3B0845fbc70f5935a5'),
* });
* ```
*
* @param client - Any Lens client.
* @param request - The query request.
* @returns List of followers accounts.
*/
export function fetchFollowers(
client: AnyClient,
request: FollowersRequest,
): ResultAsync<Paginated<Follower>, UnexpectedError> {
return client.query(FollowersQuery, { request });
}

/**
* Fetch accounts following.
*
* ```ts
* const result = await fetchFollowing(anyClient, {
* account: evmAddress('0xe2f2a5C287993345a840db3B0845fbc70f5935a5'),
* });
* ```
*
* @param client - Any Lens client.
* @param request - The query request.
* @returns List of accounts following.
*/
export function fetchFollowing(
client: AnyClient,
request: FollowingRequest,
): ResultAsync<Paginated<Following>, UnexpectedError> {
return client.query(FollowingQuery, { request });
}

/**
* Fetch accounts following.
*
* ```ts
* const result = await fetchFollowersYouKnow(anyClient, {
* observer: evmAddress('0xe2f2a5C287993345a840db3B0845fbc70f5935a5'),
* target: evmAddress('0xe5439696f4057aF073c0FB2dc6e5e755392922e1'),
* });
* ```
*
* @param client - Any Lens client.
* @param request - The query request.
* @returns List of accounts following.
*/
export function fetchFollowersYouKnow(
client: AnyClient,
request: FollowersYouKnowRequest,
): ResultAsync<Paginated<Follower>, UnexpectedError> {
return client.query(FollowersYouKnowQuery, { request });
}

/**
* Fetch follow status.
*
* ```ts
* const result = await fetchFollowStatus(anyClient, {
* account: evmAddress('0xe2f2a5C287993345a840db3B0845fbc70f5935a5'),
* follower: evmAddress('0xe5439696f4057aF073c0FB2dc6e5e755392922e1'),
* });
* ```
*
* @param client - Any Lens client.
* @param request - The query request.
* @returns Status of the follow action.
*/
export function fetchFollowStatus(
client: AnyClient,
request: FollowStatusRequest,
): ResultAsync<FollowStatusResult[], UnexpectedError> {
return client.query(FollowStatusQuery, { request });
}
3 changes: 1 addition & 2 deletions packages/client/src/actions/health.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import type { AnyClient } from '../clients';
import type { UnexpectedError } from '../errors';

/**
* Health checks.
*
* Health check query.
*
* ```ts
* const result = await health(anyClient);
Expand Down
1 change: 1 addition & 0 deletions packages/client/src/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export * from './follow';
export * from './post';
export * from './posts';
export * from './transactions';
export * from './timeline';
25 changes: 25 additions & 0 deletions packages/client/src/actions/notifications.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type { Notification, NotificationsRequest } from '@lens-protocol/graphql';
import { NotificationsQuery } from '@lens-protocol/graphql';
import type { ResultAsync } from '@lens-protocol/types';

import type { SessionClient } from '../clients';
import type { UnexpectedError } from '../errors';
import type { Paginated } from '../types';

/**
* Fetch notifications for the authenticated Account.
*
* ```ts
* const result = await fetchNotifications(sessionClient);
* ```
*
* @param client - The session client for the authenticated Account.
* @param request - The query request.
* @returns Paginated notifications.
*/
export function fetchNotifications(
client: SessionClient,
request: NotificationsRequest,
): ResultAsync<Paginated<Notification>, UnexpectedError> {
return client.query(NotificationsQuery, { request });
}
Loading

0 comments on commit 555a22a

Please sign in to comment.