solana

package
v0.0.0-...-f76b1da Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EventLogPrefix        = "Program data: "
	EventSendMessage      = "SendMessage"
	EventCallMessage      = "CallMessage"
	EventRollbackMessage  = "RollbackMessage"
	EventCallMessageSent  = "CallMessageSent"
	EventRollbackExecuted = "RollbackExecuted"
	EventResponseMessage  = "ResponseMessage"
)

Functions

func NewSolanaRemoteNet

func NewSolanaRemoteNet(testName string, log *zap.Logger, chainConfig chains.ChainConfig, client *client.Client, network string, testconfig *testconfig.Chain) chains.Chain

Types

type CallMessageEvent

type CallMessageEvent struct {
	FromNetworkAddress string
	To                 string
	Sn                 big.Int
	ReqId              big.Int
	Data               []byte
}

type CallMessageSent

type CallMessageSent struct {
	From solana.PublicKey
	To   string
	Sn   big.Int
}

type Client

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

func New

func New(rpcUrl string, rpcCl *solrpc.Client) (*Client, error)

func (Client) GetAccountInfo

func (cl Client) GetAccountInfo(ctx context.Context, acAddr string, accPtr interface{}) error

func (Client) GetAccountInfoRaw

func (cl Client) GetAccountInfoRaw(ctx context.Context, addr string) (*solrpc.Account, error)

func (Client) GetEvent

func (cl Client) GetEvent(ctx context.Context, account solana.PublicKey,
	allEvents []IdlEvent, signature, sno string) (*EventResponseEvent, error)

func (Client) GetLatestBlockHash

func (cl Client) GetLatestBlockHash(ctx context.Context) (*solana.Hash, error)

func (Client) GetLatestBlockHeight

func (cl Client) GetLatestBlockHeight(ctx context.Context, ctype solrpc.CommitmentType) (uint64, error)

func (Client) GetSignatureStatus

func (cl Client) GetSignatureStatus(
	ctx context.Context,
	searchTxHistory bool,
	sign solana.Signature,
) (*solrpc.SignatureStatusesResult, error)

func (Client) GetSignaturesForAddress

func (cl Client) GetSignaturesForAddress(
	ctx context.Context,
	account solana.PublicKey,
	opts *solrpc.GetSignaturesForAddressOpts,
) ([]*solrpc.TransactionSignature, error)

func (Client) GetTransaction

func (cl Client) GetTransaction(
	ctx context.Context,
	signature solana.Signature,
	opts *solrpc.GetTransactionOpts,
) (*solrpc.GetTransactionResult, error)

func (Client) SendTx

func (cl Client) SendTx(
	ctx context.Context,
	tx *solana.Transaction,
	opts *solrpc.TransactionOpts,
) (solana.Signature, error)

func (Client) SimulateTx

func (cl Client) SimulateTx(
	ctx context.Context,
	tx *solana.Transaction,
	opts *solrpc.SimulateTransactionOpts,
) (*solrpc.SimulateTransactionResult, error)

type Conn

type Conn struct {
	SrcEndpoint string
	DstEndpoint string
}

type ConnAc

type ConnAc struct {
	Connections []Conn
}

type DappConfigAccount

type DappConfigAccount struct {
	Sn           big.Int
	XcallAddress solana.PublicKey
	Bump         uint8
}

type EventResponse

type EventResponse struct {
	Events []EventResponseEvent `json:"events"`
}

type EventResponseEvent

type EventResponseEvent struct {
	Type         string   `json:"type"`
	ContractId   string   `json:"contractID"`
	Topic        []string `json:"topic"`
	Value        string   `json:"value"`
	ValueDecoded map[string]interface{}
}

type IDL

type IDL struct {
	Address      string           `json:"address"`
	Metadata     IdlMetadata      `json:"metadata"`
	Instructions []IdlInstruction `json:"instructions"`
	Accounts     []IdlAccount     `json:"accounts"`
	Events       []IdlEvent       `json:"events"`
	Types        []IdlType        `json:"types"`
}

func (*IDL) GetInstructionDiscriminator

func (idl *IDL) GetInstructionDiscriminator(name string) ([]byte, error)

func (*IDL) GetProgramID

func (idl *IDL) GetProgramID() (solana.PublicKey, error)

type IdlAccount

type IdlAccount struct {
	Name          string `json:"name"`
	Address       string `json:"address"`
	Writable      bool   `json:"writeable"`
	Signer        bool   `json:"signer"`
	Discriminator []byte `json:"discriminator"`
}

type IdlDS

type IdlDS struct {
	Kind   string        `json:"kind"`
	Fields []interface{} `json:"fields"`
}

IdlDS DS means data structure

type IdlEvent

type IdlEvent struct {
	Name          string `json:"name"`
	Discriminator []byte `json:"discriminator"`
}

type IdlField

type IdlField struct {
	Name string      `json:"name"`
	Type interface{} `json:"type"`
}

type IdlInstruction

type IdlInstruction struct {
	Name          string       `json:"name"`
	Discriminator []byte       `json:"discriminator"`
	Accounts      []IdlAccount `json:"accounts"`
	Args          []IdlField   `json:"args"`
}

type IdlMetadata

type IdlMetadata struct {
	Name        string `json:"name"`
	Version     string `json:"version"`
	Spec        string `json:"spec"`
	Description string `json:"description"`
}

type IdlType

type IdlType struct {
	Name string `json:"name"`
	Type IdlDS  `json:"type"`
}

type NetworkAddress

type NetworkAddress struct {
	Address string
}

type ResponseMessage

type ResponseMessage struct {
	Code uint8
	Sn   big.Int
}

type RollbackExecuted

type RollbackExecuted struct {
	Sn big.Int
}

type SolEvent

type SolEvent struct {
	Slot      uint64
	Signature solana.Signature
	Logs      []string
}

type SolanaRemoteNet

type SolanaRemoteNet struct {
	IBCAddresses map[string]string `json:"addresses"`

	Wallets map[string]ibc.Wallet `json:"wallets"`
	Client  *client.Client
	Network string

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

func (*SolanaRemoteNet) BinCommand

func (sn *SolanaRemoteNet) BinCommand(command ...string) []string

func (*SolanaRemoteNet) Config

func (sn *SolanaRemoteNet) Config() chains.ChainConfig

Config fetches the chain configuration.

func (*SolanaRemoteNet) DeployContractRemote

func (sn *SolanaRemoteNet) DeployContractRemote(ctx context.Context, contractName string) (string, error)

func (*SolanaRemoteNet) DeployXCallMockApp

func (sn *SolanaRemoteNet) DeployXCallMockApp(ctx context.Context, keyName string, connections []chains.XCallConnection) error

func (*SolanaRemoteNet) Exec

func (sn *SolanaRemoteNet) Exec(ctx context.Context, cmd []string, env []string) (stdout []byte, stderr []byte, err error)

Exec runs an arbitrary command using Chain's docker environment. Whether the invoked command is run in a one-off container or execing into an already running container is up to the chain implementation.

"env" are environment variables in the format "MY_ENV_VAR=value"

func (*SolanaRemoteNet) ExecBin

func (sn *SolanaRemoteNet) ExecBin(ctx context.Context, command ...string) ([]byte, []byte, error)

func (*SolanaRemoteNet) ExecTx

func (sn *SolanaRemoteNet) ExecTx(ctx context.Context, contractName string, command ...string) (string, error)

func (*SolanaRemoteNet) FindCallMessage

func (sn *SolanaRemoteNet) FindCallMessage(ctx context.Context, startHeight uint64, from, to, sno string) (string, string, error)

func (*SolanaRemoteNet) FindCallResponse

func (sn *SolanaRemoteNet) FindCallResponse(ctx context.Context, startHeight uint64, sno string) (string, error)

func (*SolanaRemoteNet) FindEvent

func (sn *SolanaRemoteNet) FindEvent(ctx context.Context, startHeight uint64,
	allEvents []IdlEvent, contract, signature, sno string) (*EventResponseEvent, error)

func (*SolanaRemoteNet) FindRollbackExecutedMessage

func (sn *SolanaRemoteNet) FindRollbackExecutedMessage(ctx context.Context, startHeight uint64, sno string) (string, error)

func (*SolanaRemoteNet) FindTargetXCallMessage

func (sn *SolanaRemoteNet) FindTargetXCallMessage(ctx context.Context, target chains.Chain, height uint64, to string) (*chains.XCallResponse, error)

FindTargetXCallMessage returns the request id and the data of the message sent to the target chain

func (*SolanaRemoteNet) GetAddress

func (sn *SolanaRemoteNet) GetAddress(ctx context.Context, keyName string) ([]byte, error)

GetAddress fetches the bech32 address for a test key on the "user" node (either the first fullnode or the first validator if no fullnodes).

func (*SolanaRemoteNet) GetClientBlockByHeight

func (sn *SolanaRemoteNet) GetClientBlockByHeight(ctx context.Context, height int64) (string, error)

GetBlockByHeight implements chains.Chain

func (*SolanaRemoteNet) GetContractAddress

func (sn *SolanaRemoteNet) GetContractAddress(key string) string

func (*SolanaRemoteNet) GetGRPCAddress

func (sn *SolanaRemoteNet) GetGRPCAddress() string

GetGRPCAddress retrieves the grpc address that can be reached by other containers in the docker network. Not Applicable for Icon

func (*SolanaRemoteNet) GetHostGRPCAddress

func (sn *SolanaRemoteNet) GetHostGRPCAddress() string

GetHostGRPCAddress returns the grpc address that can be reached by processes on the host machine. Note that this will not return a valid value until after Start returns. Not applicable for Icon

func (*SolanaRemoteNet) GetHostRPCAddress

func (sn *SolanaRemoteNet) GetHostRPCAddress() string

GetHostRPCAddress returns the rpc address that can be reached by processes on the host machine. Note that this will not return a valid value until after Start returns.

func (*SolanaRemoteNet) GetLastBlock

func (sn *SolanaRemoteNet) GetLastBlock(ctx context.Context) (context.Context, error)

GetLastBlock implements chains.Chain

func (*SolanaRemoteNet) GetRPCAddress

func (sn *SolanaRemoteNet) GetRPCAddress() string

GetRPCAddress retrieves the rpc address that can be reached by other containers in the docker network.

func (*SolanaRemoteNet) GetRelayConfig

func (sn *SolanaRemoteNet) GetRelayConfig(ctx context.Context, rlyHome string, keyName string) ([]byte, error)

func (*SolanaRemoteNet) Height

func (sn *SolanaRemoteNet) Height(ctx context.Context) (uint64, error)

Height returns the current block height or an error if unable to get current height.

func (*SolanaRemoteNet) HomeDir

func (sn *SolanaRemoteNet) HomeDir() string

HomeDir is the home directory of a node running in a docker container. Therefore, this maps to the container's filesystem (not the host).

func (*SolanaRemoteNet) NodeCommand

func (sn *SolanaRemoteNet) NodeCommand(command ...string) []string

func (*SolanaRemoteNet) QueryContract

func (sn *SolanaRemoteNet) QueryContract(ctx context.Context, contractAddress, methodName string, params map[string]interface{}) (context.Context, error)

QueryContract implements chains.Chain

func (*SolanaRemoteNet) SendPacketXCall

func (sn *SolanaRemoteNet) SendPacketXCall(ctx context.Context, keyName, _to string, data, rollback []byte) (context.Context, error)

func (*SolanaRemoteNet) SetupConnection

func (sn *SolanaRemoteNet) SetupConnection(ctx context.Context, target chains.Chain) error

func (*SolanaRemoteNet) SetupXCall

func (sn *SolanaRemoteNet) SetupXCall(ctx context.Context) error

func (*SolanaRemoteNet) TxCommand

func (sn *SolanaRemoteNet) TxCommand(ctx context.Context, contractName string, command ...string) []string

TxCommand is a helper to retrieve a full command for broadcasting a tx with the chain node binary.

func (*SolanaRemoteNet) XCall

func (sn *SolanaRemoteNet) XCall(ctx context.Context, targetChain chains.Chain, keyName, to string, data, rollback []byte) (*chains.XCallResponse, error)

type XcallConfigAccount

type XcallConfigAccount struct {
	Admin       solana.PublicKey
	FeeHandler  solana.PublicKey
	NetworkID   string
	ProtocolFee uint64
	SequenceNo  big.Int
	LastReqID   big.Int
	Bump        uint8
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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