router

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: 15 Imported by: 7

Documentation

Index

Constants

View Source
const (
	OutgoingOpcodeCCIPSendACK  = 0x78d0f21e
	OutgoingOpcodeCCIPSendNACK = 0x5a45d434
)

Variables

View Source
var (
	OpcodeApplyRampUpdates   = tvm.MustExtractMagic(reflect.TypeOf(ApplyRampUpdates{}))
	OpcodeCCIPSend           = tvm.MustExtractMagic(reflect.TypeOf(CCIPSend{}))
	OpcodeRouteMessage       = tvm.MustExtractMagic(reflect.TypeOf(RouteMessage{}))
	OpcodeCCIPReceiveConfirm = tvm.MustExtractMagic(reflect.TypeOf(CCIPReceiveConfirm{}))
	OpcodeMessageSent        = tvm.MustExtractMagic(reflect.TypeOf(MessageSent{}))
	OpcodeMessageRejected    = tvm.MustExtractMagic(reflect.TypeOf(MessageRejected{}))
	OpcodeRMNRemoteCurse     = tvm.MustExtractMagic(reflect.TypeOf(RMNRemoteCurse{}))
	OpcodeRMNRemoteUncurse   = tvm.MustExtractMagic(reflect.TypeOf(RMNRemoteUncurse{}))
)
View Source
var GetDestChainSelectors = tvm.NewNoArgsGetter(tvm.NoArgsOpts[[]uint64]{
	Name: "destChainSelectors",
	Decoder: tvm.NewResultDecoder(func(r *ton.ExecutionResult) ([]uint64, error) {
		selectors, err := parser.ParseLispTuple[*big.Int](r.AsTuple())
		if err != nil {
			return nil, err
		}
		return lo.Map(selectors, func(x *big.Int, _ int) uint64 { return x.Uint64() }), nil
	}),
})

GetDestChainSelectors gets all destination chain selectors

View Source
var GetOnRamp = tvm.Getter[uint64, *address.Address]{
	Name: "onRamp",
	Decoder: tvm.NewResultDecoder(func(r *ton.ExecutionResult) (*address.Address, error) {
		onRampSlice, err := r.Slice(0)
		if err != nil {
			return nil, err
		}
		return onRampSlice.LoadAddr()
	}),
}

GetOnRamp gets the onRamp address for a given destination chain selector

GetOwner gets the owner of the Router contract

View Source
var GetPendingOwner = ownable2step.GetPendingOwner

GetPendingOwner gets the pending owner of the Router contract

View Source
var GetRMNOwner = ownable2step.MakeGetOwner("rmn")
View Source
var GetRMNPendingOwner = ownable2step.MakeGetPendingOwner("rmn")
View Source
var GetVerifyNotCursed = tvm.Getter[*big.Int, bool]{
	Name: "verifyNotCursed",
	Decoder: tvm.NewResultDecoder(func(r *ton.ExecutionResult) (bool, error) {

		notCursed, err := r.Int(0)
		if err != nil {
			return false, fmt.Errorf("failed to parse verifyNotCursed result: %w", err)
		}

		return notCursed.Cmp(big.NewInt(0)) != 0, nil
	}),
}

GetVerifyNotCursed checks if the input subject is not cursed.

Functions

This section is empty.

Types

type ApplyRampUpdates

type ApplyRampUpdates struct {
	QueryID        uint64    `tlb:"## 64"`
	OnRampUpdates  *OnRamps  `tlb:"maybe ."`
	OffRampAdds    *OffRamps `tlb:"maybe ."`
	OffRampRemoves *OffRamps `tlb:"maybe ."`
	// contains filtered or unexported fields
}

crc32("ApplyRampUpdates")

type CCIPReceiveConfirm

type CCIPReceiveConfirm struct {
	ExecID *big.Int `tlb:"## 192"`
	// contains filtered or unexported fields
}

type CCIPSend

type CCIPSend struct {
	QueryID           uint64                         `tlb:"## 64"`
	DestChainSelector uint64                         `tlb:"## 64"`
	Receiver          common.CrossChainAddress       `tlb:"."`
	Data              common.SnakeBytes              `tlb:"^"`
	TokenAmounts      common.SnakedCell[TokenAmount] `tlb:"^"`
	FeeToken          *address.Address               `tlb:"addr"`
	ExtraArgs         *cell.Cell                     `tlb:"^"`
	// contains filtered or unexported fields
}

type CCIPSendACK

type CCIPSendACK struct {
	QueryID   uint64   `tlb:"## 64"`
	MessageID *big.Int `tlb:"## 256"`
	// contains filtered or unexported fields
}

type CCIPSendNACK

type CCIPSendNACK struct {
	QueryID uint64   `tlb:"## 64"`
	Error   *big.Int `tlb:"## 256"`
	// contains filtered or unexported fields
}

type ChainSelector

type ChainSelector struct {
	Value uint64 `tlb:"## 64"`
}

ChainSelector is a wrapper uint64 to support SnakedCell encoding.

type ExitCode

type ExitCode tvm.ExitCode
const (
	ErrorDestChainNotEnabled ExitCode = ExitCode(57100 + iota)
	ErrorSourceChainNotEnabled
	SenderIsNotOffRamp
	OffRampNotSetForSelector
	OffRampAddressMismatch
	ErrorSubjectCursed
	ErrorNotOnRamp
	ErrorMissingTokenAmounts
	ErrorNoMultiTokenTransfers
	ErrorInsufficientFee
)

func (ExitCode) NewFrom

func (ExitCode) NewFrom(ec tvm.ExitCode) (ExitCode, error)

func (ExitCode) String

func (i ExitCode) String() string

type MessageRejected

type MessageRejected struct {
	QueryID           uint64           `tlb:"## 64"`
	DestChainSelector uint64           `tlb:"## 64"`
	Sender            *address.Address `tlb:"addr"`
	Error             *big.Int         `tlb:"## 256"`
	// contains filtered or unexported fields
}

type MessageSent

type MessageSent struct {
	QueryID           uint64           `tlb:"## 64"`
	MessageID         *big.Int         `tlb:"## 256"`
	DestChainSelector uint64           `tlb:"## 64"`
	Sender            *address.Address `tlb:"addr"`
	// contains filtered or unexported fields
}

type OffRamps

type OffRamps struct {
	SourceChainSelectors common.SnakedCell[ChainSelector] `tlb:"^"`
	OffRamp              *address.Address                 `tlb:"addr"`
}

type OnRamps

type OnRamps struct {
	DestChainSelectors common.SnakedCell[ChainSelector] `tlb:"^"`
	OnRamps            *address.Address                 `tlb:"addr"`
}

type RMNOwnableMessage

type RMNOwnableMessage[T ownable2step.InMessage | any] struct {
	Content *codec.MessageEnvelope[T] `tlb:"."`
	// contains filtered or unexported fields
}

type RMNRemote

type RMNRemote struct {
	Admin          ownable2step.Storage `tlb:"."`
	CursedSubjects *cell.Dictionary     `tlb:"dict 128"`
	ForwardUpdates *cell.Dictionary     `tlb:"dict 267"`
}

type RMNRemoteCurse

type RMNRemoteCurse struct {
	QueryID  uint64                     `tlb:"## 64"`
	Subjects common.SnakedCell[Subject] `tlb:"^"`
	// contains filtered or unexported fields
}

RMNRemoteCurse message type for cursing subjects on the router.

type RMNRemoteUncurse

type RMNRemoteUncurse struct {
	QueryID  uint64                     `tlb:"## 64"`
	Subjects common.SnakedCell[Subject] `tlb:"^"`
	// contains filtered or unexported fields
}

RMNRemoteUncurse message type for uncursing subjects on the router.

type RouteMessage

type RouteMessage struct {
	Message  offramp.Any2TVMMessage `tlb:"^"`
	ExecID   *big.Int               `tlb:"## 192"`
	Receiver *address.Address       `tlb:"addr"`
	GasLimit tlb.Coins              `tlb:"."`
	// contains filtered or unexported fields
}

type Storage

type Storage struct {
	ID            uint32               `tlb:"## 32"`
	Ownable       ownable2step.Storage `tlb:"."`
	WrappedNative *address.Address     `tlb:"addr"`
	OnRamps       *cell.Dictionary     `tlb:"dict 64"`
	OffRamps      *cell.Dictionary     `tlb:"dict 64"`
	RMNRemote     RMNRemote            `tlb:"^"`
}

type Subject

type Subject struct {
	Value *big.Int `tlb:"## 128"`
}

Subject is a wrapper for uint128 to support SnakedCell encoding. Stored as *big.Int since Go doesn't have native uint128.

type TokenAmount

type TokenAmount struct {
	Amount tlb.Coins        `tlb:"."`
	Token  *address.Address `tlb:"addr"`
}

TokenAmount is a structure that holds the amount and token address for a CCIP transaction.

Jump to

Keyboard shortcuts

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