-
Notifications
You must be signed in to change notification settings - Fork 145
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
XMTP Frame Post Validation #123
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
package.json
Outdated
@@ -79,5 +79,8 @@ | |||
}, | |||
"default": "./lib/index.js" | |||
} | |||
}, | |||
"dependencies": { | |||
"@xmtp/frames-validator": "^0.4.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where can I read this code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also not sure if this should be a dependencies
or peerDependencies
🤔
Our leaning is to be the second
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's a peerDependency
then we're closer to the approach in #116 where we would want the caller to pass in some instance of the validator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The developer experience is a little smoother if you only need to depend on onchainkit
, but both are fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think is about choice, on what API to use.
OnchainKit contains some code might need React, and other it doesn't. Some code it needs Viem, and other it doesn't.
That's why we referred that as peerDependency.
In the documentation we will create a section called XMTP, where we will write that all those function need
yarn add @xmtp/frames-validator
to be used.
And then after that folks can do
import { getXmtpFrameMessage } from '@coinbae/onchainkit/xmtp'
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our goal is to make sure that folks will need the PROTO dependencies https://bundlephobia.com/package/@xmtp/frames-validator@0.4.0 only when using XMTP.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. You've sold me on a peer dependency approach. That seems fine as long as it's well documented.
Then we can add something like import { getOpenFramesMessage } from '@coinbase/onchainkit/open-frames'
as soon as there is a 1.0 version of that spec. It can call into this code for the XMTP implementation of the spec. But no need to wait on that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love that
src/core/getFrameMessage.ts
Outdated
@@ -44,4 +46,8 @@ async function getFrameMessage( | |||
} | |||
} | |||
|
|||
export { getFrameMessage }; | |||
function getXmtpFrameMessage(body: XmtpOpenFramesRequest): XmtpFrameValidationResponse { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's have his one file for getXmtpFrameMessage
, so we keep things clean.
@neekolas, I think we have a clear direction. If you don't mind let's start polishing this PR so we can get this approved and merged by Monday. |
@Zizzamia I have updated this PR to move everything into a
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LFG
@neekolas, I just realized there is a test failing
thoughts on this? |
Also, would you mind move the docs into |
@Zizzamia Moved the docs to the Also fixed that failing test |
@neekolas incredible work 👏 I am going to follow up with some more polishing from my side and cutting the release. |
What changed? Why?
Based on conversations with @Zizzamia I put together an alternate version of #116 with a more narrowly scoped method for validating XMTP post messages. This one does have runtime dependencies, but I've overhauled
@xmtp/frames-validator
so that it no longer depends onxmtp-js
. That both shrinks the bundle size significantly and makes it work in RN and the browser out of the box. There are no more dependencies that rely onwindow.crypto
or that call out to WASM code.For RN, it will need a version that supports Bigints, either via polyfill or by using Hermes.
The way you would need to call into it would be something like this:
How has it been tested?
Unit tests and I've been trying it locally