voting

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BasicValidationErr = &ValidationError{
	Message: "You do not meet the minimum balance requirement to vote on this proposal.",
	Code:    1002,
}
View Source
var EIP712Domain = []TypesDescription{
	{Name: "name", Type: "string"},
	{Name: "version", Type: "string"},
}
View Source
var NoVotingPowerErr = &ValidationError{
	Message: "Oops, it seems you don't have any voting power at block %s.",
	Code:    1000,
}
View Source
var NotValidErr = &ValidationError{
	Message: "Oops, you don't seem to be eligible to submit a proposal.",
	Code:    1001,
}
View Source
var PassportGatedValidationErr = &ValidationError{
	Message: "You need a Gitcoin Passport with score above %s and %s of the following stamps to vote on this proposal: %s.",
	Code:    1003,
}

PassportGatedValidationErr scoreThreshold, operator, stamps params

View Source
var VoteNumberTypes = []TypesDescription{
	{Name: "from", Type: "address"},
	{Name: "space", Type: "string"},
	{Name: "timestamp", Type: "uint64"},
	{Name: "proposal", Type: "string"},
	{Name: "choice", Type: "uint32"},
	{Name: "reason", Type: "string"},
	{Name: "app", Type: "string"},
	{Name: "metadata", Type: "string"},
}
View Source
var VoteNumberTypes2 = []TypesDescription{
	{Name: "from", Type: "address"},
	{Name: "space", Type: "string"},
	{Name: "timestamp", Type: "uint64"},
	{Name: "proposal", Type: "bytes32"},
	{Name: "choice", Type: "uint32"},
	{Name: "reason", Type: "string"},
	{Name: "app", Type: "string"},
	{Name: "metadata", Type: "string"},
}
View Source
var VoteNumbersTypes = []TypesDescription{
	{Name: "from", Type: "address"},
	{Name: "space", Type: "string"},
	{Name: "timestamp", Type: "uint64"},
	{Name: "proposal", Type: "string"},
	{Name: "choice", Type: "uint32[]"},
	{Name: "reason", Type: "string"},
	{Name: "app", Type: "string"},
	{Name: "metadata", Type: "string"},
}
View Source
var VoteNumbersTypes2 = []TypesDescription{
	{Name: "from", Type: "address"},
	{Name: "space", Type: "string"},
	{Name: "timestamp", Type: "uint64"},
	{Name: "proposal", Type: "bytes32"},
	{Name: "choice", Type: "uint32[]"},
	{Name: "reason", Type: "string"},
	{Name: "app", Type: "string"},
	{Name: "metadata", Type: "string"},
}
View Source
var VoteStringTypes = []TypesDescription{
	{Name: "from", Type: "address"},
	{Name: "space", Type: "string"},
	{Name: "timestamp", Type: "uint64"},
	{Name: "proposal", Type: "string"},
	{Name: "choice", Type: "string"},
	{Name: "reason", Type: "string"},
	{Name: "app", Type: "string"},
	{Name: "metadata", Type: "string"},
}
View Source
var VoteStringTypes2 = []TypesDescription{
	{Name: "from", Type: "address"},
	{Name: "space", Type: "string"},
	{Name: "timestamp", Type: "uint64"},
	{Name: "proposal", Type: "bytes32"},
	{Name: "choice", Type: "string"},
	{Name: "reason", Type: "string"},
	{Name: "app", Type: "string"},
	{Name: "metadata", Type: "string"},
}

Functions

This section is empty.

Types

type ActionService

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

func NewActionService

func NewActionService(snapshotSDK snapshotSDK, proposalGetter proposalGetter, typedSignDataBuilder *TypedSignDataBuilder, preparedVoteStorage preparedVoteStorage) *ActionService

func (*ActionService) GetVote added in v0.4.4

func (a *ActionService) GetVote(id string) (aggregator.VotePayload, error)

GetVote TODO think about DTO

func (*ActionService) Prepare

func (a *ActionService) Prepare(prepareParams PrepareParams) (db.PreparedVote, error)

func (*ActionService) Validate

func (a *ActionService) Validate(validateParams ValidateParams) (ValidateResult, error)

func (*ActionService) Vote

func (a *ActionService) Vote(voteParams VoteParams) (SuccessVote, error)

type Domain

type Domain struct {
	Name              string  `json:"name"`
	Version           string  `json:"version"`
	ChainId           *int    `json:"chainId,omitempty"`           // TODO do we need it?
	VerifyingContract *string `json:"verifyingContract,omitempty"` // TODO do we need it?
}

type GrpcServer

type GrpcServer struct {
	votingpb.UnimplementedVotingServer
	// contains filtered or unexported fields
}

func NewGrpcServer

func NewGrpcServer(actionService *ActionService) *GrpcServer

func (*GrpcServer) GetVote added in v0.4.4

func (*GrpcServer) Prepare

func (*GrpcServer) Validate

func (*GrpcServer) Vote

type PrepareParams

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

type ProposalType

type ProposalType string

type Relayer

type Relayer struct {
	Address string
	Receipt string
}

type SuccessVote

type SuccessVote struct {
	ID      string
	IPFS    string
	Relayer Relayer
}

type TypedData

type TypedData struct {
	Domain      Domain    `json:"domain"`
	PrimaryType string    `json:"primaryType,omitempty"`
	VoteTypes   VoteTypes `json:"types"`
	Vote        Vote      `json:"message"`
}

func (TypedData) ForSnapshot

func (t TypedData) ForSnapshot() TypedData

type TypedSignDataBuilder

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

func NewTypedSignDataBuilder

func NewTypedSignDataBuilder(cfg config.Snapshot) *TypedSignDataBuilder

func (*TypedSignDataBuilder) Build

func (t *TypedSignDataBuilder) Build(checksumVoter string, reason *string, choice json.RawMessage, pFragment *client.ProposalFragment) (TypedData, error)

type TypesDescription

type TypesDescription struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

type ValidateParams

type ValidateParams struct {
	Voter    string
	Proposal string
}

type ValidateResult

type ValidateResult struct {
	OK          bool
	VotingPower float64

	ValidationError *ValidationError
}

type ValidationError

type ValidationError struct {
	Message string
	Code    uint32
}

func (ValidationError) WithVars

func (v ValidationError) WithVars(vars ...any) *ValidationError

type Vote

type Vote struct {
	From      string          `json:"from"`
	Space     string          `json:"space"`
	Timestamp int64           `json:"timestamp"`
	Proposal  string          `json:"proposal"`
	Choice    json.RawMessage `json:"choice"`
	Reason    string          `json:"reason"`
	App       string          `json:"app"`
	Metadata  string          `json:"metadata"`
}

type VoteParams

type VoteParams struct {
	ID  uuid.UUID
	Sig string
}

type VoteTypes

type VoteTypes struct {
	EIP712Domain []TypesDescription `json:"EIP712Domain,omitempty"`
	Vote         []TypesDescription `json:"Vote"`
}

Jump to

Keyboard shortcuts

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