user

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2024 License: Apache-2.0 Imports: 26 Imported by: 7

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func InheritTxConfig

func InheritTxConfig(builder sdkclient.TxBuilder, tx authsigning.Tx) sdkclient.TxBuilder

InheritTxConfig sets all of the accessible configurations from a given tx into a given client.TxBuilder

func QueryAccount

func QueryAccount(ctx context.Context, conn *grpc.ClientConn, encCfg encoding.Config, address string) (accNum uint64, seqNum uint64, err error)

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

func QueryAccountInfo added in v1.11.0

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

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

Types

type Account added in v1.11.0

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

func NewAccount added in v1.11.0

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

func (Account) Address added in v1.11.0

func (a Account) Address() types.AccAddress

func (*Account) Copy added in v1.11.0

func (a *Account) Copy() *Account

func (Account) Name added in v1.11.0

func (a Account) Name() string

func (Account) PubKey added in v1.11.0

func (a Account) PubKey() cryptotypes.PubKey

func (Account) Sequence added in v1.11.0

func (a Account) Sequence() uint64

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

type Option added in v1.11.0

type Option func(s *TxClient)

func WithDefaultAccount added in v1.11.0

func WithDefaultAccount(name string) Option

func WithDefaultAddress added in v1.11.0

func WithDefaultAddress(address sdktypes.AccAddress) Option

func WithGasMultiplier added in v1.11.0

func WithGasMultiplier(multiplier float64) Option

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

func WithPollTime added in v1.11.0

func WithPollTime(time time.Duration) Option

type Signer

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

Signer is an abstraction for building, signing, and broadcasting Celestia transactions

func NewSigner

func NewSigner(
	keys keyring.Keyring,
	conn *grpc.ClientConn,
	address sdktypes.AccAddress,
	enc client.TxConfig,
	chainID string,
	accountNumber uint64,
	sequence uint64,
) (*Signer, error)

NewSigner returns a new signer using the provided keyring

func SetupSigner

func SetupSigner(
	ctx context.Context,
	keys keyring.Keyring,
	conn *grpc.ClientConn,
	address sdktypes.AccAddress,
	encCfg encoding.Config,
) (*Signer, error)

SetupSigner uses the underlying grpc connection to populate the chainID, accountNumber and sequence number of the account.

func SetupSingleSigner

func SetupSingleSigner(ctx context.Context, keys keyring.Keyring, conn *grpc.ClientConn, encCfg encoding.Config) (*Signer, error)

SetupSingleSigner sets up a signer based on the provided keyring. The keyring must contain exactly one key. It extracts the address from the key and uses the grpc connection to populate the chainID, account number, and sequence number.

func (*Signer) AccountNumber

func (s *Signer) AccountNumber() uint64

AccountNumber returns the account number of the signer.

func (*Signer) Address

func (s *Signer) Address() sdktypes.AccAddress

Address returns the address of the signer.

func (*Signer) BroadcastTx

func (s *Signer) BroadcastTx(ctx context.Context, tx authsigning.Tx) (*sdktypes.TxResponse, error)

BroadcastTx submits the provided transaction bytes to the chain and returns the response.

func (*Signer) ChainID

func (s *Signer) ChainID() string

ChainID returns the chain ID of the signer.

func (*Signer) ConfirmTx

func (s *Signer) 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 (*Signer) CreatePayForBlob

func (s *Signer) CreatePayForBlob(blobs []*tmproto.Blob, opts ...TxOption) ([]byte, error)

func (*Signer) CreateTx

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

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

func (*Signer) EncodeTx added in v1.8.0

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

func (*Signer) EstimateGas added in v1.8.0

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

func (*Signer) ForceSetSequence

func (s *Signer) ForceSetSequence(seq uint64)

ForceSetSequence manually overrides the current local and network level sequence number. Be careful when invoking this as it may cause the transactions to reject the sequence if it doesn't match the one in state

func (*Signer) GetSequence

func (s *Signer) GetSequence() uint64

DEPRECATED: use Sequence instead

func (*Signer) Keyring added in v1.8.0

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

Keyring exposes the signers underlying keyring

func (*Signer) LocalSequence added in v1.8.0

func (s *Signer) LocalSequence() uint64

LocalSequence returns the next sequence number of the signers locally saved

func (*Signer) NetworkSequence added in v1.8.0

func (s *Signer) NetworkSequence() uint64

func (*Signer) PubKey

func (s *Signer) PubKey() cryptotypes.PubKey

PubKey returns the public key of the signer

func (*Signer) SetPollTime

func (s *Signer) SetPollTime(pollTime time.Duration)

SetPollTime sets how often the signer should poll for the confirmation of the transaction

func (*Signer) SubmitPayForBlob

func (s *Signer) SubmitPayForBlob(ctx context.Context, blobs []*tmproto.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 (*Signer) SubmitTx

func (s *Signer) 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 TxClient added in v1.11.0

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 added in v1.11.0

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

NewTxClient returns a new signer using the provided keyring

func SetupTxClient added in v1.11.0

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 added in v1.11.0

func (s *TxClient) Account(name string) (*Account, bool)

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

func (*TxClient) AccountByAddress added in v1.11.0

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

func (*TxClient) BroadcastPayForBlob added in v1.11.0

func (s *TxClient) BroadcastPayForBlob(ctx context.Context, blobs []*tmproto.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.

func (*TxClient) BroadcastPayForBlobWithAccount added in v1.11.0

func (s *TxClient) BroadcastPayForBlobWithAccount(ctx context.Context, account string, blobs []*tmproto.Blob, opts ...TxOption) (*sdktypes.TxResponse, error)

func (*TxClient) BroadcastTx added in v1.11.0

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

func (*TxClient) ConfirmTx added in v1.11.0

func (s *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 added in v1.11.0

func (s *TxClient) DefaultAccountName() string

func (*TxClient) DefaultAddress added in v1.11.0

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

func (*TxClient) EstimateGas added in v1.11.0

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

func (*TxClient) Signer added in v1.11.0

func (s *TxClient) Signer() *TxSigner

Signer exposes the tx clients underlying signer

func (*TxClient) SubmitPayForBlob added in v1.11.0

func (s *TxClient) SubmitPayForBlob(ctx context.Context, blobs []*tmproto.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) SubmitPayForBlobsWithAccount added in v1.11.0

func (s *TxClient) SubmitPayForBlobsWithAccount(ctx context.Context, account string, blobs []*tmproto.Blob, opts ...TxOption) (*sdktypes.TxResponse, error)

func (*TxClient) SubmitTx added in v1.11.0

func (s *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

type TxSigner added in v1.11.0

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

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

func NewTxSigner added in v1.11.0

func NewTxSigner(
	keys keyring.Keyring,
	encCfg client.TxConfig,
	chainID string,
	appVersion uint64,
	accounts ...*Account,
) (*TxSigner, error)

NewTxSigner 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 (*TxSigner) Account added in v1.11.0

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

Account returns an account of the signer from the key name

func (*TxSigner) AccountByAddress added in v1.11.0

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

AccountByAddress returns the account associated with the given address

func (*TxSigner) Accounts added in v1.11.0

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

func (*TxSigner) AddAccount added in v1.11.0

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

func (*TxSigner) ChainID added in v1.11.0

func (s *TxSigner) ChainID() string

ChainID returns the chain ID of the signer.

func (*TxSigner) CreatePayForBlobs added in v1.11.0

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

func (*TxSigner) CreateTx added in v1.11.0

func (s *TxSigner) 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 (*TxSigner) DecodeTx added in v1.11.0

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

func (*TxSigner) EncodeTx added in v1.11.0

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

func (*TxSigner) IncrementSequence added in v1.11.0

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

func (*TxSigner) Keyring added in v1.11.0

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

Keyring exposes the signers underlying keyring

func (*TxSigner) SetSequence added in v1.11.0

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

func (*TxSigner) SignTx added in v1.11.0

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

Jump to

Keyboard shortcuts

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