tokens

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: AGPL-3.0 Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEndpoint = errs.Class("tokens endpoint")

ErrEndpoint - tokens endpoint error class.

View Source
var ErrService = errs.Class("tokens service")

ErrService - tokens service error class.

Functions

This section is empty.

Types

type Config

type Config struct {
	Endpoints string `` /* 395-byte string literal not displayed */
}

Config holds tokens service configuration.

type Endpoint

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

Endpoint for querying ERC20 token information from ethereum chain.

architecture: Endpoint

func NewEndpoint

func NewEndpoint(log *zap.Logger, service *Service) *Endpoint

NewEndpoint creates new payments endpoint instance.

func (*Endpoint) AllPayments

func (endpoint *Endpoint) AllPayments(w http.ResponseWriter, r *http.Request)

AllPayments endpoint retrieves all ERC20 token payments claimed by one satellite starting from particular block for ethereum address.

func (*Endpoint) Payments

func (endpoint *Endpoint) Payments(w http.ResponseWriter, r *http.Request)

Payments endpoint retrieves all ERC20 token payments of one specific wallet, starting from particular block for ethereum address.

func (*Endpoint) Register

func (endpoint *Endpoint) Register(router *mux.Router)

Register registers endpoint methods on API server subroute.

type EthEndpoint added in v1.0.5

type EthEndpoint struct {
	Name     string `json:"name"`
	URL      string `json:"url"`
	Contract string `json:"contract"`
	ChainID  int64  `json:"chainId,string,omitempty"`
}

EthEndpoint contains the URL and contract address to access a chain API.

type LatestPayments

type LatestPayments struct {
	LatestBlocks []blockchain.Header
	Payments     []Payment
}

LatestPayments contains latest payments and latest chain block header.

type Payment

type Payment struct {
	ChainID     int64
	From        blockchain.Address
	To          blockchain.Address
	TokenValue  currency.Amount
	USDValue    currency.Amount
	BlockHash   blockchain.Hash
	BlockNumber int64
	Transaction blockchain.Hash
	LogIndex    int
	Timestamp   time.Time
}

Payment is on chain payment made for particular contract and deposit wallet.

type Service

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

Service for querying ERC20 token information from ethereum chain.

architecture: Service

func NewService

func NewService(
	log *zap.Logger,
	endpoints []EthEndpoint,
	cache *blockchain.HeadersCache,
	walletDB wallets.DB,
	tokenPrice *tokenprice.Service,
	batchSize int) *Service

NewService creates new token service instance.

func (*Service) AllPayments

func (service *Service) AllPayments(ctx context.Context, satelliteID string, from map[int64]int64) (_ LatestPayments, err error)

AllPayments returns all the payments across all configured endpoints starting from a particular block per chain associated with the current satellite.

func (*Service) GetChainIds added in v1.0.5

func (service *Service) GetChainIds(ctx context.Context) (chainIds map[int64]string, err error)

GetChainIds returns the chain ids of the currently configured endpoints.

func (*Service) Payments

func (service *Service) Payments(ctx context.Context, address blockchain.Address, from map[int64]int64) (_ LatestPayments, err error)

Payments retrieves all ERC20 token payments across all configured endpoints starting from a particular block per chain for ethereum address.

func (*Service) PingAll added in v1.0.5

func (service *Service) PingAll(ctx context.Context) (err error)

PingAll checks if configured blockchain services are available for use.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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