dmens

package
v0.0.0-...-82037ee Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActionRePost
	ActionQuotePost
	ActionReply
	ActionLike
)
View Source
const (
	FunctionRegister   = "register"
	FunctionAddItem    = "add_item"
	FunctionRemoveItem = "remove_item"
)

Variables

View Source
var (
	MainnetConfig = &Configuration{
		Name:       "mainnet",
		IsMainNet:  true,
		GraphqlUrl: "https://graphql.coming.chat/sui-mainnet/graphql",
	}

	TestnetConfig = &Configuration{
		Name:       "testnet",
		GraphqlUrl: "https://graphql.coming.chat/sui-testnet/graphql",
	}

	DevnetConfig = &Configuration{
		Name:       "devnet",
		GraphqlUrl: "https://graphql.coming.chat/sui-devnet/graphql",
	}
)
View Source
var (
	ErrUserNotRegistered    = errors.New("the user not registered")
	ErrGetNullConfiguration = errors.New("get remote configuration with null")
	ErrNotValidPorfile      = errors.New("profile is not valid")
)

Functions

This section is empty.

Types

type Configuration

type Configuration struct {
	Name                 string
	FullNodeUrl          string
	GraphqlUrl           string
	ContractAddress      string
	GlobalProfileId      string
	GlobalProfileTableId string
	ProfileCheckUrl      string
	IsMainNet            bool
}

type NFTAvatar

type NFTAvatar struct {
	Id    string `json:"id"`
	Image string `json:"image"`
	Type  string `json:"type"`
	Name  string `json:"name"`
}

func NewNFTAvatar

func NewNFTAvatar() *NFTAvatar

func NewNFTAvatarWithId

func NewNFTAvatarWithId(nftId, image, typ string) *NFTAvatar

func NewNFTAvatarWithJsonString

func NewNFTAvatarWithJsonString(str string) (*NFTAvatar, error)

func (*NFTAvatar) JsonString

func (n *NFTAvatar) JsonString() (*base.OptionalString, error)

type Note

type Note struct {
	CreateTime int64  `json:"createTime"`
	NoteId     string `json:"noteId"`

	Action NoteAction `json:"action"`
	Text   string     `json:"text"`
	Poster string     `json:"poster"`
	RefId  string     `json:"refId"`

	Status *NoteStatus `json:"status"`
}

func NewNote

func NewNote() *Note

func NewNoteWithJsonString

func NewNoteWithJsonString(str string) (*Note, error)

func (*Note) JsonString

func (n *Note) JsonString() (*base.OptionalString, error)

type NoteAction

type NoteAction = int
const (
	ACTION_POST       NoteAction = 0
	ACTION_REPOST     NoteAction = 1
	ACTION_QUOTE_POST NoteAction = 2
	ACTION_REPLY      NoteAction = 3
	ACTION_LIKE       NoteAction = 4
)

type NotePage

type NotePage struct {
	*inter.SdkPageable[*Note]
}

func NewNotePage

func NewNotePage() *NotePage

func NewNotePageWithJsonString

func NewNotePageWithJsonString(str string) (*NotePage, error)

type NoteStatus

type NoteStatus struct {
	NoteId string `json:"noteId"`
	Viewer string `json:"viewer"`

	ReplyCount  int64 `json:"replyCount"`
	RepostCount int64 `json:"repostCount"`
	LikeCount   int64 `json:"likeCount"`

	// Whether the viewer reposted it
	IsReposted bool `json:"isReposted"`
	// Whether the viewer liked it
	IsLiked bool `json:"isLiked"`
}

type Poster

type Poster struct {
	*Configuration
	*PosterConfig
	// contains filtered or unexported fields
}

func NewPoster

func NewPoster(posterConfig *PosterConfig, configuration *Configuration) (*Poster, error)

func (*Poster) BatchQueryIsFollowingStatus

func (p *Poster) BatchQueryIsFollowingStatus(users *UserPage) error

BatchQueryIsFollowingStatus Batch query the following status of all users in a specified list. The query results will be modified directly in the pointer object.

func (*Poster) BatchQueryNFTAvatarByIds

func (p *Poster) BatchQueryNFTAvatarByIds(nftIds []string) (res map[string]*NFTAvatar, err error)

func (*Poster) BatchQueryNFTAvatarForUserPage

func (p *Poster) BatchQueryNFTAvatarForUserPage(page *UserPage) error

func (*Poster) BatchQueryNoteByIds

func (p *Poster) BatchQueryNoteByIds(ids []string) (*NotePage, error)

func (*Poster) BatchQueryNoteStatus

func (p *Poster) BatchQueryNoteStatus(page *NotePage, viewer string) error

BatchQueryNoteStatus 批量查询 page 中所有 note 的状态,数据会直接同步到 page 中每一个 note 对象中 @param viewer the note's viewer, if the viewer is empty, the poster's address will be queried.

func (*Poster) BatchQueryNoteStatusByIds

func (p *Poster) BatchQueryNoteStatusByIds(noteIds []string, viewer string) (map[string]*NoteStatus, error)

BatchQueryNoteStatusByIds

func (*Poster) BatchQueryUserByAddressArray

func (p *Poster) BatchQueryUserByAddressArray(array *base.StringArray) (*UserPage, error)

func (*Poster) BatchQueryUserByAddressJson

func (p *Poster) BatchQueryUserByAddressJson(jsonString string) (*UserPage, error)

BatchQueryUserByAddressJson @param jsonString address array's json string. e.g. `["0x1","0x2", "0x3"]`

func (*Poster) CheckProfile

func (p *Poster) CheckProfile(profile *Profile) (vp *ValidProfile, err error)

func (*Poster) DmensFollow

func (p *Poster) DmensFollow(addresses *base.StringArray) (*sui.Transaction, error)

func (*Poster) DmensPost

func (p *Poster) DmensPost(text string) (*sui.Transaction, error)

func (*Poster) DmensPostWithRef

func (p *Poster) DmensPostWithRef(action int, text, refIdentifier, refIdPoster string) (*sui.Transaction, error)

func (*Poster) DmensUnfollow

func (p *Poster) DmensUnfollow(addresses *base.StringArray) (*sui.Transaction, error)

func (*Poster) FetchDmensGlobalConfig

func (p *Poster) FetchDmensGlobalConfig() error

func (*Poster) FetchDmensObjecId

func (p *Poster) FetchDmensObjecId() error

FetchDmensObjecId After ios or android call profileRegister and send that transaction, this func should be recalled again to fetch the registered dmens object id

func (*Poster) IsMyFollowing

func (p *Poster) IsMyFollowing(address string) (*base.OptionalBool, error)

func (*Poster) IsRegister

func (p *Poster) IsRegister() bool

func (*Poster) MakeQuery

func (p *Poster) MakeQuery(q *Query) (string, error)

func (*Poster) QueryAllNoteList

func (p *Poster) QueryAllNoteList(pageSize int, afterCursor string) (*NotePage, error)

QueryAllNoteList @param pageSize The number of notes per page. @param afterCursor Each page has a cursor, and you need to specify the cursor to get the next page of content, If you want to get the first page of content, pass in empty.

func (*Poster) QueryDmensGlobalConfig

func (p *Poster) QueryDmensGlobalConfig() *Query

func (*Poster) QueryDmensObjectId

func (p *Poster) QueryDmensObjectId() *Query

func (*Poster) QueryNFTAvatar

func (p *Poster) QueryNFTAvatar(nftId string) (*NFTAvatar, error)

func (*Poster) QueryNoteById

func (p *Poster) QueryNoteById(noteId string) (*Note, error)

func (*Poster) QueryNoteStatusById

func (p *Poster) QueryNoteStatusById(noteId string, viewer string) (*NoteStatus, error)

QueryNoteStatusById @param noteId the note's id @param viewer the note's viewer, if the viewer is empty, the poster's address will be queried.

func (*Poster) QueryNotesMyFollowed

func (p *Poster) QueryNotesMyFollowed(pageSize int, afterCursor string) (*NotePage, error)

func (*Poster) QueryReplyNoteList

func (p *Poster) QueryReplyNoteList(noteId string, pageSize int, afterCursor string) (*NotePage, error)

func (*Poster) QuerySuiNameByAddress

func (p *Poster) QuerySuiNameByAddress(address string) (name *base.OptionalString, err error)

func (*Poster) QueryTrendNoteList

func (p *Poster) QueryTrendNoteList(pageSize int, afterCursor string) (*NotePage, error)

func (*Poster) QueryTrendUserList

func (p *Poster) QueryTrendUserList(pageSize int) (*UserPage, error)

func (*Poster) QueryUserFollowCount

func (p *Poster) QueryUserFollowCount(user string) (*UserFollowCount, error)

QueryUserFollowCount @param user If the user is empty, the poster's address will be queried.

func (*Poster) QueryUserFollowers

func (p *Poster) QueryUserFollowers(user string, pageSize int, afterCursor string) (*UserPage, error)

QueryUserFollowers @param user If the user is empty, the poster's address will be queried.

func (*Poster) QueryUserFollowing

func (p *Poster) QueryUserFollowing(user string, pageSize int, afterCursor string) (*UserPage, error)

QueryUserFollowing @param user If the user is empty, the poster's address will be queried.

func (*Poster) QueryUserInfoByAddress

func (p *Poster) QueryUserInfoByAddress(address string) (*UserInfo, error)

QueryUserInfoByAddress @param address If the address is empty, the poster's address will be queried.

func (*Poster) QueryUserNoteList

func (p *Poster) QueryUserNoteList(user string, pageSize int, afterCursor string) (*NotePage, error)

QueryUserNoteList @param user If the user is empty, the poster's address will be queried.

func (*Poster) QueryUserRepostList

func (p *Poster) QueryUserRepostList(user string, pageSize int, afterCursor string) (*RepostNotePage, error)

QueryUserRepostList @param user If the user is empty, the poster's address will be queried.

func (*Poster) QueryUserRepostListAsNotePage

func (p *Poster) QueryUserRepostListAsNotePage(user string, pageSize int, afterCursor string) (*NotePage, error)

QueryUserRepostListAsNotePage @param user If the user is empty, the poster's address will be queried.

func (*Poster) QueryUsersByName

func (p *Poster) QueryUsersByName(name string, pageSize int, afterCursor string) (*UserPage, error)

func (*Poster) Register

func (p *Poster) Register(validProfile *ValidProfile) (*sui.Transaction, error)

func (*Poster) RemoveNftAvatar

func (p *Poster) RemoveNftAvatar(avatar *NFTAvatar) (*sui.Transaction, error)

func (*Poster) SetNftAvatar

func (p *Poster) SetNftAvatar(nftId string) (*sui.Transaction, error)

func (*Poster) SwitchRpcUrl

func (p *Poster) SwitchRpcUrl(rpc string)

type PosterConfig

type PosterConfig struct {
	Address    string
	DmensNftId string
	// Default false
	Reviewing bool
	// contains filtered or unexported fields
}

func NewPosterConfig

func NewPosterConfig(address string, reviewing bool) *PosterConfig

type Profile

type Profile struct {
	Name           string `json:"name"`
	Bio            string `json:"bio"`
	Avatar         string `json:"avatar"`
	Background     string `json:"background"`
	Website        string `json:"website"`
	Identification string `json:"identification"`
}

type Query

type Query struct {
	Query         string
	OperationName string
	Variables     map[string]interface{}

	// 因为在 Variables 中使用 cursor 无法实现 `null cursor`, 因此将 cursor 单独取出来
	// cursor 为空时,表示 null
	Cursor string
}

func (*Query) ActualQueryString

func (q *Query) ActualQueryString() string

type RepostNote

type RepostNote struct {
	*Note        // origin note info
	Repost *Note `json:"repost"` // repost note info
}

func NewRepostNote

func NewRepostNote() *RepostNote

func NewRepostNoteWithJsonString

func NewRepostNoteWithJsonString(str string) (*RepostNote, error)

func (*RepostNote) JsonString

func (n *RepostNote) JsonString() (*base.OptionalString, error)

type RepostNotePage

type RepostNotePage struct {
	*inter.SdkPageable[*RepostNote]
}

func NewRepostNotePage

func NewRepostNotePage() *RepostNotePage

func NewRepostNotePageWithJsonString

func NewRepostNotePageWithJsonString(str string) (*RepostNotePage, error)

type UserFollowCount

type UserFollowCount struct {
	User string `json:"user"`

	FollowerCount  int `json:"followerCount"`
	FollowingCount int `json:"followingCount"`
}

func NewUserFollowCount

func NewUserFollowCount() *UserFollowCount

func NewUserFollowCountWithJsonString

func NewUserFollowCountWithJsonString(str string) (*UserFollowCount, error)

func (*UserFollowCount) JsonString

func (u *UserFollowCount) JsonString() (*base.OptionalString, error)

type UserInfo

type UserInfo struct {
	Address string `json:"address"`
	Avatar  string `json:"avatar"`
	Bio     string `json:"bio"`
	Name    string `json:"name"`
	NodeId  string `json:"nodeId"`

	Background     string `json:"background"`
	Website        string `json:"website"`
	Identification string `json:"identification"`

	// Only queried when call QueryUserInfoByAddress
	SuiName string `json:"suiName"`

	// NFT avatar's nftid
	Item      []string   `json:"item"`
	NFTAvatar *NFTAvatar `json:"nftAvatar"`

	IsFollowing bool `json:"isFollowing"`
}

func NewUserInfo

func NewUserInfo() *UserInfo

func NewUserInfoWithJsonString

func NewUserInfoWithJsonString(str string) (*UserInfo, error)

func (*UserInfo) JsonString

func (u *UserInfo) JsonString() (*base.OptionalString, error)

type UserPage

type UserPage struct {
	*inter.SdkPageable[*UserInfo]
}

func NewUserPage

func NewUserPage() *UserPage

func NewUserPageWithJsonString

func NewUserPageWithJsonString(str string) (*UserPage, error)

type ValidProfile

type ValidProfile struct {
	Profile   string
	Signature string
}

Jump to

Keyboard shortcuts

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