bindings

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: 21 Imported by: 13

Documentation

Index

Constants

View Source
const (
	PkgLib  = "link.chain.ton.lib"
	PkgCCIP = "link.chain.ton.ccip"
	PkgMCMS = "link.chain.ton.mcms"

	// Third-party contract types
	PkgJetton = "com.github.ton-blockchain.jetton-contract"

	// Libs and traits
	TypeOwnable      = PkgLib + ".access.Ownable"
	TypeRBAC         = PkgLib + ".access.RBAC"
	TypeWithdrawable = PkgLib + ".funding.Withdrawable"
	TypeUpgradeable  = PkgLib + ".versioning.Upgradeable"

	// MCMS
	TypeMCMS     = PkgMCMS + ".MCMS"
	TypeTimelock = PkgMCMS + ".Timelock"

	// CCIP
	TypeRouter          = PkgCCIP + ".Router"
	TypeOnRamp          = PkgCCIP + ".OnRamp"
	TypeOffRamp         = PkgCCIP + ".OffRamp"
	TypeFeeQuoter       = PkgCCIP + ".FeeQuoter"
	TypeSendExecutor    = PkgCCIP + ".CCIPSendExecutor"
	TypeDeployable      = PkgCCIP + ".Deployable"
	TypeMerkleRoot      = PkgCCIP + ".MerkleRoot"
	TypeReceiveExecutor = PkgCCIP + ".ReceiveExecutor"
	TypeTestReceiver    = PkgCCIP + ".test.Receiver"

	// Jetton
	TypeJettonWallet = PkgJetton + ".contracts.jetton-wallet"
	TypeJettonMinter = PkgJetton + ".contracts.jetton-minter"
)

TODO we should use a type alias for these, sometihng like ContractTypeLong

Variables

View Source
var AllContractTypes = []struct {
	SimpleName   string
	ContractType string
}{
	{"Router", TypeRouter},
	{"FeeQuoter", TypeFeeQuoter},
	{"OnRamp", TypeOnRamp},
	{"OffRamp", TypeOffRamp},
	{"SendExecutor", TypeSendExecutor},
	{"Deployable", TypeDeployable},
	{"MerkleRoot", TypeMerkleRoot},
	{"ReceiveExecutor", TypeReceiveExecutor},
	{"TestReceiver", TypeTestReceiver},
	{"Timelock", TypeTimelock},
	{"MCMS", TypeMCMS},
}

AllContractTypes lists every fully qualified name for contracts present in the bindings

View Source
var DefaultTraceStopCondition tracetracking.StopCondition = func(parent, current *tracetracking.ReceivedMessage) (bool, error) {

	if current.InternalMsg == nil {
		return false, nil
	}

	ec, err := current.ExitCode()
	if err != nil {
		return false, fmt.Errorf("failed to get exit code: %w", err)
	}

	opcodeCurrent, err := tvm.ExtractOpcode(current.InternalMsg.Body)
	if err != nil {
		return false, fmt.Errorf("failed to extract opcode from current message: %w", err)
	}

	if ec == tvm.ExitCodeComputeSkipReasonNoState {
		fmt.Printf("Stopping trace tracking due to NoState exit code on opcode %d\n", opcodeCurrent)
		switch uint64(opcodeCurrent) {
		case 0:
			return true, nil
		case rbac.OpcodeRoleGranted:
			return true, nil
		case rbac.OpcodeRoleRevoked:
			return true, nil
		}
	}

	if parent.InternalMsg == nil {
		return false, nil
	}

	opcodeParent, err := tvm.ExtractOpcode(parent.InternalMsg.Body)
	if err != nil {
		return false, fmt.Errorf("failed to extract opcode from parent message: %w", err)
	}

	switch uint64(opcodeParent) {

	case offramp.OpcodeCCIPReceive:

		return uint64(opcodeCurrent) != router.OpcodeCCIPReceiveConfirm, nil
	}

	return false, nil
}

DefaultTraceStopCondition is the default policy for bounded trace tracking - stopping message (DAG) trace tracking in the context of MCMS/CCIP.

Notice: we expect account contracts (e.g., Wallet contracts, MCMS/Timelock, multisigs, etc) to accept all incoming messages (replies) and not reject with 0xffff (wrong opcode) but accept/ignore.

Map of TLBs keyed by contract type

View Source
var TypeToGetterMap = map[string]GetterMap{

	TypeRouter: {
		"owner":              router.GetOwner,
		"pendingOwner":       router.GetPendingOwner,
		"rmn_owner":          router.GetRMNOwner,
		"rmn_pendingOwner":   router.GetRMNPendingOwner,
		"onRamp":             router.GetOnRamp,
		"destChainSelectors": router.GetDestChainSelectors,
	},
	TypeOnRamp: {
		"owner":              onramp.GetOwner,
		"pendingOwner":       onramp.GetPendingOwner,
		"destChainConfig":    onramp.GetDestChainConfig,
		"dynamicConfig":      onramp.GetDynamicConfig,
		"staticConfig":       onramp.GetStaticConfig,
		"destChainSelectors": onramp.GetDestChainSelectors,
	},
	TypeOffRamp: {
		"owner":                offramp.GetOwner,
		"pendingOwner":         offramp.GetPendingOwner,
		"ocr3Config":           offramp.GetOCR3Config,
		"config":               offramp.GetConfig,
		"sourceChainConfig":    offramp.GetSourceChainConfig,
		"sourceChainSelectors": offramp.GetSourceChainSelectors,
	},
	TypeFeeQuoter: {
		"owner":                    feequoter.GetOwner,
		"pendingOwner":             feequoter.GetPendingOwner,
		"destChainConfig":          feequoter.GetDestChainConfig,
		"destinationChainGasPrice": feequoter.GetDestinationChainGasPrice,
		"tokenPrice":               feequoter.GetTokenPrice,
		"staticConfig":             feequoter.GetStaticConfig,
		"destChainSelectors":       feequoter.GetDestChainSelectors,
	},

	"link.chain.ton.ccip.Common": {
		"typeAndVersion": common.GetTypeAndVersion,
	},

	TypeOwnable: {
		"owner":        ownable2step.GetOwner,
		"pendingOwner": ownable2step.GetPendingOwner,
	},

	TypeMCMS: {
		"getConfig":        mcms.GetConfig,
		"getOpCount":       mcms.GetOpCount,
		"getRoot":          mcms.GetRoot,
		"getRootMetadata":  mcms.GetRootMetadata,
		"getOracle":        mcms.GetOracle,
		"getOpPendingInfo": mcms.GetOpPendingInfo,
	},
	TypeTimelock: {
		"getMinDelay":        timelock.GetMinDelay,
		"getRoleMemberCount": timelock.GetRoleMemberCount,
		"getRoleMember":      timelock.GetRoleMember,
		"isOperation":        timelock.IsOperation,
		"isOperationPending": timelock.IsOperationPending,
		"isOperationReady":   timelock.IsOperationReady,
		"isOperationDone":    timelock.IsOperationDone,
		"isOperationError":   timelock.IsOperationError,
	},
}

TypeToGetterMap is a registry mapping contract types to their available getters. The outer map keys are contract type identifiers (e.g., "link.chain.ton.ccip.Router"). The inner map keys are getter method names (e.g., "owner", "onRamp"). The values are Getter[A, R] instances representing typed getter methods.

Functions

func GetBuildDir

func GetBuildDir(contractPath string) string

func GetBuildsDir

func GetBuildsDir() string

func GetRepoRootDir

func GetRepoRootDir() string

Types

type GetterMap

type GetterMap map[string]interface{}

GetterMap is a map of getter method names to their Getter definitions. This allows generic access to contract getters by name.

Directories

Path Synopsis
examples
lib
test

Jump to

Keyboard shortcuts

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