solana

package
v0.0.0-...-2ac5be2 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SysVarClockAddress
	SysVarClockAddress = "SysvarC1ock11111111111111111111111111111111"

	// SystemProgramIdAddress
	SystemProgramIdAddress = "11111111111111111111111111111111"

	// SysVarRentAddress
	SysVarRentAddress = "SysvarRent111111111111111111111111111111111"
)
View Source
const (
	MaxSeeds      = 16
	MaxSeedLength = 32
)
View Source
const ContextLogging = "SOLANA"

ContextLogging to use for logging

View Source
const ProgramDerivedAddressMarker = "ProgramDerivedAddress"

Variables

View Source
var ErrMaxSeedLengthExceeded = fmt.Errorf("max seed length exceeded")
View Source
var UnknownInstructionError = errors.New("Unknown instruction")

UnknownInstructionError to be returned as a sentinel for when an unknown instruction is seen

Functions

func ClassifyApplication

func ClassifyApplication(transaction solana.TransactionResult, apps map[string]applications.Application) []applications.Application

func GetAllInstructions

func GetAllInstructions(result solTypes.TransactionResult) []solTypes.TransactionInstruction

getAllInstructions extracts instructions and innerInstructions from a solana transaction

func ValidCurve

func ValidCurve(point []byte) bool

Check if point exists on the ED25519 curve. Solana program addresses must not appear on curve.

Types

type AccountMeta

type AccountMeta struct {
	PublicKey  PublicKey
	IsWritable bool
	IsSigner   bool
}

func NewAccountMeta

func NewAccountMeta(
	pubKey PublicKey,
	WRITE bool,
	SIGNER bool,
) *AccountMeta

type AccountMetaSlice

type AccountMetaSlice []*AccountMeta

type CompiledInstruction

type CompiledInstruction struct {
	// Index into the message.accountKeys array indicating the program account that executes this instruction.
	// NOTE: it is actually a uint8, but using a uint16 because uint8 is treated as a byte everywhere,
	// and that can be an issue.
	ProgramIDIndex uint16 `json:"programIdIndex"`

	// List of ordered indices into the message.accountKeys array indicating which accounts to pass to the program.
	// NOTE: it is actually a []uint8, but using a uint16 because []uint8 is treated as a []byte everywhere,
	// and that can be an issue.
	Accounts []uint16 `json:"accounts"`

	// The program input data encoded in a base-58 string.
	Data []byte `json:"data"`
}

type GenericInstruction

type GenericInstruction struct {
	AccountValues AccountMetaSlice
	ProgID        PublicKey
	DataBytes     []byte
}

func NewInstruction

func NewInstruction(
	programID PublicKey,
	accounts AccountMetaSlice,
	data []byte,
) *GenericInstruction

func (*GenericInstruction) Accounts

func (in *GenericInstruction) Accounts() []*AccountMeta

func (*GenericInstruction) Data

func (in *GenericInstruction) Data() ([]byte, error)

func (*GenericInstruction) ProgramID

func (in *GenericInstruction) ProgramID() PublicKey

type Hash

type Hash PublicKey

type Instruction

type Instruction interface {
	ProgramID() PublicKey     // the programID the instruction acts on
	Accounts() []*AccountMeta // returns the list of accounts the instructions requires
	Data() ([]byte, error)    // the binary encoded instructions
}

type Message

type Message struct {
	// List of base-58 encoded public keys used by the transaction,
	// including by the instructions and for signatures.
	// The first `message.header.numRequiredSignatures` public keys must sign the transaction.
	AccountKeys []PublicKey `json:"accountKeys"`

	// Details the account types and signatures required by the transaction.
	Header MessageHeader `json:"header"`

	// A base-58 encoded hash of a recent block in the ledger used to
	// prevent transaction duplication and to give transactions lifetimes.
	RecentBlockhash Hash `json:"recentBlockhash"`

	// List of program instructions that will be executed in sequence
	// and committed in one atomic transaction if all succeed.
	Instructions []CompiledInstruction `json:"instructions"`
}

func (*Message) MarshalBinary

func (mx *Message) MarshalBinary() ([]byte, error)

type MessageHeader

type MessageHeader struct {
	// The total number of signatures required to make the transaction valid.
	// The signatures must match the first `numRequiredSignatures` of `message.account_keys`.
	NumRequiredSignatures uint8 `json:"numRequiredSignatures"`

	// The last numReadonlySignedAccounts of the signed keys are read-only accounts.
	// Programs may process multiple transactions that load read-only accounts within
	// a single PoH entry, but are not permitted to credit or debit lamports or modify
	// account data.
	// Transactions targeting the same read-write account are evaluated sequentially.
	NumReadonlySignedAccounts uint8 `json:"numReadonlySignedAccounts"`

	// The last `numReadonlyUnsignedAccounts` of the unsigned keys are read-only accounts.
	NumReadonlyUnsignedAccounts uint8 `json:"numReadonlyUnsignedAccounts"`
}

type PrivateKey

type PrivateKey []byte

func (PrivateKey) PublicKey

func (k PrivateKey) PublicKey() PublicKey

func (PrivateKey) Sign

func (k PrivateKey) Sign(payload []byte) (Signature, error)

type PublicKey

type PublicKey [32]byte
var (
	SysVarClockPubkey     PublicKey
	SystemProgramIdPubkey PublicKey
	SysVarRentPubkey      PublicKey
)

func CreateProgramAddress

func CreateProgramAddress(seeds [][]byte, programID PublicKey) (PublicKey, error)

func FindProgramAddress

func FindProgramAddress(seed [][]byte, pub PublicKey) (PublicKey, uint8, error)

FindProgramAddress - just enough to cover the prior use case

func PublicKeyFromBase58

func PublicKeyFromBase58(b58 string) (PublicKey, error)

PublicKeyFromBase58 using btcsuite

func PublicKeyFromBytes

func PublicKeyFromBytes(b []byte) PublicKey

func (PublicKey) Bytes

func (p PublicKey) Bytes() []byte

func (PublicKey) Equals

func (pk PublicKey) Equals(pub PublicKey) bool

func (PublicKey) IsZero

func (pk PublicKey) IsZero() bool

func (PublicKey) String

func (pk PublicKey) String() string

String the public key to get it's base58 version

func (PublicKey) ToBase58

func (pk PublicKey) ToBase58() string

func (PublicKey) ToBase64

func (pk PublicKey) ToBase64() string

type PublicKeySlice

type PublicKeySlice []PublicKey

func (*PublicKeySlice) Append

func (slice *PublicKeySlice) Append(pubkeys ...PublicKey)

func (PublicKeySlice) Has

func (slice PublicKeySlice) Has(pubkey PublicKey) bool

func (*PublicKeySlice) UniqueAppend

func (slice *PublicKeySlice) UniqueAppend(pubkey PublicKey) bool

type Signature

type Signature [64]byte

func SignatureFromBase58

func SignatureFromBase58(b58 string) (Signature, error)

func (Signature) String

func (s Signature) String() string

type TokenDetailsSolana

type TokenDetailsSolana struct {
	FluidMintPubkey   PublicKey
	ObligationPubkey  PublicKey
	ReservePubkey     PublicKey
	PythPubkey        PublicKey
	SwitchboardPubkey PublicKey
	TokenDecimals     *big.Rat
	TokenName         string
	Amount            float64
}

TokenDetailsSolana containing information about tokens that we unpacked using the environment variables

func GetTokensListSolana

func GetTokensListSolana(tokensList_ string) []TokenDetailsSolana

GetTokensListSolana to parse a string list into separated token information

type Transaction

type Transaction struct {
	// A list of base-58 encoded signatures applied to the transaction.
	// The list is always of length `message.header.numRequiredSignatures` and not empty.
	// The signature at index `i` corresponds to the public key at index
	// `i` in `message.account_keys`. The first one is used as the transaction id.
	Signatures []Signature `json:"signatures"`

	// Defines the content of the transaction.
	Message Message `json:"message"`
}

func NewTransaction

func NewTransaction(instructions []Instruction, recentBlockHash Hash, opts ...TransactionOption) (*Transaction, error)

Pure clone of solana go code

func (*Transaction) MarshalBinary

func (tx *Transaction) MarshalBinary() ([]byte, error)

func (*Transaction) Sign

func (tx *Transaction) Sign(getter privateKeyGetter) (out []Signature, err error)

type TransactionOption

type TransactionOption interface {
	// contains filtered or unexported methods
}

func TransactionPayer

func TransactionPayer(payer PublicKey) TransactionOption

type Wallet

type Wallet struct {
	PrivateKey PrivateKey
}

func WalletFromPrivateKeyBase58

func WalletFromPrivateKeyBase58(b58 string) (*Wallet, error)

func (Wallet) PublicKey

func (w Wallet) PublicKey() PublicKey

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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