provider

package
v6.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPaginatorDone = errors.New("calling paginator that is in done state")
View Source
var ErrPaginatorNoIdForPage = errors.New("no id for requested page")

Functions

This section is empty.

Types

type AlchemyProvider

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

func NewAlchemyProvider

func NewAlchemyProvider(conn *rpc.Connection, chain string) (p *AlchemyProvider, err error)

func (*AlchemyProvider) Appearances

func (p *AlchemyProvider) Appearances(ctx context.Context, query *Query, errorChan chan error) (appChan chan types.Appearance)

func (*AlchemyProvider) Count

func (p *AlchemyProvider) Count(ctx context.Context, query *Query, errorChan chan error) (monitorChan chan types.Monitor)

func (*AlchemyProvider) NewPaginator

func (p *AlchemyProvider) NewPaginator(query *Query) Paginator

func (*AlchemyProvider) PrintProgress

func (p *AlchemyProvider) PrintProgress() bool

func (*AlchemyProvider) SetPrintProgress

func (p *AlchemyProvider) SetPrintProgress(print bool)

func (*AlchemyProvider) TransactionsByAddress

func (p *AlchemyProvider) TransactionsByAddress(ctx context.Context, query *Query, errorChan chan error) (txChan chan types.Slurp)

type AlchemyTx

type AlchemyTx struct {
	BlockNumber string `json:"blockNum"`
	Hash        string `json:"hash"`
	From        string `json:"from"`
	To          string `json:"to"`
}

func (*AlchemyTx) SimpleSlurp

func (tx *AlchemyTx) SimpleSlurp() (s types.Slurp, err error)

type CovalentProvider

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

func NewCovalentProvider

func NewCovalentProvider(conn *rpc.Connection, chain string) (p *CovalentProvider, err error)

func (*CovalentProvider) Appearances

func (p *CovalentProvider) Appearances(ctx context.Context, query *Query, errorChan chan error) (appChan chan types.Appearance)

func (*CovalentProvider) Count

func (p *CovalentProvider) Count(ctx context.Context, query *Query, errorChan chan error) (monitorChan chan types.Monitor)

func (*CovalentProvider) NewPaginator

func (p *CovalentProvider) NewPaginator(query *Query) Paginator

func (*CovalentProvider) PrintProgress

func (p *CovalentProvider) PrintProgress() bool

func (*CovalentProvider) SetPrintProgress

func (p *CovalentProvider) SetPrintProgress(print bool)

func (*CovalentProvider) TransactionsByAddress

func (p *CovalentProvider) TransactionsByAddress(ctx context.Context, query *Query, errorChan chan error) (txChan chan types.Slurp)

type EtherscanProvider

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

func NewEtherscanProvider

func NewEtherscanProvider(conn *rpc.Connection) (p *EtherscanProvider, err error)

func (*EtherscanProvider) Appearances

func (p *EtherscanProvider) Appearances(ctx context.Context, query *Query, errorChan chan error) (appChan chan types.Appearance)

func (*EtherscanProvider) Count

func (p *EtherscanProvider) Count(ctx context.Context, query *Query, errorChan chan error) (monitorChan chan types.Monitor)

func (*EtherscanProvider) NewPaginator

func (p *EtherscanProvider) NewPaginator(query *Query) Paginator

func (*EtherscanProvider) PrintProgress

func (p *EtherscanProvider) PrintProgress() bool

func (*EtherscanProvider) SetPrintProgress

func (p *EtherscanProvider) SetPrintProgress(print bool)

func (*EtherscanProvider) TransactionsByAddress

func (p *EtherscanProvider) TransactionsByAddress(ctx context.Context, query *Query, errorChan chan error) (txChan chan types.Slurp)

type KeyAppearance

type KeyAppearance struct {
	BlockNumber      string `json:"blockNumber"`
	TransactionIndex string `json:"transactionIndex"`
}

func (*KeyAppearance) Appearance

func (k *KeyAppearance) Appearance(address base.Address) (a types.Appearance, err error)

func (*KeyAppearance) Slurp

func (k *KeyAppearance) Slurp() (s types.Slurp, err error)

type KeyProvider

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

func NewKeyProvider

func NewKeyProvider(conn *rpc.Connection, chain string) (p *KeyProvider, err error)

func (*KeyProvider) Appearances

func (p *KeyProvider) Appearances(ctx context.Context, query *Query, errorChan chan error) (appChan chan types.Appearance)

func (*KeyProvider) Count

func (p *KeyProvider) Count(ctx context.Context, query *Query, errorChan chan error) (monitorChan chan types.Monitor)

func (*KeyProvider) NewPaginator

func (p *KeyProvider) NewPaginator(query *Query) Paginator

func (*KeyProvider) PrintProgress

func (p *KeyProvider) PrintProgress() bool

func (*KeyProvider) SetPrintProgress

func (p *KeyProvider) SetPrintProgress(print bool)

func (*KeyProvider) TransactionsByAddress

func (p *KeyProvider) TransactionsByAddress(ctx context.Context, query *Query, errorChan chan error) (txChan chan types.Slurp)

type Meta

type Meta struct {
	LastIndexedBlock base.Blknum `json:"lastIndexedBlock,omitempty"`
	Address          string      `json:"address,omitempty"`
	PreviousPageId   string      `json:"previousPageId"`
	NextPageId       string      `json:"nextPageId"`
}

type PageIdPaginator

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

PageIdPaginator can be used for providers that use keyset pagination: i.e. page tokens instead of numbers

func NewPageIdPaginator

func NewPageIdPaginator(page string, firstPage string, perPage int) *PageIdPaginator

func (*PageIdPaginator) Done

func (p *PageIdPaginator) Done() bool

func (*PageIdPaginator) NextPage

func (p *PageIdPaginator) NextPage() error

func (*PageIdPaginator) Page

func (p *PageIdPaginator) Page() any

func (*PageIdPaginator) PerPage

func (p *PageIdPaginator) PerPage() int

func (*PageIdPaginator) SetDone

func (p *PageIdPaginator) SetDone(done bool)

func (*PageIdPaginator) SetNextPage

func (p *PageIdPaginator) SetNextPage(newPage any) error

func (*PageIdPaginator) SetPage

func (p *PageIdPaginator) SetPage(newPage any) error

type PageNumberPaginator

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

PageNumberPaginator is a paginator for providers that use page numbers

func NewPageNumberPaginator

func NewPageNumberPaginator(page uint, firstPage uint, perPage int) *PageNumberPaginator

func (*PageNumberPaginator) Done

func (p *PageNumberPaginator) Done() bool

func (*PageNumberPaginator) NextPage

func (p *PageNumberPaginator) NextPage() error

func (*PageNumberPaginator) Page

func (p *PageNumberPaginator) Page() any

func (*PageNumberPaginator) PerPage

func (p *PageNumberPaginator) PerPage() int

func (*PageNumberPaginator) SetDone

func (p *PageNumberPaginator) SetDone(done bool)

func (*PageNumberPaginator) SetNextPage

func (p *PageNumberPaginator) SetNextPage(newPage any) error

func (*PageNumberPaginator) SetPage

func (p *PageNumberPaginator) SetPage(newPage any) error

type Paginator

type Paginator interface {
	// Page returns current page
	Page() any

	// PerPage returns number of items we request per page
	PerPage() int
	NextPage() error

	// Done returns true if we fetched all pages
	Done() bool
	SetPage(page any) error
	SetNextPage(page any) error
	SetDone(bool)
}

Paginator takes care of telling us either which page to fetch next or that we fetched all pages.

type Provider

type Provider interface {
	// TransactionsByAddress returns a channel that will be populated with transactions
	TransactionsByAddress(context.Context, *Query, chan error) chan types.Slurp

	// Appearances returns a channel that will be populated with appearances
	Appearances(context.Context, *Query, chan error) chan types.Appearance

	// Count returns a channel that will be populated with monitors, one for each address.
	// These monitors will only have NRecords set.
	Count(context.Context, *Query, chan error) chan types.Monitor

	// NewPaginator creates and returns Paginator that should be used for given service
	NewPaginator(*Query) Paginator

	// PrintProgress returns true if Provider should print progress bar
	PrintProgress() bool
	SetPrintProgress(bool)
}

Provider is an abstraction over different RPC services, like Etherscan or Key

type Query

type Query struct {
	Chain      string
	Addresses  []base.Address
	BlockRange []identifiers.Identifier
	// Etherscan calls them "modules"
	Resources   []string
	StartPage   uint
	StartPageId string
	PerPage     uint
}

func (*Query) Dup

func (q *Query) Dup() *Query

func (*Query) InRange

func (q *Query) InRange(bn base.Blknum) (bool, error)

type SlurpedPageItem

type SlurpedPageItem struct {
	Appearance  *types.Appearance
	Transaction *types.Slurp
}

SlurpedPageItem carries Transaction (if available) and Appearance (to give more info about Transaction, like Address). Either Transaction or Appearance comes from 3rd party RPC provider. For example, from Etherscan we get Transaction, but from Key - Appearance.

Jump to

Keyboard shortcuts

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