user

package
v9.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPollTime = 1 * time.Second

	// Gas limits for initialization transactions
	SendGasLimit         = 100000
	FeegrantGasLimit     = 800000
	DefaultWorkerBalance = 1
)

Variables

This section is empty.

Functions

func QueryAccount

func QueryAccount(ctx context.Context, conn *grpc.ClientConn, registry codectypes.InterfaceRegistry, address types.AccAddress) (accNum, seqNum uint64, err error)

QueryAccount fetches the account number and sequence number from the celestia-app node.

func QueryAccountBalance

func QueryAccountBalance(ctx context.Context, conn *grpc.ClientConn, _ codectypes.InterfaceRegistry, address types.AccAddress, denom string) (types.Coin, error)

QueryAccountBalance fetches the balance of a specific denomination for an account.

func QueryMinimumGasPrice

func QueryMinimumGasPrice(ctx context.Context, grpcConn *grpc.ClientConn) (float64, error)

QueryMinimumGasPrice queries both the nodes local and network wide minimum gas prices, returning the maximum of the two.

func QueryNetworkMinGasPrice

func QueryNetworkMinGasPrice(ctx context.Context, grpcConn *grpc.ClientConn) (float64, error)

Types

type Account

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

func NewAccount

func NewAccount(keyName string, accountNumber, sequenceNumber uint64) *Account

func (Account) AccountNumber

func (a Account) AccountNumber() uint64

func (Account) Address

func (a Account) Address() types.AccAddress

func (*Account) Copy

func (a *Account) Copy() *Account

func (Account) Name

func (a Account) Name() string

func (Account) PubKey

func (a Account) PubKey() cryptotypes.PubKey

func (Account) Sequence

func (a Account) Sequence() uint64

Sequence returns the sequence number of the account. This is locally tracked

type BroadcastTxError

type BroadcastTxError struct {
	TxHash string
	Code   uint32
	// ErrorLog is the error output of the app's logger
	ErrorLog string
}

BroadcastTxError is an error that occurs when broadcasting a transaction.

func (*BroadcastTxError) Error

func (e *BroadcastTxError) Error() string

type ExecutionError

type ExecutionError struct {
	TxHash string
	Code   uint32
	// ErrorLog is the error output of the app's logger
	ErrorLog  string
	Codespace string
	GasWanted int64
	GasUsed   int64
}

ExecutionError is an error that occurs when a transaction gets executed.

func (*ExecutionError) Error

func (e *ExecutionError) Error() string

type Option

type Option func(client *TxClient)

func WithAdditionalCoreEndpoints

func WithAdditionalCoreEndpoints(conns []*grpc.ClientConn) Option

WithAdditionalCoreEndpoints adds additional core endpoints to the TxClient. For transaction submission, the client will attempt to use the primary endpoint and the first two additional endpoints provided via this option.

func WithDefaultAccount

func WithDefaultAccount(name string) Option

func WithDefaultAddress

func WithDefaultAddress(address sdktypes.AccAddress) Option

func WithEstimatorService

func WithEstimatorService(conn *grpc.ClientConn) Option

WithEstimatorService allows a user to provide a connection to a special gas estimation service to be used by the TxClient for estimating gas price and usage.

func WithParallelQueueSize

func WithParallelQueueSize(size int) Option

WithParallelQueueSize sets the buffer size for the parallel submission job queue. Default is 100 if not specified.

func WithPollTime

func WithPollTime(time time.Duration) Option

WithPollTime sets a custom polling interval with which to check if a transaction has been submitted

func WithTxWorkers

func WithTxWorkers(numWorkers int) Option

WithTxWorkers enables parallel transaction submission with the specified number of worker accounts. Worker accounts are automatically generated with hardcoded names unless numWorkers is 1, in which case the existing default account is used. Workers are initialized automatically when SetupTxClient is called.

type Signer

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

Signer is struct for building and signing Celestia transactions It supports multiple accounts wrapping a Keyring. NOTE: All transactions may only have a single signer Signer is not thread-safe.

func NewSigner

func NewSigner(keys keyring.Keyring, encCfg client.TxConfig, chainID string, accounts ...*Account) (*Signer, error)

NewSigner returns a new signer using the provided keyring There must be at least one account in the keyring The first account provided will be set as the default

func (*Signer) Account

func (s *Signer) Account(name string) *Account

Account returns an account of the signer from the key name

func (*Signer) AccountByAddress

func (s *Signer) AccountByAddress(address sdktypes.AccAddress) *Account

AccountByAddress returns the account associated with the given address

func (*Signer) Accounts

func (s *Signer) Accounts() []*Account

func (*Signer) AddAccount

func (s *Signer) AddAccount(acc *Account) error

func (*Signer) ChainID

func (s *Signer) ChainID() string

ChainID returns the chain ID of the signer.

func (*Signer) CreatePayForBlobs

func (s *Signer) CreatePayForBlobs(accountName string, blobs []*share.Blob, opts ...TxOption) ([]byte, uint64, error)

func (*Signer) CreateTx

func (s *Signer) CreateTx(msgs []sdktypes.Msg, opts ...TxOption) ([]byte, authsigning.Tx, error)

CreateTx forms a transaction from the provided messages and signs it. TxOptions may be optionally used to set the gas limit and fee.

func (*Signer) DecodeTx

func (s *Signer) DecodeTx(txBytes []byte) (authsigning.Tx, error)

func (*Signer) EncodeTx

func (s *Signer) EncodeTx(tx sdktypes.Tx) ([]byte, error)

func (*Signer) IncrementSequence

func (s *Signer) IncrementSequence(accountName string) error

func (*Signer) Keyring

func (s *Signer) Keyring() keyring.Keyring

Keyring exposes the signers underlying keyring

func (*Signer) SetSequence

func (s *Signer) SetSequence(accountName string, seq uint64) error

func (*Signer) SignTx

func (s *Signer) SignTx(msgs []sdktypes.Msg, opts ...TxOption) (authsigning.Tx, string, uint64, error)

func (*Signer) WithSignMode

func (s *Signer) WithSignMode(signMode signing.SignMode) *Signer

WithSignMode sets the sign mode for the signer.

type SubmissionJob

type SubmissionJob struct {
	Blobs    []*share.Blob
	Options  []TxOption
	Ctx      context.Context
	ResultsC chan SubmissionResult
}

SubmissionJob represents a transaction submission task for parallel processing

type SubmissionResult

type SubmissionResult struct {
	Signer     string
	TxResponse *TxResponse
	Error      error
}

SubmissionResult contains the result of a parallel transaction submission

type TxClient

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

TxClient is an abstraction for building, signing, and broadcasting Celestia transactions It supports multiple accounts. TxClient is thread-safe.

func NewTxClient

func NewTxClient(
	cdc codec.Codec,
	signer *Signer,
	conn *grpc.ClientConn,
	registry codectypes.InterfaceRegistry,
	options ...Option,
) (*TxClient, error)

NewTxClient returns a new TxClient

func SetupTxClient

func SetupTxClient(
	ctx context.Context,
	keys keyring.Keyring,
	conn *grpc.ClientConn,
	encCfg encoding.Config,
	options ...Option,
) (*TxClient, error)

SetupTxClient initializes a TxClient by querying the chain ID and account details for all accounts in the keyring, then starts the transaction queue. The queue runs until the provided context is cancelled.

func (*TxClient) Account

func (client *TxClient) Account(name string) *Account

Account returns an account of the signer from the key name. Thread-safe.

func (*TxClient) AccountByAddress

func (client *TxClient) AccountByAddress(ctx context.Context, address sdktypes.AccAddress) *Account

AccountByAddress retrieves the Account associated with the specified address. returns nil if the account is not loaded or if an error occurred while loading.

func (*TxClient) BroadcastPayForBlob

func (client *TxClient) BroadcastPayForBlob(ctx context.Context, blobs []*share.Blob, opts ...TxOption) (*sdktypes.TxResponse, error)

BroadcastPayForBlob signs and broadcasts a transaction to pay for blobs. It does not confirm that the transaction has been committed on chain. If no gas or gas price is set, it will estimate the gas and use the max effective gas price: max(localMinGasPrice, networkMinGasPrice).

func (*TxClient) BroadcastPayForBlobWithAccount

func (client *TxClient) BroadcastPayForBlobWithAccount(ctx context.Context, accountName string, blobs []*share.Blob, opts ...TxOption) (*sdktypes.TxResponse, error)

func (*TxClient) BroadcastTx

func (client *TxClient) BroadcastTx(ctx context.Context, msgs []sdktypes.Msg, opts ...TxOption) (*sdktypes.TxResponse, error)

func (*TxClient) ConfirmTx

func (client *TxClient) ConfirmTx(ctx context.Context, txHash string) (*TxResponse, error)

ConfirmTx periodically pings the provided node for the commitment of a transaction by its hash. It will continually loop until the context is cancelled, the tx is found or an error is encountered.

func (*TxClient) DefaultAccountName

func (client *TxClient) DefaultAccountName() string

func (*TxClient) DefaultAddress

func (client *TxClient) DefaultAddress() sdktypes.AccAddress

func (*TxClient) EstimateGasPrice

func (client *TxClient) EstimateGasPrice(ctx context.Context, priority gasestimation.TxPriority) (float64, error)

EstimateGasPrice calls the gas estimation endpoint to return the estimated gas price based on priority.

func (*TxClient) EstimateGasPriceAndUsage

func (client *TxClient) EstimateGasPriceAndUsage(
	ctx context.Context,
	msgs []sdktypes.Msg,
	priority gasestimation.TxPriority,
	opts ...TxOption,
) (gasPrice float64, gasUsed uint64, err error)

EstimateGasPriceAndUsage returns the estimated gas price based on the provided priority, and also the gas limit/used for the provided transaction. The gas limit is calculated by simulating the transaction and then calculating the amount of gas that was consumed during execution.

func (*TxClient) GetTxFromTxTracker

func (client *TxClient) GetTxFromTxTracker(hash string) (sequence uint64, signer string, txBytes []byte, exists bool)

GetTxFromTxTracker gets transaction info from the tx client's local tx tracker by its hash

func (*TxClient) IsTxQueueStartedForTest

func (client *TxClient) IsTxQueueStartedForTest() bool

IsTxQueueStartedForTest returns whether the tx queue is started, for testing purposes. This function is only intended for use in tests.

func (*TxClient) QueueBlob

func (client *TxClient) QueueBlob(ctx context.Context, resultC chan SubmissionResult, blobs []*share.Blob, opts ...TxOption)

QueueBlob submits blobs to the parallel transaction queue without blocking. The result will be sent to the provided channel when the transaction is confirmed. The caller is responsible for creating and closing the result channel.

func (*TxClient) Signer

func (client *TxClient) Signer() *Signer

Signer exposes the tx clients underlying signer

func (*TxClient) StartTxQueueForTest

func (client *TxClient) StartTxQueueForTest(ctx context.Context) error

StartTxQueueForTest starts the tx queue for testing purposes. This function is only intended for use in tests.

func (*TxClient) StopTxQueueForTest

func (client *TxClient) StopTxQueueForTest()

StopTxQueueForTest stops the tx queue for testing purposes. This function is only intended for use in tests.

func (*TxClient) SubmitPayForBlob

func (client *TxClient) SubmitPayForBlob(ctx context.Context, blobs []*share.Blob, opts ...TxOption) (*TxResponse, error)

SubmitPayForBlob forms a transaction from the provided blobs, signs it, and submits it to the chain. TxOptions may be provided to set the fee and gas limit. This method broadcasts the transaction and waits for confirmation using the default account.

func (*TxClient) SubmitPayForBlobToQueue

func (client *TxClient) SubmitPayForBlobToQueue(ctx context.Context, blobs []*share.Blob, opts ...TxOption) (*TxResponse, error)

SubmitPayForBlobToQueue submits blobs to the parallel transaction queue and blocks until confirmed. TxOptions may be provided to set the fee and gas limit. This method uses the tx queue infrastructure for parallel submission.

func (*TxClient) SubmitPayForBlobWithAccount

func (client *TxClient) SubmitPayForBlobWithAccount(ctx context.Context, accountName string, blobs []*share.Blob, opts ...TxOption) (*TxResponse, error)

SubmitPayForBlobWithAccount forms a transaction from the provided blobs, signs it with the provided account, and submits it to the chain. TxOptions may be provided to set the fee and gas limit.

func (*TxClient) SubmitTx

func (client *TxClient) SubmitTx(ctx context.Context, msgs []sdktypes.Msg, opts ...TxOption) (*TxResponse, error)

SubmitTx forms a transaction from the provided messages, signs it, and submits it to the chain. TxOptions may be provided to set the fee and gas limit.

func (*TxClient) TxQueueWorkerAccountName

func (client *TxClient) TxQueueWorkerAccountName(index int) string

TxQueueWorkerAccountName returns the account name for the worker at the given index

func (*TxClient) TxQueueWorkerAddress

func (client *TxClient) TxQueueWorkerAddress(index int) string

TxQueueWorkerAddress returns the address for the worker at the given index

func (*TxClient) TxQueueWorkerCount

func (client *TxClient) TxQueueWorkerCount() int

TxQueueWorkerCount returns the number of workers in the tx queue

type TxOption

type TxOption func(builder sdkclient.TxBuilder) sdkclient.TxBuilder

func SetFee

func SetFee(fees uint64) TxOption

func SetFeeGranter

func SetFeeGranter(feeGranter sdk.AccAddress) TxOption

func SetFeePayer

func SetFeePayer(feePayer sdk.AccAddress) TxOption

func SetGasLimit

func SetGasLimit(limit uint64) TxOption

func SetGasLimitAndGasPrice

func SetGasLimitAndGasPrice(gasLimit uint64, gasPrice float64) TxOption

SetGasLimitAndGasPrice sets the gas limit and fee using the provided gas price and gas limit. Note that this could overwrite or be overwritten by other conflicting TxOptions.

func SetMemo

func SetMemo(memo string) TxOption

func SetTimeoutHeight

func SetTimeoutHeight(height uint64) TxOption

type TxResponse

type TxResponse struct {
	// Height is the block height at which the transaction was included on-chain.
	Height    int64
	TxHash    string
	Code      uint32
	Codespace string
	GasWanted int64
	GasUsed   int64
	Signers   []string
}

TxResponse is a response from the chain after a transaction has been submitted.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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