Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3036481
D13762.id45305.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D13762.id45305.diff
View Options
diff --git a/lib/types/farcaster-types.js b/lib/types/farcaster-types.js
--- a/lib/types/farcaster-types.js
+++ b/lib/types/farcaster-types.js
@@ -42,6 +42,14 @@
...
};
+export type NeynarCast = {
+ +hash: string,
+ +thread_hash: string,
+ +text: string,
+ +author: NeynarUser,
+ ...
+};
+
export type NeynarWebhookCastAuthor = {
+object: 'user',
+fid: string,
diff --git a/lib/utils/neynar-client.js b/lib/utils/neynar-client.js
--- a/lib/utils/neynar-client.js
+++ b/lib/utils/neynar-client.js
@@ -3,7 +3,11 @@
import invariant from 'invariant';
import { getMessageForException } from './errors.js';
-import type { NeynarChannel, NeynarUser } from '../types/farcaster-types.js';
+import type {
+ NeynarChannel,
+ NeynarUser,
+ NeynarCast,
+} from '../types/farcaster-types.js';
type FetchRelevantFollowersResponse = {
+all_relevant_followers_dehydrated: $ReadOnlyArray<{
@@ -31,6 +35,10 @@
+channel: NeynarChannel,
};
+type FetchFarcasterCastByHashResponse = {
+ +cast: NeynarCast,
+};
+
export type FarcasterUser = {
+username: string,
+pfpURL: string,
@@ -325,6 +333,30 @@
throw error;
}
}
+
+ async fetchFarcasterCastByHash(hash: string): Promise<NeynarCast> {
+ const url = getNeynarURL('2', 'cast', { identifier: hash, type: 'hash' });
+
+ try {
+ const response = await fetch(url, {
+ method: 'GET',
+ headers: {
+ Accept: 'application/json',
+ api_key: this.apiKey,
+ },
+ });
+
+ const json: FetchFarcasterCastByHashResponse = await response.json();
+
+ return json.cast;
+ } catch (error) {
+ console.log(
+ 'Failed to fetch Farcaster cast:',
+ getMessageForException(error) ?? 'unknown',
+ );
+ throw error;
+ }
+ }
}
export { NeynarClient };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Oct 23, 5:33 AM (4 h, 9 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2344478
Default Alt Text
D13762.id45305.diff (1 KB)
Attached To
Mode
D13762: [lib] implement fetchFarcasterCastByHash for neynar client
Attached
Detach File
Event Timeline
Log In to Comment