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

[WIP] Add Open Frames Neynar validator #116

Closed
wants to merge 2 commits into from

Conversation

neekolas
Copy link
Contributor

@neekolas neekolas commented Feb 9, 2024

What changed? Why?

This PR adds a proof-of-concept for support of Open Frames. Opening it up for discussion. It shows a path for how onchainkit can be extended to support multiple types of Frames client beyond just Farcaster.

The PR adds no new runtime dependencies. It just picks up some common types from @open-frames/types.

Notes to reviewers

If we decide this approach is reasonable, I'll add some tests. And we can discuss how we can add some better examples for extensibility.

How has it been tested?

Not at all

@Zizzamia Zizzamia self-requested a review February 10, 2024 07:33
package.json Outdated
@@ -28,6 +28,7 @@
"devDependencies": {
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.2",
"@open-frames/types": "^0.0.5",
Copy link
Contributor

Choose a reason for hiding this comment

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

Veeeery interesting

import { FarcasterOpenFramesRequest, FrameRequest, FrameValidationData } from '../../../core/types';
import { NEYNAR_DEFAULT_API_KEY, neynarFrameValidation } from '../frame/neynarFrameFunctions';
import { Options } from './types';

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh side note, we prefer Functional code vs Object Oriented, as it is much lighter in terms of memory and also easier to write test for.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair enough. All I really care about is having something that satisfies a common interface so that developers can build their own request validators and have confidence they will be able to integrate.

Whether the implementation of the interface is a module, an object, or a class is up to the implementer.

const isTrustedDataValid = typeof payload.trustedData?.messageBytes === 'string';

return isCorrectClientProtocol && isTrustedDataValid;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

So I see, isSupported is where the magic happens.

And ideally we can have as many client as we want.

There are some implementation details that we need to align, but I like where your head is @neekolas

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exactly. Here is an example of the XMTP RequestValidator that can be safely passed in to getOpenFramesMessage as an argument and will allow for processing of button clicks coming from XMTP.

@Zizzamia
Copy link
Contributor

@neekolas I think this can work, after all we are just simply saying, let's see what Client can validate this message, and when there is a match, we let that client connect with a third-party API and take care of it.

@Zizzamia
Copy link
Contributor

Closing this, as it was covered in https://onchainkit.xyz/xmtpkit/get-xmtp-frame-message

@Zizzamia Zizzamia closed this Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants