rpc

package
v0.0.0-...-810d5f5 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const LogContextHttp = "COMMON/SOLANA/HTTP"
View Source
const LogContextWebsocket = "SOLANA/RPC/WEBSOCKET"

LogContextWebsocket to use for following errors

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockResponse

type BlockResponse struct {
	Value struct {
		Slot  uint64           `json:"slot"`
		Error *solana.RpcError `json:"err"`
		Block solana.Block     `json:"block"`
	} `json:"value"`
}

type GetTokenAccountBalanceResult

type GetTokenAccountBalanceResult struct {
	RpcContext

	Value *struct {
		// Raw balance of tokens as a string, ignoring decimals.
		Amount string `json:"amount"`

		// Number of decimals configured for token's mint.
		Decimals uint8 `json:"decimals"`

		// TODO: <number> == int64 ???
		// DEPRECATED: Token amount as a float, accounting for decimals.
		UiAmount *float64 `json:"uiAmount"`

		// Token amount as a string, accounting for decimals.
		UiAmountString string `json:"uiAmountString"`
	} `json:"value"`
}

type GetTokenSupplyResult

type GetTokenSupplyResult struct {
	RpcContext

	Value *struct {
		// Raw amount of tokens as a string, ignoring decimals.
		Amount string `json:"amount"`

		// Number of decimals configured for token's mint.
		Decimals uint8 `json:"decimals"`

		// TODO: <number> == int64 ???
		// DEPRECATED: Token amount as a float, accounting for decimals.
		UiAmount *float64 `json:"uiAmount"`

		// Token amount as a string, accounting for decimals.
		UiAmountString string `json:"uiAmountString"`
	} `json:"value"`
}

type Http

type Http struct {
	http.Client
	// contains filtered or unexported fields
}

func NewHttp

func NewHttp(url_ string) (*Http, error)

func (Http) RawInvoke

func (client Http) RawInvoke(method string, params interface{}) (json.RawMessage, error)

type Provider

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

Provider supporting

func New

func New(url_ string) (*Provider, error)

New rpc provider - wss? will use Websocket, https? will use Http

func (Provider) GetAccountInfo

func (s Provider) GetAccountInfo(account_ solana.PublicKey) (*types.Account, error)

func (Provider) GetConfirmedBlocks

func (s Provider) GetConfirmedBlocks(from, to uint64) ([]uint64, error)

func (Provider) GetLatestSlot

func (s Provider) GetLatestSlot() (uint64, error)

func (*Provider) GetRecentBlockhash

func (s *Provider) GetRecentBlockhash(commitment string) (hash solana.Hash, err error)

func (*Provider) GetTokenAccountBalance

func (s *Provider) GetTokenAccountBalance(pda solana.PublicKey, commitment string) (*GetTokenAccountBalanceResult, error)

func (*Provider) GetTokenSupply

func (s *Provider) GetTokenSupply(mint solana.PublicKey, commitment string) (*GetTokenSupplyResult, error)

func (Provider) RawInvoke

func (s Provider) RawInvoke(method string, body interface{}) (json.RawMessage, error)

Invoke Solana RPC method

func (*Provider) SendTransaction

func (s *Provider) SendTransaction(transaction *solana.Transaction) (sig solana.Signature, err error)

func (Provider) SimulateTransaction

func (s Provider) SimulateTransaction(transaction []byte, signatureVerify bool, commitment string, replaceRecentBlockHash bool, accounts ...solana.PublicKey) (*SimulationValue, error)

type RpcContext

type RpcContext struct {
	Context struct {
		Slot uint64 `json:"slot"`
	} `json:"context,omitempty"`
}

RpcContext used for tracing the outcome of different uses of the RPC

type SimulationResponse

type SimulationResponse struct {
	Value SimulationValue `json:"value"`
}

type SimulationValue

type SimulationValue struct {
	TransactionError *interface{}    `json:"err"`
	Logs             []string        `json:"logs"`
	Accounts         []types.Account `json:"accounts"`
	UnitsConsumed    uint64          `json:"unitsConsumed"`
}

type Subscription

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

type SubscriptionResponse

type SubscriptionResponse struct {
	Jsonrpc string `json:"jsonrpc"`
	Result  int    `json:"result,omitempty"`
	Id      int    `json:"method"`
	Error   rpcError
}

type Websocket

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

func NewWebsocket

func NewWebsocket(url string) (*Websocket, error)

func (Websocket) RawInvoke

func (websocket Websocket) RawInvoke(method string, params interface{}) (json.RawMessage, error)

func (Websocket) SubscribeAccount

func (websocket Websocket) SubscribeAccount(publicKey solana.PublicKey, f func(types.Account))

SubscribeAccount subscribes to changes to account and dies with log.Fatal if something goes wrong

func (Websocket) SubscribeBlocks

func (websocket Websocket) SubscribeBlocks(accountOrProgram solCommon.PublicKey, f func(BlockResponse))

SubscribeBlocks to subscribe to new blocks with the given filter, if provided

func (Websocket) SubscribeSlots

func (websocket Websocket) SubscribeSlots(f func(solana.Slot))

SubscribeSlots subscribes to new slots

Jump to

Keyboard shortcuts

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