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

feat: frames 1.1 #1085

Open
wants to merge 7 commits into
base: next
Choose a base branch
from

Conversation

defispartan
Copy link

No description provided.

Copy link

changeset-bot bot commented Feb 21, 2025

⚠️ No Changeset found

Latest commit: 37e5f1e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Feb 21, 2025

@defispartan is attempting to deploy a commit to the Avara Team on Vercel.

A member of the Team first needs to authorize it.

@@ -1137,3 +1137,17 @@ export enum SimpleCollectValidationFailedReason {
NotEnoughBalance = 'NOT_ENOUGH_BALANCE',
NotAFollower = 'NOT_A_FOLLOWER',
}

export enum FrameVerifySignatureResult {
Copy link
Member

Choose a reason for hiding this comment

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

Can you please bind this new enum to the corresponding type in here? This results in GQL inferred types that reference this enum.

Copy link
Author

Choose a reason for hiding this comment

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

Added the binding

After I added it though this line now returns a type error

Is there an example of another API endpoint that directly returns an enum? I tried searching to see how the types were implemented in the SDK but I couldn't find one

Copy link
Member

Choose a reason for hiding this comment

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

Returning an enum should not be different than returning a scalar.

The closest thing I can think of is Query. appServerApiKey which returns a string.

Since you told the type system that the FrameVerifySignatureResult binds to the provided enum, you should not need to do lookup (with type assertion) at all.

export function verifyFrameSignature(
  client: AnyClient,
  request: VerifyFrameSignatureRequest,
): ResultAsync<FrameVerifySignatureResult, UnexpectedError> {
  return client
    .query(VerifyFrameSignatureQuery, { request })
-   .map((result) => FrameVerifySignatureResult[result as keyof typeof FrameVerifySignatureResult]);
}

Copy link
Member

Choose a reason for hiding this comment

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

The TSDocs examples have the Lens SDK v2 signature and jargon (e.g. 'LensClient'). Can we please update them according to the new implementation?

Copy link
Author

Choose a reason for hiding this comment

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

Updated

*
* @example
* ```ts
* const result = await createFrameTypedData(client, {
Copy link
Member

Choose a reason for hiding this comment

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

We use this naming convention to re-inforce in the example what it can be used.

Suggested change
* const result = await createFrameTypedData(client, {
* const result = await createFrameTypedData(anyClient, {

*
* @example
* ```ts
* const result = await signFrameAction(client, {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* const result = await signFrameAction(client, {
* const result = await signFrameAction(sessionClient, {

Similarly, just reinforcing what's needed.

*
* @example
* ```ts
* const result = await verifyFrameSignature(client, {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* const result = await verifyFrameSignature(client, {
* const result = await verifyFrameSignature(anyClient, {

/**
* Sign Frame action with Lens Manager if enabled
*
* ⚠️ Requires authenticated LensClient.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* ⚠️ Requires authenticated LensClient.
* ⚠️ Requires authenticated SessionClient.

Comment on lines +1142 to +1152
verified = 'VERIFIED',
postDoesntExist = 'POST_DOESNT_EXIST',
identityUnauthorized = 'IDENTITY_UNAUTHORIZED',
identityTokenNotValid = 'IDENTITY_TOKEN_NOT_VALID',
typedDataTypesIncorrectFields = 'TYPED_DATA_TYPES_INCORRECT_FIELDS',
typedDataDomainIncorrect = 'TYPED_DATA_DOMAIN_INCORRECT',
typedDataAccountNotMatchingIdentityToken = 'TYPED_DATA_ACCOUNT_NOT_MATCHING_IDENTITY_TOKEN',
identityCannotUseAccount = 'IDENTITY_CANNOT_USE_ACCOUNT',
signatureNotValid = 'SIGNATURE_NOT_VALID',
deadlineExpired = 'DEADLINE_EXPIRED',
signerAddressCannotUseAccount = 'SIGNER_ADDRESS_CANNOT_USE_ACCOUNT',
Copy link
Member

Choose a reason for hiding this comment

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

Can we please PascalCase these?

@@ -1137,3 +1137,17 @@ export enum SimpleCollectValidationFailedReason {
NotEnoughBalance = 'NOT_ENOUGH_BALANCE',
NotAFollower = 'NOT_A_FOLLOWER',
}

export enum FrameVerifySignatureResult {
Copy link
Member

Choose a reason for hiding this comment

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

Returning an enum should not be different than returning a scalar.

The closest thing I can think of is Query. appServerApiKey which returns a string.

Since you told the type system that the FrameVerifySignatureResult binds to the provided enum, you should not need to do lookup (with type assertion) at all.

export function verifyFrameSignature(
  client: AnyClient,
  request: VerifyFrameSignatureRequest,
): ResultAsync<FrameVerifySignatureResult, UnexpectedError> {
  return client
    .query(VerifyFrameSignatureQuery, { request })
-   .map((result) => FrameVerifySignatureResult[result as keyof typeof FrameVerifySignatureResult]);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants