token

package
v0.0.0-...-4017d6a Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ETHToken = &Token{
	Address:  common.HexToAddress("0x0"),
	Symbol:   "ETH",
	Decimals: 18,
}

To unify transfers processing we mimic ETH to be a token. Address is set to 0 and not used for this "token".

Functions

This section is empty.

Types

type Token

type Token struct {
	Address  common.Address
	Symbol   string
	Decimals uint8
}

func (Token) RenderValue

func (t Token) RenderValue(value *big.Int) string

type TokensDB

type TokensDB interface {
	AddToken(token *Token) error
	GetToken(addr common.Address) (*Token, error)
	Close()
}

func NewTokensDB

func NewTokensDB(dbPath string) TokensDB

type TokensManager

type TokensManager interface {
	// Returns token for the given contract address or error.
	// For unknown tokens this fetches token details from the contract.
	// NOT THREAD SAFE
	GetToken(ctx context.Context, contractAddress common.Address) (*Token, error)
	// Returns token's balance for the given address or error.
	FetchBalance(ctx context.Context, token *Token, addr common.Address) (*big.Int, error)
}

func NewTokensManager

func NewTokensManager(client *ethclient.Client, tdb TokensDB) TokensManager

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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