Page MenuHomePhabricator

D13762.id.diff
No OneTemporary

D13762.id.diff

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

Mime Type
text/plain
Expires
Thu, Oct 24, 12:05 AM (20 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2344478
Default Alt Text
D13762.id.diff (1 KB)

Event Timeline