utils

package
v0.0.0-...-89a3e1e Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 36 Imported by: 6

Documentation

Index

Constants

View Source
const (
	// ContractsVersionLocal should be used only for development.
	ContractsVersionLocal = "local"

	ContractsPackageLatestSupported = "github.com/smartcontractkit/chainlink-ton@contracts/1.6.0" // Feb 19, 2026

	PackageMetadataFile = "contracts-pkg.json"
)

Variables

View Source
var DeployableCodeHash = func() []byte {
	v, err := hex.DecodeString("61ef207c8cb9d963f1cca85894f3c279edcba27490c192f0be6c3be3f6a520fc")
	if err != nil {
		panic(fmt.Sprintf("invalid deployable code hash: %v", err))
	}
	return v
}()

Functions

func AssetNameFromReleaseTag

func AssetNameFromReleaseTag(tag string) string

AssetNameFromReleaseTag derives the release asset filename from a release tag. Convention: replace "/" and "+" with "-" and append ".tar.gz". For example, "contracts/1.6.0" → "contracts-1.6.0.tar.gz". For example, "contracts/1.6.0+abc123" → "contracts-1.6.0-abc123.tar.gz".

func CreateClient

func CreateClient(ctx context.Context, url string) (*ton.APIClient, error)

func CreateRandomHighloadWallet deprecated

func CreateRandomHighloadWallet(client ton.APIClientWrapped) (*wallet.Wallet, error)

Deprecated: use tvm.NewRandomHighloadV3TestWallet instead

func CreateRandomWallet deprecated

func CreateRandomWallet(client ton.APIClientWrapped, version wallet.VersionConfig, option wallet.Option) (*wallet.Wallet, error)

Deprecated: use tvm.NewRandomTestWallet instead

func DataStoreToAddressBook

func DataStoreToAddressBook(ds *ds.MemoryDataStore) (*cldf.AddressBookMap, error)

DataStoreToAddressBook is a temp function to transform a DataStore to the legacy AddressBook. Couldn't find any utility function to do this. Once we adopt this new change set in CLD we can remove returning AddressBook at all :)

func DownloadArtifacts

func DownloadArtifacts(ctx context.Context, in DownloadArtifactsOpts) (string, error)

func FundWallets

func FundWallets(t *testing.T, client ton.APIClientWrapped, recipients []*address.Address, amounts []tlb.Coins) error

func FundWalletsNoT

func FundWalletsNoT(client ton.APIClientWrapped, recipients []*address.Address, amounts []tlb.Coins) error

func FundWalletsWithCtx

func FundWalletsWithCtx(ctx context.Context, client ton.APIClientWrapped, recipients []*address.Address, amounts []tlb.Coins) error

func GetLocalnetFunderWallet deprecated

func GetLocalnetFunderWallet(client ton.APIClientWrapped) (*wallet.Wallet, error)

Deprecated: use tvm.MyLocalTONWalletDefault instead

func ReadCompiledContract

func ReadCompiledContract(contractMeta ton.ContractMetadata, pkgPath string, meta *ContractPackageMetadata) (ton.CompiledContract, error)

ReadCompiledContract reads a single compiled contract from pkgPath using the provided metadata. If meta is nil it is loaded from the package-metadata file in pkgPath.

pkgPath is the directory where the package files (contracts-pkg.json + *.compiled.json) live. It must already be present on disk; callers are responsible for resolving / downloading the package before calling this function.

func StartChain

func StartChain(t *testing.T, chainID uint64, once *sync.Once) (cldf_ton.Chain, error)

StartChain creates a TON chain using the CLDF CTFChainProvider. The once parameter ensures CTF network is only initialized once across test suite.

func ToTONAddress

func ToTONAddress(ref datastore.AddressRef) (*address.Address, error)

ToTONAddress formats a datastore.AddressRef into a TON *address.Address.

Types

type Artifact

type Artifact struct {
	Filename string
	Data     []byte
}

Artifact is a generic single file from a contracts package. It can be reused by other chain implementations.

type CompiledContractsPackageKind

type CompiledContractsPackageKind string
const (
	CompiledContractsPackageKindLocal   CompiledContractsPackageKind = "local"
	CompiledContractsPackageKindAbsPath CompiledContractsPackageKind = "abs_path"
	CompiledContractsPackageKindRepoRef CompiledContractsPackageKind = "repo_ref"
)

type ContractEntryMetadata

type ContractEntryMetadata struct {
	Path    string `json:"path"`
	Version string `json:"version"`
}

ContractEntryMetadata holds per-contract metadata from contracts-pkg.json.

type ContractPackageMetadata

type ContractPackageMetadata struct {
	Version   string                           `json:"version"`
	Contracts map[string]ContractEntryMetadata `json:"contracts"`
}

ContractPackageMetadata is the schema for contracts-pkg.json bundled in each release.

func LoadPackageMetadata

func LoadPackageMetadata(pkgPath string) (*ContractPackageMetadata, error)

func (*ContractPackageMetadata) ReadFrom

func (m *ContractPackageMetadata) ReadFrom(pkgPath string) error

readPackageMetadata reads contracts-pkg.json from pkgPath. Falls back to defaultPackageMetadata when the file is absent (pre-1.6.1 releases).

type ContractsPackageRef

type ContractsPackageRef struct {
	Kind CompiledContractsPackageKind

	// for KindAbsPath
	AbsPath string

	// for KindRepoRef
	Host         string
	Organization string
	Repository   string
	Tag          string
}

func ParseCompiledContractsPackageRef

func ParseCompiledContractsPackageRef(s string) (*ContractsPackageRef, error)

func (*ContractsPackageRef) FetchPackage

func (ref *ContractsPackageRef) FetchPackage(ctx context.Context, log logger.Logger, pkgsDir string) (string, error)

FetchPackage returns the local directory for a package, downloading and extracting it first when it is a remote GitHub release (disk-cached).

type DownloadArtifactsOpts

type DownloadArtifactsOpts struct {
	Host         string
	Organization string
	Repository   string
	Release      string
	Asset        string
	PkgsDir      string // base directory for the local package cache; empty = use default
}

DownloadArtifactsOpts specifies what to download and where to cache it.

type RetrieveCompiledContractsOpts

type RetrieveCompiledContractsOpts struct {
	Package   string
	Contracts []string // Fully qualified contract names from pkg/bindings/index.go (e.g. bindings.TypeRouter)
	PkgsDir   string   // optional base directory for the local package cache (passed through to DownloadArtifacts)
}

Package e.g:

  • github.com/smartcontractkit/chainlink-ton@contracts/v1.6.3
  • /usr/my-contracts-build
  • local (maps to {repo-root}/contracts/build)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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