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

Add mute/unmute account and update manager account permissions #999

Merged
merged 3 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
44 changes: 44 additions & 0 deletions packages/client/src/actions/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ import type {
CreateAccountWithUsernameRequest,
CreateAccountWithUsernameResult,
EnableSignlessResult,
MuteRequest,
RemoveSignlessResult,
SearchAccountsRequest,
SetAccountMetadataRequest,
SetAccountMetadataResult,
UnmuteRequest,
} from '@lens-protocol/graphql';
import {
AccountFeedsStatsQuery,
Expand All @@ -28,9 +30,11 @@ import {
AccountsBlockedQuery,
CreateAccountWithUsernameMutation,
EnableSignlessMutation,
MuteAccountMutation,
RemoveSignlessMutation,
SearchAccountsQuery,
SetAccountMetadataMutation,
UnmuteAccountMutation,
} from '@lens-protocol/graphql';
import type { ResultAsync } from '@lens-protocol/types';

Expand Down Expand Up @@ -254,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 });
}
60 changes: 60 additions & 0 deletions packages/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2062,6 +2062,12 @@ input FollowingRequest {
orderBy: FollowingOrderBy! = DESC
}

enum ForYouSource {
FOLLOWING
CURATED
POPULAR
}

type ForbiddenError {
reason: String!
}
Expand Down Expand Up @@ -3096,6 +3102,47 @@ type MintMetadata {
content: Encryptable!
}

input MlaccountRecommendationsRequest {
"""The page size."""
pageSize: PageSize! = FIFTY

"""The cursor."""
cursor: Cursor

"""The account to get recommendations for."""
account: EvmAddress!

"""Shuffle the recommendations."""
shuffle: Boolean! = false
}

input MlexplorePostsFilter {
since: Int
}

input MlexplorePostsRequest {
"""The page size."""
pageSize: PageSize! = FIFTY

"""The cursor."""
cursor: Cursor
filter: MlexplorePostsFilter
}

input MlpostsForYouRequest {
"""The page size."""
pageSize: PageSize! = FIFTY

"""The cursor."""
cursor: Cursor

"""The account to get for you for."""
account: EvmAddress!

"""Shuffle the for you posts."""
shuffle: Boolean! = false
}

type Mutation {
"""
Create a new app
Expand Down Expand Up @@ -3759,6 +3806,11 @@ type PaginatedPostTagsResult {
pageInfo: PaginatedResultInfo!
}

type PaginatedPostsForYouResult {
items: [PostForYou!]!
pageInfo: PaginatedResultInfo!
}

type PaginatedPostsResult {
items: [Post!]!
pageInfo: PaginatedResultInfo!
Expand Down Expand Up @@ -3903,6 +3955,11 @@ input PostEditsRequest {
cursor: Cursor
}

type PostForYou {
post: Post!
source: ForYouSource!
}

scalar PostId

union PostMetadata = ArticleMetadata | AudioMetadata | CheckingInMetadata | EmbedMetadata | EventMetadata | ImageMetadata | LinkMetadata | LivestreamMetadata | MintMetadata | SpaceMetadata | StoryMetadata | TextOnlyMetadata | ThreeDMetadata | TransactionMetadata | VideoMetadata
Expand Down Expand Up @@ -4269,6 +4326,9 @@ type Query {
You MUST be authenticated to use this query.
"""
notifications(request: NotificationRequest!): PaginatedNotificationResult!
mlAccountRecommendations(request: MlaccountRecommendationsRequest!): PaginatedAccountsResult!
mlPostsForYou(request: MlpostsForYouRequest!): PaginatedPostsForYouResult!
mlPostsExplore(request: MlexplorePostsRequest!): PaginatedPostsResult

"""Get the status of a transaction by its hash."""
transactionStatus(request: TransactionStatusRequest!): TransactionStatusResult!
Expand Down
15 changes: 14 additions & 1 deletion packages/graphql/src/accounts/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ export const SetAccountMetadataMutation = graphql(
}`,
[SetAccountMetadataResult],
);

export type SetAccountMetadataRequest = RequestOf<typeof SetAccountMetadataMutation>;

const CreateAccountResponse = graphql(
Expand Down Expand Up @@ -231,3 +230,17 @@ export const AccountsBlockedQuery = graphql(
);

export type AccountsBlockedRequest = RequestOf<typeof AccountsBlockedQuery>;

export const MuteAccountMutation = graphql(
`mutation Mute($request: MuteRequest!) {
value: mute(request: $request)
}`,
);
export type MuteRequest = RequestOf<typeof MuteAccountMutation>;

export const UnmuteAccountMutation = graphql(
`mutation Unmute($request: MuteRequest!) {
value: unmute(request: $request)
}`,
);
export type UnmuteRequest = RequestOf<typeof UnmuteAccountMutation>;
26 changes: 26 additions & 0 deletions packages/graphql/src/accounts/managers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,29 @@ export const RemoveAccountManagerMutation = graphql(
[RemoveAccountManagerResult],
);
export type RemoveAccountManagerRequest = RequestOf<typeof RemoveAccountManagerMutation>;

const UpdateAccountManagerResult = graphql(
`fragment UpdateAccountManagerResult on UpdateAccountManagerResult{
...on SponsoredTransactionRequest {
...SponsoredTransactionRequest
}
...on SelfFundedTransactionRequest {
...SelfFundedTransactionRequest
}
...on TransactionWillFail {
...TransactionWillFail
}
}`,
[SelfFundedTransactionRequest, SponsoredTransactionRequest, TransactionWillFail],
);
export type UpdateAccountManagerResult = FragmentOf<typeof UpdateAccountManagerResult>;

export const UpdateAccountManagerMutation = graphql(
`mutation RemoveAccountManager($request: UpdateAccountManagerRequest!) {
value: updateAccountManager(request: $request) {
...UpdateAccountManagerResult
}
}`,
[UpdateAccountManagerResult],
);
export type UpdateAccountManagerRequest = RequestOf<typeof UpdateAccountManagerMutation>;
15 changes: 10 additions & 5 deletions packages/graphql/src/graphql-env.d.ts

Large diffs are not rendered by default.

Loading