eth

package
v1.17.1 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EthereumNetwork = "ethereum"
	CornMainnet     = "corn-mainnet"
)

Variables

This section is empty.

Functions

func CalcSortIndex

func CalcSortIndex(blockNumber uint64, logIndex, txIndex uint) uint64

func CalcSortIndexFromLog

func CalcSortIndexFromLog(raw *types.Log) uint64

func FromDecimalForm

func FromDecimalForm(balance *big.Float, decimals int) *big.Int

func SortTransfers

func SortTransfers(transfers []ERC20Transfer)

func ToDecimalForm

func ToDecimalForm(balance *big.Int, decimals int) *big.Float

Types

type E20Cache

type E20Cache interface {
	Set(key string, val interface{}) error
	GetString(key string) (out string, err error)
	GetInt64(key string) (int64, error)
	GetUint64(key string) (uint64, error)
}

type ERC20

type ERC20 interface {
	TransferEvents(ctx context.Context, start, end uint64) ([]ERC20Transfer, error)
	BalanceOf(ctx context.Context, addr common.Address) (*big.Int, error)
	Decimals(ctx context.Context) (int, error)
	TotalSupply(ctx context.Context) (*big.Int, error)
}

func NewERC20

func NewERC20(log logrus.Ext1FieldLogger, metaDB E20Cache, ethClient *ethclient.Client, addr common.Address, network string) (ERC20, error)

type ERC20Transfer

type ERC20Transfer struct {
	From        string
	To          string
	Value       *big.Int
	TXHash      string
	LogIndex    uint
	Token       string
	BlockNumber uint64
	Timestamp   time.Time
	TXIndex     uint
}

func (ERC20Transfer) IsBurn

func (et ERC20Transfer) IsBurn() bool

func (ERC20Transfer) IsMint

func (et ERC20Transfer) IsMint() bool

func (ERC20Transfer) SQLFrom

func (et ERC20Transfer) SQLFrom() sql.NullString

func (ERC20Transfer) SQLTo

func (et ERC20Transfer) SQLTo() sql.NullString

func (ERC20Transfer) SortIndex

func (et ERC20Transfer) SortIndex() uint64

type EthClient

type EthClient interface {
	BlockNumber(ctx context.Context) (uint64, error)
	BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)
}

type Result

type Result[T any] struct {
	Err error
	Val T
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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