token_metadata

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 ProgramName = "token_metadata"

Variables

View Source
var (
	Instruction_Initialize      = binary.TypeID([8]byte{210, 225, 30, 162, 88, 184, 77, 141})
	Instruction_UpdateField     = binary.TypeID([8]byte{221, 233, 49, 45, 181, 202, 220, 200})
	Instruction_RemoveKey       = binary.TypeID([8]byte{234, 18, 32, 56, 89, 141, 37, 181})
	Instruction_UpdateAuthority = binary.TypeID([8]byte{215, 228, 166, 228, 84, 100, 86, 123})
	Instruction_Emit            = binary.TypeID([8]byte{250, 166, 180, 250, 13, 12, 184, 70})
)
View Source
var InstructionImplDef = binary.NewVariantDefinition(binary.AnchorTypeIDEncoding, []binary.VariantType{
	{
		"initialize", (*Initialize)(nil),
	},
	{
		"update_field", (*UpdateField)(nil),
	},
	{
		"remove_key", (*RemoveKey)(nil),
	},
	{
		"update_authority", (*UpdateAuthority)(nil),
	},
	{
		"emit", (*Emit)(nil),
	},
})
View Source
var ProgramID common.PublicKey = common.MustPublicKeyFromBase58("11111111111111111111111111111111")

Functions

func InstructionIDToName

func InstructionIDToName(id binary.TypeID) string

InstructionIDToName returns the name of the instruction given its ID.

func SetProgramID

func SetProgramID(pubkey common.PublicKey)

Types

type Emit

type Emit struct {
	// Start of range of data to emit
	Start *uint64 `bin:"optional"`
	// End of range of data to emit
	End *uint64 `bin:"optional"`
	// [0] = [] metadata `Metadata`
	common.AccountMetaSlice `bin:"-"`
	// contains filtered or unexported fields
}

Emit Instruction

func NewEmitInstruction

func NewEmitInstruction(

	start *uint64,

	end *uint64,
	metadata common.PublicKey,
) *Emit

NewEmitInstruction

Parameters:

start: Start of range of data to emit
end: End of range of data to emit
metadata: Metadata

func NewEmitInstructionBuilder

func NewEmitInstructionBuilder() *Emit

NewEmitInstructionBuilder creates a new `Emit` instruction builder.

func (*Emit) Build

func (obj *Emit) Build() *Instruction

func (*Emit) EncodeToTree

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

func (*Emit) GetMetadataAccount

func (obj *Emit) GetMetadataAccount() *common.AccountMeta

GetMetadataAccount gets the "metadata" parameter. Metadata

func (*Emit) MarshalWithEncoder

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

func (*Emit) SetEnd

func (obj *Emit) SetEnd(end *uint64) *Emit

SetEnd sets the "end" parameter.

func (*Emit) SetMetadataAccount

func (obj *Emit) SetMetadataAccount(metadata common.PublicKey, multiSigners ...common.PublicKey) *Emit

SetMetadataAccount sets the "metadata" parameter. Metadata

func (*Emit) SetProgramId

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

func (*Emit) SetStart

func (obj *Emit) SetStart(start *uint64) *Emit

SetStart sets the "start" parameter.

func (*Emit) UnmarshalWithDecoder

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

func (*Emit) Validate

func (obj *Emit) Validate() error

func (*Emit) ValidateAndBuild

func (obj *Emit) 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 Field

type Field struct {
	Name   *struct{} `bin:"optional"`
	Symbol *struct{} `bin:"optional"`
	Uri    *struct{} `bin:"optional"`
	Key    *FieldKey `bin:"optional"`
}

Field Enum

func NewField_Key

func NewField_Key(field0 string) Field

func NewField_Name

func NewField_Name() Field

func NewField_Symbol

func NewField_Symbol() Field

func NewField_Uri

func NewField_Uri() Field

func (*Field) AsKey

func (obj *Field) AsKey() FieldKey

func (*Field) IsKey

func (obj *Field) IsKey() bool

func (*Field) IsName

func (obj *Field) IsName() bool

func (*Field) IsSymbol

func (obj *Field) IsSymbol() bool

func (*Field) IsUri

func (obj *Field) IsUri() bool

func (*Field) MarshalWithEncoder

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

func (*Field) String

func (obj *Field) String() string

func (*Field) UnmarshalWithDecoder

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

type FieldKey

type FieldKey struct {
	Field0 string
}

func (*FieldKey) MarshalWithEncoder

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

func (*FieldKey) UnmarshalWithDecoder

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

type ImmutableMetadataError

type ImmutableMetadataError struct{}

ImmutableMetadataError Error: 901952961 `Token metadata has no update authority`

func (ImmutableMetadataError) Code

func (e ImmutableMetadataError) Code() int

func (ImmutableMetadataError) Error

func (e ImmutableMetadataError) Error() string

type IncorrectAccountError

type IncorrectAccountError struct{}

IncorrectAccountError Error: 901952957 `Incorrect account provided`

func (IncorrectAccountError) Code

func (e IncorrectAccountError) Code() int

func (IncorrectAccountError) Error

func (e IncorrectAccountError) Error() string

type IncorrectMintAuthorityError

type IncorrectMintAuthorityError struct{}

IncorrectMintAuthorityError Error: 901952959 `Incorrect mint authority has signed the instruction`

func (IncorrectMintAuthorityError) Code

func (IncorrectMintAuthorityError) Error

type IncorrectUpdateAuthorityError

type IncorrectUpdateAuthorityError struct{}

IncorrectUpdateAuthorityError Error: 901952960 `Incorrect metadata update authority has signed the instruction`

func (IncorrectUpdateAuthorityError) Code

func (IncorrectUpdateAuthorityError) Error

type Initialize

type Initialize struct {
	// Longer name of the token
	Name *string
	// Shortened symbol of the token
	Symbol *string
	// URI pointing to more metadata (image, video, etc.)
	Uri *string
	// [0] = [WRITE] metadata `Metadata`
	// [1] = [] updateAuthority `Update authority`
	// [2] = [] mint `Mint`
	// [3] = [SIGNER] mintAuthority `Mint authority`
	common.AccountMetaSlice `bin:"-"`
	// contains filtered or unexported fields
}

Initialize Instruction

func NewInitializeInstruction

func NewInitializeInstruction(
	name string,
	symbol string,
	uri string,
	metadata common.PublicKey,
	updateAuthority common.PublicKey,
	mint common.PublicKey,
	mintAuthority common.PublicKey,
) *Initialize

NewInitializeInstruction

Parameters:

name: Longer name of the token
symbol: Shortened symbol of the token
uri: URI pointing to more metadata (image, video, etc.)
metadata: Metadata
updateAuthority: Update authority
mint: Mint
mintAuthority: Mint authority

func NewInitializeInstructionBuilder

func NewInitializeInstructionBuilder() *Initialize

NewInitializeInstructionBuilder creates a new `Initialize` instruction builder.

func (*Initialize) Build

func (obj *Initialize) Build() *Instruction

func (*Initialize) EncodeToTree

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

func (*Initialize) GetMetadataAccount

func (obj *Initialize) GetMetadataAccount() *common.AccountMeta

GetMetadataAccount gets the "metadata" parameter. Metadata

func (*Initialize) GetMintAccount

func (obj *Initialize) GetMintAccount() *common.AccountMeta

GetMintAccount gets the "mint" parameter. Mint

func (*Initialize) GetMintAuthorityAccount

func (obj *Initialize) GetMintAuthorityAccount() *common.AccountMeta

GetMintAuthorityAccount gets the "mintAuthority" parameter. Mint authority

func (*Initialize) GetUpdateAuthorityAccount

func (obj *Initialize) GetUpdateAuthorityAccount() *common.AccountMeta

GetUpdateAuthorityAccount gets the "updateAuthority" parameter. Update authority

func (*Initialize) MarshalWithEncoder

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

func (*Initialize) SetMetadataAccount

func (obj *Initialize) SetMetadataAccount(metadata common.PublicKey) *Initialize

SetMetadataAccount sets the "metadata" parameter. Metadata

func (*Initialize) SetMintAccount

func (obj *Initialize) SetMintAccount(mint common.PublicKey) *Initialize

SetMintAccount sets the "mint" parameter. Mint

func (*Initialize) SetMintAuthorityAccount

func (obj *Initialize) SetMintAuthorityAccount(mintAuthority common.PublicKey, multiSigners ...common.PublicKey) *Initialize

SetMintAuthorityAccount sets the "mintAuthority" parameter. Mint authority

func (*Initialize) SetName

func (obj *Initialize) SetName(name string) *Initialize

SetName sets the "name" parameter.

func (*Initialize) SetProgramId

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

func (*Initialize) SetSymbol

func (obj *Initialize) SetSymbol(symbol string) *Initialize

SetSymbol sets the "symbol" parameter.

func (*Initialize) SetUpdateAuthorityAccount

func (obj *Initialize) SetUpdateAuthorityAccount(updateAuthority common.PublicKey) *Initialize

SetUpdateAuthorityAccount sets the "updateAuthority" parameter. Update authority

func (*Initialize) SetUri

func (obj *Initialize) SetUri(uri string) *Initialize

SetUri sets the "uri" parameter.

func (*Initialize) UnmarshalWithDecoder

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

func (*Initialize) Validate

func (obj *Initialize) Validate() error

func (*Initialize) ValidateAndBuild

func (obj *Initialize) 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

type KeyNotFoundError

type KeyNotFoundError struct{}

KeyNotFoundError Error: 901952962 `Key not found in metadata account`

func (KeyNotFoundError) Code

func (e KeyNotFoundError) Code() int

func (KeyNotFoundError) Error

func (e KeyNotFoundError) Error() string

type MintHasNoMintAuthorityError

type MintHasNoMintAuthorityError struct{}

MintHasNoMintAuthorityError Error: 901952958 `Mint has no mint authority`

func (MintHasNoMintAuthorityError) Code

func (MintHasNoMintAuthorityError) Error

type ProgramError

type ProgramError interface {
	Code() int
	Error() string
}

func GetTokenMetadataErrorFromCode

func GetTokenMetadataErrorFromCode(code int) ProgramError

func GetTokenMetadataErrorFromName

func GetTokenMetadataErrorFromName(name string) ProgramError

type RemoveKey

type RemoveKey struct {
	// If the idempotent flag is set to true, then the instruction will not,error if the key does not exist
	Idempotent *bool
	// Key to remove in the additional metadata portion
	Key *string
	// [0] = [WRITE] metadata `Metadata`
	// [1] = [SIGNER] updateAuthority `Update authority`
	common.AccountMetaSlice `bin:"-"`
	// contains filtered or unexported fields
}

RemoveKey Instruction

func NewRemoveKeyInstruction

func NewRemoveKeyInstruction(
	idempotent bool,
	key string,
	metadata common.PublicKey,
	updateAuthority common.PublicKey,
) *RemoveKey

NewRemoveKeyInstruction

Parameters:

idempotent: If the idempotent flag is set to true, then the instruction will not
error if the key does not exist

key: Key to remove in the additional metadata portion
metadata: Metadata
updateAuthority: Update authority

func NewRemoveKeyInstructionBuilder

func NewRemoveKeyInstructionBuilder() *RemoveKey

NewRemoveKeyInstructionBuilder creates a new `RemoveKey` instruction builder.

func (*RemoveKey) Build

func (obj *RemoveKey) Build() *Instruction

func (*RemoveKey) EncodeToTree

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

func (*RemoveKey) GetMetadataAccount

func (obj *RemoveKey) GetMetadataAccount() *common.AccountMeta

GetMetadataAccount gets the "metadata" parameter. Metadata

func (*RemoveKey) GetUpdateAuthorityAccount

func (obj *RemoveKey) GetUpdateAuthorityAccount() *common.AccountMeta

GetUpdateAuthorityAccount gets the "updateAuthority" parameter. Update authority

func (*RemoveKey) MarshalWithEncoder

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

func (*RemoveKey) SetIdempotent

func (obj *RemoveKey) SetIdempotent(idempotent bool) *RemoveKey

SetIdempotent sets the "idempotent" parameter.

func (*RemoveKey) SetKey

func (obj *RemoveKey) SetKey(key string) *RemoveKey

SetKey sets the "key" parameter.

func (*RemoveKey) SetMetadataAccount

func (obj *RemoveKey) SetMetadataAccount(metadata common.PublicKey) *RemoveKey

SetMetadataAccount sets the "metadata" parameter. Metadata

func (*RemoveKey) SetProgramId

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

func (*RemoveKey) SetUpdateAuthorityAccount

func (obj *RemoveKey) SetUpdateAuthorityAccount(updateAuthority common.PublicKey, multiSigners ...common.PublicKey) *RemoveKey

SetUpdateAuthorityAccount sets the "updateAuthority" parameter. Update authority

func (*RemoveKey) UnmarshalWithDecoder

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

func (*RemoveKey) Validate

func (obj *RemoveKey) Validate() error

func (*RemoveKey) ValidateAndBuild

func (obj *RemoveKey) 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 TokenMetadata

type TokenMetadata struct {
	// The authority that can sign to update the metadata
	UpdateAuthority common.PublicKey
	// The associated mint, used to counter spoofing to be sure that metadata
	// belongs to a particular mint
	Mint common.PublicKey
	// The longer name of the token
	Name string
	// The shortened symbol for the token
	Symbol string
	// The URI pointing to richer metadata
	Uri string
	// Any additional metadata about the token as key-value pairs. The program
	// must avoid storing the same key twice.
	AdditionalMetadata []struct {
		Key   string
		Value string
	}
}

TokenMetadata Struct

func (*TokenMetadata) MarshalWithEncoder

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

func (*TokenMetadata) UnmarshalWithDecoder

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

type UpdateAuthority

type UpdateAuthority struct {
	// New authority for the token metadata, or unset if `None`
	NewAuthority *common.PublicKey
	// [0] = [WRITE] metadata `Metadata`
	// [1] = [SIGNER] updateAuthority `Update authority`
	common.AccountMetaSlice `bin:"-"`
	// contains filtered or unexported fields
}

UpdateAuthority Instruction

func NewUpdateAuthorityInstruction

func NewUpdateAuthorityInstruction(
	newAuthority common.PublicKey,
	metadata common.PublicKey,
	updateAuthority common.PublicKey,
) *UpdateAuthority

NewUpdateAuthorityInstruction

Parameters:

newAuthority: New authority for the token metadata, or unset if `None`
metadata: Metadata
updateAuthority: Update authority

func NewUpdateAuthorityInstructionBuilder

func NewUpdateAuthorityInstructionBuilder() *UpdateAuthority

NewUpdateAuthorityInstructionBuilder creates a new `UpdateAuthority` instruction builder.

func (*UpdateAuthority) Build

func (obj *UpdateAuthority) Build() *Instruction

func (*UpdateAuthority) EncodeToTree

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

func (*UpdateAuthority) GetMetadataAccount

func (obj *UpdateAuthority) GetMetadataAccount() *common.AccountMeta

GetMetadataAccount gets the "metadata" parameter. Metadata

func (*UpdateAuthority) GetUpdateAuthorityAccount

func (obj *UpdateAuthority) GetUpdateAuthorityAccount() *common.AccountMeta

GetUpdateAuthorityAccount gets the "updateAuthority" parameter. Update authority

func (*UpdateAuthority) MarshalWithEncoder

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

func (*UpdateAuthority) SetMetadataAccount

func (obj *UpdateAuthority) SetMetadataAccount(metadata common.PublicKey) *UpdateAuthority

SetMetadataAccount sets the "metadata" parameter. Metadata

func (*UpdateAuthority) SetNewAuthority

func (obj *UpdateAuthority) SetNewAuthority(newAuthority common.PublicKey) *UpdateAuthority

SetNewAuthority sets the "newAuthority" parameter.

func (*UpdateAuthority) SetProgramId

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

func (*UpdateAuthority) SetUpdateAuthorityAccount

func (obj *UpdateAuthority) SetUpdateAuthorityAccount(updateAuthority common.PublicKey, multiSigners ...common.PublicKey) *UpdateAuthority

SetUpdateAuthorityAccount sets the "updateAuthority" parameter. Update authority

func (*UpdateAuthority) UnmarshalWithDecoder

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

func (*UpdateAuthority) Validate

func (obj *UpdateAuthority) Validate() error

func (*UpdateAuthority) ValidateAndBuild

func (obj *UpdateAuthority) 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 UpdateField

type UpdateField struct {
	// Field to update in the metadata
	Field *Field
	// Value to write for the field
	Value *string
	// [0] = [WRITE] metadata `Metadata`
	// [1] = [SIGNER] updateAuthority `Update authority`
	common.AccountMetaSlice `bin:"-"`
	// contains filtered or unexported fields
}

UpdateField Instruction

func NewUpdateFieldInstruction

func NewUpdateFieldInstruction(
	field Field,
	value string,
	metadata common.PublicKey,
	updateAuthority common.PublicKey,
) *UpdateField

NewUpdateFieldInstruction

Parameters:

field: Field to update in the metadata
value: Value to write for the field
metadata: Metadata
updateAuthority: Update authority

func NewUpdateFieldInstructionBuilder

func NewUpdateFieldInstructionBuilder() *UpdateField

NewUpdateFieldInstructionBuilder creates a new `UpdateField` instruction builder.

func (*UpdateField) Build

func (obj *UpdateField) Build() *Instruction

func (*UpdateField) EncodeToTree

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

func (*UpdateField) GetMetadataAccount

func (obj *UpdateField) GetMetadataAccount() *common.AccountMeta

GetMetadataAccount gets the "metadata" parameter. Metadata

func (*UpdateField) GetUpdateAuthorityAccount

func (obj *UpdateField) GetUpdateAuthorityAccount() *common.AccountMeta

GetUpdateAuthorityAccount gets the "updateAuthority" parameter. Update authority

func (*UpdateField) MarshalWithEncoder

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

func (*UpdateField) SetField

func (obj *UpdateField) SetField(field Field) *UpdateField

SetField sets the "field" parameter.

func (*UpdateField) SetMetadataAccount

func (obj *UpdateField) SetMetadataAccount(metadata common.PublicKey) *UpdateField

SetMetadataAccount sets the "metadata" parameter. Metadata

func (*UpdateField) SetProgramId

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

func (*UpdateField) SetUpdateAuthorityAccount

func (obj *UpdateField) SetUpdateAuthorityAccount(updateAuthority common.PublicKey, multiSigners ...common.PublicKey) *UpdateField

SetUpdateAuthorityAccount sets the "updateAuthority" parameter. Update authority

func (*UpdateField) SetValue

func (obj *UpdateField) SetValue(value string) *UpdateField

SetValue sets the "value" parameter.

func (*UpdateField) UnmarshalWithDecoder

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

func (*UpdateField) Validate

func (obj *UpdateField) Validate() error

func (*UpdateField) ValidateAndBuild

func (obj *UpdateField) 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.

Jump to

Keyboard shortcuts

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