ton

package
v0.0.0-...-da90e6b Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrCodeContractNotInitialized = -256
)

Variables

View Source
var ErrBlockNotFound = errors.New("block not found")
View Source
var ErrIncorrectResultType = errors.New("incorrect result type")
View Source
var ErrMessageNotAccepted = errors.New("message was not accepted by the contract")
View Source
var ErrNoNewBlocks = errors.New("no new blocks in a given timeout or in 10 seconds")
View Source
var ErrNoProof = fmt.Errorf("liteserver has no proof for this account in a given block, request newer block or disable proof checks")
View Source
var ErrNoTransactionsWereFound = errors.New("no transactions were found")
View Source
var ErrResultIndexOutOfRange = errors.New("result index is out of range")

Functions

func CheckAccountStateProof

func CheckAccountStateProof(addr *address.Address, block *BlockIDExt, stateProof []*cell.Cell, shardProof []*cell.Cell, shardHash []byte, skipBlockCheck bool) (*tlb.ShardAccount, *tlb.DepthBalanceInfo, error)

func CheckBackwardBlockProof

func CheckBackwardBlockProof(from, to *BlockIDExt, toKey bool, stateProof, destProof, proof *cell.Cell) error

func CheckBlockProof

func CheckBlockProof(proof *cell.Cell, blockRootHash []byte) (*tlb.Block, error)

func CheckBlockShardStateProof

func CheckBlockShardStateProof(proof []*cell.Cell, blockRootHash []byte) (*tlb.ShardStateUnsplit, error)

func CheckForwardBlockProof

func CheckForwardBlockProof(from, to *BlockIDExt, toKey bool, configProof, destProof *cell.Cell, signatures *SignatureSet) error

func CheckShardInMasterProof

func CheckShardInMasterProof(master *BlockIDExt, shardProof []*cell.Cell, workchain int32, shardRootHash []byte) error

func CheckShardMcStateExtraProof

func CheckShardMcStateExtraProof(master *BlockIDExt, shardProof []*cell.Cell) (*tlb.McStateExtra, error)

func CheckTransactionProof

func CheckTransactionProof(txHash []byte, txLT uint64, txAccount []byte, shardAccounts *tlb.ShardAccountBlocks) error

Types

type APIClient

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

func NewAPIClient

func NewAPIClient(client LiteClient, proofCheckPolicy ...ProofCheckPolicy) *APIClient

func (*APIClient) Client

func (c *APIClient) Client() LiteClient

func (*APIClient) CurrentMasterchainInfo

func (c *APIClient) CurrentMasterchainInfo(ctx context.Context) (_ *BlockIDExt, err error)

CurrentMasterchainInfo - cached version of GetMasterchainInfo to not do it in parallel many times

func (*APIClient) GetAccount

func (c *APIClient) GetAccount(ctx context.Context, block *BlockIDExt, addr *address.Address) (*tlb.Account, error)

func (*APIClient) GetBlockData

func (c *APIClient) GetBlockData(ctx context.Context, block *BlockIDExt) (*tlb.Block, error)

GetBlockData - get block detailed information

func (*APIClient) GetBlockDataEx

func (c *APIClient) GetBlockDataEx(ctx context.Context, block *BlockIDExt) (*tlb.Block, *cell.Cell, error)

GetBlockDataEx - get block detailed information

func (*APIClient) GetBlockProof

func (c *APIClient) GetBlockProof(ctx context.Context, known, target *BlockIDExt) (*PartialBlockProof, error)

GetBlockProof - gets proof chain for the block

func (*APIClient) GetBlockShardsInfo

func (c *APIClient) GetBlockShardsInfo(ctx context.Context, master *BlockIDExt) ([]*BlockIDExt, error)

GetBlockShardsInfo - gets the information about workchains and its shards at given masterchain state

func (*APIClient) GetBlockTransactionsV2

func (c *APIClient) GetBlockTransactionsV2(ctx context.Context, block *BlockIDExt, count uint32, after ...*TransactionID3) ([]TransactionShortInfo, bool, error)

GetBlockTransactionsV2 - list of block transactions

func (*APIClient) GetBlockchainConfig

func (c *APIClient) GetBlockchainConfig(ctx context.Context, block *BlockIDExt, onlyParams ...int32) (*BlockchainConfig, error)

func (*APIClient) GetLibraries

func (c *APIClient) GetLibraries(ctx context.Context, hashes ...[]byte) ([]*cell.Cell, error)

func (*APIClient) GetMasterchainInfo

func (c *APIClient) GetMasterchainInfo(ctx context.Context) (*BlockIDExt, error)

GetMasterchainInfo - gets the latest state of master chain

func (*APIClient) GetTime

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

func (*APIClient) GetTransaction

func (c *APIClient) GetTransaction(ctx context.Context, block *BlockIDExt, addr *address.Address, lt uint64) (*tlb.Transaction, error)

func (*APIClient) GetTransactionEx

func (c *APIClient) GetTransactionEx(ctx context.Context, block *BlockIDExt, addr *address.Address, lt uint64) (*tlb.Transaction, *TransactionInfo, error)

func (*APIClient) ListTransactions

func (c *APIClient) ListTransactions(ctx context.Context, addr *address.Address, limit uint32, lt uint64, txHash []byte) ([]*tlb.Transaction, error)

ListTransactions - returns list of transactions before (including) passed lt and hash, the oldest one is first in result slice Transactions will be verified to match final tx hash, which should be taken from proved account state, then it is safe.

func (*APIClient) LookupBlock

func (c *APIClient) LookupBlock(ctx context.Context, workchain int32, shard int64, seqno uint32) (*BlockIDExt, error)

LookupBlock - find block information by seqno, shard and chain

func (*APIClient) RunGetMethod

func (c *APIClient) RunGetMethod(ctx context.Context, blockInfo *BlockIDExt, addr *address.Address, method string, params ...any) (*ExecutionResult, error)

func (*APIClient) SendExternalMessage

func (c *APIClient) SendExternalMessage(ctx context.Context, msg *tlb.ExternalMessage) error

func (*APIClient) SetTrustedBlock

func (c *APIClient) SetTrustedBlock(block *BlockIDExt)

SetTrustedBlock - set starting point to verify master block proofs chain

func (*APIClient) SetTrustedBlockFromConfig

func (c *APIClient) SetTrustedBlockFromConfig(cfg *liteclient.GlobalConfig)

SetTrustedBlockFromConfig - same as SetTrustedBlock but takes init block from config

func (*APIClient) SubscribeOnTransactions

func (c *APIClient) SubscribeOnTransactions(workerCtx context.Context, addr *address.Address, lastProcessedLT uint64, channel chan<- *tlb.Transaction)

func (*APIClient) VerifyProofChain

func (c *APIClient) VerifyProofChain(ctx context.Context, from, to *BlockIDExt) error

func (*APIClient) WaitForBlock

func (c *APIClient) WaitForBlock(seqno uint32) APIClientWrapped

WaitForBlock - waits for the given master block seqno will be available on the requested node

func (*APIClient) WithRetry

func (c *APIClient) WithRetry(maxTries ...int) APIClientWrapped

WithRetry - automatically retires request to another available liteserver when adnl timeout, or error code 651 or -400 is received. If maxTries > 0, limits additional attempts to this number.

type APIClientWaiter deprecated

type APIClientWaiter = APIClientWrapped

Deprecated: use APIClientWrapped

type APIClientWrapped

type APIClientWrapped interface {
	Client() LiteClient
	GetTime(ctx context.Context) (uint32, error)
	GetLibraries(ctx context.Context, list ...[]byte) ([]*cell.Cell, error)
	LookupBlock(ctx context.Context, workchain int32, shard int64, seqno uint32) (*BlockIDExt, error)
	GetBlockData(ctx context.Context, block *BlockIDExt) (*tlb.Block, error)
	GetBlockTransactionsV2(ctx context.Context, block *BlockIDExt, count uint32, after ...*TransactionID3) ([]TransactionShortInfo, bool, error)
	GetBlockShardsInfo(ctx context.Context, master *BlockIDExt) ([]*BlockIDExt, error)
	GetBlockchainConfig(ctx context.Context, block *BlockIDExt, onlyParams ...int32) (*BlockchainConfig, error)
	GetMasterchainInfo(ctx context.Context) (*BlockIDExt, error)
	GetAccount(ctx context.Context, block *BlockIDExt, addr *address.Address) (*tlb.Account, error)
	SendExternalMessage(ctx context.Context, msg *tlb.ExternalMessage) error
	RunGetMethod(ctx context.Context, blockInfo *BlockIDExt, addr *address.Address, method string, params ...interface{}) (*ExecutionResult, error)
	ListTransactions(ctx context.Context, addr *address.Address, num uint32, lt uint64, txHash []byte) ([]*tlb.Transaction, error)
	GetTransaction(ctx context.Context, block *BlockIDExt, addr *address.Address, lt uint64) (*tlb.Transaction, error)
	GetBlockProof(ctx context.Context, known, target *BlockIDExt) (*PartialBlockProof, error)
	CurrentMasterchainInfo(ctx context.Context) (_ *BlockIDExt, err error)
	SubscribeOnTransactions(workerCtx context.Context, addr *address.Address, lastProcessedLT uint64, channel chan<- *tlb.Transaction)
	VerifyProofChain(ctx context.Context, from, to *BlockIDExt) error
	WaitForBlock(seqno uint32) APIClientWrapped
	WithRetry(maxRetries ...int) APIClientWrapped
	SetTrustedBlock(block *BlockIDExt)
	SetTrustedBlockFromConfig(cfg *liteclient.GlobalConfig)
}

type AccountID

type AccountID struct {
	Workchain int32  `tl:"int"`
	ID        []byte `tl:"int256"`
}

type AccountState

type AccountState struct {
	ID         *BlockIDExt  `tl:"struct"`
	Shard      *BlockIDExt  `tl:"struct"`
	ShardProof []*cell.Cell `tl:"cell optional 2"`
	Proof      []*cell.Cell `tl:"cell optional 2"`
	State      *cell.Cell   `tl:"cell optional"`
}

type AllShardsInfo

type AllShardsInfo struct {
	ID    *BlockIDExt `tl:"struct"`
	Proof []byte      `tl:"bytes"`
	Data  *cell.Cell  `tl:"cell"`
}

type BlockData

type BlockData struct {
	ID      *BlockIDExt `tl:"struct"`
	Payload *cell.Cell  `tl:"cell"`
}

type BlockHeader

type BlockHeader struct {
	ID          *BlockIDExt `tl:"struct"`
	Mode        uint32      `tl:"flags"`
	HeaderProof []byte      `tl:"bytes"`
}

type BlockID

type BlockID struct {
	RootHash []byte `tl:"int256"`
	FileHash []byte `tl:"int256"`
}

type BlockIDExt

type BlockIDExt = tlb.BlockInfo

TODO: will be moved here in the next version

func LoadShardsFromHashes

func LoadShardsFromHashes(shardHashes *cell.Dictionary, skipPruned bool) (shards []*BlockIDExt, err error)

type BlockInfoShort

type BlockInfoShort struct {
	Workchain int32 `tl:"int"`
	Shard     int64 `tl:"long"`
	Seqno     int32 `tl:"int"`
}

type BlockLinkBackward

type BlockLinkBackward struct {
	ToKeyBlock bool        `tl:"bool"`
	From       *BlockIDExt `tl:"struct"`
	To         *BlockIDExt `tl:"struct"`
	DestProof  []byte      `tl:"bytes"`
	Proof      []byte      `tl:"bytes"`
	StateProof []byte      `tl:"bytes"`
}

type BlockLinkForward

type BlockLinkForward struct {
	ToKeyBlock   bool          `tl:"bool"`
	From         *BlockIDExt   `tl:"struct"`
	To           *BlockIDExt   `tl:"struct"`
	DestProof    []byte        `tl:"bytes"`
	ConfigProof  []byte        `tl:"bytes"`
	SignatureSet *SignatureSet `tl:"struct boxed"`
}

type BlockTransactions

type BlockTransactions struct {
	ID             *BlockIDExt     `tl:"struct"`
	ReqCount       int32           `tl:"int"`
	Incomplete     bool            `tl:"bool"`
	TransactionIds []TransactionID `tl:"vector struct"`
	Proof          []byte          `tl:"bytes"`
}

type BlockchainConfig

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

func (*BlockchainConfig) All

func (b *BlockchainConfig) All() map[int32]*cell.Cell

func (*BlockchainConfig) Get

func (b *BlockchainConfig) Get(id int32) *cell.Cell

type ConfigAll

type ConfigAll struct {
	Mode        int         `tl:"int"`
	ID          *BlockIDExt `tl:"struct"`
	StateProof  *cell.Cell  `tl:"cell"`
	ConfigProof *cell.Cell  `tl:"cell"`
}

type ContractExecError

type ContractExecError struct {
	Code int32
}

func (ContractExecError) Error

func (e ContractExecError) Error() string

func (ContractExecError) Is

func (e ContractExecError) Is(err error) bool

type CurrentTime

type CurrentTime struct {
	Now uint32 `tl:"int"`
}

type ExecutionResult

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

func NewExecutionResult

func NewExecutionResult(data []any) *ExecutionResult

func (ExecutionResult) AsTuple

func (r ExecutionResult) AsTuple() []any

func (ExecutionResult) Builder

func (r ExecutionResult) Builder(index uint) (*cell.Builder, error)

func (ExecutionResult) Cell

func (r ExecutionResult) Cell(index uint) (*cell.Cell, error)

func (ExecutionResult) Int

func (r ExecutionResult) Int(index uint) (*big.Int, error)

func (ExecutionResult) IsNil

func (r ExecutionResult) IsNil(index uint) (bool, error)

func (ExecutionResult) MustBuilder

func (r ExecutionResult) MustBuilder(index uint) *cell.Builder

func (ExecutionResult) MustCell

func (r ExecutionResult) MustCell(index uint) *cell.Cell

func (ExecutionResult) MustInt

func (r ExecutionResult) MustInt(index uint) *big.Int

func (ExecutionResult) MustIsNil

func (r ExecutionResult) MustIsNil(index uint) bool

func (ExecutionResult) MustSlice

func (r ExecutionResult) MustSlice(index uint) *cell.Slice

func (ExecutionResult) MustTuple

func (r ExecutionResult) MustTuple(index uint) []any

func (ExecutionResult) Slice

func (r ExecutionResult) Slice(index uint) (*cell.Slice, error)

func (ExecutionResult) Tuple

func (r ExecutionResult) Tuple(index uint) ([]any, error)

type GetAccountState

type GetAccountState struct {
	ID      *BlockIDExt `tl:"struct"`
	Account AccountID   `tl:"struct"`
}

type GetAllShardsInfo

type GetAllShardsInfo struct {
	ID *BlockIDExt `tl:"struct"`
}

type GetBlockData

type GetBlockData struct {
	ID *BlockIDExt `tl:"struct"`
}

type GetBlockProof

type GetBlockProof struct {
	Mode        uint32      `tl:"flags"`
	KnownBlock  *BlockIDExt `tl:"struct"`
	TargetBlock *BlockIDExt `tl:"?0 struct"`
}

type GetConfigAll

type GetConfigAll struct {
	Mode    int32       `tl:"int"`
	BlockID *BlockIDExt `tl:"struct"`
}

type GetConfigParams

type GetConfigParams struct {
	Mode    int32       `tl:"int"`
	BlockID *BlockIDExt `tl:"struct"`
	Params  []int32     `tl:"vector int"`
}

type GetLibraries

type GetLibraries struct {
	LibraryList [][]byte `tl:"vector int256"`
}

type GetMasterchainInf

type GetMasterchainInf struct{}

type GetOneTransaction

type GetOneTransaction struct {
	ID    *BlockIDExt `tl:"struct"`
	AccID *AccountID  `tl:"struct"`
	LT    int64       `tl:"long"`
}

type GetTime

type GetTime struct{}

type GetTransactions

type GetTransactions struct {
	Limit  int32      `tl:"int"`
	AccID  *AccountID `tl:"struct"`
	LT     int64      `tl:"long"`
	TxHash []byte     `tl:"int256"`
}

type LSError

type LSError struct {
	Code int32  `tl:"int"`
	Text string `tl:"string"`
}

func (LSError) Error

func (e LSError) Error() string

func (LSError) Is

func (e LSError) Is(err error) bool

type LibraryEntry

type LibraryEntry struct {
	Hash []byte     `tl:"int256"`
	Data *cell.Cell `tl:"cell"`
}

type LibraryResult

type LibraryResult struct {
	Result []*LibraryEntry `tl:"vector struct"`
}

type ListBlockTransactions

type ListBlockTransactions struct {
	ID           *BlockIDExt     `tl:"struct"`
	Mode         uint32          `tl:"flags"`
	Count        uint32          `tl:"int"`
	After        *TransactionID3 `tl:"?7 struct"`
	ReverseOrder *True           `tl:"?6 struct"`
	WantProof    *True           `tl:"?5 struct"`
}

type LiteClient

type LiteClient interface {
	QueryLiteserver(ctx context.Context, payload tl.Serializable, result tl.Serializable) error
	StickyContext(ctx context.Context) context.Context
	StickyContextNextNode(ctx context.Context) (context.Context, error)
	StickyNodeID(ctx context.Context) uint32
}

type LookupBlock

type LookupBlock struct {
	Mode  uint32          `tl:"flags"`
	ID    *BlockInfoShort `tl:"struct"`
	LT    uint64          `tl:"?1 long"`
	UTime uint32          `tl:"?2 int"`
}

type MasterchainInfo

type MasterchainInfo struct {
	Last          *BlockIDExt     `tl:"struct"`
	StateRootHash []byte          `tl:"int256"`
	Init          *ZeroStateIDExt `tl:"struct"`
}

type Object

type Object struct{}

type PartialBlockProof

type PartialBlockProof struct {
	Complete bool        `tl:"bool"`
	From     *BlockIDExt `tl:"struct"`
	To       *BlockIDExt `tl:"struct"`
	Steps    []any       `tl:"vector struct boxed [liteServer.blockLinkForward, liteServer.blockLinkBack]"`
}

type ProofCheckPolicy

type ProofCheckPolicy int
const (
	ProofCheckPolicyUnsafe ProofCheckPolicy = iota
	ProofCheckPolicyFast                    // Without master block checks
	ProofCheckPolicySecure
)

type RunMethodResult

type RunMethodResult struct {
	Mode       uint32      `tl:"flags"`
	ID         *BlockIDExt `tl:"struct"`
	ShardBlock *BlockIDExt `tl:"struct"`
	ShardProof []byte      `tl:"?0 bytes"`
	Proof      []byte      `tl:"?0 bytes"`
	StateProof []byte      `tl:"?1 bytes"`
	InitC7     []byte      `tl:"?3 bytes"`
	LibExtras  []byte      `tl:"?4 bytes"`
	ExitCode   int32       `tl:"int"`
	Result     []byte      `tl:"?2 bytes"`
}

type RunSmcMethod

type RunSmcMethod struct {
	Mode     uint32      `tl:"int"`
	ID       *BlockIDExt `tl:"struct"`
	Account  AccountID   `tl:"struct"`
	MethodID uint64      `tl:"long"`
	Params   []byte      `tl:"bytes"`
}

type SendMessage

type SendMessage struct {
	Body []byte `tl:"bytes"`
}

type SendMessageStatus

type SendMessageStatus struct {
	Status int32 `tl:"int"`
}

type Signature

type Signature struct {
	NodeIDShort []byte `tl:"int256"`
	Signature   []byte `tl:"bytes"`
}

type SignatureSet

type SignatureSet struct {
	ValidatorSetHash int32       `tl:"int"`
	CatchainSeqno    int32       `tl:"int"`
	Signatures       []Signature `tl:"vector struct"`
}

type TransactionID

type TransactionID struct {
	Flags   uint32 `tl:"flags"`
	Account []byte `tl:"?0 int256"`
	LT      uint64 `tl:"?1 long"`
	Hash    []byte `tl:"?2 int256"`
}

type TransactionID3

type TransactionID3 struct {
	Account []byte `tl:"int256"`
	LT      uint64 `tl:"long"`
}

type TransactionInfo

type TransactionInfo struct {
	ID          *BlockIDExt `tl:"struct"`
	Proof       []byte      `tl:"bytes"`
	Transaction []byte      `tl:"bytes"`
}

func (*TransactionInfo) ToTransaction

func (t *TransactionInfo) ToTransaction(proofCheckPolicy ProofCheckPolicy, blockRootHash []byte) (*tlb.Transaction, error)

type TransactionList

type TransactionList struct {
	IDs          []*BlockIDExt `tl:"vector struct"`
	Transactions []byte        `tl:"bytes"`
}

type TransactionShortInfo

type TransactionShortInfo struct {
	Account []byte
	LT      uint64
	Hash    []byte
}

func (*TransactionShortInfo) ID3

type True

type True struct{}

type ValidatorItemHashable

type ValidatorItemHashable struct {
	Key    []byte `tl:"int256"`
	Weight uint64 `tl:"long"`
	Addr   []byte `tl:"int256"`
}

type ValidatorSetHashable

type ValidatorSetHashable struct {
	CCSeqno    uint32                  `tl:"int"`
	Validators []ValidatorItemHashable `tl:"vector struct"`
}

type ValidatorSetPRNG

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

func NewValidatorSetPRNG

func NewValidatorSetPRNG(shard int64, workchain int32, catchainSeqno uint32, seed []byte) *ValidatorSetPRNG

func (*ValidatorSetPRNG) NextRanged

func (r *ValidatorSetPRNG) NextRanged(rg uint64) uint64

func (*ValidatorSetPRNG) NextUint64

func (r *ValidatorSetPRNG) NextUint64() uint64

type WaitMasterchainSeqno

type WaitMasterchainSeqno struct {
	Seqno   int32 `tl:"int"`
	Timeout int32 `tl:"int"`
}

type ZeroStateIDExt

type ZeroStateIDExt struct {
	Workchain int32  `tl:"int"`
	RootHash  []byte `tl:"int256"`
	FileHash  []byte `tl:"int256"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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