solana

package
v0.5.15 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: GPL-3.0 Imports: 15 Imported by: 2

Documentation

Index

Constants

View Source
const DefaultClientRPCURL = "http://localhost:8899"

DefaultClientRPCURL is the default RPC URL for the Solana cluster.

Variables

This section is empty.

Functions

func FindProgramAddress added in v0.3.0

func FindProgramAddress(seeds []byte, program address.RawAddress) (address.Address, error)

FindProgramAddress is a wrapper function that calls the Solana FFI to find the deterministic program-derived address using the program and seeds.

func ProgramDerivedAddress added in v0.3.0

func ProgramDerivedAddress(seeds pack.Bytes, program address.Address) address.Address

ProgramDerivedAddress derives an address for an account that only the given program has the authority to sign. The address is of the same form as a Solana pubkey, except they are ensured to not be on the es25519 curve and thus have no associated private key. This address is deterministic, based upon the program and the seeds slice.

func SendRawPost

func SendRawPost(data []byte, url string) (*http.Response, error)

SendRawPost sends a raw bytes as a POST request to the URL specified

func SendRequest

func SendRequest(request Request, url string) (*http.Response, error)

SendRequest sends the JSON-2.0 request to the target url and returns the response and any error.

func SendRequestWithRetry

func SendRequestWithRetry(request Request, url string, timeoutInSecs int, retries int) (response *http.Response, err error)

SendRequestWithRetry calls SendRequest but with configurable retry logic

func UniquePubkey added in v0.3.0

func UniquePubkey() address.Address

UniquePubkey creates an atomically incrementing pubkey used for tests and benchmarking purposes.

Types

type AccountContext

type AccountContext struct {
	Slot int `json:"slot"`
}

AccountContext is the JSON-interface of the account's context representing what slot the account's value has been returned for.

type AccountValue

type AccountValue struct {
	Data       [2]string `json:"data"`
	Executable bool      `json:"executable"`
	Lamports   int       `json:"lamports"`
	Owner      string    `json:"owner"`
	RentEpoch  int       `json:"rentEpoch"`
}

AccountValue is the JSON-interface of the account's information.

type AddressDecoder

type AddressDecoder struct{}

AddressDecoder implements the address.Decoder interface.

func (AddressDecoder) DecodeAddress

func (AddressDecoder) DecodeAddress(encoded address.Address) (address.RawAddress, error)

DecodeAddress consumes a human-readable Base58 format and decodes it into a raw byte-representation.

type AddressEncodeDecoder added in v0.3.0

type AddressEncodeDecoder struct {
	AddressEncoder
	AddressDecoder
}

AddressEncodeDecoder implements the address.EncodeDecoder interface.

func NewAddressEncodeDecoder added in v0.3.0

func NewAddressEncodeDecoder() AddressEncodeDecoder

NewAddressEncodeDecoder constructs and returns a new AddressEncodeDecoder.

type AddressEncoder added in v0.3.0

type AddressEncoder struct{}

AddressEncoder implements the address.Encoder interface.

func (AddressEncoder) EncodeAddress added in v0.3.0

func (AddressEncoder) EncodeAddress(rawAddress address.RawAddress) (address.Address, error)

EncodeAddress consumes a raw byte-representation of an address and encodes it to the human-readable Base58 format.

type Client

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

Client represents a Solana client that implements the multichain Contract API.

func NewClient

func NewClient(opts ClientOptions) *Client

NewClient returns a new solana.Client interface that implements the multichain Contract API.

func (*Client) CallContract

func (client *Client) CallContract(
	ctx context.Context,
	program address.Address,
	calldata contract.CallData,
) (pack.Bytes, error)

CallContract implements the multichain Contract API. In the case of Solana, it is used to fetch burn logs associated with a particular burn nonce.

func (*Client) GetAccountData added in v0.3.5

func (client *Client) GetAccountData(account address.Address) (pack.Bytes, error)

GetAccountData fetches and returns the account data.

type ClientOptions

type ClientOptions struct {
	Logger *zap.Logger
	RPCURL string
}

ClientOptions define the options to instantiate a new Solana client.

func DefaultClientOptions

func DefaultClientOptions() ClientOptions

DefaultClientOptions return the client options used to instantiate a Solana client by default.

func (ClientOptions) WithRPCURL added in v0.3.0

func (opts ClientOptions) WithRPCURL(rpcURL pack.String) ClientOptions

WithRPCURL returns a modified version of the options with the given API rpc-url

type Error

type Error struct {
	Code    int              `json:"code"`
	Message string           `json:"message"`
	Data    *json.RawMessage `json:"data"`
}

Error defines a JSON-RPC 2.0 error object. See https://www.jsonrpc.org/specification for more information.

type Request

type Request struct {
	Version string          `json:"jsonrpc"`
	ID      interface{}     `json:"id"`
	Method  string          `json:"method"`
	Params  json.RawMessage `json:"params,omitempty"`
}

Request defines a JSON-RPC 2.0 request object. See https://www.jsonrpc.org/specification for more information. A Request should not be explicitly created, but instead unmarshaled from JSON.

type Response

type Response struct {
	Version string           `json:"jsonrpc"`
	ID      interface{}      `json:"id"`
	Result  *json.RawMessage `json:"result,omitempty"`
	Error   *Error           `json:"error,omitempty"`
}

Response defines a JSON-RPC 2.0 response object. See https://www.jsonrpc.org/specification for more information. A Response is usually marshaled into bytes and returned in response to a Request.

func SendData

func SendData(method string, data []byte, url string) (Response, error)

SendData sends data to method via jsonrpc

func SendDataWithRetry

func SendDataWithRetry(method string, data []byte, url string) (Response, error)

SendDataWithRetry is the same as SendData but will retry if sending the request failed

type ResponseGetAccountInfo

type ResponseGetAccountInfo struct {
	Context AccountContext `json:"context"`
	Value   AccountValue   `json:"value"`
}

ResponseGetAccountInfo is the JSON-interface of the response for the getAccountInfo query.

Jump to

Keyboard shortcuts

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