tlbe

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsUnsigned

func AsUnsigned(v *big.Int, sz uint) *big.Int

AsUnsigned interprets the given big.Int as an unsigned integer of size sz bits.

This is useful for masking sign bits when dealing with fixed-width unsigned integers. For example, a 160-bit unsigned integer with the high bit set would be interpreted as a negative number in big.Int, so we mask it to get the correct unsigned value.

func LoadFromCell

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

LoadFromCell is a helper that decodes basic types directly, and falls back to tlb.LoadFromCell for others.

func ToCell

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

ToCell is a helper that encodes basic types directly, and falls back to tlb.ToCell for others.

Types

type BigUint

type BigUint struct {
	Bits  uint
	Value *big.Int
}

BigUint stores an unsigned integer with a fixed bit width for TLB encoding.

type Cell

type Cell[T any] cell.Cell

Cell is a generic wrapper around cell.Cell, adds underlying type information T.

func ManyCellsFrom

func ManyCellsFrom[T any](values []T) ([]*Cell[T], error)

ManyCellsFrom creates multiple Cell[T] from a slice of values of type T.

func NewCellFrom

func NewCellFrom[T any](v T) (*Cell[T], error)

NewCellFrom creates a new Cell[T] from a value of type T.

The type parameter T must be a value type, not a pointer type. For example, use Cell[tlb.InternalMessage], not Cell[tlb.InternalMessage].

func (*Cell[T]) LoadFromCell

func (c *Cell[T]) LoadFromCell(loader *cell.Slice) error

LoadFromCell implements the tlb.Unmarshaller interface

func (*Cell[T]) MarshalJSON

func (c *Cell[T]) MarshalJSON() ([]byte, error)

func (*Cell[T]) MustToCell

func (c *Cell[T]) MustToCell() *cell.Cell

func (*Cell[T]) ToCell

func (c *Cell[T]) ToCell() (*cell.Cell, error)

ToCell implements the tlb.Marshaller interface

func (*Cell[T]) ToValue

func (c *Cell[T]) ToValue() (T, error)

ToValue converts the cell back to its original value type T.

If T is a pointer type, this will fail because tlb.LoadFromCell requires a pointer to a value type, not a pointer to a pointer.

func (*Cell[T]) UnmarshalJSON

func (c *Cell[T]) UnmarshalJSON(data []byte) error

type Dict

type Dict[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func NewDict

func NewDict[K comparable, V any](entries map[K]V) *Dict[K, V]

func NewDictFromDictionary

func NewDictFromDictionary[K comparable, V any](dict *cell.Dictionary) (*Dict[K, V], error)

func NewDictFromSlice

func NewDictFromSlice[K integerKey, V any](data []V) (*Dict[K, V], error)

func NewEmptyDict

func NewEmptyDict[K comparable, V any]() *Dict[K, V]

func (Dict[K, V]) AsDictionary

func (d Dict[K, V]) AsDictionary() (*cell.Dictionary, error)

func (*Dict[K, V]) AsMap

func (d *Dict[K, V]) AsMap() map[K]V

func (*Dict[K, V]) Delete

func (d *Dict[K, V]) Delete(key K)

func (*Dict[K, V]) Get

func (d *Dict[K, V]) Get(key K) (V, bool)

func (Dict[K, V]) Len

func (d Dict[K, V]) Len() int

func (*Dict[K, V]) LoadFromCell

func (d *Dict[K, V]) LoadFromCell(slice *cell.Slice) error

func (*Dict[K, V]) LoadFromDictionary

func (d *Dict[K, V]) LoadFromDictionary(dict *cell.Dictionary) error

func (Dict[K, V]) MarshalJSON

func (d Dict[K, V]) MarshalJSON() ([]byte, error)

MarshalJSON implements the encoding/json.Marshaler interface, serializing the dictionary as an array of key-value pairs.

func (*Dict[K, V]) Set

func (d *Dict[K, V]) Set(key K, value V)

func (Dict[K, V]) ToCell

func (d Dict[K, V]) ToCell() (*cell.Cell, error)

func (*Dict[K, V]) UnmarshalJSON

func (d *Dict[K, V]) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the encoding/json.Unmarshaler interface, deserializing the dictionary from an array of key-value pairs.

type DictKey

type DictKey interface {
	BitsLen() uint
}

type InternalMessageHeader

type InternalMessageHeader struct {
	IHRDisabled bool             `tlb:"bool"`
	Bounce      bool             `tlb:"bool"`
	Bounced     bool             `tlb:"bool"`
	SrcAddr     *address.Address `tlb:"addr"`
	DstAddr     *address.Address `tlb:"addr"`
	Amount      tlb.Coins        `tlb:"."`
	// contains filtered or unexported fields
}

InternalMessageHeader is a helper struct to read internal message header (subset of fields).

type Uint160

type Uint160 big.Int

Uint160 is a 160-bit unsigned integer wrapper.

func NewUint160

func NewUint160(v *big.Int) *Uint160

func (*Uint160) BitsLen

func (*Uint160) BitsLen() uint

func (*Uint160) LoadFromCell

func (x *Uint160) LoadFromCell(loader *cell.Slice) error

LoadFromCell implements tlb.Unmarshaler.

func (*Uint160) MarshalJSON

func (x *Uint160) MarshalJSON() ([]byte, error)

func (Uint160) String

func (x Uint160) String() string

func (Uint160) ToCell

func (x Uint160) ToCell() (*cell.Cell, error)

ToCell implements tlb.Marshaller.

func (*Uint160) UnmarshalJSON

func (x *Uint160) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the encoding/json.Unmarshaler interface.

func (Uint160) Value

func (x Uint160) Value() *big.Int

type Uint256

type Uint256 big.Int

Uint256 is a 256-bit unsigned integer wrapper.

func NewUint256

func NewUint256(v *big.Int) *Uint256

func (*Uint256) BitsLen

func (*Uint256) BitsLen() uint

func (*Uint256) Cmp

func (x *Uint256) Cmp(y *Uint256) (r int)

func (*Uint256) LoadFromCell

func (x *Uint256) LoadFromCell(loader *cell.Slice) error

LoadFromCell implements tlb.Unmarshaler.

func (*Uint256) MarshalJSON

func (x *Uint256) MarshalJSON() ([]byte, error)

func (Uint256) String

func (x Uint256) String() string

func (Uint256) ToCell

func (x Uint256) ToCell() (*cell.Cell, error)

ToCell implements tlb.Marshaller.

func (*Uint256) UnmarshalJSON

func (x *Uint256) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the encoding/json.Unmarshaler interface.

func (Uint256) Value

func (x Uint256) Value() *big.Int

Jump to

Keyboard shortcuts

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