Documentation
¶
Index ¶
- Constants
- func QueryAccount(ctx context.Context, conn *grpc.ClientConn, ...) (accNum, seqNum uint64, err error)
- func QueryAccountBalance(ctx context.Context, conn *grpc.ClientConn, _ codectypes.InterfaceRegistry, ...) (types.Coin, error)
- func QueryMinimumGasPrice(ctx context.Context, grpcConn *grpc.ClientConn) (float64, error)
- func QueryNetworkMinGasPrice(ctx context.Context, grpcConn *grpc.ClientConn) (float64, error)
- type Account
- type BroadcastTxError
- type ExecutionError
- type Option
- func WithAdditionalCoreEndpoints(conns []*grpc.ClientConn) Option
- func WithDefaultAccount(name string) Option
- func WithDefaultAddress(address sdktypes.AccAddress) Option
- func WithEstimatorService(conn *grpc.ClientConn) Option
- func WithParallelQueueSize(size int) Option
- func WithPollTime(time time.Duration) Option
- func WithTxWorkers(numWorkers int) Option
- type Signer
- func (s *Signer) Account(name string) *Account
- func (s *Signer) AccountByAddress(address sdktypes.AccAddress) *Account
- func (s *Signer) Accounts() []*Account
- func (s *Signer) AddAccount(acc *Account) error
- func (s *Signer) ChainID() string
- func (s *Signer) CreatePayForBlobs(accountName string, blobs []*share.Blob, opts ...TxOption) ([]byte, uint64, error)
- func (s *Signer) CreateTx(msgs []sdktypes.Msg, opts ...TxOption) ([]byte, authsigning.Tx, error)
- func (s *Signer) DecodeTx(txBytes []byte) (authsigning.Tx, error)
- func (s *Signer) EncodeTx(tx sdktypes.Tx) ([]byte, error)
- func (s *Signer) IncrementSequence(accountName string) error
- func (s *Signer) Keyring() keyring.Keyring
- func (s *Signer) SetSequence(accountName string, seq uint64) error
- func (s *Signer) SignTx(msgs []sdktypes.Msg, opts ...TxOption) (authsigning.Tx, string, uint64, error)
- func (s *Signer) WithSignMode(signMode signing.SignMode) *Signer
- type SubmissionJob
- type SubmissionResult
- type TxClient
- func (client *TxClient) Account(name string) *Account
- func (client *TxClient) AccountByAddress(ctx context.Context, address sdktypes.AccAddress) *Account
- func (client *TxClient) BroadcastPayForBlob(ctx context.Context, blobs []*share.Blob, opts ...TxOption) (*sdktypes.TxResponse, error)
- func (client *TxClient) BroadcastPayForBlobWithAccount(ctx context.Context, accountName string, blobs []*share.Blob, opts ...TxOption) (*sdktypes.TxResponse, error)
- func (client *TxClient) BroadcastTx(ctx context.Context, msgs []sdktypes.Msg, opts ...TxOption) (*sdktypes.TxResponse, error)
- func (client *TxClient) ConfirmTx(ctx context.Context, txHash string) (*TxResponse, error)
- func (client *TxClient) DefaultAccountName() string
- func (client *TxClient) DefaultAddress() sdktypes.AccAddress
- func (client *TxClient) EstimateGasPrice(ctx context.Context, priority gasestimation.TxPriority) (float64, error)
- func (client *TxClient) EstimateGasPriceAndUsage(ctx context.Context, msgs []sdktypes.Msg, priority gasestimation.TxPriority, ...) (gasPrice float64, gasUsed uint64, err error)
- func (client *TxClient) GetTxFromTxTracker(hash string) (sequence uint64, signer string, txBytes []byte, exists bool)
- func (client *TxClient) IsTxQueueStartedForTest() bool
- func (client *TxClient) QueueBlob(ctx context.Context, resultC chan SubmissionResult, blobs []*share.Blob, ...)
- func (client *TxClient) Signer() *Signer
- func (client *TxClient) StartTxQueueForTest(ctx context.Context) error
- func (client *TxClient) StopTxQueueForTest()
- func (client *TxClient) SubmitPayForBlob(ctx context.Context, blobs []*share.Blob, opts ...TxOption) (*TxResponse, error)
- func (client *TxClient) SubmitPayForBlobToQueue(ctx context.Context, blobs []*share.Blob, opts ...TxOption) (*TxResponse, error)
- func (client *TxClient) SubmitPayForBlobWithAccount(ctx context.Context, accountName string, blobs []*share.Blob, opts ...TxOption) (*TxResponse, error)
- func (client *TxClient) SubmitTx(ctx context.Context, msgs []sdktypes.Msg, opts ...TxOption) (*TxResponse, error)
- func (client *TxClient) TxQueueWorkerAccountName(index int) string
- func (client *TxClient) TxQueueWorkerAddress(index int) string
- func (client *TxClient) TxQueueWorkerCount() int
- type TxOption
- func SetFee(fees uint64) TxOption
- func SetFeeGranter(feeGranter sdk.AccAddress) TxOption
- func SetFeePayer(feePayer sdk.AccAddress) TxOption
- func SetGasLimit(limit uint64) TxOption
- func SetGasLimitAndGasPrice(gasLimit uint64, gasPrice float64) TxOption
- func SetMemo(memo string) TxOption
- func SetTimeoutHeight(height uint64) TxOption
- type TxResponse
Constants ¶
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 ¶
QueryMinimumGasPrice queries both the nodes local and network wide minimum gas prices, returning the maximum of the two.
func QueryNetworkMinGasPrice ¶
Types ¶
type Account ¶
type Account struct {
// contains filtered or unexported fields
}
func NewAccount ¶
func (Account) AccountNumber ¶
func (Account) Address ¶
func (a Account) Address() types.AccAddress
func (Account) PubKey ¶
func (a Account) PubKey() cryptotypes.PubKey
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 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 ¶
WithParallelQueueSize sets the buffer size for the parallel submission job queue. Default is 100 if not specified.
func WithPollTime ¶
WithPollTime sets a custom polling interval with which to check if a transaction has been submitted
func WithTxWorkers ¶
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) AccountByAddress ¶
func (s *Signer) AccountByAddress(address sdktypes.AccAddress) *Account
AccountByAddress returns the account associated with the given address
func (*Signer) AddAccount ¶
func (*Signer) CreatePayForBlobs ¶
func (*Signer) CreateTx ¶
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) IncrementSequence ¶
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) AccountByAddress ¶
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 (*TxClient) BroadcastTx ¶
func (*TxClient) ConfirmTx ¶
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 (*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 ¶
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) StartTxQueueForTest ¶
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 ¶
TxQueueWorkerAccountName returns the account name for the worker at the given index
func (*TxClient) TxQueueWorkerAddress ¶
TxQueueWorkerAddress returns the address for the worker at the given index
func (*TxClient) TxQueueWorkerCount ¶
TxQueueWorkerCount returns the number of workers in the tx queue
type TxOption ¶
func SetFeeGranter ¶
func SetFeeGranter(feeGranter sdk.AccAddress) TxOption
func SetFeePayer ¶
func SetFeePayer(feePayer sdk.AccAddress) TxOption
func SetGasLimit ¶
func SetGasLimitAndGasPrice ¶
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 SetTimeoutHeight ¶
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.