Skip to content
This repository was archived by the owner on Jul 17, 2024. It is now read-only.
This repository was archived by the owner on Jul 17, 2024. It is now read-only.

v2.2.0 adding useful hooks - 1 #3

@SamuelLHuber

Description

@SamuelLHuber

Useful building Hooks - 1

Highlevel Overview

Most functionality is build once and use thousands of times and even more if you add the different kinds of data providers you may want to use.

Why not abstract it away? In Farcaster there are mutliple dataproviders offering similar data and some combinations are needed to get some information combined. This can be done once, used thousands of times.

This is what this set of hooks is for.

New Hooks to create

getConnectedAddresses

getConnectedAddresses(provider: Provider, fid: number, ethereum?: boolean, solana?: boolean);

  • returns: array of connectedAddresses for selected chain (ethereum, solana) via boolean set to true or not. If both are set to true both are returned, default is return both

return object is always of type:

{
  ethereum: [
  ... addresses ...
  ],
  solana: [
  ... addresses ...
  ]
}

where addresses are strings.

though based on selection a different provider is used and one array may be empty as not requested

in the future this can easily be extended with any new chain/ecosystem added to the verifications/connectedAddresses

getFollowerCount

getFollowerCount(provider: Provider, fid: number);

  • returns number of followers.

return object is always of type number

update getCasts to allow Filters

Filters could be

  • channels
  • FID of posting user
    • Allow any boolean Function
      • Like <=10000 to allow only FID <= 10k
      • Like = 3 to surface only Casts by user with FID 3
      • Like in set [3, 16085] to show only casts by FID 3 and 16085
  • number of likes of the cast
  • number of recasts of the cast

A channel filter would be:
only getting casts specific to a channel e.g. from a Hub which isdocumented here or another provider

getMutuals

getMutuals(provider: Provider, fid: number);

  • returns number[ ] containing all FIDs followed by the input fid that also follow back

return object is always of type number[ ]

isMutual

isMutual(provider: Provider, fid: number, mutual:number)

  • returns boolean true if mutual is in number[] returned by getMutuals(provider, fid)

simple helper function to remove the need to implement the check everytime for devs

getChannelFollowers

getChannelFollowers(provider: Provider, channel: string, pagination?: boolean);

  • returns number[] containing all FIDs following the channel.

returns All if pagination is set to false. else if true paginated like Neynar API and matches "1:1" queries. Other proividers not implemented as Channels are still Warpcast only as of 2023-03-01

For NeynarProvider:
The fun challenge with this frame was to make it channel gated. The way we did it was to use this neynar endpoint https://docs.neynar.com/reference/channel-followers and cache the latest cursor and previous pages as the limit (1000) is reached and keep fetching only the last page.
by mehdi-loup here on Warpcast

TODOs

  • [ ]

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions