upgradeable

package
v0.0.0-...-f5152f3 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 10 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Upgrade = operations.NewOperation(
	"ton/ops/lib/versioning/upgradeable/upgrade",
	semver.MustParse("0.1.0"),
	"Upgrades upgradeable contracts to a new implementation",
	func(b operations.Bundle, dp *dep.DependencyProvider, in UpgradeInput) (UpgradeOutput, error) {

		messages := make([]opston.InternalMessage[any], len(in.Messages))
		for i, u := range in.Messages {
			contractProvider, err := dep.Resolve[opston.ContractCodeProvider](dp)
			if err != nil {
				return UpgradeOutput{}, fmt.Errorf("failed to resolve contract provider: %w", err)
			}

			c, err := contractProvider.GetContract(b.GetContext(), u.ContractMeta)
			if err != nil {
				return UpgradeOutput{}, fmt.Errorf("failed to get contract code: %w", err)
			}

			m := u.Message

			body := m.Body

			if body == nil {
				body, err = codec.WrapMessage(bindings.TypeUpgradeable, upgradeable.Upgrade{QueryID: 0, Code: c.Code})
				if err != nil {
					return UpgradeOutput{}, fmt.Errorf("failed to wrap upgrade message: %w", err)
				}
			}

			val := body.Value
			val.Code = c.Code
			valAny := any(val)

			bodyCell, err := tlb.ToCell(val)
			if err != nil {
				return UpgradeOutput{}, fmt.Errorf("failed to serialize upgrade body to cell: %w", err)
			}

			bodyAny := &codec.MessageEnvelope[any]{
				Metadata: body.Metadata,
				Payload:  body.Payload,
				Cell:     bodyCell,
				Value:    &valAny,
			}

			messages[i] = opston.InternalMessage[any]{
				Bounce:  m.Bounce,
				DstAddr: m.DstAddr,
				Amount:  m.Amount,
				Body:    bodyAny,
			}
		}

		_in := opston.SendMessagesInput{
			Messages: messages,
			Plan:     in.Plan,
		}

		r, err := operations.ExecuteOperation(b, opston.SendMessages, dp, _in)
		if err != nil {
			return UpgradeOutput{}, fmt.Errorf("failed to exec send messages operation: %w", err)
		}

		return UpgradeOutput(r.Output), nil
	},
)

Functions

This section is empty.

Types

type UpgradeInput

type UpgradeInput struct {
	Messages []UpgradeMessage `json:"messages"`
	Plan     bool             `json:"plan"`
}

func (UpgradeInput) IsPlan

func (in UpgradeInput) IsPlan() bool

type UpgradeMessage

type UpgradeMessage struct {
	Message      opston.InternalMessage[upgradeable.Upgrade] `json:"message"`
	ContractMeta opston.ContractMetadata                     `json:"contract_meta"`
}

type UpgradeOutput

type UpgradeOutput opston.SendMessagesOutput

func (UpgradeOutput) GetPlans

func (o UpgradeOutput) GetPlans() []opston.MessagePlanRaw

func (UpgradeOutput) GetTransaction

func (o UpgradeOutput) GetTransaction() *tlbe.Cell[tlb.Transaction]

Jump to

Keyboard shortcuts

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