addressbook

package
v1.13.13 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2025 License: MIT Imports: 25 Imported by: 4

Documentation

Index

Constants

View Source
const (
	KnownAccountWeight = 5000
	BoostForFullMatch  = 100
	BoostForVerified   = 50
)

AttachedAccountType represents the type of the attached account

Variables

View Source
var NormalizeReg = regexp.MustCompile("[^\\p{L}\\p{N}]")

NormalizeReg is a regular expression to remove all non-letter and non-number characters

Functions

func FindIndexes added in v1.3.0

func FindIndexes(sortedList []AttachedAccount, prefix string) (int, int)

FindIndexes finds the start and end indexes of the prefix in the sorted list

func GenerateSlugVariants added in v1.3.0

func GenerateSlugVariants(name string) []string

GenerateSlugVariants generates name variants by rotating the words

func Refresher added in v1.3.0

func Refresher(name string, interval, errorInterval time.Duration, logger *zap.Logger, f func() error)

Refresher periodically calls the provided function at the specified interval

Types

type AttachedAccount

type AttachedAccount struct {
	Name       string              `json:"name"`
	Preview    string              `json:"preview"`
	Wallet     ton.AccountID       `json:"wallet"`
	Slug       string              `json:"-"`
	Symbol     string              `json:"-"`
	Type       AttachedAccountType `json:"-"`
	Weight     int64               `json:"-"`
	Popular    int64               `json:"-"`
	Trust      core.TrustType      `json:"-"`
	Normalized string              `json:"-"`
}

AttachedAccount represents domains, nft collections for quick search by name are presented

func ConvertAttachedAccount added in v1.3.0

func ConvertAttachedAccount(name, slug, image string, account ton.AccountID, weight int, trust core.TrustType, accountType AttachedAccountType) (AttachedAccount, error)

ConvertAttachedAccount converts a known account to an attached account

type AttachedAccountType added in v1.3.0

type AttachedAccountType string

AttachedAccountType defines different types of accounts (e.g., manual, NFT)

const (
	ManualAccountType        AttachedAccountType = "manual"
	NftCollectionAccountType AttachedAccountType = "collection"
	NftItemAccountType       AttachedAccountType = "nft"
	TonDomainAccountType     AttachedAccountType = "ton_domain"
	TgDomainAccountType      AttachedAccountType = "tg_domain"
	JettonSymbolAccountType  AttachedAccountType = "jetton_symbol"
	JettonNameAccountType    AttachedAccountType = "jetton_name"
)

type Book

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

Book holds information about known accounts, jettons, NFT collections manually crafted by the tonkeeper team and the community

func NewAddressBook

func NewAddressBook(logger *zap.Logger, addressPath, jettonPath, collectionPath string, storage accountsStatesSource, opts ...Option) *Book

NewAddressBook initializes a Book and starts background refreshers tasks

func (*Book) GetAddressInfoByAddress

func (b *Book) GetAddressInfoByAddress(a tongo.AccountID) (KnownAddress, bool)

GetAddressInfoByAddress fetches address info if available

func (*Book) GetCollectionInfoByAddress

func (b *Book) GetCollectionInfoByAddress(a tongo.AccountID) (KnownCollection, bool)

GetCollectionInfoByAddress retrieves collection info for a specific address

func (*Book) GetJettonInfoByAddress

func (b *Book) GetJettonInfoByAddress(a tongo.AccountID) (KnownJetton, bool)

GetJettonInfoByAddress fetches jetton info for a specific address

func (*Book) GetKnownCollections added in v1.1.0

func (b *Book) GetKnownCollections() map[tongo.AccountID]KnownCollection

GetKnownCollections returns all known collections

func (*Book) GetKnownJettons

func (b *Book) GetKnownJettons() map[tongo.AccountID]KnownJetton

GetKnownJettons returns all known jettons

func (*Book) GetTFPoolInfo

func (b *Book) GetTFPoolInfo(a tongo.AccountID) (TFPoolInfo, bool)

GetTFPoolInfo retrieves token pool info for an account

func (*Book) IsWallet added in v1.2.0

func (b *Book) IsWallet(addr tongo.AccountID) (bool, error)

IsWallet checks if the address is a wallet

func (*Book) SearchAttachedAccountsByPrefix

func (b *Book) SearchAttachedAccountsByPrefix(prefix string) []AttachedAccount

SearchAttachedAccountsByPrefix searches for accounts by prefix

func (*Book) TFPools

func (b *Book) TFPools() []tongo.AccountID

TFPools returns a list of all token pools

type KnownAddress

type KnownAddress struct {
	IsScam      bool   `json:"is_scam,omitempty"`
	RequireMemo bool   `json:"require_memo,omitempty"`
	Name        string `json:"name"`
	Address     string `json:"address"`
	Image       string `json:"image,omitempty"`
}

KnownAddress represents additional manually crafted information about a particular account in the blockchain

type KnownCollection

type KnownCollection struct {
	Address   string `json:"address"`
	Approvers []oas.NftApprovedByItem
}

KnownCollection represents additional manually crafted information about a particular NFT collection in the blockchain

type KnownJetton

type KnownJetton struct {
	Name          string          `json:"name"`
	Verification  core.TrustType  `json:"verification"`
	Description   string          `json:"description"`
	Image         string          `json:"image"`
	Address       string          `json:"address"`
	Symbol        string          `json:"symbol"`
	MaxSupply     decimal.Decimal `json:"max_supply"`
	Websites      []string        `json:"websites,omitempty"`
	Social        []string        `json:"social,omitempty"`
	Coinmarketcap string          `json:"coinmarketcap,omitempty"`
	Coingecko     string          `json:"coingecko,omitempty"`
}

KnownJetton represents additional manually crafted information about a particular jetton in the blockchain

type Option

type Option func(o *Options)

func WithAdditionalAddressesSource

func WithAdditionalAddressesSource(a addresser) Option

type Options

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

type TFPoolInfo

type TFPoolInfo struct {
	Name      string `json:"name"`
	GroupName string `json:"groupName"`
	Address   string `json:"address"`
}

TFPoolInfo holds information about a token pool

Jump to

Keyboard shortcuts

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