rpc

package
v0.0.0-...-33cbf18 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CommitmentProcessed queries the most recent block which has reached 1 confirmation by the connected node
	CommitmentProcessed = CommitmentType("processed")
	// CommitmentConfirmed queries the most recent block which has reached 1 confirmation by the cluster
	CommitmentConfirmed = CommitmentType("confirmed")
	// CommitmentConfirmed queries the most recent block which has been finalized by the cluster
	CommitmentFinalized = CommitmentType("finalized")

	// The following are deprecated
	CommitmentMax          = CommitmentType("max")          // Deprecated as of v1.5.5
	CommitmentRecent       = CommitmentType("recent")       // Deprecated as of v1.5.5
	CommitmentRoot         = CommitmentType("root")         // Deprecated as of v1.5.5
	CommitmentSingle       = CommitmentType("single")       // Deprecated as of v1.5.5
	CommitmentSingleGossip = CommitmentType("singleGossip") // Deprecated as of v1.5.5
)

Variables

View Source
var ErrNotFound = errors.New("not found")
View Source
var WithDebug = func() ClientOption {
	return func(cli *Client) *Client {
		cli.debug = true
		return cli
	}
}

Functions

This section is empty.

Types

type Account

type Account struct {
	Lamports   bin.Uint64       `json:"lamports"`
	Data       solana.Data      `json:"data"`
	Owner      solana.PublicKey `json:"owner"`
	Executable bool             `json:"executable"`
	RentEpoch  bin.Uint64       `json:"rentEpoch"`
}

type BlockhashResult

type BlockhashResult struct {
	Blockhash            solana.PublicKey `json:"blockhash"` /* make this a `Hash` type, which is a copy of the PublicKey` type */
	LastValidBlockHeight bin.Uint64       `json:"lastValidBlockHeight"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(rpcURL string, opts ...ClientOption) *Client

func (*Client) DoRequest

func (c *Client) DoRequest(out interface{}, method string, params ...interface{}) error

func (*Client) GetAccountDataIn

func (c *Client) GetAccountDataIn(account solana.PublicKey, inVar interface{}) (err error)

func (*Client) GetAccountInfo

func (c *Client) GetAccountInfo(account solana.PublicKey) (out *GetAccountInfoResult, err error)

func (*Client) GetBalance

func (c *Client) GetBalance(publicKey solana.PublicKey, commitment *CommitmentType) (out *GetBalanceResult, err error)

func (*Client) GetBlock

func (c *Client) GetBlock(slotNum uint64) (out *GetBlockResult, err error)

func (*Client) GetConfirmedTransaction

func (c *Client) GetConfirmedTransaction(signature string) (out *GetTransactionResponse, err error)

func (*Client) GetLatestBlockhash

func (c *Client) GetLatestBlockhash(commitment CommitmentType) (out *GetRecentBlockhashResult, err error)

func (*Client) GetMinimumBalanceForRentExemption

func (c *Client) GetMinimumBalanceForRentExemption(dataSize int) (lamport int, err error)

func (*Client) GetProgramAccounts

func (c *Client) GetProgramAccounts(publicKey solana.PublicKey, opts *GetProgramAccountsOpts) (out GetProgramAccountsResult, err error)

func (*Client) GetSignaturesForAddress

func (c *Client) GetSignaturesForAddress(address solana.PublicKey, opts *GetSignaturesForAddressOpts) (out GetSignaturesForAddressResult, err error)

func (*Client) GetSlot

func (c *Client) GetSlot(commitment *CommitmentType) (uint64, error)

func (*Client) GetTransaction

func (c *Client) GetTransaction(signature string, commitmentType *CommitmentType) (out *GetTransactionResponse, err error)

GetTransaction For processing many dependent transactions in series, it's recommended to use "confirmed" commitment, which balances speed with rollback safety. For total safety, it's recommended to use"finalized" commitment.

func (*Client) RequestAirdrop

func (c *Client) RequestAirdrop(account *solana.PublicKey, lamport uint64, commitment CommitmentType) (signature string, err error)

func (*Client) SendTransaction

func (c *Client) SendTransaction(transaction *solana.Transaction, opts *SendTransactionOptions) (signature string, err error)

func (*Client) SetHeader

func (c *Client) SetHeader(k, v string)

func (*Client) SimulateTransaction

func (c *Client) SimulateTransaction(transaction *solana.Transaction) (*SimulateTransactionResponse, error)

type ClientOption

type ClientOption = func(cli *Client) *Client

type CommitmentType

type CommitmentType string

CommitmentType is the level of commitment desired when querying state. https://docs.solana.com/developing/clients/jsonrpc-api#configuring-state-commitment

type Context

type Context struct {
	Slot bin.Uint64
}

type GetAccountInfoResult

type GetAccountInfoResult struct {
	RPCContext
	Value *Account `json:"value"`
}

type GetBalanceResult

type GetBalanceResult struct {
	RPCContext
	Value bin.Uint64 `json:"value"`
}

type GetBlockResult

type GetBlockResult struct {
	// For blocs below ~ 900K RPC nodes often return nil
	BlockHeight *bin.Uint64 `json:"blockHeight"`
	// For blocs below ~ 900K RPC nodes often return nil
	BlockTime         *bin.Uint64      `json:"blockTime"`
	Blockhash         solana.PublicKey `json:"blockhash"`
	ParentSlot        bin.Uint64       `json:"parentSlot"`
	PreviousBlockhash solana.PublicKey `json:"previousBlockhash"`
}

type GetProgramAccountsOpts

type GetProgramAccountsOpts struct {
	Commitment CommitmentType `json:"commitment,omitempty"`
	// Filter on accounts, implicit AND between filters
	Filters []RPCFilter `json:"filters,omitempty"`
}

type GetProgramAccountsResult

type GetProgramAccountsResult []*KeyedAccount

type GetRecentBlockhashResult

type GetRecentBlockhashResult struct {
	RPCContext
	Value *BlockhashResult `json:"value"`
}

type GetSignaturesForAddressOpts

type GetSignaturesForAddressOpts struct {
	Limit  uint64 `json:"limit,omitempty"`
	Before string `json:"before,omitempty"`
	Until  string `json:"until,omitempty"`
}

type GetSignaturesForAddressResult

type GetSignaturesForAddressResult []*TransactionSignature

type GetTransactionResponse

type GetTransactionResponse struct {
	Slot        bin.Uint64   `json:"slot"`
	BlockTime   *bin.Uint64  `json:"blockTime"`
	Transaction *Transaction `json:"transaction"`
	Meta        *Meta        `json:"meta"`
}

type InnerInstruction

type InnerInstruction struct {
	Index        bin.Uint64        `json:"index"`
	Instructions []InstructionMeta `json:"instructions"`
}

type Instruction

type Instruction struct {
	ProgramIdIndex bin.Uint64   `json:"programIdIndex"`
	Accounts       []bin.Uint64 `json:"accounts"`
	Data           string       `json:"data"`
}

type InstructionMeta

type InstructionMeta struct {
	Accounts       []bin.Uint64 `json:"accounts"`
	Data           string       `json:"data"`
	ProgramIdIndex bin.Uint64   `json:"programIdIndex"`
}

type KeyedAccount

type KeyedAccount struct {
	Pubkey  solana.PublicKey `json:"pubkey"`
	Account *Account         `json:"account"`
}

type Message

type Message struct {
	AccountKeys     []solana.PublicKey `json:"accountKeys"`
	Header          MessageHeader      `json:"header"`
	Instructions    []Instruction      `json:"instructions"`
	RecentBlockhash solana.PublicKey   `json:"recentBlockhash"`
}

type MessageHeader

type MessageHeader struct {
	NumReadonlySignedAccounts   bin.Uint64 `json:"numReadonlySignedAccounts"`
	NumReadonlyUnsignedAccounts bin.Uint64 `json:"numReadonlyUnsignedAccounts"`
	NumRequiredSignatures       bin.Uint64 `json:"numRequiredSignatures"`
}

type Meta

type Meta struct {
	Err               *TransactionError   `json:"err"`
	Fee               bin.Uint64          `json:"fee"`
	PreBalances       []bin.Uint64        `json:"preBalances"`
	PostBalances      []bin.Uint64        `json:"postBalances"`
	InnerInstructions []*InnerInstruction `json:"innerInstructions"`
	PostTokenBalances []*TokeBalance      `json:"postTokenBalances"`
	PreTokenBalances  []*TokeBalance      `json:"preTokenBalances"`
	LogMessages       []string            `json:"logMessages"`
	Rewards           []interface{}       `json:"rewards"`
}

type RPCContext

type RPCContext struct {
	Context Context `json:"context,omitempty"`
}

type RPCFilter

type RPCFilter struct {
	Memcmp   *RPCFilterMemcmp `json:"memcmp,omitempty"`
	DataSize bin.Uint64       `json:"dataSize,omitempty"`
}

type RPCFilterMemcmp

type RPCFilterMemcmp struct {
	Offset int           `json:"offset"`
	Bytes  solana.Base58 `json:"bytes"`
}

type RpcError

type RpcError struct {
	*jsonrpc.RPCError

	Logs []string
	// contains filtered or unexported fields
}

type SendTransactionOptions

type SendTransactionOptions struct {
	SkipPreflight       bool           // disable transaction verification step
	PreflightCommitment CommitmentType // preflight commitment level; default: "finalized"
}

type SimulateTransactionResponse

type SimulateTransactionResponse struct {
	Err  *TransactionError
	Logs []string
}

type TokeBalance

type TokeBalance struct {
	AccountIndex bin.Uint64       `json:"accountIndex"`
	Mint         solana.PublicKey `json:"mint"`
	Owner        solana.PublicKey `json:"owner"`
}

type Transaction

type Transaction struct {
	Signatures []string `json:"signatures"`
	Message    *Message `json:"message"`
}

func (*Transaction) ResolveProgramIdIndex

func (t *Transaction) ResolveProgramIdIndex(programIdIndex uint64) (out solana.PublicKey, err error)

type TransactionError

type TransactionError struct {
	Raw                  map[string]interface{} `json:"data,omitempty"`
	InstructionIndex     uint64
	InstructionErrorCode string
	InstructionErrorType string
}

func (*TransactionError) UnmarshalJSON

func (t *TransactionError) UnmarshalJSON(data []byte) (err error)

type TransactionSignature

type TransactionSignature struct {
	BlockTime          bin.Uint64        `json:"blockTime"`
	ConfirmationStatus string            `json:"confirmationStatus"`
	Err                *TransactionError `json:"err"`
	Memo               *string           `json:"memo"`
	Signature          string            `json:"signature"`
	Slot               bin.Uint64        `json:"slot"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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