-
Notifications
You must be signed in to change notification settings - Fork 166
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
fix: handle neynar responses + add additional information #35
Conversation
users: NeynarUserModel[]; | ||
} | ||
|
||
export class NeynarUserFunction { |
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.
QQ: would we be better off with the official SDK? Implementing our own client on top of their HTTP api is more work than we might want to do over the long run.
One con to using the SDK would be that the bundlesize is a bit high: https://bundlephobia.com/package/@neynar/[email protected] though because this would be running server-side it's not as big a deal cc @Zizzamia
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 would be open to it.. looks like most of the library is auto-generated.. I wanted to keep our imports lightweight, but it is a great question on future support / extensibility.
src/core/getFrameAccountAddress.ts
Outdated
// Get the user verifications from the response | ||
if (responseBody.users) { | ||
const userVerifications = responseBody.users[0] as FidResponse; | ||
const neynarClient = new NeynarClient(); |
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 wonder if we should create a new instance of NeynarClient()
everytime getFrameAccountAddress
is called.
So far it seems we are doing:
- someone might use
getFrameAccountAddress
multiple times - each time a new
neynarClient
instance is created fromNeynarClient
- each time a new
this.user
instance is created fromNeynarUserFunction(apiKey);
So my personal feeling after reading this three times, I think we should avoid using Classes just because:
- anytime
new
is run in JS it has some hidden memory and cpu cost that I would like to avoid from our side - all the data generated it feels gated inside an instance
- the user will abuse our funtion, so every small code weakness will become extra big publically, so beacuse 1 and 2, this feels a bit worry to me.
@robpolak would you be ok to rewrite this as Functional-oriented instead of Class-oriented?
Also as mention over our sync, let's use utils
as folder instead of internals
.
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.
classes have been purged.. it does make testing much easier.
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.
Dope, reading the PR now
@@ -0,0 +1,6 @@ | |||
export class FetchError extends Error { |
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.
nit. for next PR, we can probably have Fetch Error shared in a utils/network
folder internal utils.
@@ -3,5 +3,5 @@ module.exports = { | |||
transform: { | |||
'^.+\\.tsx?$': 'ts-jest', | |||
}, | |||
testMatch: ['**/?(*.)+(spec|test).ts'], | |||
testMatch: ['**/?(*.)+(spec|test|integ).ts'], |
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.
users: NeynarUserModel[]; | ||
} | ||
|
||
export async function neynarBulkUserLookup( |
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.
nit. for follow up PR, let's have more docs in here to explain what's going on.
Also let's try to keep the internal architecture as flat as possible, so that instead of having src/utils/neynar/user/neynarUserFunctions.ts
we just have src/utils/neynar/neynarUserFunctions.ts
as it will make it easier to understand for folks reading and contributing back.
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.
LEGEND
Just left a few notes for a follow up PR.
What changed? Why?
2. Added a neynar client which will allow for extensions without a kitchen sink class (e.g. see how we inject the user API).
3. Added a neynar integration test to ensure our lookups are working as expected.
Integration tests: yarn test:integration
Unit tests : yarn test
Notes to reviewers
How has it been tested?
See unit test runs above