solana

package
v0.0.0-...-ae0dd77 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AddressLookupTableProgram        = "address-lookup-table"
	BpfLoaderProgram                 = "bpf-loader"
	BpfUpgradeableLoaderProgram      = "bpf-upgradeable-loader"
	VoteProgram                      = "vote"
	SystemProgram                    = "system"
	StakeProgram                     = "stake"
	SplMemoProgram                   = "spl-memo"
	SplTokenProgram                  = "spl-token"
	SplToken2022Program              = "spl-token-2022"
	SplAssociatedTokenAccountProgram = "spl-associated-token-account"
	UnparsedProgram                  = ""

	// Program: vote
	VoteInitializeInstruction  = "initialize"
	VoteVoteInstruction        = "vote"
	VoteWithdrawInstruction    = "withdraw"
	VoteCompactUpdateVoteState = "compactupdatevotestate"

	// Program: system
	SystemCreateAccountInstruction         = "createAccount"
	SystemTransferInstruction              = "transfer"
	SystemCreateAccountWithSeedInstruction = "createAccountWithSeed"
	SystemTransferWithSeedInstruction      = "transferWithSeed"

	// Program: stake
	StakeInitializeInstruction = "initialize"
	StakeDelegateInstruction   = "delegate"
	StakeDeactivateInstruction = "deactivate"
	StakeMergeInstruction      = "merge"
	StakeSplitInstruction      = "split"
	StakeWithdrawInstruction   = "withdraw"

	// Program: spl-token
	SplTokenGetAccountDataSizeInstruction       = "getAccountDataSize"
	SplTokenInitializeImmutableOwnerInstruction = "initializeImmutableOwner"
	SplTokenTransferInstruction                 = "transfer"
)

#nosec G101 These are not credentials

View Source
const (
	SolanaLegacyVersion = int32(-1)

	SolanaLegacyVersionStr = "legacy"
)
View Source
const (
	OpStatusFailure = "FAILURE"
	OpStatusSuccess = "SUCCESS"

	OpTypeFee      = "FEE"
	OpTypeTransfer = "TRANSFER"
	OpTypeReward   = "REWARD"

	NativeSymbol          = "SOL"
	UnknownCurrencySymbol = "UNKNOWN_CURRENCY"

	// TODO: align with other rosetta implementation
	ContractAddressAmountMetadataKey = "contract_address"
)

Variables

View Source
var Module = fx.Options(
	internal.NewParserBuilder("solana", NewSolanaNativeParser).
		SetRosettaParserFactory(NewSolanaRosettaParser).
		SetCheckerFactory(NewSolanaChecker).
		Build(),
)

Functions

func GetTokenBalanceAmountMap

func GetTokenBalanceAmountMap(balances []*api.SolanaTokenBalance, accountKeys []*api.AccountKey) (map[string]*big.Int, error)

func GetTokenBalanceMapKey

func GetTokenBalanceMapKey(mint string, address string) string

func NewSolanaChecker

func NewSolanaChecker(params internal.ParserParams) (internal.Checker, error)

func NewSolanaRosettaParser

func NewSolanaRosettaParser(
	params internal.ParserParams,
	nativeParser internal.NativeParser,
	opts ...internal.ParserFactoryOption,
) (internal.RosettaParser, error)

func ValidateSolanaParsedTransactionId

func ValidateSolanaParsedTransactionId(signatureList []string) (string, error)

Types

type AccountKey

type AccountKey struct {
	Pubkey   string `json:"pubkey"`
	Signer   bool   `json:"signer"`
	Source   string `json:"source"`
	Writable bool   `json:"writable"`
}

type SolanaBlock

type SolanaBlock struct {
	BlockHash         string              `json:"blockhash"`
	BlockHeight       uint64              `json:"blockHeight"`
	ParentSlot        uint64              `json:"parentSlot"`
	PreviousBlockHash string              `json:"previousBlockhash"`
	BlockTime         int64               `json:"blockTime"`
	Transactions      []SolanaTransaction `json:"transactions"`
	Rewards           []SolanaReward      `json:"rewards"`
}

type SolanaBlockLit

type SolanaBlockLit struct {
	BlockHash         string                 `json:"blockhash"`
	BlockHeight       uint64                 `json:"blockHeight"`
	ParentSlot        uint64                 `json:"parentSlot"`
	PreviousBlockHash string                 `json:"previousBlockhash"`
	BlockTime         int64                  `json:"blockTime"`
	Transactions      []SolanaTransactionLit `json:"transactions"`
}

type SolanaBlockV2

type SolanaBlockV2 struct {
	BlockHash         string                `json:"blockhash"`
	BlockHeight       uint64                `json:"blockHeight"`
	ParentSlot        uint64                `json:"parentSlot"`
	PreviousBlockHash string                `json:"previousBlockhash"`
	BlockTime         int64                 `json:"blockTime"`
	Transactions      []SolanaTransactionV2 `json:"transactions"`
	Rewards           []SolanaReward        `json:"rewards"`
}

type SolanaInnerInstruction

type SolanaInnerInstruction struct {
	Index        uint64              `json:"index"`
	Instructions []SolanaInstruction `json:"instructions"`
}

type SolanaInnerInstructionV2

type SolanaInnerInstructionV2 struct {
	Index        uint64                `json:"index"`
	Instructions []SolanaInstructionV2 `json:"instructions"`
}

type SolanaInstruction

type SolanaInstruction struct {
	ProgramIDIndex uint16   `json:"programIdIndex"`
	Accounts       []uint16 `json:"accounts"`
	Data           string   `json:"data"`
}

type SolanaInstructionV2

type SolanaInstructionV2 struct {
	Program           string          `json:"program"`
	ProgramId         string          `json:"programId"`
	ParsedInstruction json.RawMessage `json:"parsed"`
	SolanaRawInstructionV2
}

type SolanaLoadedAddresses

type SolanaLoadedAddresses struct {
	Readonly []string `json:"readonly"`
	Writable []string `json:"writable"`
}

type SolanaMessage

type SolanaMessage struct {
	Header          SolanaMessageHeader `json:"header"`
	AccountKeys     []string            `json:"accountKeys"`
	RecentBlockHash string              `json:"recentBlockhash"`
	Instructions    []SolanaInstruction `json:"instructions"`
}

type SolanaMessageHeader

type SolanaMessageHeader struct {
	NumRequiredSignatures       uint64 `json:"numRequiredSignatures"`
	NumReadOnlySignedAccounts   uint64 `json:"numReadonlySignedAccounts"`
	NumReadOnlyUnsignedAccounts uint64 `json:"numReadonlyUnsignedAccounts"`
}

type SolanaMessageV2

type SolanaMessageV2 struct {
	AccountKeys         []AccountKey          `json:"accountKeys"`
	AddressTableLookups []TableLookup         `json:"addressTableLookups"`
	Instructions        []SolanaInstructionV2 `json:"instructions"`
	RecentBlockHash     string                `json:"recentBlockhash"`
}

type SolanaParsedInstruction

type SolanaParsedInstruction struct {
	InstructionInfo json.RawMessage `json:"info"`
	InstructionType string          `json:"type"`
}

type SolanaRawInstructionV2

type SolanaRawInstructionV2 struct {
	Accounts  []string `json:"accounts"`
	Data      string   `json:"data"`
	ProgramId string   `json:"programId"`
}

type SolanaReward

type SolanaReward struct {
	Pubkey      string  `json:"pubkey"`
	Lamports    int64   `json:"lamports"`
	PostBalance uint64  `json:"postBalance"`
	RewardType  string  `json:"rewardType"`
	Commission  *uint64 `json:"commission"`
}

type SolanaTokenAmount

type SolanaTokenAmount struct {
	Amount         string `json:"amount"`
	Decimals       uint64 `json:"decimals"`
	UIAmountString string `json:"uiAmountString"`
}

type SolanaTokenBalance

type SolanaTokenBalance struct {
	AccountIndex uint64            `json:"accountIndex"`
	Mint         string            `json:"mint"`
	TokenAmount  SolanaTokenAmount `json:"uiTokenAmount"`
	Owner        string            `json:"owner"`
}

type SolanaTransaction

type SolanaTransaction struct {
	Payload *SolanaTransactionPayload `json:"transaction"`
	Meta    *SolanaTransactionMeta    `json:"meta"`
	Version *SolanaTransactionVersion `json:"version"`
}

type SolanaTransactionError

type SolanaTransactionError = any

type SolanaTransactionLit

type SolanaTransactionLit struct {
	Payload *SolanaTransactionPayloadLit `json:"transaction"`
}

type SolanaTransactionMeta

type SolanaTransactionMeta struct {
	Err               SolanaTransactionError   `json:"err"`
	Fee               uint64                   `json:"fee"`
	PreBalances       []uint64                 `json:"preBalances"`
	PostBalances      []uint64                 `json:"postBalances"`
	PreTokenBalances  []SolanaTokenBalance     `json:"preTokenBalances"`
	PostTokenBalances []SolanaTokenBalance     `json:"postTokenBalances"`
	InnerInstructions []SolanaInnerInstruction `json:"innerInstructions"`
	LogMessages       []string                 `json:"logMessages"`
	Rewards           []SolanaReward           `json:"rewards"`
	LoadedAddresses   *SolanaLoadedAddresses   `json:"loadedAddresses"`
}

type SolanaTransactionMetaV2

type SolanaTransactionMetaV2 struct {
	Err               SolanaTransactionError     `json:"err"`
	Fee               uint64                     `json:"fee"`
	PreBalances       []uint64                   `json:"preBalances"`
	PostBalances      []uint64                   `json:"postBalances"`
	PreTokenBalances  []SolanaTokenBalance       `json:"preTokenBalances"`
	PostTokenBalances []SolanaTokenBalance       `json:"postTokenBalances"`
	InnerInstructions []SolanaInnerInstructionV2 `json:"innerInstructions"`
	LogMessages       []string                   `json:"logMessages"`
	Rewards           []SolanaReward             `json:"rewards"`
	LoadedAddresses   *SolanaLoadedAddresses     `json:"loadedAddresses"`
}

type SolanaTransactionPayload

type SolanaTransactionPayload struct {
	Signatures []string      `json:"signatures"`
	Message    SolanaMessage `json:"message"`
}

type SolanaTransactionPayloadLit

type SolanaTransactionPayloadLit struct {
	Signatures []string `json:"signatures"`
}

type SolanaTransactionPayloadV2

type SolanaTransactionPayloadV2 struct {
	Signatures []string        `json:"signatures"`
	Message    SolanaMessageV2 `json:"message"`
}

type SolanaTransactionV2

type SolanaTransactionV2 struct {
	Payload *SolanaTransactionPayloadV2 `json:"transaction"`
	Meta    *SolanaTransactionMetaV2    `json:"meta"`
	Version *SolanaTransactionVersion   `json:"version"`
}

type SolanaTransactionVersion

type SolanaTransactionVersion int32

func (*SolanaTransactionVersion) UnmarshalJSON

func (v *SolanaTransactionVersion) UnmarshalJSON(input []byte) error

func (SolanaTransactionVersion) Value

func (v SolanaTransactionVersion) Value() int32

type SplTokenGetAccountDataSizeInstructionInfo

type SplTokenGetAccountDataSizeInstructionInfo struct {
	Mint           string   `json:"mint" validate:"required"`
	ExtensionTypes []string `json:"extensionTypes"`
}

Program: spl-token

type SplTokenInitializeImmutableOwnerInstructionInfo

type SplTokenInitializeImmutableOwnerInstructionInfo struct {
	Account string `json:"account" validate:"required"`
}

Instruction reference: https://github.com/solana-labs/solana/blob/master/transaction-status/src/

type SplTokenTransferInstructionInfo

type SplTokenTransferInstructionInfo struct {
	Source      string `json:"source" validate:"required"`
	Destination string `json:"destination" validate:"required"`
	Authority   string `json:"authority"`
	Amount      string `json:"amount" validate:"required"`
}

Instruction reference: https://github.com/solana-labs/solana/blob/master/transaction-status/src/

type StakeDeactivateInstructionInfo

type StakeDeactivateInstructionInfo struct {
	StakeAccount   string `json:"stakeAcount"`
	ClockSysvar    string `json:"clockSysvar" validate:"required"`
	StakeAuthority string `json:"stakeAuthority" validate:"required"`
}

Instruction reference: https://github.com/solana-labs/solana/blob/master/transaction-status/src/

type StakeDelegateInstructionInfo

type StakeDelegateInstructionInfo struct {
	StakeAccount       string `json:"stakeAcount"`
	VoteAccount        string `json:"voteAccount" validate:"required"`
	ClockSysvar        string `json:"clockSysvar" validate:"required"`
	StakeHistorySysvar string `json:"stakeHistorySysvar" validate:"required"`
	StakeConfigAccount string `json:"stakeConfigAccount" validate:"required"`
	StakeAuthority     string `json:"stakeAuthority" validate:"required"`
}

Instruction reference: https://github.com/solana-labs/solana/blob/master/transaction-status/src/

type StakeInitializeInstructionInfo

type StakeInitializeInstructionInfo struct {
	StakeAccount string `json:"stakeAcount"`
	RentSysvar   string `json:"rentSysvar" validate:"required"`

	Authorized struct {
		Staker     string `json:"staker" validate:"required"`
		Withdrawer string `json:"withdrawer" validate:"required"`
	} `json:"authorized"`

	Lockup struct {
		UnixTimestamp int64  `json:"unixTimestamp"`
		Epoch         uint64 `json:"epoch"`
		Custodian     string `json:"custodian" validate:"required"`
	} `json:"lockup" validate:"required"`
}

Program: stake

type StakeMergeInstructionInfo

type StakeMergeInstructionInfo struct {
	Destination        string `json:"destination" validate:"required"`
	Source             string `json:"source" validate:"required"`
	ClockSysvar        string `json:"clockSysvar" validate:"required"`
	StakeHistorySysvar string `json:"stakeHistorySysvar" validate:"required"`
	StakeAuthority     string `json:"stakeAuthority" validate:"required"`
}

Instruction reference: https://github.com/solana-labs/solana/blob/master/transaction-status/src/

type StakeSplitInstructionInfo

type StakeSplitInstructionInfo struct {
	StakeAccount    string `json:"stakeAcount"`
	NewSplitAccount string `json:"newSplitAccount" validate:"required"`
	StakeAuthority  string `json:"stakeAuthority" validate:"required"`
	Lamports        uint64 `json:"lamports"`
}

Instruction reference: https://github.com/solana-labs/solana/blob/master/transaction-status/src/

type StakeWithdrawInstructionInfo

type StakeWithdrawInstructionInfo struct {
	StakeAccount       string `json:"stakeAcount"`
	Destination        string `json:"destination" validate:"required"`
	ClockSysvar        string `json:"clockSysvar" validate:"required"`
	StakeHistorySysvar string `json:"stakeHistorySysvar" validate:"required"`
	WithdrawAuthority  string `json:"withdrawAuthority" validate:"required"`
	Lamports           uint64 `json:"lamports"`
}

Instruction reference: https://github.com/solana-labs/solana/blob/master/transaction-status/src/

type SystemCreateAccountInstructionInfo

type SystemCreateAccountInstructionInfo struct {
	Source     string `json:"source" validate:"required"`
	NewAccount string `json:"newAccount" validate:"required"`
	Lamports   uint64 `json:"lamports"`
	Space      uint64 `json:"space"`
	Owner      string `json:"owner" validate:"required"`
}

Program: system

type SystemCreateAccountWithSeedInstructionInfo

type SystemCreateAccountWithSeedInstructionInfo struct {
	Source     string `json:"source" validate:"required"`
	NewAccount string `json:"newAccount" validate:"required"`
	Base       string `json:"base" validate:"required"`
	Seed       string `json:"seed"`
	Lamports   uint64 `json:"lamports"`
	Space      uint64 `json:"space"`
	Owner      string `json:"owner" validate:"required"`
}

Instruction reference: https://github.com/solana-labs/solana/blob/master/transaction-status/src/

type SystemTransferInstructionInfo

type SystemTransferInstructionInfo struct {
	Source      string `json:"source" validate:"required"`
	Destination string `json:"destination" validate:"required"`
	Lamports    uint64 `json:"lamports"`
}

Instruction reference: https://github.com/solana-labs/solana/blob/master/transaction-status/src/

type SystemTransferWithSeedInstructionInfo

type SystemTransferWithSeedInstructionInfo struct {
	Source      string `json:"source" validate:"required"`
	SourceBase  string `json:"sourceBase" validate:"required"`
	Destination string `json:"destination" validate:"required"`
	Lamports    uint64 `json:"lamports"`
	SourceSeed  string `json:"sourceSeed"`
	SourceOwner string `json:"sourceOwner" validate:"required"`
}

Instruction reference: https://github.com/solana-labs/solana/blob/master/transaction-status/src/

type TableLookup

type TableLookup struct {
	AccountKey      string   `json:"accountKey"`
	ReadonlyIndexes []uint64 `json:"readonlyIndexes"`
	WritableIndexes []uint64 `json:"writableIndexes"`
}

type UnknownInstructionInfo

type UnknownInstructionInfo struct {
	Info []byte `json:"info"`
}

Generic

type VoteCompactUpdateVoteStateInstructionInfo

type VoteCompactUpdateVoteStateInstructionInfo struct {
	VoteAccount     string `json:"voteAccount" validate:"required"`
	VoteAuthority   string `json:"voteAuthority" validate:"required"`
	VoteStateUpdate struct {
		Lockouts []struct {
			ConfirmationCount uint64 `json:"confirmation_count"`
			Slot              uint64 `json:"slot"`
		} `json:"lockouts"`
		Hash      string `json:"hash"`
		Root      uint64 `json:"root"`
		Timestamp int64  `json:"timestamp"`
	} `json:"voteStateUpdate" validate:"required"`
}

Instruction reference: https://github.com/solana-labs/solana/blob/master/transaction-status/src/

type VoteInitializeInstructionInfo

type VoteInitializeInstructionInfo struct {
	VoteAccount          string `json:"voteAccount" validate:"required"`
	RentSysvar           string `json:"rentSysvar" validate:"required"`
	ClockSysvar          string `json:"clockSysvar" validate:"required"`
	Node                 string `json:"node" validate:"required"`
	AuthorizedVoter      string `json:"authorizedVoter" validate:"required"`
	AuthorizedWithdrawer string `json:"authorizedWithdrawer" validate:"required"`
	Commission           uint8  `json:"commission"`
}

Program: vote

type VoteVoteInstructionInfo

type VoteVoteInstructionInfo struct {
	VoteAccount      string `json:"voteAccount" validate:"required"`
	SlotHashesSysvar string `json:"slotHashesSysvar" validate:"required"`
	ClockSysvar      string `json:"clockSysvar" validate:"required"`
	VoteAuthority    string `json:"voteAuthority" validate:"required"`
	Vote             struct {
		Hash      string   `json:"hash" validate:"required"`
		Slots     []uint64 `json:"slots" validate:"required"`
		Timestamp int64    `json:"timestamp"`
	} `json:"vote" validate:"required"`
}

Instruction reference: https://github.com/solana-labs/solana/blob/master/transaction-status/src/

type VoteWithdrawInstructionInfo

type VoteWithdrawInstructionInfo struct {
	VoteAccount       string `json:"voteAccount" validate:"required"`
	Destination       string `json:"destination" validate:"required"`
	WithdrawAuthority string `json:"withdrawAuthority" validate:"required"`
	Lamports          uint64 `json:"lamports"`
}

Instruction reference: https://github.com/solana-labs/solana/blob/master/transaction-status/src/

Jump to

Keyboard shortcuts

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