sdk

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: May 23, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const PACKET_DATA_SIZE = 1280 - 40 - 8
View Source
const SizeOfMintAccount = 82
View Source
const SizeOfMultisigAccount = 355

Variables

View Source
var (
	SystemProgram                    = PublicKey("11111111111111111111111111111111")
	RentProgram                      = PublicKey("SysvarRent111111111111111111111111111111111")
	ConfigProgram                    = PublicKey("Config1111111111111111111111111111111111111")
	StakeProgram                     = PublicKey("Stake11111111111111111111111111111111111111")
	VoteProgram                      = PublicKey("Vote111111111111111111111111111111111111111")
	BPFLoaderProgram                 = PublicKey("BPFLoader1111111111111111111111111111111111")
	Secp256k1Program                 = PublicKey("KeccakSecp256k11111111111111111111111111111")
	TokenProgram                     = PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA")
	MemoProgram                      = PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr")
	SPLAssociatedTokenAccountProgram = PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL")
	SPLNameServiceProgram            = PublicKey("namesLPneVptA9Z5rqUDD9tMTWEJwofgaYwp8cawRkX")
	MetaplexTokenMetaProgram         = PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s")
	ComputeBudgetProgram             = PublicKey("ComputeBudget111111111111111111111111111111")
)
View Source
var NilPublicKey = PublicKey("11111111111111111111111111111111")
View Source
var PDAMarker = []byte("ProgramDerivedAddress")

Functions

func CreateProgramAddress added in v0.2.4

func CreateProgramAddress(seeds [][]byte, program ed25519.PublicKey) (ed25519.PublicKey, error)

func FindProgramAddress added in v0.2.4

func FindProgramAddress(seed [][]byte, programID ed25519.PublicKey) (ed25519.PublicKey, error)

func IsOnCurve added in v0.2.4

func IsOnCurve(b []byte) bool

func PrivateKey

func PrivateKey(key string) ed25519.PrivateKey

func PublicKey

func PublicKey(key string) ed25519.PublicKey

func PublicKeyFromPrivateKey

func PublicKeyFromPrivateKey(private ed25519.PrivateKey) ed25519.PublicKey

func WriteUvarint

func WriteUvarint(w io.ByteWriter, x uint16) error

Types

type CompactArray

type CompactArray[T Serializable] struct {
	Length uint16
	Items  []T
}

func NewCompactArray

func NewCompactArray[T Serializable](Length uint16, Items ...T) *CompactArray[T]

func (*CompactArray[T]) Serialize

func (compactArray *CompactArray[T]) Serialize(buffer *bytes.Buffer) *bytes.Buffer

type Instruction

type Instruction struct {
	ProgramIDIndex        SerializableUInt8
	AccountAddressIndexes *CompactArray[SerializableUInt8]
	Data                  *CompactArray[*InstructionData]
}

func (*Instruction) Serialize

func (instruction *Instruction) Serialize(buffer *bytes.Buffer) *bytes.Buffer

type InstructionData

type InstructionData struct {
	Data interface{}
}

func (*InstructionData) Serialize

func (instructionData *InstructionData) Serialize(buffer *bytes.Buffer) *bytes.Buffer

type Keypair

type Keypair struct {
	PublicKey  ed25519.PublicKey
	PrivateKey ed25519.PrivateKey
}

func NewKeypair

func NewKeypair() *Keypair

func NewKeypairFromFile

func NewKeypairFromFile(path string) *Keypair

func NewKeypairFromSeed

func NewKeypairFromSeed(seed [32]byte) *Keypair

type Message

type Message struct {
	Header           MessageHeader
	AccountAddresses *CompactArray[SerializablePublicKey]
	RecentBlockhash  RecentBlockhash
	Instructions     *CompactArray[*Instruction]
}

func (*Message) Serialize

func (message *Message) Serialize(buffer *bytes.Buffer) *bytes.Buffer

type MessageHeader

type MessageHeader struct {
	NumberRequiredSignatures       SerializableUInt8
	NumberReadOnlySignedAccounts   SerializableUInt8
	NumberReadOnlyUnsignedAccounts SerializableUInt8
}

func NewMessageHeader added in v0.1.1

func NewMessageHeader(requiredSignatures, readOnlySigned, readOnlyUnsigned uint8) MessageHeader

func (*MessageHeader) Serialize

func (header *MessageHeader) Serialize(buffer *bytes.Buffer) *bytes.Buffer

type MetadataInstruction added in v0.2.1

type MetadataInstruction uint8
const (
	CreateMetadataAccount MetadataInstruction = iota
	UpdateMetadataAccount
	DeprecatedCreateMasterEdition
	DeprecatedMintNewEditionFromMasterEditionViaPrintingToken
	UpdatePrimarySaleHappenedViaToken
	DeprecatedSetReservationList
	DeprecatedCreateReservationList
	SignMetadata
	DeprecatedMintPrintingTokensViaToken
	DeprecatedMintPrintingTokens
	CreateMasterEdition
	MintNewEditionFromMasterEditionViaToken
	ConvertMasterEditionV1ToV2
	MintNewEditionFromMasterEditionViaVaultProxy
	PuffMetadata
	UpdateMetadataAccountV2
	CreateMetadataAccountV2
	CreateMasterEditionV3
	VerifyCollection
	Utilize
	ApproveUseAuthority
	RevokeUseAuthority
	UnverifyCollection
	ApproveCollectionAuthority
	RevokeCollectionAuthority
	SetAndVerifyCollection
	FreezeDelegatedAccount
	ThawDelegatedAccount
	RemoveCreatorVerification
)

type RecentBlockhash

type RecentBlockhash SerializablePublicKey

func RecentBlockhashFromString

func RecentBlockhashFromString(hash string) RecentBlockhash

func (RecentBlockhash) Serialize

func (blockhash RecentBlockhash) Serialize(buffer *bytes.Buffer) *bytes.Buffer

type Serializable

type Serializable interface {
	Serialize(buffer *bytes.Buffer) *bytes.Buffer
}

type SerializablePrivateKey

type SerializablePrivateKey ed25519.PrivateKey

func (SerializablePrivateKey) Serialize

func (spk SerializablePrivateKey) Serialize(buffer *bytes.Buffer) *bytes.Buffer

type SerializablePublicKey

type SerializablePublicKey ed25519.PublicKey

func (SerializablePublicKey) Serialize

func (spk SerializablePublicKey) Serialize(buffer *bytes.Buffer) *bytes.Buffer

type SerializableUInt8

type SerializableUInt8 uint8

func (SerializableUInt8) Serialize

func (sui8 SerializableUInt8) Serialize(buffer *bytes.Buffer) *bytes.Buffer

type SystemInstruction

type SystemInstruction uint32
const (
	CreateAccount SystemInstruction = iota
	Assign
	SystemInstructionTransfer
	CreateAccountWithSeed
	AdvanceNonceAccount
	WithdrawNonceAccount
	InitializeNonceAccount
	AuthorizeNonceAccount
	Allocate
	AllocateWithSeed
	AssignWithSeed
	TransferWithSeed
)

type TokenAuthorityType added in v0.2.6

type TokenAuthorityType uint8
const (
	MintTokens TokenAuthorityType = iota
	FreezeAccount
	AccountOwner
	CloseAccount
	TransferFeeConfig
	WithheldWithdraw
	CloseMint
)

type TokenInstruction added in v0.1.2

type TokenInstruction uint8
const (
	InitializeMint TokenInstruction = iota
	InitializeAccount
	InitializeMultisig
	TokenInstructionTransfer
	Approve
	Revoke
	SetAuthority
	MintTo
	Burn
	TokenInstructionCloseAccount
	TokenInstructionFreezeAccount
	ThawAccount
	TransferChecked
	ApproveChecked
	MintToChecked
	BurnChecked
	InitializeAccount2
	SyncNative
	InitializeAccount3
	InitializeMultisig2
	InitializeMint2
)

type Transaction

type Transaction struct {
	Signatures *CompactArray[SerializablePrivateKey]
	Message    Message
}

func (*Transaction) Serialize

func (transaction *Transaction) Serialize(buffer *bytes.Buffer) *bytes.Buffer

func (*Transaction) Sign

func (transaction *Transaction) Sign(buffer *bytes.Buffer) string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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