liteapi

package
v1.0.16 Latest Latest
Warning

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

Go to latest
Published: May 27, 2023 License: MIT Imports: 19 Imported by: 32

README

Lite client implementation.

This library implements TON lite client over ADNL protocol to communicate with TON lite servers.

TL schemas for lite server API you can find here:

Usage

Example

Documentation

Index

Constants

View Source
const (
	IntTag                             uint32 = 0xda9b50a8
	LongTag                            uint32 = 0xba6c0722
	DoubleTag                          uint32 = 0x54c11022
	StringTag                          uint32 = 0x246e28b5
	ObjectTag                          uint32 = 0xa04c7029
	FunctionTag                        uint32 = 0x97c1cb7a
	BytesTag                           uint32 = 0xd1144618
	TrueTag                            uint32 = 0x39d3ed3f
	BoolTrueTag                        uint32 = 0xb5757299
	BoolFalseTag                       uint32 = 0x379779bc
	VectorTag                          uint32 = 0x144a1a50
	Int128Tag                          uint32 = 0xb7f7cc84
	Int256Tag                          uint32 = 0x5bebed7b
	TonNodeBlockIdTag                  uint32 = 0x67b1cdb7
	TonNodeBlockIdExtTag               uint32 = 0x78eb5267
	TonNodeZeroStateIdExtTag           uint32 = 0xae35721d
	AdnlMessageQueryTag                uint32 = 0x7af98bb4
	AdnlMessageAnswerTag               uint32 = 0x1684ac0f
	LiteServerErrorTag                 uint32 = 0x48e1a9bb
	LiteServerAccountIdTag             uint32 = 0xc5e2a075
	LiteServerMasterchainInfoTag       uint32 = 0x81288385
	LiteServerMasterchainInfoExtTag    uint32 = 0xf5e0cca8
	LiteServerCurrentTimeTag           uint32 = 0xd0053e9
	LiteServerVersionTag               uint32 = 0xe591045a
	LiteServerBlockDataTag             uint32 = 0x6ced74a5
	LiteServerBlockStateTag            uint32 = 0xcdcadab
	LiteServerBlockHeaderTag           uint32 = 0x19822d75
	LiteServerSendMsgStatusTag         uint32 = 0x97e55039
	LiteServerAccountStateTag          uint32 = 0x51c77970
	LiteServerRunMethodResultTag       uint32 = 0x6b619aa3
	LiteServerShardInfoTag             uint32 = 0x84cde69f
	LiteServerAllShardsInfoTag         uint32 = 0x2de78f09
	LiteServerTransactionInfoTag       uint32 = 0x47edde0e
	LiteServerTransactionListTag       uint32 = 0x9dd72eb9
	LiteServerTransactionIdTag         uint32 = 0xaf652fb1
	LiteServerTransactionId3Tag        uint32 = 0x77da812c
	LiteServerBlockTransactionsTag     uint32 = 0x5c6c542f
	LiteServerSignatureTag             uint32 = 0x55f8dea3
	LiteServerSignatureSetTag          uint32 = 0x9755e192
	LiteServerBlockLinkBackTag         uint32 = 0xef1b7eef
	LiteServerBlockLinkForwardTag      uint32 = 0x1cce0f52
	LiteServerPartialBlockProofTag     uint32 = 0xc1d2d08e
	LiteServerConfigInfoTag            uint32 = 0x2f277bae
	LiteServerValidatorStatsTag        uint32 = 0xd896f7b9
	LiteServerDebugVerbosityTag        uint32 = 0x3347405d
	LiteServerGetMasterchainInfoTag    uint32 = 0x2ee6b589
	LiteServerGetMasterchainInfoExtTag uint32 = 0xdf71a670
	LiteServerGetTimeTag               uint32 = 0x345aad16
	LiteServerGetVersionTag            uint32 = 0xb942b23
	LiteServerGetBlockTag              uint32 = 0xdcf7763
	LiteServerGetStateTag              uint32 = 0xb62e6eba
	LiteServerGetBlockHeaderTag        uint32 = 0x9e06ec21
	LiteServerSendMessageTag           uint32 = 0x82d40a69
	LiteServerGetAccountStateTag       uint32 = 0x250e896b
	LiteServerRunSmcMethodTag          uint32 = 0xd25dc65c
	LiteServerGetShardInfoTag          uint32 = 0x25f4a246
	LiteServerGetAllShardsInfoTag      uint32 = 0x6bfdd374
	LiteServerGetOneTransactionTag     uint32 = 0xea240fd4
	LiteServerGetTransactionsTag       uint32 = 0xa1e7401c
	LiteServerLookupBlockTag           uint32 = 0x1ef7c8fa
	LiteServerListBlockTransactionsTag uint32 = 0xdac7fcad
	LiteServerGetBlockProofTag         uint32 = 0x449cea8a
	LiteServerGetConfigAllTag          uint32 = 0xb7261b91
	LiteServerGetConfigParamsTag       uint32 = 0x638df89e
	LiteServerGetValidatorStatsTag     uint32 = 0xbc581a09
	LiteServerQueryPrefixTag           uint32 = 0x86e6d372
	LiteServerQueryTag                 uint32 = 0xdf068c79
	LiteServerWaitMasterchainSeqnoTag  uint32 = 0x92b8eaba
)
View Source
const (
	LiteServerEnvName = "LITE_SERVERS"
)

Variables

View Source
var (
	// ErrAccountNotFound is returned by lite server when executing a method for an account that has not been deployed to the blockchain.
	ErrAccountNotFound = errors.New("account not found")
)
View Source
var (
	ErrOnchainContentOnly = fmt.Errorf("only onchain jetton data supported")
)

Functions

func VerifySendMessagePayload added in v1.0.14

func VerifySendMessagePayload(payload []byte) error

VerifySendMessagePayload verifies that the given payload is an external message ready to be sent to the blockchain.

Types

type Client

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

func NewClient

func NewClient(opts ...Option) (*Client, error)

NewClient Get options and create new lite client. If no options provided - download public config for mainnet from ton.org.

func NewClientWithDefaultMainnet

func NewClientWithDefaultMainnet() (*Client, error)

func NewClientWithDefaultTestnet

func NewClientWithDefaultTestnet() (*Client, error)

func (*Client) DnsResolve

func (c *Client) DnsResolve(ctx context.Context, address tongo.AccountID, domain string, category *big.Int) (int, *boc.Cell, error)

DnsResolve is deprecated. please use github.com/tonkeeper/tongo/contract/dns

func (*Client) GetAccountState

func (c *Client) GetAccountState(ctx context.Context, accountID tongo.AccountID) (tlb.ShardAccount, error)

func (*Client) GetAllShardsInfo

func (c *Client) GetAllShardsInfo(ctx context.Context, blockID tongo.BlockIDExt) ([]tongo.BlockIDExt, error)

func (*Client) GetBlock

func (c *Client) GetBlock(ctx context.Context, blockID tongo.BlockIDExt) (tlb.Block, error)

func (*Client) GetBlockHeader

func (c *Client) GetBlockHeader(ctx context.Context, blockID tongo.BlockIDExt, mode uint32) (tlb.BlockInfo, error)

func (*Client) GetBlockProof

func (c *Client) GetBlockProof(
	ctx context.Context,
	knownBlock tongo.BlockIDExt,
	targetBlock *tongo.BlockIDExt,
) (liteclient.LiteServerPartialBlockProofC, error)

func (*Client) GetConfigAll

func (c *Client) GetConfigAll(ctx context.Context, mode ConfigMode) (tlb.ConfigParams, error)

GetConfigAll returns a current configuration of the blockchain.

func (*Client) GetConfigParams

func (c *Client) GetConfigParams(ctx context.Context, mode ConfigMode, paramList []uint32) (tlb.ConfigParams, error)

func (*Client) GetJettonBalance

func (c *Client) GetJettonBalance(ctx context.Context, jettonWallet tongo.AccountID) (*big.Int, error)

GetJettonBalance TEP-74 Fungible tokens (Jettons) standard https://github.com/ton-blockchain/TEPs/blob/master/text/0074-jettons-standard.md

func (*Client) GetJettonData

func (c *Client) GetJettonData(ctx context.Context, master tongo.AccountID) (tongo.JettonMetadata, error)

GetJettonData TEP-74 Fungible tokens (Jettons) standard https://github.com/ton-blockchain/TEPs/blob/master/text/0074-jettons-standard.md

func (*Client) GetJettonWallet

func (c *Client) GetJettonWallet(ctx context.Context, master, owner tongo.AccountID) (tongo.AccountID, error)

GetJettonWallet TEP-74 Fungible tokens (Jettons) standard https://github.com/ton-blockchain/TEPs/blob/master/text/0074-jettons-standard.md

func (*Client) GetLastTransactions

func (c *Client) GetLastTransactions(ctx context.Context, a tongo.AccountID, limit int) ([]tongo.Transaction, error)

func (*Client) GetLibraries

func (c *Client) GetLibraries(ctx context.Context, libraryList []tongo.Bits256) ([]liteclient.LiteServerLibraryEntryC, error)

func (*Client) GetMasterchainInfo

func (c *Client) GetMasterchainInfo(ctx context.Context) (liteclient.LiteServerMasterchainInfoC, error)

func (*Client) GetMasterchainInfoExt

func (c *Client) GetMasterchainInfoExt(ctx context.Context, mode uint32) (liteclient.LiteServerMasterchainInfoExtC, error)

func (*Client) GetOneTransactionFromBlock

func (c *Client) GetOneTransactionFromBlock(
	ctx context.Context,
	accountID tongo.AccountID,
	blockId tongo.BlockIDExt,
	lt uint64,
) (tongo.Transaction, error)

func (*Client) GetRootDNS

func (c *Client) GetRootDNS(ctx context.Context) (tongo.AccountID, error)

func (*Client) GetSeqno

func (c *Client) GetSeqno(ctx context.Context, account tongo.AccountID) (uint32, error)

func (*Client) GetShardBlockProof

func (c *Client) GetShardBlockProof(ctx context.Context) (liteclient.LiteServerShardBlockProofC, error)

func (*Client) GetShardInfo

func (c *Client) GetShardInfo(
	ctx context.Context,
	blockID tongo.BlockIDExt,
	workchain uint32,
	shard uint64,
	exact bool,
) (tongo.BlockIDExt, error)

func (*Client) GetState

func (c *Client) GetState(ctx context.Context, blockID tongo.BlockIDExt) ([]byte, tongo.Bits256, tongo.Bits256, error)

func (*Client) GetTime

func (c *Client) GetTime(ctx context.Context) (uint32, error)

func (*Client) GetTransactions

func (c *Client) GetTransactions(
	ctx context.Context,
	count uint32,
	accountID tongo.AccountID,
	lt uint64,
	hash tongo.Bits256,
) ([]tongo.Transaction, error)

func (*Client) GetValidatorStats

func (c *Client) GetValidatorStats(
	ctx context.Context,
	mode, limit uint32,
	startAfter *tongo.Bits256,
	modifiedAfter *uint32,
) (*tlb.McStateExtra, error)

func (*Client) GetVersion

func (c *Client) GetVersion(ctx context.Context) (liteclient.LiteServerVersionC, error)

func (*Client) ListBlockTransactions

func (c *Client) ListBlockTransactions(
	ctx context.Context,
	blockID tongo.BlockIDExt,
	mode, count uint32,
	after *liteclient.LiteServerTransactionId3C,
) ([]liteclient.LiteServerTransactionIdC, bool, error)

func (*Client) LookupBlock

func (c *Client) LookupBlock(ctx context.Context, blockID tongo.BlockID, mode uint32, lt *uint64, utime *uint32) (tongo.BlockIDExt, tlb.BlockInfo, error)

func (*Client) RunSmcMethod

func (c *Client) RunSmcMethod(
	ctx context.Context,
	accountID tongo.AccountID,
	method string,
	params tlb.VmStack,
) (uint32, tlb.VmStack, error)

func (*Client) RunSmcMethodByID

func (c *Client) RunSmcMethodByID(ctx context.Context, accountID tongo.AccountID, methodID int, params tlb.VmStack) (uint32, tlb.VmStack, error)

func (*Client) SendMessage

func (c *Client) SendMessage(ctx context.Context, payload []byte) (uint32, error)

SendMessage verifies that the given payload contains an external message and sends it to a lite server.

func (*Client) WithBlock

func (c *Client) WithBlock(block tongo.BlockIDExt) *Client

type ConfigMode

type ConfigMode uint32
const (
	NeedStateRoot      ConfigMode = 1
	NeedLibraries      ConfigMode = 2
	NeedStateExtraRoot ConfigMode = 4
	NeedShardHashes    ConfigMode = 8
	NeedValidatorSet   ConfigMode = 16
	NeedSpecialSmc     ConfigMode = 32
	NeedAccountsRoot   ConfigMode = 64
	NeedPrevBlocks     ConfigMode = 128
	NeedWorkchainInfo  ConfigMode = 256
	NeedCapabilities   ConfigMode = 512
)

constants below are different flags for "mode" param of GetConfigAll. one needs to OR them to get different aspects of TON's configuration.

type Option

type Option func(o *Options) error

func FromEnvs added in v1.0.15

func FromEnvs() Option

FromEnvs configures a Client based on the following environment variables: LITE_SERVERS - a list of lite servers to use

func Mainnet added in v1.0.15

func Mainnet() Option

Mainnet configures a client to use lite servers from the mainnet.

func Testnet added in v1.0.15

func Testnet() Option

Testnet configures a client to use lite servers from the testnet.

func WithConfigurationFile

func WithConfigurationFile(file config.GlobalConfigurationFile) Option

func WithLiteServers

func WithLiteServers(servers []config.LiteServer) Option

func WithTimeout

func WithTimeout(timeout time.Duration) Option

type Options

type Options struct {
	LiteServers []config.LiteServer
	Timeout     time.Duration
}

Options holds parameters to configure a lite api instance.

Jump to

Keyboard shortcuts

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