rpc

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2022 License: Apache-2.0 Imports: 17 Imported by: 11

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 AccountKey

type AccountKey struct {
	PublicKey solana.PublicKey `json:"pubkey"`
	Signer    bool             `json:"signer"`
	Writable  bool             `json:"writable"`
}

type BlockReward

type BlockReward struct {
	Pubkey   solana.PublicKey `json:"pubkey"`
	Lamports bin.Uint64       `json:"lamports"`
}

type BlockhashResult

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

type Client

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

func NewClient

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

func (*Client) DoRequest added in v0.5.1

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

func (*Client) GetAccountDataIn

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

func (*Client) GetAccountInfo

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

func (*Client) GetBalance

func (c *Client) GetBalance(ctx context.Context, publicKey string, commitment CommitmentType) (out *GetBalanceResult, err error)

func (*Client) GetConfirmedBlock

func (c *Client) GetConfirmedBlock(ctx context.Context, slot uint64, encoding string) (out *GetConfirmedBlockResult, err error)

func (*Client) GetConfirmedSignaturesForAddress2

func (c *Client) GetConfirmedSignaturesForAddress2(ctx context.Context, address solana.PublicKey, opts *GetConfirmedSignaturesForAddress2Opts) (out GetConfirmedSignaturesForAddress2Result, err error)

func (*Client) GetConfirmedTransaction

func (c *Client) GetConfirmedTransaction(ctx context.Context, signature string) (out TransactionWithMeta, err error)

func (*Client) GetMinimumBalanceForRentExemption

func (c *Client) GetMinimumBalanceForRentExemption(ctx context.Context, dataSize int) (lamport int, err error)

func (*Client) GetProgramAccounts

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

func (*Client) GetRecentBlockhash

func (c *Client) GetRecentBlockhash(ctx context.Context, commitment CommitmentType) (out *GetRecentBlockhashResult, err error)

func (*Client) GetSignaturesForAddress

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

func (*Client) GetSlot

func (c *Client) GetSlot(ctx context.Context, commitment CommitmentType) (out GetSlotResult, err error)

func (*Client) RequestAirdrop

func (c *Client) RequestAirdrop(ctx context.Context, 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(ctx context.Context, 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 FeeCalculator

type FeeCalculator struct {
	LamportsPerSignature bin.Uint64 `json:"lamportsPerSignature"`
}

type GetAccountInfoResult

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

type GetBalanceResult

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

type GetConfirmedBlockResult

type GetConfirmedBlockResult struct {
	Blockhash         solana.PublicKey      `json:"blockhash"`
	PreviousBlockhash solana.PublicKey      `json:"previousBlockhash"` // could be zeroes if ledger was clean-up and this is unavailable
	ParentSlot        bin.Uint64            `json:"parentSlot"`
	Transactions      []TransactionWithMeta `json:"transactions"`
	Rewards           []BlockReward         `json:"rewards"`
	BlockTime         bin.Uint64            `json:"blockTime,omitempty"`
}

type GetConfirmedSignaturesForAddress2Opts

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

type GetConfirmedSignaturesForAddress2Result

type GetConfirmedSignaturesForAddress2Result []*TransactionSignature

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 GetSlotResult

type GetSlotResult bin.Uint64

type InstructionInfo

type InstructionInfo struct {
	Info            map[string]interface{} `json:"info"`
	InstructionType string                 `json:"type"`
}

type KeyedAccount

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

type Message

type Message struct {
	AccountKeys     []*AccountKey       `json:"accountKeys"`
	RecentBlockhash solana.PublicKey    `json:"recentBlockhash"`
	Instructions    []ParsedInstruction `json:"instructions"`
}

type ParsedInstruction

type ParsedInstruction struct {
	Accounts  []solana.PublicKey `json:"accounts,omitempty"`
	Data      solana.Base58      `json:"data,omitempty"`
	Parsed    *InstructionInfo   `json:"parsed,omitempty"`
	Program   string             `json:"program,omitempty"`
	ProgramID solana.PublicKey   `json:"programId"`
}

func (*ParsedInstruction) IsParsed

func (p *ParsedInstruction) IsParsed() bool

type ParsedTransaction

type ParsedTransaction struct {
	Signatures []solana.Signature `json:"signatures"`
	Message    Message            `json:"message"`
}

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 SendTransactionOptions

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

type SimulateTransactionResponse

type SimulateTransactionResponse struct {
	Err  interface{}
	Logs []string
}

type TransactionError

type TransactionError struct {
	InstructionIndex     uint64
	Logs                 []string
	InstructionErrorCode string
	InstructionErrorType string
	// contains filtered or unexported fields
}

type TransactionMeta

type TransactionMeta struct {
	Err          interface{}  `json:"err"`
	Fee          bin.Uint64   `json:"fee"`
	PreBalances  []bin.Uint64 `json:"preBalances"`
	PostBalances []bin.Uint64 `json:"postBalances"`
}

type TransactionParsed

type TransactionParsed struct {
	Transaction *ParsedTransaction `json:"transaction"`
	Meta        *TransactionMeta   `json:"meta,omitempty"`
}

type TransactionSignature

type TransactionSignature struct {
	Err       interface{} `json:"err,omitempty"`
	Memo      string      `json:"memo,omitempty"`
	Signature string      `json:"signature,omitempty"`
	Slot      bin.Uint64  `json:"slot,omitempty"`
}

type TransactionWithMeta

type TransactionWithMeta struct {
	Transaction *solana.Transaction `json:"transaction"`
	Meta        *TransactionMeta    `json:"meta,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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