ownable2step

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GetOwner        = MakeGetOwner()        // default (owner) role - owner getter
	GetPendingOwner = MakeGetPendingOwner() // default (owner) role - pending owner getter
	AddressRes      = tvm.NewResultDecoder(func(r *ton.ExecutionResult) (*address.Address, error) {
		ownerSlice, err := r.Slice(0)
		if err != nil {
			return nil, err
		}

		return ownerSlice.LoadAddr()
	})
)

Functions

func MakeGetOwner

func MakeGetOwner(role ...string) tvm.Getter[struct{}, *address.Address]

MakeGetOwner creates a getter for the owner address, for a specified role (prefix).

func MakeGetPendingOwner

func MakeGetPendingOwner(role ...string) tvm.Getter[struct{}, *address.Address]

MakeGetPendingOwner creates a getter for the pending owner address, for a specified role (prefix).

Types

type AcceptOwnership

type AcceptOwnership struct {
	QueryID uint64 `tlb:"## 64"`
	// contains filtered or unexported fields
}

AcceptOwnership allows the pending owner to accept ownership of the contract.

type ExitCode

type ExitCode tvm.ExitCode
const (
	ErrorOnlyCallableByOwner ExitCode = iota + 49800 // Facility ID * 100
	ErrorCannotTransferToSelf
	ErrorMustBeProposedOwner
)

func (ExitCode) NewFrom

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

func (ExitCode) String

func (i ExitCode) String() string

type InMessage

type InMessage interface {
	TransferOwnership |
		AcceptOwnership
}

type Storage

type Storage struct {
	Owner        *address.Address `tlb:"addr"`
	PendingOwner *address.Address `tlb:"addr"`
}

Ownable2Step represents a two-step ownership structure, where an owner can set a pending owner.

Note: PendingOwner uses `tlb:"addr"` (not `tlb:"maybe addr"`) because Tolk's `address?` compiles to LDOPTSTDADDR, which reads raw MsgAddress directly. The 2-bit discriminator (addr_none$00 = null, addr_std$10 = address) already encodes nullability. Using `tlb:"maybe addr"` would add a 1-bit Maybe prefix, causing Tolk to misparse the cell.

type TransferOwnership

type TransferOwnership struct {
	QueryID  uint64           `tlb:"## 64"`
	NewOwner *address.Address `tlb:"addr"`
	// contains filtered or unexported fields
}

Sets a new pending owner. Can only be called by the current owner.

Jump to

Keyboard shortcuts

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