delegate

package
v0.4.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Consumer added in v0.3.2

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

func NewConsumer added in v0.3.2

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

func (*Consumer) Start added in v0.3.2

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

type DaoFilter added in v0.4.0

type DaoFilter struct {
	ID string
}

DaoFilter Who delegate voting power

func (DaoFilter) Apply added in v0.4.0

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

type DaoProvider

type DaoProvider interface {
	GetByID(id uuid.UUID) (*dao.Dao, error)
	GetIDByOriginalID(string) (uuid.UUID, error)
}

type DaoSearcher added in v0.4.0

type DaoSearcher interface {
	GetByFilters(filters []dao.Filter) (dao.DaoList, error)
}

type Delegate

type Delegate struct {
	Address               string
	ENSName               string
	DelegatorCount        int32
	PercentOfDelegators   float64
	VotingPower           float64
	PercentOfVotingPower  float64
	About                 string
	Statement             string
	VotesCount            int32
	CreatedProposalsCount int32
}

type DelegateFilter added in v0.4.0

type DelegateFilter struct {
	Address string
}

DelegateFilter Whom delegate voting power

func (DelegateFilter) Apply added in v0.4.0

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

type DelegationDetails added in v0.3.2

type DelegationDetails struct {
	Address string
	Weight  int
}

type Delegations added in v0.3.2

type Delegations struct {
	Details    []DelegationDetails
	Expiration int
}

type DelegatorFilter added in v0.4.0

type DelegatorFilter struct {
	Address string
}

DelegatorFilter Who delegate voting power

func (DelegatorFilter) Apply added in v0.4.0

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

type EnsResolver

type EnsResolver interface {
	GetByNames(names []string) ([]ensresolver.EnsName, error)
	GetByAddresses(addresses []string) ([]ensresolver.EnsName, error)
	AddRequests(list []string)
}

type Filter added in v0.4.0

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

type GetDelegateProfileRequest

type GetDelegateProfileRequest struct {
	DaoID   uuid.UUID
	Address string
}

type GetDelegateProfileResponse

type GetDelegateProfileResponse struct {
	Address              string
	VotingPower          float64
	IncomingPower        float64
	OutgoingPower        float64
	PercentOfVotingPower float64
	PercentOfDelegators  float64
	Delegates            []ProfileDelegateItem
	Expiration           *time.Time
}

type GetDelegatesRequest

type GetDelegatesRequest struct {
	DaoID         uuid.UUID
	QueryAccounts []string
	Sort          *string
	Limit         int
	Offset        int
}

type GetDelegatesResponse

type GetDelegatesResponse struct {
	Delegates []Delegate
	Total     int32
}

type History added in v0.3.2

type History struct {
	Action          string
	AddressFrom     string
	OriginalSpaceID string
	ChainID         string
	BlockNumber     int
	BlockTimestamp  int
	Delegations     Delegations `gorm:"-"`
	Payload         json.RawMessage
}

History storing delegate actions history

func (History) TableName added in v0.3.2

func (History) TableName() string

type OrderByAddressFromFilter added in v0.4.0

type OrderByAddressFromFilter struct {
}

func (OrderByAddressFromFilter) Apply added in v0.4.0

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

type OrderByAddressToFilter added in v0.4.0

type OrderByAddressToFilter struct {
}

func (OrderByAddressToFilter) Apply added in v0.4.0

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

type PageFilter added in v0.4.0

type PageFilter struct {
	Offset int
	Limit  int
}

func (PageFilter) Apply added in v0.4.0

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

type ProfileDelegateItem

type ProfileDelegateItem struct {
	Address        string
	ENSName        string
	Weight         float64
	DelegatedPower float64
}

type Proposal added in v0.3.2

type Proposal struct {
	ID            string
	OriginalDaoID string
	Author        string
}

type Publisher added in v0.3.2

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

type Repo added in v0.3.2

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

func NewRepo added in v0.3.2

func NewRepo(db *gorm.DB) *Repo

func (*Repo) CallInTx added in v0.3.2

func (r *Repo) CallInTx(cb func(tx *gorm.DB) error) error

func (*Repo) CreateHistory added in v0.3.2

func (r *Repo) CreateHistory(tx *gorm.DB, dd History) error

CreateHistory creates one history info

func (*Repo) CreateSummary added in v0.3.2

func (r *Repo) CreateSummary(tx *gorm.DB, sm Summary) error

CreateSummary creates one summary info

func (*Repo) FindDelegator added in v0.3.2

func (r *Repo) FindDelegator(daoID, author string) (*Summary, error)

func (*Repo) FindDelegatorsByVotes added in v0.3.2

func (r *Repo) FindDelegatorsByVotes(votes []Vote) ([]summaryByVote, error)

func (*Repo) GetByFilters added in v0.4.0

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

func (*Repo) GetCnt added in v0.4.0

func (r *Repo) GetCnt(filters ...Filter) (int64, error)

func (*Repo) GetSummaryBlockTimestamp added in v0.3.2

func (r *Repo) GetSummaryBlockTimestamp(tx *gorm.DB, addressFrom, daoID string) (int, error)

func (*Repo) GetTopDelegatesByAddress added in v0.4.0

func (r *Repo) GetTopDelegatesByAddress(address string, limit int) ([]Summary, error)

fixme: check it

func (*Repo) GetTopDelegatorsByAddress added in v0.4.0

func (r *Repo) GetTopDelegatorsByAddress(address string, limit int) ([]Summary, error)

fixme: check it

func (*Repo) RemoveSummary added in v0.3.2

func (r *Repo) RemoveSummary(tx *gorm.DB, addressFrom, daoID string) error

func (*Repo) UpdateSummaryExpiration added in v0.3.2

func (r *Repo) UpdateSummaryExpiration(tx *gorm.DB, addressFrom, daoID string, expiration, blockTimestamp int) error

type Server

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

func NewServer

func NewServer(sp *Service, ds DaoSearcher) *Server

func (*Server) GetDelegates

func (*Server) GetDelegatesByDao added in v0.4.0

func (*Server) GetDelegationSummary added in v0.4.0

func (*Server) GetDelegatorsByDao added in v0.4.0

func (*Server) GetTopDelegates added in v0.4.0

func (*Server) GetTopDelegators added in v0.4.0

type Service

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

func NewService

func NewService(repo *Repo, dc delegatepb.DelegateClient, daoProvider DaoProvider, ensResolver EnsResolver, ep Publisher) *Service

func (*Service) GetByFilters added in v0.4.0

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

func (*Service) GetCntByFilters added in v0.4.0

func (s *Service) GetCntByFilters(filters ...Filter) (int64, error)

func (*Service) GetDelegateProfile

func (s *Service) GetDelegateProfile(ctx context.Context, request GetDelegateProfileRequest) (GetDelegateProfileResponse, error)

func (*Service) GetDelegates

func (s *Service) GetDelegates(ctx context.Context, request GetDelegatesRequest) (*GetDelegatesResponse, error)

type Summary added in v0.3.2

type Summary struct {
	AddressFrom        string
	AddressTo          string
	DaoID              string
	Weight             int
	LastBlockTimestamp int
	ExpiresAt          int64
	CreatedAt          time.Time

	// virtual property
	MaxCnt int `gorm:"-"`
}

func (*Summary) Expired added in v0.3.2

func (s *Summary) Expired() bool

func (*Summary) SelfDelegation added in v0.3.2

func (s *Summary) SelfDelegation() bool

func (Summary) TableName added in v0.3.2

func (Summary) TableName() string

type Vote added in v0.3.2

type Vote struct {
	Voter         string
	OriginalDaoID string
	ProposalID    string
}

Jump to

Keyboard shortcuts

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