solana

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckError added in v0.3.0

func CheckError(err error) xc.ClientError

func FindAssociatedTokenAddress

func FindAssociatedTokenAddress(addr string, contract string) (string, error)

FindAssociatedTokenAddress returns the associated token account (ATA) for a given account and token

func NewAddressBuilder

func NewAddressBuilder(asset xc.ITask) (xc.AddressBuilder, error)

NewAddressBuilder creates a new Solana AddressBuilder

func NewSigner

func NewSigner(cfgI xc.ITask) (xc.Signer, error)

NewSigner creates a new Solana Signer

func NewTxBuilder

func NewTxBuilder(asset xc.ITask) (xc.TxBuilder, error)

NewTxBuilder creates a new Solana TxBuilder

Types

type AddressBuilder

type AddressBuilder struct {
}

AddressBuilder for Solana

func (AddressBuilder) GetAddressFromPublicKey

func (ab AddressBuilder) GetAddressFromPublicKey(publicKeyBytes []byte) (xc.Address, error)

GetAddressFromPublicKey returns an Address given a public key

func (AddressBuilder) GetAllPossibleAddressesFromPublicKey

func (ab AddressBuilder) GetAllPossibleAddressesFromPublicKey(publicKeyBytes []byte) ([]xc.PossibleAddress, error)

GetAllPossibleAddressesFromPublicKey returns all PossubleAddress(es) given a public key

type Client

type Client struct {
	SolClient *rpc.Client
	Asset     xc.ITask
}

Client for Solana

func NewClient

func NewClient(cfgI xc.ITask) (*Client, error)

NewClient returns a new JSON-RPC Client to the Solana node

func (*Client) FetchBalance added in v0.2.0

func (client *Client) FetchBalance(ctx context.Context, address xc.Address) (xc.AmountBlockchain, error)

FetchBalance fetches token balance for a Solana address

func (*Client) FetchBalanceForAsset added in v0.3.0

func (client *Client) FetchBalanceForAsset(ctx context.Context, address xc.Address, assetCfg xc.ITask) (xc.AmountBlockchain, error)

FetchBalanceForAsset fetches a specific token balance which may not be the asset configured for the client

func (*Client) FetchNativeBalance added in v0.2.0

func (client *Client) FetchNativeBalance(ctx context.Context, address xc.Address) (xc.AmountBlockchain, error)

FetchNativeBalance fetches account balance for a Solana address

func (*Client) FetchTxInfo

func (client *Client) FetchTxInfo(ctx context.Context, txHash xc.TxHash) (xc.TxInfo, error)

FetchTxInfo returns tx info for a Solana tx

func (*Client) FetchTxInput

func (client *Client) FetchTxInput(ctx context.Context, from xc.Address, to xc.Address) (xc.TxInput, error)

FetchTxInput returns tx input for a Solana tx, namely a RecentBlockHash

func (*Client) SubmitTx

func (client *Client) SubmitTx(ctx context.Context, txInput xc.Tx) error

type Signer

type Signer struct {
}

Signer for Solana

func (Signer) ImportPrivateKey added in v0.2.0

func (signer Signer) ImportPrivateKey(privateKey string) (xc.PrivateKey, error)

ImportPrivateKey imports a Solana private key

func (Signer) Sign

func (signer Signer) Sign(privateKey xc.PrivateKey, data xc.TxDataToSign) (xc.TxSignature, error)

Sign a Solana tx

type Tx

type Tx struct {
	SolTx       *solana.Transaction
	ParsedSolTx *rpc.ParsedTransaction // similar, but different type
	// contains filtered or unexported fields
}

Tx for Solana, encapsulating a solana.Transaction and other info

func (Tx) AddSignatures added in v0.3.0

func (tx Tx) AddSignatures(signatures ...xc.TxSignature) error

AddSignatures adds a signature to Tx

func (Tx) Amount added in v0.2.0

func (tx Tx) Amount() xc.AmountBlockchain

Amount returns the tx amount

func (Tx) ContractAddress

func (tx Tx) ContractAddress() xc.ContractAddress

ContractAddress returns the contract address for a token transfer

func (Tx) From

func (tx Tx) From() xc.Address

From is the sender of a transfer

func (Tx) Hash

func (tx Tx) Hash() xc.TxHash

Hash returns the tx hash or id, for Solana it's signature

func (*Tx) ParseTransfer

func (tx *Tx) ParseTransfer()

ParseTransfer parses a tx and extracts higher-level transfer information

func (Tx) RecentBlockhash

func (tx Tx) RecentBlockhash() string

RecentBlockhash returns the recent block hash used as a nonce for a Solana tx

func (Tx) Serialize added in v0.2.0

func (tx Tx) Serialize() ([]byte, error)

Serialize returns the serialized tx

func (*Tx) SetAssociatedTokenAccount

func (tx *Tx) SetAssociatedTokenAccount(ata *token.Account)

SetAssociatedTokenAccount sets the associated token account

func (Tx) Sighashes added in v0.3.0

func (tx Tx) Sighashes() ([]xc.TxDataToSign, error)

Sighashes returns the tx payload to sign, aka sighashes

func (Tx) To

func (tx Tx) To() xc.Address

To is the account receiving a transfer

func (Tx) ToAlt

func (tx Tx) ToAlt() xc.Address

ToAlt returns an alternative recipient, for Solana the Associated Token Account

type TxBuilder

type TxBuilder struct {
	Asset xc.ITask
}

TxBuilder for Solana

func (TxBuilder) BuildUnwrapEverythingTx added in v0.3.0

func (txBuilder TxBuilder) BuildUnwrapEverythingTx(from xc.Address, to xc.Address, amount xc.AmountBlockchain, txInput *TxInput) (xc.Tx, error)

func (TxBuilder) BuildWrapTx added in v0.3.0

func (txBuilder TxBuilder) BuildWrapTx(from xc.Address, to xc.Address, amount xc.AmountBlockchain, txInput *TxInput) (xc.Tx, error)

func (TxBuilder) NewNativeTransfer

func (txBuilder TxBuilder) NewNativeTransfer(from xc.Address, to xc.Address, amount xc.AmountBlockchain, input xc.TxInput) (xc.Tx, error)

NewNativeTransfer creates a new transfer for a native asset

func (TxBuilder) NewTask added in v0.3.0

func (txBuilder TxBuilder) NewTask(from xc.Address, to xc.Address, amount xc.AmountBlockchain, input xc.TxInput) (xc.Tx, error)

func (TxBuilder) NewTokenTransfer

func (txBuilder TxBuilder) NewTokenTransfer(from xc.Address, to xc.Address, amount xc.AmountBlockchain, input xc.TxInput) (xc.Tx, error)

NewTokenTransfer creates a new transfer for a token asset

func (TxBuilder) NewTransfer

func (txBuilder TxBuilder) NewTransfer(from xc.Address, to xc.Address, amount xc.AmountBlockchain, input xc.TxInput) (xc.Tx, error)

NewTransfer creates a new transfer for an Asset, either native or token

type TxInput

type TxInput struct {
	xc.TxInputEnvelope
	RecentBlockHash solana.Hash
	ToIsATA         bool
	ShouldCreateATA bool
}

TxInput for Solana

func NewTxInput added in v0.3.0

func NewTxInput() *TxInput

NewTxInput returns a new Solana TxInput

Jump to

Keyboard shortcuts

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