Documentation
¶
Index ¶
- Constants
- Variables
- func AddEarlyVoteAchievement(db *s.Database, v *Vote) error
- func AddWinningVoteAchievement(db *s.Database, votes []*VoteWithBalance, p ProposalResults) error
- func CreateUserNFTRecord(db *s.Database, v *VoteWithBalance) error
- func DoesNFTExist(db *s.Database, v *VoteWithBalance) (bool, error)
- func EnsureRoleForCommunity(db *s.Database, addr string, communityId int, userType string) error
- func EnsureValidRole(userType string) bool
- func GetActiveStrategiesForCommunity(db *s.Database, communityId int) ([]string, error)
- func GetCategoryCount(db *s.Database, search string) (map[string]int, error)
- func GrantAdminRolesToAddress(db *s.Database, communityId int, addr string) error
- func GrantAuthorRolesToAddress(db *s.Database, communityId int, addr string) error
- func GrantRolesToCommunityCreator(db *s.Database, addr string, communityId int) error
- func IsNFTStrategy(name string) bool
- func ValidateVoteMessage(message string, proposal Proposal) error
- type Balance
- type Community
- func GetCommunities(db *s.Database, pageParams shared.PageParams) ([]*Community, int, error)
- func GetDefaultCommunities(db *s.Database, params shared.PageParams, filters []string, isSearch bool) ([]*Community, int, error)
- func SearchForCommunity(db *s.Database, query string, filters []string, params shared.PageParams) ([]*Community, int, error)
- func (c *Community) CanUpdateCommunity(db *s.Database, addr string) error
- func (c *Community) CreateCommunity(db *s.Database) error
- func (c *Community) GetCommunity(db *s.Database) error
- func (c *Community) GetCommunityByProposalId(db *s.Database, proposalId int) error
- func (c *Community) GetStrategy(name string) (Strategy, error)
- func (c *Community) UpdateCommunity(db *s.Database, p *UpdateCommunityRequestPayload) error
- type CommunityType
- type CommunityUser
- type CommunityUserPayload
- type CommunityUserType
- type CreateCommunityRequestPayload
- type LeaderboardPayload
- type LeaderboardUser
- type List
- type ListPayload
- type ListUpdatePayload
- type NFT
- type Proposal
- func (p *Proposal) CreateProposal(db *s.Database) error
- func (p *Proposal) EnforceMaxWeight(balance float64) float64
- func (p *Proposal) GetProposalById(db *s.Database) error
- func (p *Proposal) IsLive() bool
- func (p *Proposal) UpdateProposal(db *s.Database) error
- func (p *Proposal) ValidateBalance(weight float64) error
- type ProposalResults
- type Strategy
- type UpdateCommunityRequestPayload
- type UpdateProposalRequestPayload
- type UserAchievements
- type UserCommunity
- type UserTypes
- type Vote
- type VoteWithBalance
- func GetAllVotesForProposal(db *s.Database, proposalId int, strategy string) ([]*VoteWithBalance, error)
- func GetVotesForAddress(db *s.Database, address string, proposalIds *[]int, ...) ([]*VoteWithBalance, int, error)
- func GetVotesForProposal(db *s.Database, proposalId int, strategy string, pageParams shared.PageParams) ([]*VoteWithBalance, int, error)
- type VotingStrategy
- type VotingStreak
Constants ¶
View Source
const ( EarlyVote string = "earlyVote" Streak = "streak" WinningVote = "winningVote" )
View Source
const COUNT_CATEGORIES_DEFAULT_SQL = `` /* 139-byte string literal not displayed */
View Source
const COUNT_CATEGORIES_SEARCH_SQL = `` /* 145-byte string literal not displayed */
View Source
const DEFAULT_SEARCH_SQL = `
SELECT id, name, body, logo, category
FROM communities
WHERE is_featured = 'true'
AND category IS NOT NULL
`
View Source
const HOMEPAGE_SQL = `` /* 450-byte string literal not displayed */
View Source
const INSERT_COMMUNITY_SQL = `` /* 566-byte string literal not displayed */
View Source
const SEARCH_COMMUNITIES_SQL = `` /* 152-byte string literal not displayed */
View Source
const UPDATE_COMMUNITY_SQL = `` /* 937-byte string literal not displayed */
Variables ¶
View Source
var USER_TYPES = UserTypes{"member", "author", "admin"}
Functions ¶
func AddWinningVoteAchievement ¶
func AddWinningVoteAchievement(db *s.Database, votes []*VoteWithBalance, p ProposalResults) error
func CreateUserNFTRecord ¶
func CreateUserNFTRecord(db *s.Database, v *VoteWithBalance) error
func DoesNFTExist ¶
func DoesNFTExist(db *s.Database, v *VoteWithBalance) (bool, error)
func EnsureRoleForCommunity ¶
func EnsureValidRole ¶
func GetCategoryCount ¶
func IsNFTStrategy ¶
func ValidateVoteMessage ¶
Types ¶
type Balance ¶
type Balance struct { ID string `json:"id"` Addr string `json:"addr"` PrimaryAccountBalance uint64 `json:"primaryAccountBalance"` SecondaryAddress string `json:"secondaryAddress"` SecondaryAccountBalance uint64 `json:"secondaryAccountBalance"` StakingBalance uint64 `json:"stakingBalance"` ScriptResult string `json:"scriptResult"` Stakes []string `json:"stakes"` BlockHeight uint64 `json:"blockHeight"` Proposal_id int `json:"proposal_id"` NFTCount int `json:"nftCount"` CreatedAt time.Time `json:"createdAt"` }
type Community ¶
type Community struct { ID int `json:"id,omitempty"` Name string `json:"name,omitempty"` Category *string `json:"category,omitempty" validate:"required"` Category_count *int `json:"categoryCount,omitempty"` Logo *string `json:"logo,omitempty"` Body *string `json:"body,omitempty"` Strategies *[]Strategy `json:"strategies,omitempty"` Strategy *string `json:"strategy,omitempty"` Banner_img_url *string `json:"bannerImgUrl,omitempty"` Website_url *string `json:"websiteUrl,omitempty"` Twitter_url *string `json:"twitterUrl,omitempty"` Github_url *string `json:"githubUrl,omitempty"` Discord_url *string `json:"discordUrl,omitempty"` Instagram_url *string `json:"instagramUrl,omitempty"` Terms_and_conditions_url *string `json:"termsAndConditionsUrl,omitempty"` Proposal_validation *string `json:"proposalValidation,omitempty"` Proposal_threshold *string `json:"proposalThreshold,omitempty"` Slug *string `json:"slug,omitempty" validate:"required"` Is_featured *bool `json:"isFeatured,omitempty"` Total *int `json:"total,omitempty"` // for search only Contract_name *string `json:"contractName,omitempty"` Contract_addr *string `json:"contractAddr,omitempty"` Contract_type *string `json:"contractType,omitempty"` Public_path *string `json:"publicPath,omitempty"` Timestamp string `json:"timestamp" validate:"required"` Composite_signatures *[]s.CompositeSignature `json:"compositeSignatures"` Creator_addr string `json:"creatorAddr" validate:"required"` Signing_addr *string `json:"signingAddr,omitempty"` Voucher *shared.Voucher `json:"voucher,omitempty"` Created_at *time.Time `json:"createdAt,omitempty"` Cid *string `json:"cid,omitempty"` }
func GetCommunities ¶
func GetDefaultCommunities ¶
func SearchForCommunity ¶
func (*Community) CanUpdateCommunity ¶
func (*Community) GetCommunityByProposalId ¶
func (*Community) UpdateCommunity ¶
func (c *Community) UpdateCommunity(db *s.Database, p *UpdateCommunityRequestPayload) error
type CommunityType ¶
type CommunityType struct { Key string `json:"key" validate:"required"` Name string `json:"name" validate:"required"` Description string `json:"description,omitempty"` }
func GetCommunityTypes ¶
func GetCommunityTypes(db *s.Database) ([]*CommunityType, error)
type CommunityUser ¶
type CommunityUser struct { Community_id int `json:"communityId" validate:"required"` Addr string `json:"addr" validate:"required"` User_type string `json:"userType" validate:"required"` }
func GetUsersForCommunityByType ¶
func GetUsersForCommunityByType( db *s.Database, communityId int, user_type string, pageParams shared.PageParams, ) ([]CommunityUser, int, error)
func (*CommunityUser) CreateCommunityUser ¶
func (u *CommunityUser) CreateCommunityUser(db *s.Database) error
func (*CommunityUser) GetCommunityUser ¶
func (u *CommunityUser) GetCommunityUser(db *s.Database) error
type CommunityUserPayload ¶
type CommunityUserPayload struct { CommunityUser Signing_addr string `json:"signingAddr"` Timestamp string `json:"timestamp"` Composite_signatures *[]s.CompositeSignature `json:"compositeSignatures"` Voucher *s.Voucher `json:"voucher"` }
type CommunityUserType ¶
type CommunityUserType struct { Community_id int `json:"communityId" validate:"required"` Addr string `json:"addr" validate:"required"` Is_admin bool `json:"isAdmin" validate:"required"` Is_member bool `json:"isMember" validate:"required"` }
func GetUsersForCommunity ¶
func GetUsersForCommunity(db *s.Database, communityId int, pageParams shared.PageParams) ([]CommunityUserType, int, error)
type LeaderboardPayload ¶
type LeaderboardPayload struct { Users []LeaderboardUser `json:"users"` CurrentUser LeaderboardUser `json:"currentUser"` }
func GetCommunityLeaderboard ¶
func GetCommunityLeaderboard( db *s.Database, communityId int, addr string, pageParams shared.PageParams, ) (LeaderboardPayload, int, error)
type LeaderboardUser ¶
type List ¶
type List struct { ID int `json:"id"` Community_id int `json:"communityId"` Addresses []string `json:"addresses,omitempty" validate:"required"` List_type *string `json:"listType,omitempty"` Cid *string `json:"cid,omitempty"` Created_at *time.Time `json:"createdAt,omitempty"` }
func GetListsForCommunity ¶
func (*List) AddAddresses ¶
func (*List) RemoveAddresses ¶
type ListPayload ¶
type ListPayload struct { List s.TimestampSignaturePayload }
type ListUpdatePayload ¶
type ListUpdatePayload struct { ID int `json:"id"` Addresses []string `json:"addresses,omitempty" validate:"required"` s.TimestampSignaturePayload }
type NFT ¶
type NFT struct { ID interface{} `json:"id"` Contract_addr string `json:"contract_addr"` Created_at time.Time `json:"created_at"` Float_event_id uint64 `json:"event_id,omitempty"` }
func GetUserNFTs ¶
func GetUserNFTs(db *s.Database, vote *VoteWithBalance) ([]*NFT, error)
type Proposal ¶
type Proposal struct { ID int `json:"id,omitempty"` Name string `json:"name" validate:"required"` Community_id int `json:"communityId"` Choices []s.Choice `json:"choices" validate:"required"` Strategy *string `json:"strategy,omitempty"` Max_weight *float64 `json:"maxWeight,omitempty"` Min_balance *float64 `json:"minBalance,omitempty"` Creator_addr string `json:"creatorAddr" validate:"required"` Start_time time.Time `json:"startTime" validate:"required"` Result *string `json:"result,omitempty"` End_time time.Time `json:"endTime" validate:"required"` Created_at *time.Time `json:"createdAt,omitempty"` Cid *string `json:"cid,omitempty"` Status *string `json:"status,omitempty"` Body *string `json:"body,omitempty" validate:"required"` Block_height *uint64 `json:"block_height"` Total_votes int `json:"total_votes"` Timestamp string `json:"timestamp" validate:"required"` Composite_signatures *[]s.CompositeSignature `json:"compositeSignatures"` Computed_status *string `json:"computedStatus,omitempty"` Snapshot_status *string `json:"snapshotStatus,omitempty"` Voucher *shared.Voucher `json:"voucher,omitempty"` Achievements_done bool `json:"achievementsDone"` }
func (*Proposal) EnforceMaxWeight ¶
func (*Proposal) ValidateBalance ¶
Returns an error if the account's balance is insufficient to cast a vote on the proposal.
type ProposalResults ¶
type ProposalResults struct { Proposal_id int `json:"proposalId" validate:"required"` Results map[string]int `json:"results" validate:"required"` Results_float map[string]float64 `json:"resultsFloat" validate:"required"` Updated_at time.Time `json:"updatedAt" validate:"required"` Cid *string `json:"cid,omitempty"` Achievements_done bool `json:"achievementsDone"` }
func NewProposalResults ¶
func NewProposalResults(id int, choices []s.Choice) *ProposalResults
func (*ProposalResults) GetLatestProposalResultsById ¶
func (r *ProposalResults) GetLatestProposalResultsById(db *s.Database) error
type Strategy ¶
type UpdateCommunityRequestPayload ¶
type UpdateCommunityRequestPayload struct { Name *string `json:"name,omitempty"` Category *string `json:"category,omitempty"` Body *string `json:"body,omitempty"` Logo *string `json:"logo,omitempty"` Strategies *[]Strategy `json:"strategies,omitempty"` Strategy *string `json:"strategy,omitempty"` Banner_img_url *string `json:"bannerImgUrl,omitempty"` Website_url *string `json:"websiteUrl,omitempty"` Twitter_url *string `json:"twitterUrl,omitempty"` Github_url *string `json:"githubUrl,omitempty"` Discord_url *string `json:"discordUrl,omitempty"` Instagram_url *string `json:"instagramUrl,omitempty"` Terms_and_conditions_url *string `json:"termsAndConditionsUrl,omitempty"` Proposal_validation *string `json:"proposalValidation,omitempty"` Proposal_threshold *string `json:"proposalThreshold,omitempty"` Voucher *shared.Voucher `json:"voucher,omitempty"` //TODO dup fields in Community struct, make sub struct for both to use Contract_name *string `json:"contractName,omitempty"` Contract_addr *string `json:"contractAddr,omitempty"` Contract_type *string `json:"contractType,omitempty"` Public_path *string `json:"publicPath,omitempty"` Threshold *float64 `json:"threshold,omitempty"` s.TimestampSignaturePayload }
type UpdateProposalRequestPayload ¶
type UpdateProposalRequestPayload struct { Status string `json:"status"` Voucher *s.Voucher `json:"voucher,omitempty"` s.TimestampSignaturePayload }
type UserAchievements ¶
type UserCommunity ¶
func GetCommunitiesForUser ¶
func GetCommunitiesForUser(db *s.Database, addr string, pageParams shared.PageParams) ([]UserCommunity, int, error)
type Vote ¶
type Vote struct { ID int `json:"id,omitempty"` Proposal_id int `json:"proposalId"` Addr string `json:"addr" validate:"required"` Choice string `json:"choice" validate:"required"` Composite_signatures *[]s.CompositeSignature `json:"compositeSignatures" validate:"required"` Created_at time.Time `json:"createdAt,omitempty"` Cid *string `json:"cid"` Message string `json:"message"` Voucher *shared.Voucher `json:"voucher,omitempty"` IsCancelled bool `json:"isCancelled"` IsEarly bool `json:"isEarly"` IsWinning bool `json:"isWinning"` }
func (*Vote) ValidateChoice ¶
type VoteWithBalance ¶
type VoteWithBalance struct { // Extend Vote Vote // Balance BlockHeight *uint64 `json:"blockHeight" pg:"block_height"` Balance *uint64 `json:"balance"` PrimaryAccountBalance *uint64 `json:"primaryAccountBalance"` SecondaryAccountBalance *uint64 `json:"secondaryAccountBalance"` StakingBalance *uint64 `json:"stakingBalance"` Weight *float64 `json:"weight"` NFTs []*NFT }
func GetAllVotesForProposal ¶
func GetVotesForAddress ¶
func GetVotesForAddress( db *s.Database, address string, proposalIds *[]int, pageParams shared.PageParams, ) ([]*VoteWithBalance, int, error)
func GetVotesForProposal ¶
func GetVotesForProposal( db *s.Database, proposalId int, strategy string, pageParams shared.PageParams, ) ([]*VoteWithBalance, int, error)
type VotingStrategy ¶
type VotingStrategy struct { Key string `json:"key" validate:"required"` Name string `json:"name" validate:"required"` Description string `json:"description,omitempty"` Scripts []s.CustomScript `json:"scripts,omitempty"` }
func GetVotingStrategies ¶
func GetVotingStrategies(db *s.Database) ([]*VotingStrategy, error)
type VotingStreak ¶
Click to show internal directories.
Click to hide internal directories.