-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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: working farcaster client with neynar #570
Conversation
Thanks! Neynar is The Way. |
can you include #386 so it adds my commits too |
.env.example
Outdated
# Farcaster Neynar Configuration | ||
FARCASTER_FID= | ||
FARCASTER_NEYNAR_SIGNER_UUID= | ||
FARCASTER_NEYNAR_API_KEY= |
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.
@sayangel Add comments for the newly added environment variables (FARCASTER_FID
, FARCASTER_NEYNAR_SIGNER_UUID
, FARCASTER_NEYNAR_API_KEY
) to explain what each variable is used for and any format restrictions. This will help developers understand how to set up these configurations correctly.
@@ -17,6 +17,7 @@ | |||
"@ai16z/client-auto": "workspace:*", | |||
"@ai16z/client-direct": "workspace:*", | |||
"@ai16z/client-discord": "workspace:*", | |||
"@ai16z/client-farcaster": "workspace:*", |
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.
@sayangel Ensure that you review and update the documentation to reflect this new dependency.
@@ -0,0 +1,19 @@ | |||
{ | |||
"name": "@ai16z/client-farcaster", | |||
"version": "0.0.1", |
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.
@sayangel Review the new package’s version (0.0.1
). Consider versioning best practices see semver.org
}, | ||
"scripts": { | ||
"build": "tsup --format esm --dts", | ||
"dev": "tsup --watch" |
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.
@sayangel add both the lint
and test
scripts, refer to other packages to get more details about their implementations.
async stop() { | ||
await Promise.all([this.posts.stop(), this.interactions.stop()]); | ||
} | ||
} |
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.
@sayangel Ensure the new client-farcaster
package is covered by tests, including unit tests and integration tests, to verify its functionality.
async stop() { | ||
await Promise.all([this.posts.stop(), this.interactions.stop()]); | ||
} | ||
} |
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.
@sayangel Update or add relevant documentation, such as the README, with information on the new package and environment variables.
Ensure to add any documentation for developers on how to configure the newly added @ai16z/client-farcaster
and related environment variables.
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.
LGTM added some nits but overall amazing work! Please add a screengrab of successful run if you can thanks so much! Amazing work!
} | ||
} catch (err) { | ||
if (isApiErrorResponse(err)) { | ||
console.log(err.response.data); |
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 use elizaLogger everywhere before throwing and not console log please thanks :)
}); | ||
const cast = { | ||
hash: response.cast.hash, | ||
//parentHash: cast.parent_hash, |
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 remove this
fid: request.fid, | ||
limit: request.pageSize, | ||
}); | ||
//console.log(response); |
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.
same here
}); | ||
const result = await this.neynar.fetchBulkUsers({ fids: [fid] }); | ||
if (!result.users || result.users.length < 1) { | ||
console.log("getUserDataByFid 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.
same here
} | ||
|
||
return { | ||
timeline, | ||
nextPageToken: results.nextPageToken, | ||
//TODO implement paging |
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.
can we add an issue for this and reference it here
return; | ||
} | ||
|
||
if (!memory.content.text) { | ||
console.log("skipping cast with no text", cast.id); | ||
console.log("skipping cast with no text", cast.hash); |
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.
^^
@@ -196,16 +207,18 @@ export class FarcasterInteractionManager { | |||
if (!response.text) return; | |||
|
|||
try { | |||
console.log(`Replying to cast ${cast.hash}.`); |
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.
^^
// const farcasterUserName = | ||
// this.runtime.getSetting("FARCASTER_USERNAME")!; | ||
|
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 remove this
@@ -126,15 +125,16 @@ export class FarcasterPostManager { | |||
const [{ cast }] = await sendCast({ | |||
client: this.client, | |||
runtime: this.runtime, | |||
signer: this.signer, | |||
//: this.signer, |
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.
same here
@@ -144,6 +144,11 @@ export class FarcasterPostManager { | |||
roomId | |||
); | |||
|
|||
console.log( |
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.
^^
Relates to:
Farcaster client: #300
Modification of open PR: #386
Risks
Low
Background
What does this PR do?
Adds a farcaster-client package so that Eliza agents can post to Farcaster. This PR modifies an existing Farcaster client PR to use Neynar instead of a direct hub. This makes it easier for people to deploy hubs and makes it easier to add additional features in the future using Neynar's APIs for interacting with Farcaster data.
What kind of change is this?
Features (non-breaking change which adds functionality)
Documentation changes needed?
Needs documentation on how to create a signer that can submit messages to Farcaster (via Neynar).
Testing
I have tested this PR by running a local eliza agent that is making posts on Farcaster via the Yoinker account: https://warpcast.com/yoinker
All the accounts in this cast have been created by a local Eliza instance.
Where should a reviewer start?
Detailed testing steps