user

package
v2.0.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: Apache-2.0 Imports: 30 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaultPollTime              = 3 * time.Second
	DefaultGasMultiplier float64 = 1.1
)

Variables

This section is empty.

Functions

func QueryAccount

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

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

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) 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 Option

type Option func(client *TxClient)

func WithDefaultAccount

func WithDefaultAccount(name string) Option

func WithDefaultAddress

func WithDefaultAddress(address sdktypes.AccAddress) Option

func WithDefaultGasPrice

func WithDefaultGasPrice(price float64) Option

WithDefaultGasPrice sets the gas price.

func WithGasMultiplier

func WithGasMultiplier(multiplier float64) Option

WithGasMultiplier is a functional option allows to configure the gas multiplier.

func WithPollTime

func WithPollTime(time time.Duration) Option

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,
	appVersion uint64,
	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 []*blob.Blob, opts ...TxOption) ([]byte, uint64, error)

func (*Signer) CreateTx

func (s *Signer) CreateTx(msgs []sdktypes.Msg, opts ...TxOption) ([]byte, 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)

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. If none is specified, it will try use the default account. TxClient is thread-safe.

func NewTxClient

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

NewTxClient returns a new signer using the provided keyring

func SetupTxClient

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

SetupTxClient uses the underlying grpc connection to populate the chainID, accountNumber and sequence number of all the accounts in the keyring.

func (*TxClient) Account

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

Account returns an account of the signer from the key name. Also returns a bool if the account exists. Thread-safe

func (*TxClient) AccountByAddress

func (client *TxClient) AccountByAddress(address sdktypes.AccAddress) *Account

func (*TxClient) BroadcastPayForBlob

func (client *TxClient) BroadcastPayForBlob(ctx context.Context, blobs []*blob.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, account string, blobs []*blob.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) (*sdktypes.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) EstimateGas

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

EstimateGas simulates the transaction, calculating the amount of gas that was consumed during execution. The final result will be multiplied by gasMultiplier(that is set in TxClient)

func (*TxClient) SetDefaultGasPrice

func (client *TxClient) SetDefaultGasPrice(price float64)

func (*TxClient) SetGasMultiplier

func (client *TxClient) SetGasMultiplier(multiplier float64)

func (*TxClient) Signer

func (client *TxClient) Signer() *Signer

Signer exposes the tx clients underlying signer

func (*TxClient) SubmitPayForBlob

func (client *TxClient) SubmitPayForBlob(ctx context.Context, blobs []*blob.Blob, opts ...TxOption) (*sdktypes.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.

func (*TxClient) SubmitPayForBlobWithAccount

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

func (*TxClient) SubmitTx

func (client *TxClient) SubmitTx(ctx context.Context, msgs []sdktypes.Msg, opts ...TxOption) (*sdktypes.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.

type TxOption

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

func SetFee

func SetFee(fees uint64) TxOption

func SetFeeAmount

func SetFeeAmount(fees sdk.Coins) 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 SetGasLimitAndFee

func SetGasLimitAndFee(gasLimit uint64, gasPrice float64) TxOption

SetGasLimitAndFee 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

func SetTip

func SetTip(tip *tx.Tip) TxOption

Jump to

Keyboard shortcuts

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