upgradeable

package
v0.0.0-...-b50a61c Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: MIT Imports: 10 Imported by: 0

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(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 {
				contractType := bindings.PkgLib + ".versioning.Upgradeable"
				body, err = codec.WrapMessage(contractType, 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)

			bodyAny := &codec.MessageEnvelope[any]{
				Metadata: body.Metadata,
				Payload:  body.Payload,
				Cell:     body.Cell,
				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