token

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2024 License: MPL-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventCommunityTokenReceived walletevent.EventType = "wallet-community-token-received"
)

Variables

This section is empty.

Functions

func GetTokenPegSymbol added in v0.131.11

func GetTokenPegSymbol(symbol string) string

Types

type ChainBalance added in v0.180.31

type ChainBalance struct {
	RawBalance     string         `json:"rawBalance"`
	Balance        *big.Float     `json:"balance"`
	Balance1DayAgo string         `json:"balance1DayAgo"`
	Address        common.Address `json:"address"`
	ChainID        uint64         `json:"chainId"`
	HasError       bool           `json:"hasError"`
}

type DefaultStore added in v0.138.8

type DefaultStore struct {
	TokenListID []*Token
}

func (*DefaultStore) GetName added in v0.171.21

func (s *DefaultStore) GetName() string

func (*DefaultStore) GetSource added in v0.171.21

func (s *DefaultStore) GetSource() string

func (*DefaultStore) GetTokens added in v0.138.8

func (s *DefaultStore) GetTokens() []*Token

func (*DefaultStore) GetUpdatedAt added in v0.171.21

func (s *DefaultStore) GetUpdatedAt() int64

func (*DefaultStore) GetVersion added in v0.171.21

func (s *DefaultStore) GetVersion() string

type List added in v0.171.21

type List struct {
	Name    string   `json:"name"`
	Tokens  []*Token `json:"tokens"`
	Source  string   `json:"source"`
	Version string   `json:"version"`
}

type ListWrapper added in v0.173.0

type ListWrapper struct {
	UpdatedAt int64   `json:"updatedAt"`
	Data      []*List `json:"data"`
}

type Manager

type Manager struct {
	balancefetcher.BalanceFetcher

	RPCClient     rpc.ClientInterface
	ContractMaker *contracts.ContractMaker
	// contains filtered or unexported fields
}

Manager is used for accessing token store. It changes the token store based on overridden tokens

func NewTokenManager

func NewTokenManager(
	db *sql.DB,
	RPCClient rpc.ClientInterface,
	communityManager *community.Manager,
	networkManager network.ManagerInterface,
	appDB *sql.DB,
	mediaServer *server.MediaServer,
	walletFeed *event.Feed,
	accountFeed *event.Feed,
	accountsDB *accounts.Database,
	tokenBalancesStorage TokenBalancesStorage,
) *Manager

func (*Manager) DeleteCustom

func (tm *Manager) DeleteCustom(chainID uint64, address common.Address) error

func (*Manager) DiscoverToken

func (tm *Manager) DiscoverToken(ctx context.Context, chainID uint64, address common.Address) (*Token, error)

func (*Manager) FindOrCreateTokenByAddress added in v0.166.7

func (tm *Manager) FindOrCreateTokenByAddress(ctx context.Context, chainID uint64, address common.Address) *Token

func (*Manager) FindSNT

func (tm *Manager) FindSNT(chainID uint64) *Token

func (*Manager) FindToken

func (tm *Manager) FindToken(network *params.Network, tokenSymbol string) *Token

func (*Manager) FindTokenByAddress added in v0.156.1

func (tm *Manager) FindTokenByAddress(chainID uint64, address common.Address) *Token

func (*Manager) GetAllTokens added in v0.115.5

func (tm *Manager) GetAllTokens() ([]*Token, error)

func (*Manager) GetCachedBalancesByChain added in v0.180.31

func (tm *Manager) GetCachedBalancesByChain(accounts, tokenAddresses []common.Address, chainIDs []uint64) (map[uint64]map[common.Address]map[common.Address]*hexutil.Big, error)

func (*Manager) GetCustoms

func (tm *Manager) GetCustoms(onlyCommunityCustoms bool) ([]*Token, error)

func (*Manager) GetList added in v0.171.21

func (tm *Manager) GetList() *ListWrapper

func (*Manager) GetPreviouslyOwnedTokens added in v0.178.0

func (tm *Manager) GetPreviouslyOwnedTokens() (map[common.Address][]Token, error)

func (*Manager) GetToken added in v0.159.2

func (tm *Manager) GetToken(chainID uint64, tokenSymbol string) *Token

GetToken returns token by chainID and tokenSymbol. Use ToToken for native token

func (*Manager) GetTokenHistoricalBalance added in v0.176.7

func (tm *Manager) GetTokenHistoricalBalance(account common.Address, chainID uint64, symbol string, timestamp int64) (*big.Int, error)

func (*Manager) GetTokens

func (tm *Manager) GetTokens(chainID uint64) ([]*Token, error)

func (*Manager) GetTokensByChainIDs added in v0.154.0

func (tm *Manager) GetTokensByChainIDs(chainIDs []uint64) ([]*Token, error)

func (*Manager) LookupToken added in v0.159.2

func (tm *Manager) LookupToken(chainID *uint64, tokenSymbol string) (token *Token, isNative bool)

func (*Manager) LookupTokenIdentity added in v0.159.2

func (tm *Manager) LookupTokenIdentity(chainID uint64, address common.Address, native bool) *Token

func (*Manager) MarkAsPreviouslyOwnedToken added in v0.171.39

func (tm *Manager) MarkAsPreviouslyOwnedToken(token *Token, owner common.Address) (bool, error)

func (*Manager) SetTokens added in v0.167.5

func (tm *Manager) SetTokens(tokens []*Token)

func (*Manager) SignalCommunityTokenReceived added in v0.172.1

func (tm *Manager) SignalCommunityTokenReceived(address common.Address, txHash common.Hash, value *big.Int, t *Token, isFirst bool)

func (*Manager) Start added in v0.178.0

func (tm *Manager) Start()

func (*Manager) Stop added in v0.178.0

func (tm *Manager) Stop()

func (*Manager) ToToken added in v0.115.5

func (tm *Manager) ToToken(network *params.Network) *Token

func (*Manager) UpsertCustom

func (tm *Manager) UpsertCustom(token Token) error

type ManagerInterface added in v0.166.7

type ManagerInterface interface {
	balancefetcher.BalanceFetcher
	LookupTokenIdentity(chainID uint64, address common.Address, native bool) *Token
	LookupToken(chainID *uint64, tokenSymbol string) (token *Token, isNative bool)
	GetTokenHistoricalBalance(account common.Address, chainID uint64, symbol string, timestamp int64) (*big.Int, error)
	GetTokensByChainIDs(chainIDs []uint64) ([]*Token, error)
}

type Persistence added in v0.180.31

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

func NewPersistence added in v0.180.31

func NewPersistence(db *sql.DB) *Persistence

func (*Persistence) GetTokens added in v0.180.31

func (p *Persistence) GetTokens() (map[common.Address][]StorageToken, error)

func (*Persistence) SaveTokens added in v0.180.31

func (p *Persistence) SaveTokens(tokens map[common.Address][]StorageToken) (err error)

type ReceivedToken added in v0.172.1

type ReceivedToken struct {
	Token
	Amount  float64     `json:"amount"`
	TxHash  common.Hash `json:"txHash"`
	IsFirst bool        `json:"isFirst"`
}

type StorageToken added in v0.180.31

type StorageToken struct {
	Token
	BalancesPerChain        map[uint64]ChainBalance      `json:"balancesPerChain"`
	Description             string                       `json:"description"`
	AssetWebsiteURL         string                       `json:"assetWebsiteUrl"`
	BuiltOn                 string                       `json:"builtOn"`
	MarketValuesPerCurrency map[string]TokenMarketValues `json:"marketValuesPerCurrency"`
}

type Token

type Token struct {
	Address common.Address `json:"address"`
	Name    string         `json:"name"`
	Symbol  string         `json:"symbol"`
	// Decimals defines how divisible the token is. For example, 0 would be
	// indivisible, whereas 18 would allow very small amounts of the token
	// to be traded.
	Decimals uint   `json:"decimals"`
	ChainID  uint64 `json:"chainId"`
	// PegSymbol indicates that the token is pegged to some fiat currency, using the
	// ISO 4217 alphabetic code. For example, an empty string means it is not
	// pegged, while "USD" means it's pegged to the United States Dollar.
	PegSymbol string `json:"pegSymbol"`
	Image     string `json:"image,omitempty"`

	CommunityData *community.Data `json:"community_data,omitempty"`
	Verified      bool            `json:"verified"`
	TokenListID   string          `json:"tokenListId"`
}

func (*Token) IsNative

func (t *Token) IsNative() bool

type TokenBalancesStorage added in v0.180.31

type TokenBalancesStorage interface {
	SaveTokens(tokens map[common.Address][]StorageToken) error
	GetTokens() (map[common.Address][]StorageToken, error)
}

type TokenMarketValues added in v0.180.31

type TokenMarketValues struct {
	MarketCap       float64 `json:"marketCap"`
	HighDay         float64 `json:"highDay"`
	LowDay          float64 `json:"lowDay"`
	ChangePctHour   float64 `json:"changePctHour"`
	ChangePctDay    float64 `json:"changePctDay"`
	ChangePct24hour float64 `json:"changePct24hour"`
	Change24hour    float64 `json:"change24hour"`
	Price           float64 `json:"price"`
	HasError        bool    `json:"hasError"`
}

Directories

Path Synopsis
mock
balance_persistence
Package mock_balance_persistence is a generated GoMock package.
Package mock_balance_persistence is a generated GoMock package.
token
Package mock_token is a generated GoMock package.
Package mock_token is a generated GoMock package.

Jump to

Keyboard shortcuts

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