ocr

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: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CommitCallData = func(
	rawReportCtx [64]byte,
	report ocr3types.ReportWithInfo[[]byte],
	signatures [][96]byte,
) (*cell.Cell, error) {
	reportCell, err := cell.FromBOC(report.Report)
	if err != nil {
		return nil, err
	}

	var commitReport ocr.CommitReport
	if err = tlb.LoadFromCell(&commitReport, reportCell.BeginParse()); err != nil {
		return nil, fmt.Errorf("cannot decode commit report from cell: %w", err)
	}

	sigs := make(common.SnakedCell[ocr.SignatureEd25519], len(signatures))
	for i, sig := range signatures {
		sigs[i] = ocr.SignatureEd25519{Data: sig[:]}
	}

	commit := offramp.Commit{
		QueryID:          0,
		ConfigDigest:     rawReportCtx[:],
		CommitReport:     commitReport,
		SignatureEd25519: sigs,
	}

	commitCell, err := tlb.ToCell(commit)
	if err != nil {
		return nil, fmt.Errorf("failed to encode commit to cell: %w", err)
	}

	return commitCell, nil
}

CommitCallData creates the call data for the OffRamp_Commit method

View Source
var DefaultConfigSet = Config{
	CommitPriceUpdateOnlyCostTON: 0.05,
	CommitPriceAndRootCostTON:    0.07,
	ExecuteCostTON:               0.085,
}
View Source
var ExecuteCallData = func(
	rawReportCtx [64]byte,
	report ocr3types.ReportWithInfo[[]byte],
	signatures [][96]byte,
) (*cell.Cell, error) {
	reportCell, err := cell.FromBOC(report.Report)
	if err != nil {
		return nil, fmt.Errorf("failed to decode BOC (len=%d, hex=%x): %w", len(report.Report), report.Report, err)
	}

	// Decode as single ExecuteReport (not array) since TON supports single chain only
	var executeReport ocr.ExecuteReport
	if err = tlb.LoadFromCell(&executeReport, reportCell.BeginParse()); err != nil {
		return nil, fmt.Errorf("cannot decode execute report from cell (reportLen=%d, cellBits=%d, cellRefs=%d): %w",
			len(report.Report), reportCell.BitsSize(), reportCell.RefsNum(), err)
	}

	execute := offramp.Execute{
		QueryID:       0,
		ConfigDigest:  rawReportCtx[:],
		ExecuteReport: executeReport,
	}

	executeCell, err := tlb.ToCell(execute)
	if err != nil {
		return nil, fmt.Errorf("failed to encode execute to cell: %w", err)
	}

	return executeCell, nil
}

ExecuteCallData creates the call data for the OffRamp_Execute method

Functions

func NewCCIPTransmitter

func NewCCIPTransmitter(
	txm txm.TxManager,
	lggr logger.Logger,
	offrampAddress string,
	toEd25519CalldataFn ToEd25519CalldataFunc,
	cfg *Config,
) (ocr3types.ContractTransmitter[[]byte], error)

Types

type Config

type Config struct {
	CommitPriceUpdateOnlyCostTON float64 // Cost in TON for commit price update only (no merkle roots)
	CommitPriceAndRootCostTON    float64 // Cost in TON for commit price update with merkle roots
	ExecuteCostTON               float64 // Cost in TON for execute
}

Config holds configuration parameters for the Contract Transmitter. NOTE: when adding new fields, please update ApplyDefaults, DefaultConfigSet, and ValidateConfig accordingly. Also check toml_test.go TestNewDecodedTOMLConfig() to ensure new fields are tested there.

func (*Config) ApplyDefaults

func (c *Config) ApplyDefaults()

func (*Config) ValidateConfig

func (c *Config) ValidateConfig() (err error)

type ToEd25519CalldataFunc

type ToEd25519CalldataFunc func(
	rawReportCtxBytes [64]byte,
	report ocr3types.ReportWithInfo[[]byte],
	signatures [][96]byte,
) (cell *cell.Cell, err error)

Jump to

Keyboard shortcuts

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