client

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountInfo

type AccountInfo struct {
	Lamports   uint64
	Owner      common.PublicKey
	Executable bool
	RentEpoch  uint64
	Data       []byte
}

type Block

type Block struct {
	Blockhash         string
	BlockTime         *time.Time
	BlockHeight       *int64
	PreviousBlockhash string
	ParentSlot        uint64
	Transactions      []BlockTransaction
	Signatures        []string
	Rewards           []Reward
}

type BlockTransaction

type BlockTransaction struct {
	// rpc fields
	Meta        *TransactionMeta
	Transaction types.Transaction

	// custom fileds
	AccountKeys []common.PublicKey
}

type Client

type Client struct {
	RpcClient rpc.RpcClient
}

func New

func New(opts ...rpc.Option) *Client

func NewClient

func NewClient(endpoint string) *Client

func (*Client) GetAccountInfo

func (c *Client) GetAccountInfo(ctx context.Context, base58Addr string) (AccountInfo, error)

GetAccountInfo return account's info

func (*Client) GetAccountInfoAndContext

func (c *Client) GetAccountInfoAndContext(ctx context.Context, base58Addr string) (rpc.ValueWithContext[AccountInfo], error)

GetAccountInfoAndContext return account's info

func (*Client) GetAccountInfoAndContextWithConfig

func (c *Client) GetAccountInfoAndContextWithConfig(ctx context.Context, base58Addr string, cfg GetAccountInfoConfig) (rpc.ValueWithContext[AccountInfo], error)

GetAccountInfoAndContextWithConfig return account's info

func (*Client) GetAccountInfoWithConfig

func (c *Client) GetAccountInfoWithConfig(ctx context.Context, base58Addr string, cfg GetAccountInfoConfig) (AccountInfo, error)

GetAccountInfoWithConfig return account's info

func (*Client) GetBalance

func (c *Client) GetBalance(ctx context.Context, base58Addr string) (uint64, error)

GetBalance fetch users lamports(SOL) balance

func (*Client) GetBalanceAndContext

func (c *Client) GetBalanceAndContext(ctx context.Context, base58Addr string) (rpc.ValueWithContext[uint64], error)

GetBalanceAndContext fetch users lamports(SOL) balance

func (*Client) GetBalanceAndContextWithConfig

func (c *Client) GetBalanceAndContextWithConfig(ctx context.Context, base58Addr string, cfg GetBalanceConfig) (rpc.ValueWithContext[uint64], error)

GetBalanceAndContextWithConfig fetch users lamports(SOL) balance with specific commitment

func (*Client) GetBalanceWithConfig

func (c *Client) GetBalanceWithConfig(ctx context.Context, base58Addr string, cfg GetBalanceConfig) (uint64, error)

GetBalanceWithConfig fetch users lamports(SOL) balance with specific commitment

func (*Client) GetBlock

func (c *Client) GetBlock(ctx context.Context, slot uint64) (*Block, error)

func (*Client) GetBlockTime

func (c *Client) GetBlockTime(ctx context.Context, slot uint64) (*int64, error)

GetBlockTime returns the estimated production time of a block.

func (*Client) GetBlockWithConfig

func (c *Client) GetBlockWithConfig(ctx context.Context, slot uint64, cfg GetBlockConfig) (*Block, error)

func (*Client) GetClusterNodes

func (c *Client) GetClusterNodes(ctx context.Context) ([]ClusterNode, error)

GetClusterNodes returns information about all the nodes participating in the cluster

func (*Client) GetEpochInfo

func (c *Client) GetEpochInfo(ctx context.Context) (GetEpochInfo, error)

GetEpochInfo returns information about the current epoch

func (*Client) GetFeeForMessage

func (c *Client) GetFeeForMessage(ctx context.Context, message types.Message) (*uint64, error)

func (*Client) GetFeeForMessageAndContext

func (c *Client) GetFeeForMessageAndContext(ctx context.Context, message types.Message) (rpc.ValueWithContext[*uint64], error)

func (*Client) GetFeeForMessageAndContextWithConfig

func (c *Client) GetFeeForMessageAndContextWithConfig(ctx context.Context, message types.Message, cfg GetFeeForMessageConfig) (rpc.ValueWithContext[*uint64], error)

func (*Client) GetFeeForMessageWithConfig

func (c *Client) GetFeeForMessageWithConfig(ctx context.Context, message types.Message, cfg GetFeeForMessageConfig) (*uint64, error)

func (*Client) GetFirstAvailableBlock

func (c *Client) GetFirstAvailableBlock(ctx context.Context) (uint64, error)

GetFirstAvailableBlock returns the slot of the lowest confirmed block that has not been purged from the ledger

func (*Client) GetGenesisHash

func (c *Client) GetGenesisHash(ctx context.Context) (string, error)

GetGenesisHash returns the genesis hash

func (*Client) GetHealth

func (c *Client) GetHealth(ctx context.Context) (bool, error)

GetHealthResponse returns the current health of the node. A healthy node is one that is within HEALTH_CHECK_SLOT_DISTANCE slots of the latest cluster confirmed slot.

func (*Client) GetIdentity

func (c *Client) GetIdentity(ctx context.Context) (rpc.GetIdentity, error)

GetIdentity returns the identity pubkey for the current node

func (*Client) GetLatestBlockhash

func (c *Client) GetLatestBlockhash(ctx context.Context) (rpc.GetLatestBlockhashValue, error)

GetLatestBlockhash returns the latest blockhash

func (*Client) GetLatestBlockhashAndContext

func (c *Client) GetLatestBlockhashAndContext(ctx context.Context) (rpc.ValueWithContext[rpc.GetLatestBlockhashValue], error)

GetLatestBlockhashAndContext returns the latest blockhash

func (*Client) GetLatestBlockhashAndContextWithConfig

func (c *Client) GetLatestBlockhashAndContextWithConfig(ctx context.Context, cfg GetLatestBlockhashConfig) (rpc.ValueWithContext[rpc.GetLatestBlockhashValue], error)

GetLatestBlockhashAndContextWithConfig returns the latest blockhash

func (*Client) GetLatestBlockhashWithConfig

func (c *Client) GetLatestBlockhashWithConfig(ctx context.Context, cfg GetLatestBlockhashConfig) (rpc.GetLatestBlockhashValue, error)

GetLatestBlockhash returns the latest blockhash

func (*Client) GetMinimumBalanceForRentExemption

func (c *Client) GetMinimumBalanceForRentExemption(ctx context.Context, dataLen uint64) (uint64, error)

GetMinimumBalanceForRentExemption returns minimum balance required to make account rent exempt

func (*Client) GetMinimumBalanceForRentExemptionWithConfig

func (c *Client) GetMinimumBalanceForRentExemptionWithConfig(ctx context.Context, dataLen uint64, cfg GetMinimumBalanceForRentExemptionConfig) (uint64, error)

GetMinimumBalanceForRentExemption returns minimum balance required to make account rent exempt

func (*Client) GetMultipleAccounts

func (c *Client) GetMultipleAccounts(ctx context.Context, addrs []string) ([]AccountInfo, error)

GetMultipleAccounts returns multiple accounts info

func (*Client) GetMultipleAccountsAndContext

func (c *Client) GetMultipleAccountsAndContext(ctx context.Context, addrs []string) (rpc.ValueWithContext[[]AccountInfo], error)

GetMultipleAccounts returns multiple accounts info

func (*Client) GetMultipleAccountsAndContextWithConfig

func (c *Client) GetMultipleAccountsAndContextWithConfig(ctx context.Context, addrs []string, cfg GetMultipleAccountsConfig) (rpc.ValueWithContext[[]AccountInfo], error)

GetMultipleAccountsWithConfig return account's info

func (*Client) GetMultipleAccountsWithConfig

func (c *Client) GetMultipleAccountsWithConfig(ctx context.Context, addrs []string, cfg GetMultipleAccountsConfig) ([]AccountInfo, error)

GetMultipleAccountsWithConfig return account's info

func (*Client) GetNonceAccount

func (c *Client) GetNonceAccount(ctx context.Context, base58Addr string) (system.NonceAccount, error)

func (*Client) GetNonceFromNonceAccount

func (c *Client) GetNonceFromNonceAccount(ctx context.Context, base58Addr string) (string, error)

func (*Client) GetRecentPrioritizationFees

func (c *Client) GetRecentPrioritizationFees(ctx context.Context, addresses []common.PublicKey) (rpc.PrioritizationFees, error)

GetRecentPrioritizationFees returns a list of prioritization fees from recent blocks.

func (*Client) GetSignatureStatus

func (c *Client) GetSignatureStatus(ctx context.Context, signature string) (*rpc.SignatureStatus, error)

func (*Client) GetSignatureStatusWithConfig

func (c *Client) GetSignatureStatusWithConfig(ctx context.Context, signature string, cfg GetSignatureStatusesConfig) (*rpc.SignatureStatus, error)

func (*Client) GetSignatureStatuses

func (c *Client) GetSignatureStatuses(ctx context.Context, signatures []string) (rpc.SignatureStatuses, error)

func (*Client) GetSignatureStatusesWithConfig

func (c *Client) GetSignatureStatusesWithConfig(ctx context.Context, signatures []string, cfg GetSignatureStatusesConfig) (rpc.SignatureStatuses, error)

func (*Client) GetSignaturesForAddress

func (c *Client) GetSignaturesForAddress(ctx context.Context, addr string) (rpc.GetSignaturesForAddress, error)

func (*Client) GetSignaturesForAddressWithConfig

func (c *Client) GetSignaturesForAddressWithConfig(ctx context.Context, addr string, cfg GetSignaturesForAddressConfig) (rpc.GetSignaturesForAddress, error)

func (*Client) GetSlot

func (c *Client) GetSlot(ctx context.Context) (uint64, error)

GetSlot get current slot (finalized)

func (*Client) GetSlotLeader

func (c *Client) GetSlotLeader(ctx context.Context) (string, error)

GetSlotLeader returns the current slot leader

func (*Client) GetSlotLeaderWithConfig

func (c *Client) GetSlotLeaderWithConfig(ctx context.Context, cfg GetSlotLeaderConfig) (string, error)

GetSlotWithConfig returns the current slot leader

func (*Client) GetSlotLeaders

func (c *Client) GetSlotLeaders(ctx context.Context, startSlot uint64, limit uint64) ([]string, error)

GetSlotLeaders returns the slot leaders for a given slot range (limit: 1~5000)

func (*Client) GetSlotWithConfig

func (c *Client) GetSlotWithConfig(ctx context.Context, cfg GetSlotConfig) (uint64, error)

GetSlotWithConfig get slot by commitment

func (*Client) GetTokenAccount

func (c *Client) GetTokenAccount(ctx context.Context, base58Addr string) (token.TokenAccount, error)

func (*Client) GetTokenAccountBalance

func (c *Client) GetTokenAccountBalance(ctx context.Context, addr string) (TokenAmount, error)

func (*Client) GetTokenAccountBalanceAndContext

func (c *Client) GetTokenAccountBalanceAndContext(ctx context.Context, addr string) (rpc.ValueWithContext[TokenAmount], error)

func (*Client) GetTokenAccountBalanceAndContextWithConfig

func (c *Client) GetTokenAccountBalanceAndContextWithConfig(ctx context.Context, addr string, cfg GetTokenAccountBalanceConfig) (rpc.ValueWithContext[TokenAmount], error)

func (*Client) GetTokenAccountBalanceWithConfig

func (c *Client) GetTokenAccountBalanceWithConfig(ctx context.Context, addr string, cfg GetTokenAccountBalanceConfig) (TokenAmount, error)

func (*Client) GetTokenAccountsByOwnerByMint

func (c *Client) GetTokenAccountsByOwnerByMint(ctx context.Context, owner, mintAddr string) ([]TokenAccount, error)

func (*Client) GetTokenAccountsByOwnerByProgram

func (c *Client) GetTokenAccountsByOwnerByProgram(ctx context.Context, owner, programId string) ([]TokenAccount, error)

func (*Client) GetTokenAccountsByOwnerWithContextByMint

func (c *Client) GetTokenAccountsByOwnerWithContextByMint(ctx context.Context, owner, mintAddr string) (rpc.ValueWithContext[[]TokenAccount], error)

func (*Client) GetTokenAccountsByOwnerWithContextByProgram

func (c *Client) GetTokenAccountsByOwnerWithContextByProgram(ctx context.Context, owner, programId string) (rpc.ValueWithContext[[]TokenAccount], error)

func (*Client) GetTokenSupply

func (c *Client) GetTokenSupply(ctx context.Context, mintAddr string) (TokenAmount, error)

func (*Client) GetTokenSupplyAndContext

func (c *Client) GetTokenSupplyAndContext(ctx context.Context, mintAddr string) (rpc.ValueWithContext[TokenAmount], error)

func (*Client) GetTokenSupplyAndContextWithConfig

func (c *Client) GetTokenSupplyAndContextWithConfig(ctx context.Context, mintAddr string, cfg GetTokenSupplyConfig) (rpc.ValueWithContext[TokenAmount], error)

func (*Client) GetTokenSupplyWithConfig

func (c *Client) GetTokenSupplyWithConfig(ctx context.Context, mintAddr string, cfg GetTokenSupplyConfig) (TokenAmount, error)

func (*Client) GetTransaction

func (c *Client) GetTransaction(ctx context.Context, txhash string) (*Transaction, error)

GetTransaction returns transaction details for a confirmed transaction

func (*Client) GetTransactionCount

func (c *Client) GetTransactionCount(ctx context.Context) (uint64, error)

GetTransactionCount returns the current Transaction count from the ledger

func (*Client) GetTransactionCountWithConfig

func (c *Client) GetTransactionCountWithConfig(ctx context.Context, cfg GetTransactionCountConfig) (uint64, error)

GetTransactionCount returns the current Transaction count from the ledger

func (*Client) GetTransactionWithConfig

func (c *Client) GetTransactionWithConfig(ctx context.Context, txhash string, cfg GetTransactionConfig) (*Transaction, error)

GetTransaction returns transaction details for a confirmed transaction

func (*Client) GetVersion

func (c *Client) GetVersion(ctx context.Context) (rpc.GetVersion, error)

GetVersion returns the current solana versions running on the node

func (*Client) GetVoteAccounts

func (c *Client) GetVoteAccounts(ctx context.Context) (VoteAccountStatus, error)

GetVoteAccounts returns the account info and associated stake for all the voting accounts in the current bank.

func (*Client) IsBlockhashValid

func (c *Client) IsBlockhashValid(ctx context.Context, blockhash string) (bool, error)

func (*Client) IsBlockhashValidAndContext

func (c *Client) IsBlockhashValidAndContext(ctx context.Context, blockhash string) (rpc.ValueWithContext[bool], error)

func (*Client) IsBlockhashValidAndContextWithConfig

func (c *Client) IsBlockhashValidAndContextWithConfig(ctx context.Context, blockhash string, cfg IsBlockhashValidConfig) (rpc.ValueWithContext[bool], error)

func (*Client) IsBlockhashValidWithConfig

func (c *Client) IsBlockhashValidWithConfig(ctx context.Context, blockhash string, cfg IsBlockhashValidConfig) (bool, error)

func (*Client) MinimumLedgerSlot

func (c *Client) MinimumLedgerSlot(ctx context.Context) (uint64, error)

MinimumLedgerSlot returns the lowest slot that the node has information about in its ledger. This value may increase over time if the node is configured to purge older ledger data

func (*Client) QuickSendTransaction deprecated

func (c *Client) QuickSendTransaction(ctx context.Context, param QuickSendTransactionParam) (string, error)

Deprecated: please use sendTransaction QuickSendTransaction is a quick way to send tx

func (*Client) RequestAirdrop

func (c *Client) RequestAirdrop(ctx context.Context, base58Addr string, lamports uint64) (string, error)

RequestAirdrop requests an airdrop of lamports to a Pubkey

func (*Client) RequestAirdropWithConfig

func (c *Client) RequestAirdropWithConfig(ctx context.Context, base58Addr string, lamports uint64, cfg RequestAirdropConfig) (string, error)

RequestAirdrop requests an airdrop of lamports to a Pubkey

func (*Client) SendTransaction

func (c *Client) SendTransaction(ctx context.Context, tx types.Transaction) (string, error)

SendTransaction send transaction struct directly

func (*Client) SendTransactionWithConfig

func (c *Client) SendTransactionWithConfig(ctx context.Context, tx types.Transaction, cfg SendTransactionConfig) (string, error)

SendTransaction send transaction struct directly

func (*Client) SimulateTransaction

func (c *Client) SimulateTransaction(ctx context.Context, tx types.Transaction) (SimulateTransaction, error)

func (*Client) SimulateTransactionAndContext

func (c *Client) SimulateTransactionAndContext(ctx context.Context, tx types.Transaction) (rpc.ValueWithContext[SimulateTransaction], error)

func (*Client) SimulateTransactionWithConfig

func (c *Client) SimulateTransactionWithConfig(ctx context.Context, tx types.Transaction, cfg SimulateTransactionConfig) (SimulateTransaction, error)

type ClusterNode

type ClusterNode struct {
	Pubkey       common.PublicKey
	Gossip       *string
	Tpu          *string
	Rpc          *string
	Version      *string
	FeatureSet   *uint32
	ShredVersion *uint16
}

type EpochCredits

type EpochCredits struct {
	Epoch           uint64
	Credits         uint64
	PreviousCredits uint64
}

type GetAccountInfoConfig

type GetAccountInfoConfig struct {
	Commitment rpc.Commitment
	DataSlice  *rpc.DataSlice
}

type GetBalanceConfig

type GetBalanceConfig struct {
	Commitment rpc.Commitment
}

type GetBlockConfig

type GetBlockConfig struct {
	Commitment         rpc.Commitment
	TransactionDetails rpc.GetBlockConfigTransactionDetails
	Rewards            *bool
}

type GetEpochInfo

type GetEpochInfo struct {
	AbsoluteSlot     uint64
	BlockHeight      uint64
	Epoch            uint64
	SlotIndex        uint64
	SlotsInEpoch     uint64
	TransactionCount *uint64
}

type GetFeeForMessageConfig

type GetFeeForMessageConfig struct {
	Commitment rpc.Commitment
}

type GetLatestBlockhashConfig

type GetLatestBlockhashConfig struct {
	Commitment rpc.Commitment
}

type GetLatestBlockhashValue

type GetLatestBlockhashValue struct {
	Commitment rpc.Commitment
}

type GetMinimumBalanceForRentExemptionConfig

type GetMinimumBalanceForRentExemptionConfig struct {
	Commitment rpc.Commitment
}

type GetMultipleAccountsConfig

type GetMultipleAccountsConfig struct {
	Commitment rpc.Commitment
	DataSlice  *rpc.DataSlice
}

type GetSignatureStatusesConfig

type GetSignatureStatusesConfig struct {
	SearchTransactionHistory bool
}

type GetSignaturesForAddressConfig

type GetSignaturesForAddressConfig struct {
	Limit      int
	Before     string
	Until      string
	Commitment rpc.Commitment
}

type GetSlotConfig

type GetSlotConfig struct {
	Commitment rpc.Commitment
}

type GetSlotLeaderConfig

type GetSlotLeaderConfig struct {
	Commitment     *rpc.Commitment
	MinContextSlot *uint64
}

type GetTokenAccountBalanceConfig

type GetTokenAccountBalanceConfig struct {
	Commitment rpc.Commitment
}

type GetTokenSupplyConfig

type GetTokenSupplyConfig struct {
	Commitment rpc.Commitment
}

type GetTransactionConfig

type GetTransactionConfig struct {
	Commitment rpc.Commitment
}

type GetTransactionCountConfig

type GetTransactionCountConfig struct {
	Commitment rpc.Commitment
}

type InnerInstruction

type InnerInstruction struct {
	Index        uint64
	Instructions []types.CompiledInstruction
}

type IsBlockhashValidConfig

type IsBlockhashValidConfig struct {
	Commitment rpc.Commitment
}

type QuickSendTransactionParam

type QuickSendTransactionParam struct {
	Instructions []types.Instruction
	Signers      []types.Account
	FeePayer     common.PublicKey
}

type RequestAirdropConfig

type RequestAirdropConfig struct {
	Commitment rpc.Commitment
}

type ReturnData

type ReturnData struct {
	ProgramId common.PublicKey
	Data      []byte
}

type Reward

type Reward struct {
	Pubkey       common.PublicKey `json:"pubkey"`
	Lamports     int64            `json:"lamports"`
	PostBalances uint64           `json:"postBalance"`
	RewardType   *rpc.RewardType  `json:"rewardType"`
	Commission   *uint8           `json:"commission"`
}

type SendTransactionConfig

type SendTransactionConfig struct {
	SkipPreflight       bool
	PreflightCommitment rpc.Commitment
	MaxRetries          uint64
}

type SimulateTransaction

type SimulateTransaction struct {
	Err          any
	Logs         []string
	Accounts     []*AccountInfo
	ReturnData   *ReturnData
	UnitConsumed *uint64
}

type SimulateTransactionConfig

type SimulateTransactionConfig struct {
	SigVerify              bool
	Commitment             rpc.Commitment
	ReplaceRecentBlockhash bool
	Addresses              []string
}

type TokenAccount

type TokenAccount struct {
	token.TokenAccount
	PublicKey common.PublicKey
}

type TokenAmount

type TokenAmount struct {
	Amount         uint64
	Decimals       uint8
	UIAmountString string
}

type Transaction

type Transaction struct {
	// rpc
	Slot        uint64
	Meta        *TransactionMeta
	Transaction types.Transaction
	BlockTime   *int64

	// custom
	AccountKeys []common.PublicKey
}

func (Transaction) Version

func (t Transaction) Version() types.MessageVersion

type TransactionMeta

type TransactionMeta struct {
	Err                  any
	Fee                  uint64
	PreBalances          []int64
	PostBalances         []int64
	PreTokenBalances     []rpc.TransactionMetaTokenBalance
	PostTokenBalances    []rpc.TransactionMetaTokenBalance
	LogMessages          []string
	InnerInstructions    []InnerInstruction
	LoadedAddresses      rpc.TransactionLoadedAddresses
	ReturnData           *ReturnData
	ComputeUnitsConsumed *uint64
}

type VoteAccountInfo

type VoteAccountInfo struct {
	VotePubkey       common.PublicKey
	NodePubkey       common.PublicKey
	ActivatedStake   uint64
	Commission       uint8
	EpochVoteAccount bool
	LastVote         uint64
	EpochCredits     []EpochCredits
	RootSlot         uint64
}

type VoteAccountStatus

type VoteAccountStatus struct {
	Current    []VoteAccountInfo
	Delinquent []VoteAccountInfo
}

Jump to

Keyboard shortcuts

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