Documentation
¶
Index ¶
- Constants
- func FilterInboundEvents(txResult *rpc.GetTransactionResult, gatewayID solana.PublicKey, ...) ([]*clienttypes.InboundEvent, error)
- func ParseGatewayInstruction(txResult *rpc.GetTransactionResult, gatewayID solana.PublicKey, ...) (contracts.OutboundInstruction, error)
- type Observer
- func (ob *Observer) BuildInboundVoteMsgFromEvent(event *clienttypes.InboundEvent) *crosschaintypes.MsgVoteInbound
- func (ob *Observer) CheckFinalizedTx(ctx context.Context, txHash string, nonce uint64, coinType coin.CoinType) (*rpc.GetTransactionResult, bool)
- func (ob *Observer) CheckRPCStatus(ctx context.Context) error
- func (ob *Observer) CreateMsgVoteOutbound(cctxIndex string, outboundHash string, txResult *rpc.GetTransactionResult, ...) *crosschaintypes.MsgVoteOutbound
- func (ob *Observer) FilterInboundEventsAndVote(ctx context.Context, txResult *rpc.GetTransactionResult) error
- func (ob *Observer) GetTxResult(nonce uint64) *rpc.GetTransactionResult
- func (ob *Observer) IsEventProcessable(event clienttypes.InboundEvent) bool
- func (ob *Observer) IsTxFinalized(nonce uint64) bool
- func (ob *Observer) LoadLastTxScanned() error
- func (ob *Observer) ObserveInbound(ctx context.Context) error
- func (ob *Observer) PostGasPrice(ctx context.Context) error
- func (ob *Observer) PostVoteOutbound(ctx context.Context, cctxIndex string, outboundHash string, ...)
- func (ob *Observer) ProcessInboundTrackers(ctx context.Context) error
- func (ob *Observer) ProcessOutboundTrackers(ctx context.Context) error
- func (ob *Observer) SetTxResult(nonce uint64, result *rpc.GetTransactionResult)
- func (ob *Observer) VoteOutboundIfConfirmed(ctx context.Context, cctx *crosschaintypes.CrossChainTx) (bool, error)
Constants ¶
const ( // SolanaTransactionFee is the static fee per transaction, 5k lamports. SolanaTransactionFee = 5000 // MicroLamportsPerLamport is the number of micro lamports in a lamport. MicroLamportsPerLamport = 1_000_000 // SolanaDefaultComputeBudget is the default compute budget for a transaction. SolanaDefaultComputeBudget = 200_000 // Solana uses micro lamports (0.000001 lamports) as the smallest unit of gas price. // The gas fee formula 'gasFee = gasPrice * gasLimit' won't fit Solana in the ZRC20 SOL contract. // We could use lamports as the unit of gas price and 10K CU as the smallest unit of compute units. // SolanaDefaultGasPrice10KCUs is the default gas price (in lamports) per 10K compute units. SolanaDefaultGasPrice10KCUs = 100 // SolanaDefaultGasLimit is the default compute units (in 10K CU) for a transaction. SolanaDefaultGasLimit10KCU = 50 )
const (
// MaxSignaturesPerTicker is the maximum number of signatures to process on a ticker
MaxSignaturesPerTicker = 100
)
Variables ¶
This section is empty.
Functions ¶
func FilterInboundEvents ¶
func FilterInboundEvents( txResult *rpc.GetTransactionResult, gatewayID solana.PublicKey, senderChainID int64, logger zerolog.Logger, ) ([]*clienttypes.InboundEvent, error)
FilterInboundEvents filters inbound events from a tx result. Note: for consistency with EVM chains, this method
- takes at one event (the first) per token (SOL or SPL) per transaction.
- takes at most two events (one SOL + one SPL) per transaction.
- ignores exceeding events.
func ParseGatewayInstruction ¶
func ParseGatewayInstruction( txResult *rpc.GetTransactionResult, gatewayID solana.PublicKey, coinType coin.CoinType, ) (contracts.OutboundInstruction, error)
ParseGatewayInstruction parses the outbound instruction from tx result
Types ¶
type Observer ¶
type Observer struct { // base.Observer implements the base chain observer *base.Observer // contains filtered or unexported fields }
Observer is the observer for the Solana chain
func New ¶
func New(baseObserver *base.Observer, solClient interfaces.SolanaRPCClient, gatewayAddress string) (*Observer, error)
New Observer constructor
func (*Observer) BuildInboundVoteMsgFromEvent ¶
func (ob *Observer) BuildInboundVoteMsgFromEvent(event *clienttypes.InboundEvent) *crosschaintypes.MsgVoteInbound
BuildInboundVoteMsgFromEvent builds a MsgVoteInbound from an inbound event
func (*Observer) CheckFinalizedTx ¶
func (ob *Observer) CheckFinalizedTx( ctx context.Context, txHash string, nonce uint64, coinType coin.CoinType, ) (*rpc.GetTransactionResult, bool)
CheckFinalizedTx checks if a txHash is finalized for given nonce and coinType returns (tx result, true) if finalized or (nil, false) otherwise
func (*Observer) CheckRPCStatus ¶
checkRPCStatus checks the RPC status of the Solana chain
func (*Observer) CreateMsgVoteOutbound ¶
func (ob *Observer) CreateMsgVoteOutbound( cctxIndex string, outboundHash string, txResult *rpc.GetTransactionResult, valueReceived *big.Int, status chains.ReceiveStatus, nonce uint64, coinType coin.CoinType, ) *crosschaintypes.MsgVoteOutbound
CreateMsgVoteOutbound creates a vote outbound message for Solana chain
func (*Observer) FilterInboundEventsAndVote ¶
func (ob *Observer) FilterInboundEventsAndVote(ctx context.Context, txResult *rpc.GetTransactionResult) error
FilterInboundEventsAndVote filters inbound events from a txResult and post a vote.
func (*Observer) GetTxResult ¶
func (ob *Observer) GetTxResult(nonce uint64) *rpc.GetTransactionResult
GetTxResult returns the tx result for the given nonce
func (*Observer) IsEventProcessable ¶
func (ob *Observer) IsEventProcessable(event clienttypes.InboundEvent) bool
IsEventProcessable checks if the inbound event is processable
func (*Observer) IsTxFinalized ¶
IsTxFinalized returns true if there is a finalized tx for nonce
func (*Observer) LoadLastTxScanned ¶
LoadLastTxScanned loads the last scanned tx from the database.
func (*Observer) ObserveInbound ¶
ObserveInbound observes the Solana chain for inbounds and post votes to zetacore.
func (*Observer) PostGasPrice ¶
PostGasPrice posts gas price to zetacore
func (*Observer) PostVoteOutbound ¶
func (ob *Observer) PostVoteOutbound( ctx context.Context, cctxIndex string, outboundHash string, txResult *rpc.GetTransactionResult, valueReceived *big.Int, status chains.ReceiveStatus, nonce uint64, coinType coin.CoinType, )
PostVoteOutbound posts vote to zetacore for the finalized outbound
func (*Observer) ProcessInboundTrackers ¶
ProcessInboundTrackers processes inbound trackers
func (*Observer) ProcessOutboundTrackers ¶
ProcessOutboundTrackers processes Solana outbound trackers
func (*Observer) SetTxResult ¶
func (ob *Observer) SetTxResult(nonce uint64, result *rpc.GetTransactionResult)
SetTxResult sets the tx result for the given nonce
func (*Observer) VoteOutboundIfConfirmed ¶
func (ob *Observer) VoteOutboundIfConfirmed(ctx context.Context, cctx *crosschaintypes.CrossChainTx) (bool, error)
VoteOutboundIfConfirmed checks outbound status and returns (continueKeysign, error)