cpi_guard

package
v0.0.0-...-3968f94 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const CPI_GUARD_SIZE = 1
View Source
const ProgramName = "cpi_guard"

Variables

View Source
var (
	Instruction_Enable  uint8 = 0
	Instruction_Disable uint8 = 1
)
View Source
var InstructionImplDef = binary.NewVariantDefinition(binary.Uint8TypeIDEncoding, []binary.VariantType{
	{
		"enable", (*Enable)(nil),
	},
	{
		"disable", (*Disable)(nil),
	},
})
View Source
var ProgramID common.PublicKey = common.MustPublicKeyFromBase58("11111111111111111111111111111111")

Functions

func InstructionIDToName

func InstructionIDToName(id uint8) string

InstructionIDToName returns the name of the instruction given its ID.

func SetProgramID

func SetProgramID(pubkey common.PublicKey)

Types

type CpiGuard

type CpiGuard struct {
	// Lock privileged token operations from happening via CPI
	LockCpi bool
}

CpiGuard Struct

func (*CpiGuard) MarshalWithEncoder

func (obj *CpiGuard) MarshalWithEncoder(encoder *binary.Encoder) (err error)

func (*CpiGuard) UnmarshalWithDecoder

func (obj *CpiGuard) UnmarshalWithDecoder(decoder *binary.Decoder) (err error)

type Disable

type Disable struct {
	// [0] = [WRITE] account `The account to update.`
	// [1] = [SIGNER] owner `The account's owner.`
	common.AccountMetaSlice `bin:"-"`
	// contains filtered or unexported fields
}

Disable Instruction

func NewDisableInstruction

func NewDisableInstruction(
	account common.PublicKey,
	owner common.PublicKey,
) *Disable

NewDisableInstruction

Parameters:

account: The account to update.
owner: The account's owner.

func NewDisableInstructionBuilder

func NewDisableInstructionBuilder() *Disable

NewDisableInstructionBuilder creates a new `Disable` instruction builder.

func (*Disable) Build

func (obj *Disable) Build() *Instruction

func (*Disable) EncodeToTree

func (obj *Disable) EncodeToTree(parent treeout.Branches)

func (*Disable) GetAccountAccount

func (obj *Disable) GetAccountAccount() *common.AccountMeta

GetAccountAccount gets the "account" parameter. The account to update.

func (*Disable) GetOwnerAccount

func (obj *Disable) GetOwnerAccount() *common.AccountMeta

GetOwnerAccount gets the "owner" parameter. The account's owner.

func (*Disable) MarshalWithEncoder

func (obj *Disable) MarshalWithEncoder(encoder *binary.Encoder) (err error)

func (*Disable) SetAccountAccount

func (obj *Disable) SetAccountAccount(account common.PublicKey) *Disable

SetAccountAccount sets the "account" parameter. The account to update.

func (*Disable) SetOwnerAccount

func (obj *Disable) SetOwnerAccount(owner common.PublicKey, multiSigners ...common.PublicKey) *Disable

SetOwnerAccount sets the "owner" parameter. The account's owner.

func (*Disable) SetProgramId

func (obj *Disable) SetProgramId(programId *common.PublicKey) *Disable

func (*Disable) UnmarshalWithDecoder

func (obj *Disable) UnmarshalWithDecoder(decoder *binary.Decoder) (err error)

func (*Disable) Validate

func (obj *Disable) Validate() error

func (*Disable) ValidateAndBuild

func (obj *Disable) ValidateAndBuild() (*Instruction, error)

ValidateAndBuild validates the instruction parameters and accounts; if there is a validation error, it returns the error. Otherwise, it builds and returns the instruction.

type Enable

type Enable struct {
	// [0] = [WRITE] account `The account to update.`
	// [1] = [SIGNER] owner `The account's owner.`
	common.AccountMetaSlice `bin:"-"`
	// contains filtered or unexported fields
}

Enable Instruction

func NewEnableInstruction

func NewEnableInstruction(
	account common.PublicKey,
	owner common.PublicKey,
) *Enable

NewEnableInstruction

Parameters:

account: The account to update.
owner: The account's owner.

func NewEnableInstructionBuilder

func NewEnableInstructionBuilder() *Enable

NewEnableInstructionBuilder creates a new `Enable` instruction builder.

func (*Enable) Build

func (obj *Enable) Build() *Instruction

func (*Enable) EncodeToTree

func (obj *Enable) EncodeToTree(parent treeout.Branches)

func (*Enable) GetAccountAccount

func (obj *Enable) GetAccountAccount() *common.AccountMeta

GetAccountAccount gets the "account" parameter. The account to update.

func (*Enable) GetOwnerAccount

func (obj *Enable) GetOwnerAccount() *common.AccountMeta

GetOwnerAccount gets the "owner" parameter. The account's owner.

func (*Enable) MarshalWithEncoder

func (obj *Enable) MarshalWithEncoder(encoder *binary.Encoder) (err error)

func (*Enable) SetAccountAccount

func (obj *Enable) SetAccountAccount(account common.PublicKey) *Enable

SetAccountAccount sets the "account" parameter. The account to update.

func (*Enable) SetOwnerAccount

func (obj *Enable) SetOwnerAccount(owner common.PublicKey, multiSigners ...common.PublicKey) *Enable

SetOwnerAccount sets the "owner" parameter. The account's owner.

func (*Enable) SetProgramId

func (obj *Enable) SetProgramId(programId *common.PublicKey) *Enable

func (*Enable) UnmarshalWithDecoder

func (obj *Enable) UnmarshalWithDecoder(decoder *binary.Decoder) (err error)

func (*Enable) Validate

func (obj *Enable) Validate() error

func (*Enable) ValidateAndBuild

func (obj *Enable) ValidateAndBuild() (*Instruction, error)

ValidateAndBuild validates the instruction parameters and accounts; if there is a validation error, it returns the error. Otherwise, it builds and returns the instruction.

type Instruction

type Instruction struct {
	binary.BaseVariant
	// contains filtered or unexported fields
}

func DecodeInstruction

func DecodeInstruction(accounts []*common.AccountMeta, data []byte) (*Instruction, error)

func (*Instruction) Accounts

func (obj *Instruction) Accounts() (out []*common.AccountMeta)

func (*Instruction) Data

func (obj *Instruction) Data() ([]byte, error)

func (*Instruction) EncodeToTree

func (obj *Instruction) EncodeToTree(parent treeout.Branches)

func (*Instruction) MarshalWithEncoder

func (obj *Instruction) MarshalWithEncoder(encoder *binary.Encoder) error

func (*Instruction) ProgramID

func (obj *Instruction) ProgramID() common.PublicKey

func (*Instruction) TextEncode

func (obj *Instruction) TextEncode(encoder *text.Encoder, option *text.Option) error

func (*Instruction) UnmarshalWithDecoder

func (obj *Instruction) UnmarshalWithDecoder(decoder *binary.Decoder) error

Jump to

Keyboard shortcuts

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