vote

package
v0.1.18 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2024 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	OrderByVp = proposal.Order{
		Field:     "vp",
		Direction: proposal.DirectionDesc,
	}
	OrderByCreated = proposal.Order{
		Field:     "created",
		Direction: proposal.DirectionDesc,
	}
)

Functions

This section is empty.

Types

type Consumer

type Consumer struct {
	// contains filtered or unexported fields
}

func NewConsumer

func NewConsumer(nc *nats.Conn, s *Service) (*Consumer, error)

func (*Consumer) Start

func (c *Consumer) Start(ctx context.Context) error

type DaoProvider

type DaoProvider interface {
	GetIDByOriginalID(string) (uuid.UUID, error)
}

type DataProvider

type DataProvider interface {
	BatchCreate(data []Vote) error
	GetByFilters(filters []Filter) (List, error)
	UpdateVotes(list []ResolvedAddress) error
	GetUnique(string, int64) ([]string, error)
	GetByVoter(string) ([]string, error)
}

type EnsResolver

type EnsResolver interface {
	AddRequests(list []string)
}

type Filter

type Filter interface {
	Apply(*gorm.DB) *gorm.DB
}

type List

type List struct {
	Votes      []Vote
	TotalCount int64
	TotalVp    float32
}

type PageFilter

type PageFilter struct {
	Offset int
	Limit  int
}

func (PageFilter) Apply

func (f PageFilter) Apply(db *gorm.DB) *gorm.DB

type PrepareRequest

type PrepareRequest struct {
	Voter    string
	Proposal string
	Choice   json.RawMessage
	Reason   *string
}

type PrepareResponse

type PrepareResponse struct {
	ID        string
	TypedData string
}

type ProposalIDsFilter

type ProposalIDsFilter struct {
	ProposalIDs []string
}

func (ProposalIDsFilter) Apply

func (f ProposalIDsFilter) Apply(db *gorm.DB) *gorm.DB

type Publisher

type Publisher interface {
	PublishJSON(ctx context.Context, subject string, obj any) error
}

type Relayer

type Relayer struct {
	Address string
	Receipt string
}

type Repo

type Repo struct {
	// contains filtered or unexported fields
}

func NewRepo

func NewRepo(db *gorm.DB) *Repo

func (*Repo) BatchCreate

func (r *Repo) BatchCreate(data []Vote) error

BatchCreate creates votes in batch

func (*Repo) GetByFilters

func (r *Repo) GetByFilters(filters []Filter) (List, error)

func (*Repo) GetByVoter added in v0.1.9

func (r *Repo) GetByVoter(voter string) ([]string, error)

func (*Repo) GetUnique

func (r *Repo) GetUnique(cursor string, limit int64) ([]string, error)

func (*Repo) UpdateVotes

func (r *Repo) UpdateVotes(list []ResolvedAddress) error

type ResolvedAddress

type ResolvedAddress struct {
	Address string
	Name    string
}

type Server

type Server struct {
	storagepb.UnimplementedVoteServer
	// contains filtered or unexported fields
}

func NewServer

func NewServer(sp *Service) *Server

func (*Server) GetDaosVotedIn added in v0.1.9

func (*Server) Prepare

func (*Server) Validate

func (*Server) Vote

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(
	r DataProvider,
	dp DaoProvider,
	p Publisher,
	er EnsResolver,
	dsClient votingpb.VotingClient,
) (*Service, error)

func (*Service) FetchAndStoreVote added in v0.1.4

func (s *Service) FetchAndStoreVote(ctx context.Context, id string)

func (*Service) GetByFilters

func (s *Service) GetByFilters(filters []Filter) (List, error)

func (*Service) GetDaosVotedIn added in v0.1.9

func (s *Service) GetDaosVotedIn(voter string) ([]string, error)

func (*Service) HandleResolvedAddresses

func (s *Service) HandleResolvedAddresses(list []ResolvedAddress) error

func (*Service) HandleVotes

func (s *Service) HandleVotes(ctx context.Context, votes []Vote) error

func (*Service) Prepare

func (s *Service) Prepare(ctx context.Context, req PrepareRequest) (PrepareResponse, error)

func (*Service) Validate

func (s *Service) Validate(ctx context.Context, req ValidateRequest) (ValidateResponse, error)

func (*Service) Vote

func (s *Service) Vote(ctx context.Context, req VoteRequest) (VoteResponse, error)

type Totals added in v0.1.6

type Totals struct {
	Votes int64
	Vp    float32
}

type ValidateRequest

type ValidateRequest struct {
	Proposal string
	Voter    string
}

type ValidateResponse

type ValidateResponse struct {
	OK bool

	VotingPower     float64
	ValidationError *ValidationError
}

type ValidationError

type ValidationError struct {
	Message string
	Code    uint32
}

type Vote

type Vote struct {
	ID            string `gorm:"primary_key"`
	CreatedAt     time.Time
	UpdatedAt     time.Time
	Ipfs          string
	OriginalDaoID string `gorm:"-"`
	DaoID         uuid.UUID
	ProposalID    string
	Voter         string
	EnsName       string
	Created       int
	Reason        string
	Choice        json.RawMessage
	App           string
	Vp            float64
	VpByStrategy  []float64 `gorm:"serializer:json"`
	VpState       string
}

type VoteRequest

type VoteRequest struct {
	ID  string
	Sig string
}

type VoteResponse

type VoteResponse struct {
	ID      string
	IPFS    string
	Relayer Relayer
}

type VoterFilter

type VoterFilter struct {
	Voter string
}

func (VoterFilter) Apply

func (f VoterFilter) Apply(db *gorm.DB) *gorm.DB

Jump to

Keyboard shortcuts

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