Skip to content

@ecp.eth/sdk


@ecp.eth/sdk / indexer / fetchComments

Function: fetchComments()

function fetchComments(options): Promise<{
  extra: {
     moderationEnabled: boolean;
     moderationKnownReactions: string[];
  };
  pagination: {
     endCursor?: `0x${string}`;
     hasNext: boolean;
     hasPrevious: boolean;
     limit: number;
     startCursor?: `0x${string}`;
  };
  results: {
     app: `0x${string}`;
     author: {
        address: `0x${string}`;
        ens?: {
           avatarUrl: null | string;
           name: string;
        };
        farcaster?: {
           displayName?: string;
           fid: number;
           pfpUrl?: string;
           username: string;
        };
     };
     chainId: number;
     channelId: bigint;
     commentType: number;
     content: string;
     createdAt: Date;
     cursor: `0x${string}`;
     deletedAt: null | Date;
     hookMetadata: {
        key: `0x${string}`;
        value: `0x${string}`;
     }[];
     id: `0x${string}`;
     logIndex: null | number;
     metadata: {
        key: `0x${string}`;
        value: `0x${string}`;
     }[];
     moderationClassifierResult: Record<string, number>;
     moderationClassifierScore: number;
     moderationStatus: "approved" | "pending" | "rejected";
     moderationStatusChangedAt: Date;
     parentId: null | `0x${string}`;
     path: string;
     reactionCounts: Record<string, number>;
     references: (
        | {
        address: `0x${string}`;
        avatarUrl: null | string;
        name: string;
        position: {
           end: number;
           start: number;
        };
        type: "ens";
        url: string;
      }
        | {
        address: `0x${string}`;
        displayName: null | string;
        fid: number;
        fname: string;
        pfpUrl: null | string;
        position: {
           end: number;
           start: number;
        };
        type: "farcaster";
        url: string;
        username: string;
      }
        | {
        address: `0x${string}`;
        chainId: null | number;
        chains: {
           caip: string;
           chainId: number;
        }[];
        decimals: number;
        logoURI: null | string;
        name: string;
        position: {
           end: number;
           start: number;
        };
        symbol: string;
        type: "erc20";
      }
        | {
        description: null | string;
        favicon: null | string;
        mediaType: string;
        opengraph:   | null
           | {
           description: null | string;
           image: string;
           title: string;
           url: string;
         };
        position: {
           end: number;
           start: number;
        };
        title: string;
        type: "webpage";
        url: string;
      }
        | {
        mediaType: string;
        position: {
           end: number;
           start: number;
        };
        type: "file";
        url: string;
      }
        | {
        dimension?: {
           height: number;
           width: number;
        };
        mediaType: string;
        position: {
           end: number;
           start: number;
        };
        type: "image";
        url: string;
      }
        | {
        mediaType: string;
        position: {
           end: number;
           start: number;
        };
        type: "video";
        url: string;
        videoTracks?: {
           codec?: ... | ...;
           dimension: {
              height: ...;
              width: ...;
           };
        }[];
      }
        | {
        chainId: number;
        id: `0x${string}`;
        position: {
           end: number;
           start: number;
        };
        type: "quoted_comment";
     })[];
     replies: {
        extra: {
           moderationEnabled: boolean;
           moderationKnownReactions: string[];
        };
        pagination: {
           count: number;
           endCursor?: `0x${string}`;
           hasNext: boolean;
           hasPrevious: boolean;
           limit: number;
           startCursor?: `0x${string}`;
        };
        results: IndexerAPICommentSchemaType[];
     };
     revision: number;
     targetUri: string;
     txHash: `0x${string}`;
     updatedAt: Date;
     viewerReactions: Record<string, IndexerAPICommentSchemaType[]>;
     zeroExSwap:   | null
        | {
        from: {
           address: `0x${string}`;
           amount: string;
           symbol: string;
        };
        to: {
           address: "" | `0x${string}`;
           amount: string;
           symbol: string;
        };
      };
  }[];
}>;

Defined in: packages/sdk/src/indexer/api.ts:314

Fetch comments from the Indexer API

Parameters

options

FetchCommentsOptions

Returns

Promise<{ extra: { moderationEnabled: boolean; moderationKnownReactions: string[]; }; pagination: { endCursor?: `0x${string}`; hasNext: boolean; hasPrevious: boolean; limit: number; startCursor?: `0x${string}`; }; results: { app: `0x${string}`; author: { address: `0x${string}`; ens?: { avatarUrl: null | string; name: string; }; farcaster?: { displayName?: string; fid: number; pfpUrl?: string; username: string; }; }; chainId: number; channelId: bigint; commentType: number; content: string; createdAt: Date; cursor: `0x${string}`; deletedAt: null | Date; hookMetadata: { key: `0x${string}`; value: `0x${string}`; }[]; id: `0x${string}`; logIndex: null | number; metadata: { key: `0x${string}`; value: `0x${string}`; }[]; moderationClassifierResult: Record<string, number>; moderationClassifierScore: number; moderationStatus: "approved" | "pending" | "rejected"; moderationStatusChangedAt: Date; parentId: null | `0x${string}`; path: string; reactionCounts: Record<string, number>; references: ( | { address: `0x${string}`; avatarUrl: null | string; name: string; position: { end: number; start: number; }; type: "ens"; url: string; } | { address: `0x${string}`; displayName: null | string; fid: number; fname: string; pfpUrl: null | string; position: { end: number; start: number; }; type: "farcaster"; url: string; username: string; } | { address: `0x${string}`; chainId: null | number; chains: { caip: string; chainId: number; }[]; decimals: number; logoURI: null | string; name: string; position: { end: number; start: number; }; symbol: string; type: "erc20"; } | { description: null | string; favicon: null | string; mediaType: string; opengraph: | null | { description: null | string; image: string; title: string; url: string; }; position: { end: number; start: number; }; title: string; type: "webpage"; url: string; } | { mediaType: string; position: { end: number; start: number; }; type: "file"; url: string; } | { dimension?: { height: number; width: number; }; mediaType: string; position: { end: number; start: number; }; type: "image"; url: string; } | { mediaType: string; position: { end: number; start: number; }; type: "video"; url: string; videoTracks?: { codec?: ... | ...; dimension: { height: ...; width: ...; }; }[]; } | { chainId: number; id: `0x${string}`; position: { end: number; start: number; }; type: "quoted_comment"; })[]; replies: { extra: { moderationEnabled: boolean; moderationKnownReactions: string[]; }; pagination: { count: number; endCursor?: `0x${string}`; hasNext: boolean; hasPrevious: boolean; limit: number; startCursor?: `0x${string}`; }; results: IndexerAPICommentSchemaType[]; }; revision: number; targetUri: string; txHash: `0x${string}`; updatedAt: Date; viewerReactions: Record<string, IndexerAPICommentSchemaType[]>; zeroExSwap: | null | { from: { address: `0x${string}`; amount: string; symbol: string; }; to: { address: "" | `0x${string}`; amount: string; symbol: string; }; }; }[]; }>

A promise that resolves comments fetched from the Indexer API

Throws

If there is some request failure.