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

T-23039: Implement signless actions #979

Merged
merged 1 commit into from
Nov 28, 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
49 changes: 43 additions & 6 deletions packages/client/src/actions/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@ import type {
Account,
AccountRequest,
CreateAccountWithUsernameRequest,
CreateAccountWithUsernameResult,
EnableSignlessResult,
SetAccountMetadataRequest,
SetAccountMetadataResult,
} from '@lens-protocol/graphql';
import {
AccountQuery,
CreateAccountWithUsernameMutation,
EnableSignlessMutation,
RemoveSignlessMutation,
SetAccountMetadataMutation,
} from '@lens-protocol/graphql';
import type { ResultAsync } from '@lens-protocol/types';

import type { SetAccountMetadataResult } from '@lens-protocol/graphql';
import type { CreateAccountWithUsernameResult } from '@lens-protocol/graphql';
import type { RemoveSignlessResult } from '@lens-protocol/graphql';
import type { AnyClient, SessionClient } from '../clients';
import type { UnauthenticatedError, UnexpectedError } from '../errors';

Expand All @@ -23,8 +27,6 @@ import type { UnauthenticatedError, UnexpectedError } from '../errors';
*
* ```ts
* const result = await fetchAccount(anyClient, {
* legacyProfileId?: legacyProfileId('0x01'),
* username?: userNameValue('alice'),
* address?: evmAddress('0xe2f2a5C287993345a840db3B0845fbc70f5935a5'),
* });
* ```
Expand Down Expand Up @@ -65,8 +67,9 @@ export function setAccountMetadata(
*
* ```ts
* const result = await createAccountWithUsername(sessionClient, {
* accountManager: [evmAddress('0x01')],
* localName: 'wagmi',
* username: {
* localname: 'wagmi'
* },
Copy link
Member

Choose a reason for hiding this comment

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

thank you!

* metadataUri: uri('lens://bafybxiky5jf…'),
* });
* ```
Expand All @@ -81,3 +84,37 @@ export function createAccountWithUsername(
): ResultAsync<CreateAccountWithUsernameResult, UnexpectedError | UnauthenticatedError> {
return client.mutation(CreateAccountWithUsernameMutation, { request });
}

/**
* Get transaction to enable signless.
*
* ```ts
* const result = await enableSignless(sessionClient);
* ```
*
* @param client - The session client for the authenticated Account.
* @param request - The mutation request.
* @returns Tiered transaction result.
*/
export function enableSignless(
client: SessionClient,
): ResultAsync<EnableSignlessResult, UnexpectedError | UnauthenticatedError> {
return client.mutation(EnableSignlessMutation, {});
}

/**
* Get transaction to remove signless.
*
* ```ts
* const result = await removeSignless(sessionClient);
* ```
*
* @param client - The session client for the authenticated Account.
* @param request - The mutation request.
* @returns Tiered transaction result.
*/
export function removeSignless(
client: SessionClient,
): ResultAsync<RemoveSignlessResult, UnexpectedError | UnauthenticatedError> {
return client.mutation(RemoveSignlessMutation, {});
}
6 changes: 0 additions & 6 deletions packages/client/src/actions/accountManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ export function fetchAccountManagers(
* ```ts
* const result = await addAccountManager(sessionClient, {
* address: evmAddress("0x90c8c68d0Abfb40D4fCD72316A65e42161520BC3"),
* permissions: {
* canSetMetadataUri: true,
* canTransferNative: true,
* canTransferTokens: true,
* canExecuteTransactions: true,
* },
* });
* ```
*
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2279,7 +2279,7 @@ enum ManagedAccountsVisibility {

type MeResult {
"""The logged in account."""
account: AccountAvailable!
loggedInAs: AccountAvailable!

"""Whether the account is signless."""
isSignless: Boolean!
Expand Down
1 change: 1 addition & 0 deletions packages/graphql/src/accounts/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './account';
export * from './managers';
export * from './signless';
2 changes: 1 addition & 1 deletion packages/graphql/src/accounts/managers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const AccountManager = graphql(
`fragment AccountManager on AccountManager {
__typename
addedAt
# address - not possible to query (probably a bug)
manager
isLensManager
permissions {
canExecuteTransactions
Expand Down
58 changes: 58 additions & 0 deletions packages/graphql/src/accounts/signless.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import type { FragmentOf } from 'gql.tada';

import {
SelfFundedTransactionRequest,
SponsoredTransactionRequest,
TransactionWillFail,
} from '../fragments';
import { graphql } from '../graphql';

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

export const EnableSignlessMutation = graphql(
`mutation EnableSignless {
value: enableSignless {
...EnableSignlessResult
}
}`,
[EnableSignlessResult],
);

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

export const RemoveSignlessMutation = graphql(
`mutation RemoveSignless {
value: removeSignless {
...RemoveSignlessResult
}
}`,
[RemoveSignlessResult],
);
2 changes: 1 addition & 1 deletion packages/graphql/src/graphql-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export type introspection_types = {
'LoggedInPostOperations': { kind: 'OBJECT'; name: 'LoggedInPostOperations'; fields: { 'canComment': { name: 'canComment'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'ENUM'; name: 'TriStateValue'; ofType: null; }; } }; 'canQuote': { name: 'canQuote'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'ENUM'; name: 'TriStateValue'; ofType: null; }; } }; 'canRepost': { name: 'canRepost'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'ENUM'; name: 'TriStateValue'; ofType: null; }; } }; 'hasBookmarked': { name: 'hasBookmarked'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Boolean'; ofType: null; }; } }; 'hasCommented': { name: 'hasCommented'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'OBJECT'; name: 'BooleanValue'; ofType: null; }; } }; 'hasQuoted': { name: 'hasQuoted'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'OBJECT'; name: 'BooleanValue'; ofType: null; }; } }; 'hasReacted': { name: 'hasReacted'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Boolean'; ofType: null; }; } }; 'hasReported': { name: 'hasReported'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Boolean'; ofType: null; }; } }; 'hasReposted': { name: 'hasReposted'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'OBJECT'; name: 'BooleanValue'; ofType: null; }; } }; 'id': { name: 'id'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'ID'; ofType: null; }; } }; 'isNotInterested': { name: 'isNotInterested'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Boolean'; ofType: null; }; } }; }; };
'MainContentFocus': { name: 'MainContentFocus'; enumValues: 'ARTICLE' | 'AUDIO' | 'CHECKING_IN' | 'EMBED' | 'EVENT' | 'IMAGE' | 'LINK' | 'LIVESTREAM' | 'MINT' | 'SHORT_VIDEO' | 'SPACE' | 'STORY' | 'TEXT_ONLY' | 'THREE_D' | 'TRANSACTION' | 'VIDEO'; };
'ManagedAccountsVisibility': { name: 'ManagedAccountsVisibility'; enumValues: 'NONE_HIDDEN' | 'HIDDEN_ONLY' | 'ALL'; };
'MeResult': { kind: 'OBJECT'; name: 'MeResult'; fields: { 'account': { name: 'account'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'UNION'; name: 'AccountAvailable'; ofType: null; }; } }; 'appLoggedIn': { name: 'appLoggedIn'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'EvmAddress'; ofType: null; }; } }; 'isSignless': { name: 'isSignless'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Boolean'; ofType: null; }; } }; 'isSponsored': { name: 'isSponsored'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Boolean'; ofType: null; }; } }; 'limit': { name: 'limit'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'OBJECT'; name: 'SponsorshipAllowance'; ofType: null; }; } }; }; };
'MeResult': { kind: 'OBJECT'; name: 'MeResult'; fields: { 'appLoggedIn': { name: 'appLoggedIn'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'EvmAddress'; ofType: null; }; } }; 'isSignless': { name: 'isSignless'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Boolean'; ofType: null; }; } }; 'isSponsored': { name: 'isSponsored'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Boolean'; ofType: null; }; } }; 'limit': { name: 'limit'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'OBJECT'; name: 'SponsorshipAllowance'; ofType: null; }; } }; 'loggedInAs': { name: 'loggedInAs'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'UNION'; name: 'AccountAvailable'; ofType: null; }; } }; }; };
'MediaAudio': { kind: 'OBJECT'; name: 'MediaAudio'; fields: { 'artist': { name: 'artist'; type: { kind: 'SCALAR'; name: 'Encryptable'; ofType: null; } }; 'attributes': { name: 'attributes'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'LIST'; name: never; ofType: { kind: 'NON_NULL'; name: never; ofType: { kind: 'OBJECT'; name: 'MetadataAttribute'; ofType: null; }; }; }; } }; 'cover': { name: 'cover'; type: { kind: 'SCALAR'; name: 'Encryptable'; ofType: null; } }; 'credits': { name: 'credits'; type: { kind: 'SCALAR'; name: 'Encryptable'; ofType: null; } }; 'duration': { name: 'duration'; type: { kind: 'SCALAR'; name: 'Int'; ofType: null; } }; 'genre': { name: 'genre'; type: { kind: 'SCALAR'; name: 'Encryptable'; ofType: null; } }; 'item': { name: 'item'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Encryptable'; ofType: null; }; } }; 'kind': { name: 'kind'; type: { kind: 'ENUM'; name: 'MediaAudioKind'; ofType: null; } }; 'license': { name: 'license'; type: { kind: 'ENUM'; name: 'MetadataLicenseType'; ofType: null; } }; 'lyrics': { name: 'lyrics'; type: { kind: 'SCALAR'; name: 'Encryptable'; ofType: null; } }; 'recordLabel': { name: 'recordLabel'; type: { kind: 'SCALAR'; name: 'Encryptable'; ofType: null; } }; 'type': { name: 'type'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'ENUM'; name: 'MediaAudioType'; ofType: null; }; } }; }; };
'MediaAudioKind': { name: 'MediaAudioKind'; enumValues: 'MUSIC' | 'PODCAST' | 'AUDIOBOOK' | 'VOICE_NOTE' | 'SOUND' | 'OTHER'; };
'MediaAudioType': { name: 'MediaAudioType'; enumValues: 'AUDIO_WAV' | 'AUDIO_VND_WAVE' | 'AUDIO_MPEG' | 'AUDIO_OGG' | 'AUDIO_MP_4' | 'AUDIO_AAC' | 'AUDIO_WEBM' | 'AUDIO_FLAC'; };
Expand Down