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 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
44 changes: 44 additions & 0 deletions packages/client/src/actions/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ import type {
CreateAccountWithUsernameRequest,
CreateAccountWithUsernameResult,
EnableSignlessResult,
MuteRequest,
RemoveSignlessResult,
SearchAccountsRequest,
SetAccountMetadataRequest,
SetAccountMetadataResult,
UnmuteRequest,
} from '@lens-protocol/graphql';
import {
AccountFeedsStatsQuery,
Expand All @@ -22,9 +24,11 @@ import {
AccountStatsQuery,
CreateAccountWithUsernameMutation,
EnableSignlessMutation,
MuteAccountMutation,
RemoveSignlessMutation,
SearchAccountsQuery,
SetAccountMetadataMutation,
UnmuteAccountMutation,
} from '@lens-protocol/graphql';
import type { ResultAsync } from '@lens-protocol/types';

Expand Down Expand Up @@ -210,3 +214,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 });
}
15 changes: 14 additions & 1 deletion packages/graphql/src/accounts/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ export const SetAccountMetadataMutation = graphql(
}`,
[SetAccountMetadataResult],
);

export type SetAccountMetadataRequest = RequestOf<typeof SetAccountMetadataMutation>;

const CreateAccountResponse = graphql(
Expand Down Expand Up @@ -197,3 +196,17 @@ export const AccountGraphsStatsQuery = graphql(
);

export type AccountGraphsStatsRequest = RequestOf<typeof AccountGraphsStatsQuery>;

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 @@ -90,3 +90,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>;
Loading