liteclient

package
v0.11.6 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2023 License: MIT Imports: 19 Imported by: 9

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
)

Variables

View Source
var (
	ErrBlockNotApplied = fmt.Errorf("block is not applied")
)

Functions

This section is empty.

Types

type Client

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

func New

func New(options ...Option) (*Client, error)

New returns a new instance of Client.

func NewClient

func NewClient(configurationFile config.GlobalConfigurationFile) (*Client, error)

NewClient Get options and create new lite client. If no options provided - download public config for mainnet from ton.org. Deprecated: use New(WithConfigurationFile()) instead.

func NewClientWithDefaultMainnet

func NewClientWithDefaultMainnet() (*Client, error)

func NewClientWithDefaultTestnet

func NewClientWithDefaultTestnet() (*Client, error)

func (*Client) BlocksGetShards

func (c *Client) BlocksGetShards(ctx context.Context, last tongo.TonNodeBlockIdExt) ([]tongo.TonNodeBlockIdExt, error)

func (*Client) DnsResolve

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

DnsResolve TEP-81 TON DNS Standard https://github.com/ton-blockchain/TEPs/blob/master/text/0081-dns-standard.md Returns the length (in bits) of the prefix of the internal representation of the domain that has been resolved and Cell with the TON DNS record Returns 0,nil,nil if DNS record is Null

func (*Client) GetAccountState

func (c *Client) GetAccountState(ctx context.Context, accountId tongo.AccountID) (tongo.AccountInfo, error)

func (*Client) GetBlock

GetBlock liteServer.getBlock id:tonNode.blockIdExt = liteServer.BlockData; liteServer.blockData id:tonNode.blockIdExt data:bytes = liteServer.BlockData;

func (*Client) GetBlockProof

func (c *Client) GetBlockProof(ctx context.Context, mode uint32, knownBlock tongo.TonNodeBlockIdExt, targetBlock *tongo.TonNodeBlockIdExt) ([]tongo.BlockProof, error)

func (*Client) GetConfigAll

func (c *Client) GetConfigAll(ctx context.Context) (*tongo.McStateExtra, error)

GetConfigAll liteServer.getConfigAll mode:# id:tonNode.blockIdExt = liteServer.ConfigInfo; liteServer.configInfo mode:# id:tonNode.blockIdExt state_proof:bytes config_proof:bytes = liteServer.ConfigInfo; Returns config: (Hashmap 32 ^Cell) as a Cell from config_proof

func (*Client) GetConfigAllById

func (c *Client) GetConfigAllById(ctx context.Context, last tongo.TonNodeBlockIdExt) (*tongo.ShardState, 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) GetLastConfigAll

func (c *Client) GetLastConfigAll(ctx context.Context) (*boc.Cell, error)

GetLastConfigAll liteServer.getConfigAll mode:# id:tonNode.blockIdExt = liteServer.ConfigInfo; liteServer.configInfo mode:# id:tonNode.blockIdExt state_proof:bytes config_proof:bytes = liteServer.ConfigInfo; Returns config: (Hashmap 32 ^Cell) as a Cell from config_proof

func (*Client) GetLastRawAccount

func (c *Client) GetLastRawAccount(ctx context.Context, accountId tongo.AccountID) (tongo.Account, error)

func (*Client) GetLastShardAccount

func (c *Client) GetLastShardAccount(ctx context.Context, accountId tongo.AccountID) (tongo.ShardAccount, error)

func (*Client) GetMasterchainInfo

func (c *Client) GetMasterchainInfo(ctx context.Context) (tongo.TonNodeBlockIdExt, error)

GetMasterchainInfo liteServer.getMasterchainInfo = liteServer.MasterchainInfo; liteServer.masterchainInfo last:tonNode.blockIdExt state_root_hash:int256 init:tonNode.zeroStateIdExt = liteServer.MasterchainInfo;

func (*Client) GetMasterchainInfoExt

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

GetMasterchainInfoExt liteServer.getMasterchainInfoExt mode:# = liteServer.MasterchainInfoExt; liteServer.masterchainInfoExt mode:# version:int capabilities:long last:tonNode.blockIdExt last_utime:int now:int state_root_hash:int256 init:tonNode.zeroStateIdExt = liteServer.MasterchainInfoExt;

func (*Client) GetOneRawTransaction

func (c *Client) GetOneRawTransaction(ctx context.Context, id tongo.TonNodeBlockIdExt, accountId tongo.AccountID, lt uint64) ([]*boc.Cell, []byte, error)

GetOneRawTransaction liteServer.getOneTransaction id:tonNode.blockIdExt account:liteServer.accountId lt:long = liteServer.TransactionInfo; liteServer.transactionInfo id:tonNode.blockIdExt proof:bytes transaction:bytes = liteServer.TransactionInfo;

func (*Client) GetRawAccountById

func (c *Client) GetRawAccountById(ctx context.Context, accountId tongo.AccountID, blockId tongo.TonNodeBlockIdExt) (tongo.Account, error)

func (*Client) GetRawBlock

func (c *Client) GetRawBlock(ctx context.Context, blockID tongo.TonNodeBlockIdExt) (*tongo.RawBlock, error)

GetRawBlock returns a raw block without TL-B deserialization.

func (*Client) GetRawTransactions

func (c *Client) GetRawTransactions(ctx context.Context, count uint32, accountId tongo.AccountID, lt uint64, hash tongo.Hash) ([]*boc.Cell, error)

GetRawTransactions Returns []boc.Cell of the transaction$0111 tlb constructor. Be careful when reading Cell. Some Cells are shared between slice elements. Use cell.ResetCounters()

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) GetTransactions

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

func (*Client) LookupBlock

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

LookupBlock liteServer.lookupBlock mode:# id:tonNode.blockId lt:mode.1?long utime:mode.2?int = liteServer.BlockHeader; liteServer.blockHeader id:tonNode.blockIdExt mode:# header_proof:bytes = liteServer.BlockHeader;

func (*Client) RunSmcMethod

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

RunSmcMethod Run smart contract method by name and parameters liteServer.runSmcMethod mode:# id:tonNode.blockIdExt account:liteServer.accountId method_id:long params:bytes = liteServer.RunMethodResult; liteServer.runMethodResult mode:# id:tonNode.blockIdExt shardblk:tonNode.blockIdExt shard_proof:mode.0?bytes proof:mode.0?bytes state_proof:mode.1?bytes init_c7:mode.3?bytes lib_extras:mode.4?bytes exit_code:int result:mode.2?bytes = liteServer.RunMethodResult;

func (*Client) RunSmcMethodByExtBlockId

func (c *Client) RunSmcMethodByExtBlockId(ctx context.Context, mode uint32, id tongo.TonNodeBlockIdExt, accountId tongo.AccountID, method string, params tongo.VmStack) (tongo.VmStack, error)

RunSmcMethod Run smart contract method by name and parameters liteServer.runSmcMethod mode:# id:tonNode.blockIdExt account:liteServer.accountId method_id:long params:bytes = liteServer.RunMethodResult; liteServer.runMethodResult mode:# id:tonNode.blockIdExt shardblk:tonNode.blockIdExt shard_proof:mode.0?bytes proof:mode.0?bytes state_proof:mode.1?bytes init_c7:mode.3?bytes lib_extras:mode.4?bytes exit_code:int result:mode.2?bytes = liteServer.RunMethodResult;

func (*Client) SendRawMessage

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

SendRawMessage Send binary payload to TON blockchain liteServer.sendMessage body:bytes = liteServer.SendMsgStatus; liteServer.sendMsgStatus status:int = liteServer.SendMsgStatus;

func (*Client) ValidatorStats

func (c *Client) ValidatorStats(ctx context.Context, mode uint32, last tongo.TonNodeBlockIdExt, limit uint32, startAfter *tongo.Hash, modifiedAfter *uint32) (*tongo.ShardStateUnsplit, error)

type LiteServerAccountState

type LiteServerAccountState struct {
	Id         tongo.TonNodeBlockIdExt
	ShardBlk   tongo.TonNodeBlockIdExt
	ShardProof []byte
	Proof      []byte
	State      []byte
}

type LiteServerAllShardsInfo

type LiteServerAllShardsInfo struct {
	Id    tongo.TonNodeBlockIdExt
	Proof []byte
	Data  []byte
}

type LiteServerError

type LiteServerError struct {
	Code    int32
	Message string
}

type LiteServerMasterchainInfo

type LiteServerMasterchainInfo struct {
	Last          tongo.TonNodeBlockIdExt
	StateRootHash tongo.Hash
}

type LiteServerMasterchainInfoExt

type LiteServerMasterchainInfoExt struct {
	Mode          uint32
	Version       uint32
	Capabilities  uint64
	Last          tongo.TonNodeBlockIdExt
	LastUTime     uint32
	Now           uint32
	StateRootHash tongo.Hash
}

type Option

type Option func(o *Options)

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 client instance.

Jump to

Keyboard shortcuts

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