tokens

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildUniqueTokenAddressesFromEvents

func BuildUniqueTokenAddressesFromEvents(allEvents []*chain.TransferEvent) map[common.Address]*AddressMapValue

func DeleteTokenCache

func DeleteTokenCache(chainId string)

func GetGlobalTokensLoadedCount

func GetGlobalTokensLoadedCount() uint

func Init

func Init(chainId string)

Init is called to load just the master data for the desired chainId

func MergeTokensIntoGlobalTokenMap

func MergeTokensIntoGlobalTokenMap(newTokens map[string]TokenDataFromSource)

func PrintContents

func PrintContents(addressesMap map[common.Address]*AddressMapValue)

func RemoveUnknownTokens

func RemoveUnknownTokens(addressesMap map[common.Address]*AddressMapValue) map[common.Address]*AddressMapValue

RemoveUnknownTokens takes a map of addresses and removes those that are not known in the global tokenMap

func WriteGlobalTokenMapToCache

func WriteGlobalTokenMapToCache(chainId string)

WriteGlobalTokenMapToCache takes the whole of the tokenMap master data and dumps it all out to the local cache .csv file. If any troubles, it just does nothing.

func WriteTokenInfoToFile

func WriteTokenInfoToFile(filename string, tokenInfo [][]string)

Types

type AddressMapValue

type AddressMapValue struct {
	TransferType string
	Count        uint
}

type AddressValue

type AddressValue struct {
	Address      common.Address
	TransferType string
	Count        uint
}

func SortAddressesByCount

func SortAddressesByCount(uniqueAddresses map[common.Address]*AddressMapValue) []AddressValue

type TokenData

type TokenData struct {
	// Name is the token free text name
	Name string

	// Symbol is the short token symbol or ticker
	Symbol string

	// Decimals are how many decimal places the token has (ERC20 only, 0 for ERC721)
	Decimals int
}

TokenData is what is returned by GetTokenData calls to the tokens package

func GetTokenMasterData

func GetTokenMasterData(tokenAddr string) (tokenData TokenData, exists bool)

GetTokenMasterData returns master data for token, or correct defaults if no master data found. This function returns valid data regardless of the token type (ERC20, ERC721, ERC1155).

type TokenDataFromSource

type TokenDataFromSource struct {
	// ChainId uniquely identifies an EVM-compatible chain see https://chainlist.org/
	ChainId string

	// Name is the token free text name
	Name string

	// Symbol is the short token symbol or ticker
	Symbol string

	// Decimals are how many decimal places the token has (ERC20 only, 0 for ERC721)
	Decimals int

	// TokenAddress is the contract address of the token
	TokenAddress string
}

TokenDataFromSource is token master data from source: CSV file, cache, or chain

func GetTokenFromChain

func GetTokenFromChain(chainId string, client *ethclient.Client, tokenAddr common.Address, transferType string) (tokenData TokenDataFromSource)

Directories

Path Synopsis
contracts

Jump to

Keyboard shortcuts

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