Skip to content

Commit

Permalink
Merge branch 'next' into T-23199/js-action-username-usernames-queries
Browse files Browse the repository at this point in the history
  • Loading branch information
juangm authored Dec 9, 2024
2 parents f20ed44 + 9dcd3b3 commit 513c73f
Show file tree
Hide file tree
Showing 16 changed files with 1,421 additions and 27 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 });
}
Loading

0 comments on commit 513c73f

Please sign in to comment.