sol

package
v0.0.0-...-5068620 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultWatchLimit = 1000

Variables

View Source
var NotFoundProgramDataErr = errors.New("program data not found")

Functions

This section is empty.

Types

type Attrs

type Attrs struct {
	ChainId      uint64
	Chain        string
	DeployedSlot uint64 // contract deployment slot

	// has been processed on tx signature
	//  can set the earliest transaction signature to start
	ProcessedTxSignature solana.Signature
	WatchBlockLimit      int                     // Limit the number of blocks scanned each time, default is 1000
	ContractToDesc       map[string]ContractDesc // key is programId
}

type Contract

type Contract struct {
	Attrs

	ProgramId solana.PublicKey

	IsRunning atomic.Bool
	IsClose   atomic.Bool
	// contains filtered or unexported fields
}

func New

func New(programId string, attrs *Attrs) (*Contract, error)

func (*Contract) Close

func (c *Contract) Close() error

func (*Contract) DoneSignal

func (c *Contract) DoneSignal() <-chan struct{}

func (*Contract) GetContractDesc

func (c *Contract) GetContractDesc(programId string) (ContractDesc, error)

func (*Contract) GetProcessedTxSignature

func (c *Contract) GetProcessedTxSignature() solana.Signature

GetProcessedTxSignature ...

func (*Contract) HandleEvent

func (c *Contract) HandleEvent(client *rpcclient.SolClient, event Event, txInfo TxInfo) error

HandleEvent method call Hook

func (*Contract) Init

func (c *Contract) Init(attrs Attrs)

func (*Contract) RegisterEventHook

func (c *Contract) RegisterEventHook(event Event, f func(client *rpcclient.SolClient, txInfo TxInfo) error) error

RegisterEventHook Hook is a function that handles event, HandleEvent method call this Hook

func (*Contract) Scan

func (c *Contract) Scan(client *rpcclient.SolClient) error

func (*Contract) UpdateProcessedTxSignature

func (c *Contract) UpdateProcessedTxSignature(txSig solana.Signature) error

UpdateProcessedTxSignature ...

type ContractDesc

type ContractDesc struct {
	Name     string
	Symbol   string
	Decimals uint8
}

type Event

type Event string

func (Event) String

func (e Event) String() string

type IContract

type IContract interface {
	Init(attrs Attrs)
	Close() error
	DoneSignal() <-chan struct{}
	RegisterEventHook(event Event, f func(client *rpcclient.SolClient, txInfo TxInfo) error) error
	HandleEvent(client *rpcclient.SolClient, event Event, txInfo TxInfo) error
	UpdateProcessedTxSignature(txSig solana.Signature) error
	GetProcessedBlockNumber() solana.Signature
	Scan(client *rpcclient.SolClient) error
	GetContractDesc(programId string) (ContractDesc, error)
}

type TxInfo

type TxInfo struct {
	ProgramId  solana.PublicKey
	TxSig      solana.Signature
	TxDetail   *rpc.GetTransactionResult
	DataBytes  []byte // ProgramData
	EventIndex uint64 // ProgramData index
}

Jump to

Keyboard shortcuts

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