history

package
v0.128.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2023 License: MPL-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventBalanceHistoryUpdateStarted           walletevent.EventType = "wallet-balance-history-update-started"
	EventBalanceHistoryUpdateFinished          walletevent.EventType = "wallet-balance-history-update-finished"
	EventBalanceHistoryUpdateFinishedWithError walletevent.EventType = "wallet-balance-history-update-finished-with-error"
)

EventBalanceHistoryUpdateStarted and EventBalanceHistoryUpdateDone are used to notify the UI that balance history is being updated

Variables

This section is empty.

Functions

This section is empty.

Types

type Balance

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

func NewBalance

func NewBalance(db *BalanceDB) *Balance

type BalanceDB

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

func NewBalanceDB

func NewBalanceDB(sqlDb *sql.DB) *BalanceDB

type DataPoint

type DataPoint struct {
	Value       *hexutil.Big `json:"value"`
	Timestamp   uint64       `json:"time"`
	BlockNumber *hexutil.Big `json:"blockNumber"`
}

type DataSource

type DataSource interface {
	HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
	BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)
	ChainID() uint64
	Currency() string
	TimeNow() int64
}

DataSource used as an abstraction to fetch required data from a specific blockchain

type Service

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

func NewService

func NewService(db *sql.DB, eventFeed *event.Feed, rpcClient *statusrpc.Client, tokenManager *token.Manager) *Service

func (*Service) GetBalanceHistory

func (s *Service) GetBalanceHistory(ctx context.Context, chainIDs []uint64, address common.Address, currency string, endTimestamp int64, timeInterval TimeInterval) ([]*DataPoint, error)

GetBalanceHistory returns token count balance TODO: fetch token to FIAT exchange rates and return FIAT balance

func (*Service) StartBalanceHistory

func (s *Service) StartBalanceHistory()

func (*Service) Stop

func (s *Service) Stop()

func (*Service) UpdateVisibleTokens

func (s *Service) UpdateVisibleTokens(symbols []string)

type TimeInterval

type TimeInterval int
const (
	BalanceHistory7Days TimeInterval = iota + 1
	BalanceHistory1Month
	BalanceHistory6Months
	BalanceHistory1Year
	BalanceHistoryAllTime
)

Specific time intervals for which balance history can be fetched

Jump to

Keyboard shortcuts

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