tlb

package
v0.0.0-...-bcde84c Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccountStatusActive   = "ACTIVE"
	AccountStatusUninit   = "UNINIT"
	AccountStatusFrozen   = "FROZEN"
	AccountStatusNonExist = "NON_EXIST"
)

Variables

View Source
var ErrStackEmpty = errors.New("stack is empty")

Functions

func ConvertShardIdentToShard

func ConvertShardIdentToShard(si ShardIdent) (workchain int32, shard uint64)

func LoadFromCell

func LoadFromCell(v any, loader *cell.Slice) error

LoadFromCell automatically parses cell based on struct tags ## N - means integer with N bits, if size <= 64 it loads to uint of any size, if > 64 it loads to *big.Int ^ - loads ref and calls recursively, if field type is *cell.Cell, it loads without parsing . - calls recursively to continue load from current loader (inner struct) [^]dict N [-> array [^]] - loads dictionary with key size N, transformation '->' can be applied to convert dict to array, example: 'dict 256 -> array ^' will give you array of deserialized refs (^) of values bits N - loads bit slice N len to []byte bool - loads 1 bit boolean addr - loads ton address maybe - reads 1 bit, and loads rest if its 1, can be used in combination with others only either X Y - reads 1 bit, if its 0 - loads X, if 1 - loads Y Some tags can be combined, for example "dict 256", "maybe ^" Magic can be used to load first bits and check struct type, in tag can be specified magic number itself, in [#]HEX or [$]BIN format Example: _ Magic `tlb:"#deadbeef" _ Magic `tlb:"$1101"

func MethodNameHash

func MethodNameHash(name string) uint64

func ToCell

func ToCell(v any) (*cell.Cell, error)

Types

type Account

type Account struct {
	IsActive   bool
	State      *AccountState
	Data       *cell.Cell
	Code       *cell.Cell
	LastTxLT   uint64
	LastTxHash []byte
}

func (*Account) HasGetMethod

func (a *Account) HasGetMethod(name string) bool

type AccountBlock

type AccountBlock struct {
	Addr         []byte           `tlb:"bits 256"`
	Transactions *cell.Dictionary `tlb:"dict 64"`
	StateUpdate  *cell.Cell       `tlb:"^"`
	// contains filtered or unexported fields
}

type AccountState

type AccountState struct {
	IsValid     bool
	Address     *address.Address
	StorageInfo StorageInfo

	AccountStorage
}

func (*AccountState) LoadFromCell

func (a *AccountState) LoadFromCell(loader *cell.Slice) error

type AccountStatus

type AccountStatus string

func (*AccountStatus) LoadFromCell

func (g *AccountStatus) LoadFromCell(loader *cell.Slice) error

func (AccountStatus) ToCell

func (g AccountStatus) ToCell() (*cell.Cell, error)

type AccountStorage

type AccountStorage struct {
	Status            AccountStatus
	LastTransactionLT uint64
	Balance           Coins

	// has value when active
	StateInit *StateInit
	// has value when frozen
	StateHash []byte
}

func (*AccountStorage) LoadFromCell

func (s *AccountStorage) LoadFromCell(loader *cell.Slice) error

type AllShardsInfo

type AllShardsInfo struct {
	ShardHashes *cell.Dictionary `tlb:"dict 32"`
}

type AnyMessage

type AnyMessage interface {
	Payload() *cell.Cell
	SenderAddr() *address.Address
	DestAddr() *address.Address
}

type BinTree

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

func (*BinTree) All

func (b *BinTree) All() []*cell.HashmapKV

func (*BinTree) Get

func (b *BinTree) Get(key *cell.Cell) *cell.Cell

func (*BinTree) LoadFromCell

func (b *BinTree) LoadFromCell(loader *cell.Slice) error

type BlkPrevInfo

type BlkPrevInfo struct {
	Prev1 ExtBlkRef
	Prev2 *ExtBlkRef
}

type Block

type Block struct {
	GlobalID    int32       `tlb:"## 32"`
	BlockInfo   BlockHeader `tlb:"^"`
	ValueFlow   *cell.Cell  `tlb:"^"`
	StateUpdate StateUpdate `tlb:"^"`
	Extra       *BlockExtra `tlb:"^"`
	// contains filtered or unexported fields
}

type BlockExtra

type BlockExtra struct {
	InMsgDesc          *cell.Cell    `tlb:"^"`
	OutMsgDesc         *cell.Cell    `tlb:"^"`
	ShardAccountBlocks *cell.Cell    `tlb:"^"`
	RandSeed           []byte        `tlb:"bits 256"`
	CreatedBy          []byte        `tlb:"bits 256"`
	Custom             *McBlockExtra `tlb:"maybe ^"`
	// contains filtered or unexported fields
}

type BlockHeader

type BlockHeader struct {
	GenSoftware *GlobalVersion
	MasterRef   *ExtBlkRef
	PrevRef     BlkPrevInfo
	PrevVertRef *BlkPrevInfo
	// contains filtered or unexported fields
}

func (*BlockHeader) GetParentBlocks

func (h *BlockHeader) GetParentBlocks() ([]*BlockInfo, error)

func (*BlockHeader) LoadFromCell

func (h *BlockHeader) LoadFromCell(loader *cell.Slice) error

type BlockInfo deprecated

type BlockInfo struct {
	Workchain int32  `tl:"int"`
	Shard     int64  `tl:"long"`
	SeqNo     uint32 `tl:"int"`
	RootHash  []byte `tl:"int256"`
	FileHash  []byte `tl:"int256"`
}

Deprecated: use ton.BlockIDExt

type Coins

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

func FromNanoTON

func FromNanoTON(val *big.Int) Coins

func FromNanoTONU

func FromNanoTONU(val uint64) Coins

func FromTON

func FromTON(val string) (Coins, error)

func MustFromTON

func MustFromTON(val string) Coins

func (*Coins) LoadFromCell

func (g *Coins) LoadFromCell(loader *cell.Slice) error

func (Coins) MarshalJSON

func (g Coins) MarshalJSON() ([]byte, error)

func (Coins) NanoTON

func (g Coins) NanoTON() *big.Int

func (Coins) String

func (g Coins) String() string

func (Coins) TON

func (g Coins) TON() string

func (Coins) ToCell

func (g Coins) ToCell() (*cell.Cell, error)

type ConfigParams

type ConfigParams struct {
	ConfigAddr *address.Address
	Config     *cell.Dictionary
}

func (*ConfigParams) LoadFromCell

func (p *ConfigParams) LoadFromCell(loader *cell.Slice) error

type CurrencyCollection

type CurrencyCollection struct {
	Coins           Coins            `tlb:"."`
	ExtraCurrencies *cell.Dictionary `tlb:"dict 32"`
}

type DepthBalanceInfo

type DepthBalanceInfo struct {
	Depth      uint32             `tlb:"## 5"`
	Currencies CurrencyCollection `tlb:"."`
}

type ExtBlkRef

type ExtBlkRef struct {
	EndLt    uint64 `tlb:"## 64"`
	SeqNo    uint32 `tlb:"## 32"`
	RootHash []byte `tlb:"bits 256"`
	FileHash []byte `tlb:"bits 256"`
}

type ExternalMessage

type ExternalMessage struct {
	SrcAddr   *address.Address `tlb:"addr"`
	DstAddr   *address.Address `tlb:"addr"`
	ImportFee Coins            `tlb:"."`

	StateInit *StateInit `tlb:"maybe either . ^"`
	Body      *cell.Cell `tlb:"either . ^"`
	// contains filtered or unexported fields
}

func (*ExternalMessage) DestAddr

func (m *ExternalMessage) DestAddr() *address.Address

func (*ExternalMessage) Payload

func (m *ExternalMessage) Payload() *cell.Cell

func (*ExternalMessage) SenderAddr

func (m *ExternalMessage) SenderAddr() *address.Address

func (*ExternalMessage) ToCell

func (m *ExternalMessage) ToCell() (*cell.Cell, error)

type ExternalMessageOut

type ExternalMessageOut struct {
	SrcAddr   *address.Address `tlb:"addr"`
	DstAddr   *address.Address `tlb:"addr"`
	CreatedLT uint64           `tlb:"## 64"`
	CreatedAt uint32           `tlb:"## 32"`

	StateInit *StateInit `tlb:"maybe either . ^"`
	Body      *cell.Cell `tlb:"either . ^"`
	// contains filtered or unexported fields
}

func (*ExternalMessageOut) DestAddr

func (m *ExternalMessageOut) DestAddr() *address.Address

func (*ExternalMessageOut) Payload

func (m *ExternalMessageOut) Payload() *cell.Cell

func (*ExternalMessageOut) SenderAddr

func (m *ExternalMessageOut) SenderAddr() *address.Address

type GlobalVersion

type GlobalVersion struct {
	Version      uint32 `tlb:"## 32"`
	Capabilities uint64 `tlb:"## 64"`
	// contains filtered or unexported fields
}

type InternalMessage

type InternalMessage struct {
	IHRDisabled     bool             `tlb:"bool"`
	Bounce          bool             `tlb:"bool"`
	Bounced         bool             `tlb:"bool"`
	SrcAddr         *address.Address `tlb:"addr"`
	DstAddr         *address.Address `tlb:"addr"`
	Amount          Coins            `tlb:"."`
	ExtraCurrencies *cell.Dictionary `tlb:"dict 32"`
	IHRFee          Coins            `tlb:"."`
	FwdFee          Coins            `tlb:"."`
	CreatedLT       uint64           `tlb:"## 64"`
	CreatedAt       uint32           `tlb:"## 32"`

	StateInit *StateInit `tlb:"maybe either . ^"`
	Body      *cell.Cell `tlb:"either . ^"`
	// contains filtered or unexported fields
}

func (*InternalMessage) Comment

func (m *InternalMessage) Comment() string

func (*InternalMessage) DestAddr

func (m *InternalMessage) DestAddr() *address.Address

func (*InternalMessage) Dump

func (m *InternalMessage) Dump() string

func (*InternalMessage) Payload

func (m *InternalMessage) Payload() *cell.Cell

func (*InternalMessage) SenderAddr

func (m *InternalMessage) SenderAddr() *address.Address

func (*InternalMessage) ToCell

func (m *InternalMessage) ToCell() (*cell.Cell, error)

type Magic

type Magic struct{}

type McBlockExtra

type McBlockExtra struct {
	KeyBlock    uint8            `tlb:"## 1"`
	ShardHashes *cell.Dictionary `tlb:"dict 32"`
	ShardFees   *cell.Dictionary `tlb:"dict 96"`
	// contains filtered or unexported fields
}

type McStateExtra

type McStateExtra struct {
	ShardHashes   *cell.Dictionary   `tlb:"dict 32"`
	ConfigParams  ConfigParams       `tlb:"."`
	Info          *cell.Cell         `tlb:"^"`
	GlobalBalance CurrencyCollection `tlb:"."`
	// contains filtered or unexported fields
}

type Message

type Message struct {
	MsgType MsgType
	Msg     AnyMessage
}

func (*Message) AsExternalIn

func (m *Message) AsExternalIn() *ExternalMessage

func (*Message) AsExternalOut

func (m *Message) AsExternalOut() *ExternalMessageOut

func (*Message) AsInternal

func (m *Message) AsInternal() *InternalMessage

func (*Message) LoadFromCell

func (m *Message) LoadFromCell(loader *cell.Slice) error

type MsgType

type MsgType string
const (
	MsgTypeInternal    MsgType = "INTERNAL"
	MsgTypeExternalIn  MsgType = "EXTERNAL_IN"
	MsgTypeExternalOut MsgType = "EXTERNAL_OUT"
)

type ShardAccountBlocks

type ShardAccountBlocks struct {
	Accounts *cell.Dictionary `tlb:"dict 256"`
}

type ShardDesc

type ShardDesc struct {
	SeqNo              uint32 `tlb:"## 32"`
	RegMcSeqno         uint32 `tlb:"## 32"`
	StartLT            uint64 `tlb:"## 64"`
	EndLT              uint64 `tlb:"## 64"`
	RootHash           []byte `tlb:"bits 256"`
	FileHash           []byte `tlb:"bits 256"`
	BeforeSplit        bool   `tlb:"bool"`
	BeforeMerge        bool   `tlb:"bool"`
	WantSplit          bool   `tlb:"bool"`
	WantMerge          bool   `tlb:"bool"`
	NXCCUpdated        bool   `tlb:"bool"`
	Flags              uint8  `tlb:"## 3"`
	NextCatchainSeqNo  uint32 `tlb:"## 32"`
	NextValidatorShard int64  `tlb:"## 64"`
	MinRefMcSeqNo      uint32 `tlb:"## 32"`
	GenUTime           uint32 `tlb:"## 32"`
	// contains filtered or unexported fields
}

type ShardIdent

type ShardIdent struct {
	PrefixBits  int8   `tlb:"## 6"` // #<= 60
	WorkchainID int32  `tlb:"## 32"`
	ShardPrefix uint64 `tlb:"## 64"`
	// contains filtered or unexported fields
}

type ShardState

type ShardState struct {
	Left  ShardStateUnsplit
	Right *ShardStateUnsplit
}

func (*ShardState) LoadFromCell

func (s *ShardState) LoadFromCell(loader *cell.Slice) error

type ShardStateUnsplit

type ShardStateUnsplit struct {
	GlobalID        int32      `tlb:"## 32"`
	ShardIdent      ShardIdent `tlb:"."`
	Seqno           uint32     `tlb:"## 32"`
	VertSeqno       uint32     `tlb:"## 32"`
	GenUTime        uint32     `tlb:"## 32"`
	GenLT           uint64     `tlb:"## 64"`
	MinRefMCSeqno   uint32     `tlb:"## 32"`
	OutMsgQueueInfo *cell.Cell `tlb:"^"`
	BeforeSplit     bool       `tlb:"bool"`
	Accounts        struct {
		ShardAccounts *cell.Dictionary `tlb:"dict 256"`
	} `tlb:"^"`
	Stats        *cell.Cell    `tlb:"^"`
	McStateExtra *McStateExtra `tlb:"maybe ^"`
	// contains filtered or unexported fields
}

type SigPubKeyED25519

type SigPubKeyED25519 struct {
	Key []byte `tlb:"bits 256"`
	// contains filtered or unexported fields
}

type Stack

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

func NewStack

func NewStack() *Stack

func (*Stack) Depth

func (s *Stack) Depth() uint

func (*Stack) LoadFromCell

func (s *Stack) LoadFromCell(loader *cell.Slice) error

func (*Stack) Pop

func (s *Stack) Pop() (any, error)

func (*Stack) Push

func (s *Stack) Push(obj any)

func (*Stack) ToCell

func (s *Stack) ToCell() (*cell.Cell, error)

type StackElement

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

type StackNaN

type StackNaN struct{}

type StateInit

type StateInit struct {
	Depth    *uint64          `tlb:"maybe ## 5"`
	TickTock *TickTock        `tlb:"maybe ."`
	Code     *cell.Cell       `tlb:"maybe ^"`
	Data     *cell.Cell       `tlb:"maybe ^"`
	Lib      *cell.Dictionary `tlb:"dict 256"`
}

type StateUpdate

type StateUpdate struct {
	Old ShardState `tlb:"^"`
	New *cell.Cell `tlb:"^"`
}

type StorageInfo

type StorageInfo struct {
	StorageUsed StorageUsed
	LastPaid    uint32
	DuePayment  *big.Int
}

func (*StorageInfo) LoadFromCell

func (s *StorageInfo) LoadFromCell(loader *cell.Slice) error

type StorageUsed

type StorageUsed struct {
	BitsUsed        uint64
	CellsUsed       uint64
	PublicCellsUsed uint64
}

func (*StorageUsed) LoadFromCell

func (s *StorageUsed) LoadFromCell(loader *cell.Slice) error

type TickTock

type TickTock struct {
	Tick bool `tlb:"bool"`
	Tock bool `tlb:"bool"`
}

type Transaction

type Transaction struct {
	AccountAddr []byte        `tlb:"bits 256"`
	LT          uint64        `tlb:"## 64"`
	PrevTxHash  []byte        `tlb:"bits 256"`
	PrevTxLT    uint64        `tlb:"## 64"`
	Now         uint32        `tlb:"## 32"`
	OutMsgCount uint16        `tlb:"## 15"`
	OrigStatus  AccountStatus `tlb:"."`
	EndStatus   AccountStatus `tlb:"."`
	IO          struct {
		In  *Message   `tlb:"maybe ^"`
		Out []*Message `tlb:"dict 15 -> array ^"`
	} `tlb:"^"`
	TotalFees   CurrencyCollection `tlb:"."`
	StateUpdate *cell.Cell         `tlb:"^"`
	Description *cell.Cell         `tlb:"^"`

	// not in scheme, but will be filled based on request data for flexibility
	Hash []byte `tlb:"-"`
	// contains filtered or unexported fields
}

func (*Transaction) Dump

func (t *Transaction) Dump() string

func (*Transaction) String

func (t *Transaction) String() string

type TransactionID deprecated

type TransactionID struct {
	LT        uint64
	Hash      []byte
	AccountID []byte
}

Deprecated: use ton.TransactionShortInfo

type Validator

type Validator struct {
	PublicKey SigPubKeyED25519 `tlb:"."`
	Weight    uint64           `tlb:"## 64"`
	// contains filtered or unexported fields
}

type ValidatorAddr

type ValidatorAddr struct {
	PublicKey SigPubKeyED25519 `tlb:"."`
	Weight    uint64           `tlb:"## 64"`
	ADNLAddr  []byte           `tlb:"bits 256"`
	// contains filtered or unexported fields
}

type ValidatorSet

type ValidatorSet struct {
	UTimeSince uint32           `tlb:"## 32"`
	UTimeUntil uint32           `tlb:"## 32"`
	Total      uint16           `tlb:"## 16"`
	Main       uint16           `tlb:"## 16"`
	List       *cell.Dictionary `tlb:"dict 16"`
	// contains filtered or unexported fields
}

type ValidatorSetExt

type ValidatorSetExt struct {
	UTimeSince  uint32           `tlb:"## 32"`
	UTimeUntil  uint32           `tlb:"## 32"`
	Total       uint16           `tlb:"## 16"`
	Main        uint16           `tlb:"## 16"`
	TotalWeight uint64           `tlb:"## 64"`
	List        *cell.Dictionary `tlb:"dict 16"`
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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