farcaster

package
v0.5.20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Public Instances https://www.thehubble.xyz/intro/hubble.html
	EndpointMainnet = "https://nemes.farcaster.xyz:2281"

	DefaultTimeout  = 5 * time.Second
	DefaultAttempts = 3
	// https://github.com/farcasterxyz/hub-monorepo/blob/77ff79ed804104956eb153247c22c00099c7b122/packages/core/src/time.ts#L4
	FarcasterEpoch = 1609459200 // January 1, 2021 UTC
	SequenceBits   = 12
)

Variables

This section is empty.

Functions

func AccountTypeStrings added in v0.4.22

func AccountTypeStrings() []string

AccountTypeStrings returns a slice of all String values of the enum

func ConvertEventIDToTimestampMilli added in v0.4.21

func ConvertEventIDToTimestampMilli(eventID uint64) uint64

ConvertEventIDToTimestampMilli Convert the timestampMilli from a farcaster event ID.

func ConvertTimestampMilliToEventID added in v0.5.15

func ConvertTimestampMilliToEventID(timestamp int64) uint64

ConvertTimestampMilliToEventID Convert a timestampMilli to a farcaster event ID.

func CovertFarcasterTimeToTimestamp

func CovertFarcasterTimeToTimestamp(timestamp int64) int64

CovertFarcasterTimeToTimestamp Converts a Farcaster seconds timestamp to a Unix timestamp.

func HubEventTypeStrings

func HubEventTypeStrings() []string

HubEventTypeStrings returns a slice of all String values of the enum

func MessageTypeStrings

func MessageTypeStrings() []string

MessageTypeStrings returns a slice of all String values of the enum

func NewAuthenticationTransport added in v0.2.3

func NewAuthenticationTransport(apiKey string) http.RoundTripper

func ReactionTypeStrings

func ReactionTypeStrings() []string

ReactionTypeStrings returns a slice of all String values of the enum

func UserDataTypeStrings

func UserDataTypeStrings() []string

UserDataTypeStrings returns a slice of all String values of the enum

func UsernameProofTypeStrings

func UsernameProofTypeStrings() []string

UsernameProofTypeStrings returns a slice of all String values of the enum

Types

type AccountType added in v0.4.22

type AccountType int
const (
	ProtocolEthereum AccountType = 0
	ProtocolSolana   AccountType = 1
)

func AccountTypeString added in v0.4.22

func AccountTypeString(s string) (AccountType, error)

AccountTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func AccountTypeValues added in v0.4.22

func AccountTypeValues() []AccountType

AccountTypeValues returns all values of the enum

func (AccountType) IsAAccountType added in v0.4.22

func (i AccountType) IsAAccountType() bool

IsAAccountType returns "true" if the value is listed in the enum definition. "false" otherwise

func (AccountType) String added in v0.4.22

func (i AccountType) String() string

func (AccountType) Values added in v0.4.22

func (AccountType) Values() []string

type AuthenticationTransport added in v0.2.3

type AuthenticationTransport struct {
	APIKey string
	// contains filtered or unexported fields
}

func (*AuthenticationTransport) RoundTrip added in v0.2.3

func (a *AuthenticationTransport) RoundTrip(request *http.Request) (*http.Response, error)

type CastAddBody

type CastAddBody struct {
	EmbedsDeprecated  []string `json:"embedsDeprecated"`
	Mentions          []uint64 `json:"mentions"`
	MentionsUsernames []string `json:"mentionsUsernames"`
	ParentCastID      *CastID  `json:"parentCastId,omitempty"`
	ParentCast        *Message `json:"parentCast,omitempty"`
	ParentURL         string   `json:"parentUrl,omitempty"`
	Text              string   `json:"text"`
	MentionsPositions []int32  `json:"mentionsPositions"`
	Embeds            []Embed  `json:"embeds"`
}

type CastID

type CastID struct {
	Fid  uint64 `json:"fid"`
	Hash string `json:"hash"`
}

type CastRemoveBody

type CastRemoveBody struct {
	TargetHash string `json:"targeHash"`
}

type Client

type Client interface {
	GetCastsByFid(ctx context.Context, fid *int64, reverse bool, pageSize *int, pageToken string) (*MessageResponse, error)
	GetCastByFidAndHash(ctx context.Context, fid *int64, hash string) (*Message, error)
	GetVerificationsByFid(ctx context.Context, fid *int64, pageToken string) (*MessageResponse, error)
	GetUserNameProofsByFid(ctx context.Context, fid *int64) (*ProofResponse, error)
	GetUserNameProofByName(ctx context.Context, name string) (*UserNameProof, error)
	GetUserDataByFid(ctx context.Context, fid *int64, pageToken string) (*MessageResponse, error)
	GetUserDataByFidAndType(ctx context.Context, fid *int64, userDataType string) (*Message, error)
	GetEvents(ctx context.Context, fromEventID *int64) (*EventResponse, error)
	GetFids(ctx context.Context, reverse bool, pageSize *int) (*FidResponse, error)
	GetReactionsByFid(ctx context.Context, fid *int64, reverse bool, pageSize *int, pageToken, reactionType string) (*MessageResponse, error)
	GetReaction(ctx context.Context, fid, targetFid *int64, targetHash, reactionType string) (*Message, error)
}

func NewClient

func NewClient(endpoint string, options ...ClientOption) (Client, error)

type ClientOption

type ClientOption func(client *client) error

func WithAPIKey added in v0.2.3

func WithAPIKey(apiKey *string) ClientOption

type Embed

type Embed struct {
	URL string `json:"url"`
}

type EventResponse

type EventResponse struct {
	NextPageEventID uint64     `json:"nextPageEventId"`
	Events          []HubEvent `json:"events"`
}

type FidResponse

type FidResponse struct {
	Fids          []uint64 `json:"fids"`
	NextPageToken string   `json:"nextPageToken"`
}

type HTTPError added in v0.4.22

type HTTPError struct {
	StatusCode int
	Message    string
}

func (*HTTPError) Error added in v0.4.22

func (e *HTTPError) Error() string

type HubEvent

type HubEvent struct {
	Type                   string                  `json:"type"`
	ID                     uint64                  `json:"id"`
	MergeMessageBody       *MergeMessageBody       `json:"mergeMessageBody,omitempty"`
	PruneMessageBody       *PruneMessageBody       `json:"pruneMessageBody,omitempty"`
	RevokeMessageBody      *RevokeMessageBody      `json:"revokeMessageBody,omitempty"`
	MergeUserNameProofBody *MergeUserNameProofBody `json:"mergeUserNameProofBody,omitempty"`
	MergeOnChainEventBody  *MergeOnChainEventBody  `json:"mergeOnChainEventBody,omitempty"`
}

type HubEventType

type HubEventType int
const (
	HubEventTypeNone               HubEventType = 0 // Invalid default value
	HubEventTypeMergeMessage       HubEventType = 1 // A message was merged into the Hub
	HubEventTypePruneMessage       HubEventType = 2 // A message was pruned because a limit was exceeded
	HubEventTypeRevokeMessage      HubEventType = 3 // A message was revoked by a user
	HubEventTypeMergeUsernameProof HubEventType = 6
	HubEventTypeMergeOnChainEvent  HubEventType = 9
)

func HubEventTypeString

func HubEventTypeString(s string) (HubEventType, error)

HubEventTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func HubEventTypeValues

func HubEventTypeValues() []HubEventType

HubEventTypeValues returns all values of the enum

func (HubEventType) IsAHubEventType

func (i HubEventType) IsAHubEventType() bool

IsAHubEventType returns "true" if the value is listed in the enum definition. "false" otherwise

func (HubEventType) String

func (i HubEventType) String() string

func (HubEventType) Values

func (HubEventType) Values() []string

type LinkBody

type LinkBody struct {
	Type             string `json:"type"`
	DisplayTimestamp uint32 `json:"displayTimestamp"`
	TargetFid        uint64 `json:"targetFid"`
}

type MergeMessageBody

type MergeMessageBody struct {
	Message         Message   `json:"message"`
	DeletedMessages []Message `json:"deletedMessages"`
}

type MergeOnChainEventBody

type MergeOnChainEventBody struct{}

type MergeUserNameProofBody

type MergeUserNameProofBody struct {
	UserNameProof               UserNameProof `json:"usernameProof"`
	DeletedUserNameProof        UserNameProof `json:"deletedUsernameProof"`
	UsernameProofMessage        Message       `json:"usernameProofMessage"`
	DeletedUsernameProofMessage Message       `json:"deletedUsernameProofMessage"`
}

type Message

type Message struct {
	Data            MessageData `json:"data"`
	Hash            string      `json:"hash"`
	HashScheme      string      `json:"hashScheme"`
	Signature       string      `json:"signature"`
	SignatureScheme string      `json:"signatureScheme"`
	Signer          string      `json:"signer"`
}

type MessageData

type MessageData struct {
	Type                          string                         `json:"type"`
	Fid                           uint64                         `json:"fid"`
	Profile                       *model.Profile                 `json:"profile,omitempty"`
	Timestamp                     uint32                         `json:"timestamp"`
	Network                       string                         `json:"network"`
	CastAddBody                   *CastAddBody                   `json:"castAddBody,omitempty"`
	CastRemoveBody                *CastRemoveBody                `json:"castRemoveBody,omitempty"`
	UserDataBody                  *UserDataBody                  `json:"userDataBody,omitempty"`
	ReactionBody                  *ReactionBody                  `json:"reactionBody,omitempty"`
	LinkBody                      *LinkBody                      `json:"linkBody,omitempty"`
	VerificationAddEthAddressBody *VerificationAddEthAddressBody `json:"verificationAddEthAddressBody,omitempty"`
	VerificationRemoveBody        *VerificationRemoveBody        `json:"verificationRemoveBody,omitempty"`
	UserNameProof                 *UserNameProof                 `json:"userNameProof,omitempty"`
}

type MessageResponse

type MessageResponse struct {
	Messages      []Message `json:"messages"`
	NextPageToken string    `json:"nextPageToken"`
}

type MessageType

type MessageType int
const (
	MessageTypeNone                      MessageType = 0  // Invalid default value
	MessageTypeCastAdd                   MessageType = 1  // Add a new Cast
	MessageTypeCastRemove                MessageType = 2  // Remove an existing Cast
	MessageTypeReactionAdd               MessageType = 3  // Add a Reaction to a Cast
	MessageTypeReactionRemove            MessageType = 4  // Remove a Reaction from a Cast
	MessageTypeLinkAdd                   MessageType = 5  // Add a Link to a target
	MessageTypeLinkRemove                MessageType = 6  // Remove a Link from a target
	MessageTypeVerificationAddEthAddress MessageType = 7  // Add a Verification of an Ethereum Address
	MessageTypeVerificationRemove        MessageType = 8  // Remove a Verification
	MessageTypeUserDataAdd               MessageType = 11 // Add metadata about a user
	MessageTypeUsernameProof             MessageType = 12 // Add or replace a username proof
)

func MessageTypeString

func MessageTypeString(s string) (MessageType, error)

MessageTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func MessageTypeValues

func MessageTypeValues() []MessageType

MessageTypeValues returns all values of the enum

func (MessageType) IsAMessageType

func (i MessageType) IsAMessageType() bool

IsAMessageType returns "true" if the value is listed in the enum definition. "false" otherwise

func (MessageType) String

func (i MessageType) String() string

func (MessageType) Values

func (MessageType) Values() []string

type Profile

type Profile struct {
	Username       string
	CustodyAddress string
	EthAddresses   []string
}

Profile redis profile

type ProofResponse

type ProofResponse struct {
	Proofs []UserNameProof `json:"proofs"`
}

type PruneMessageBody

type PruneMessageBody struct {
	Message Message `json:"message"`
}

type ReactionBody

type ReactionBody struct {
	Type         string   `json:"type"`
	TargetCastID CastID   `json:"targetCastId"`
	TargetCast   *Message `json:"targetCast"`
	TargetURL    string   `json:"targetUrl"`
}

type ReactionType

type ReactionType int
const (
	ReactionTypeNone   ReactionType = 0 // Invalid default value
	ReactionTypeLike   ReactionType = 1 // Like the target cast
	ReactionTypeRecast ReactionType = 2 // Share target cast to the user's audience
)

func ReactionTypeString

func ReactionTypeString(s string) (ReactionType, error)

ReactionTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func ReactionTypeValues

func ReactionTypeValues() []ReactionType

ReactionTypeValues returns all values of the enum

func (ReactionType) IsAReactionType

func (i ReactionType) IsAReactionType() bool

IsAReactionType returns "true" if the value is listed in the enum definition. "false" otherwise

func (ReactionType) String

func (i ReactionType) String() string

func (ReactionType) Values

func (ReactionType) Values() []string

type RevokeMessageBody

type RevokeMessageBody struct {
	Message Message `json:"message"`
}

type UserDataBody

type UserDataBody struct {
	Type  string `json:"type"`
	Value string `json:"value"`
}

type UserDataType

type UserDataType int
const (
	UserDataTypeNone     UserDataType = 0 // Invalid default value
	UserDataTypePfp      UserDataType = 1 // Profile Picture for the user
	UserDataTypeDisplay  UserDataType = 2 // Display Name for the user
	UserDataTypeBio      UserDataType = 3 // Bio for the user
	UserDataTypeURL      UserDataType = 5 // URL of the user
	UserDataTypeUsername UserDataType = 6 // Preferred Farcaster Name for the user
)

func UserDataTypeString

func UserDataTypeString(s string) (UserDataType, error)

UserDataTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func UserDataTypeValues

func UserDataTypeValues() []UserDataType

UserDataTypeValues returns all values of the enum

func (UserDataType) IsAUserDataType

func (i UserDataType) IsAUserDataType() bool

IsAUserDataType returns "true" if the value is listed in the enum definition. "false" otherwise

func (UserDataType) String

func (i UserDataType) String() string

func (UserDataType) Values

func (UserDataType) Values() []string

type UserNameProof

type UserNameProof struct {
	Timestamp uint32 `json:"timestamp"`
	Name      string `json:"name"`
	Owner     string `json:"owner"`
	Signature string `json:"signature"`
	Fid       uint64 `json:"fid"`
	Type      string `json:"type"`
}

type UsernameProofType

type UsernameProofType int
const (
	UsernameTypeNone  UsernameProofType = 0
	UsernameTypeFname UsernameProofType = 1
	UsernameTypeEnsL1 UsernameProofType = 2
)

func UsernameProofTypeString

func UsernameProofTypeString(s string) (UsernameProofType, error)

UsernameProofTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func UsernameProofTypeValues

func UsernameProofTypeValues() []UsernameProofType

UsernameProofTypeValues returns all values of the enum

func (UsernameProofType) IsAUsernameProofType

func (i UsernameProofType) IsAUsernameProofType() bool

IsAUsernameProofType returns "true" if the value is listed in the enum definition. "false" otherwise

func (UsernameProofType) String

func (i UsernameProofType) String() string

func (UsernameProofType) Values

func (UsernameProofType) Values() []string

type VerificationAddEthAddressBody

type VerificationAddEthAddressBody struct {
	Address      string `json:"address"`
	EthSignature string `json:"ethSignature"`
	BlockHash    string `json:"blockHash"`
	Protocol     string `json:"protocol"`
}

type VerificationRemoveBody

type VerificationRemoveBody struct {
	Address string `json:"address"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL