base

package
v1.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client provides common Cosmos SDK gRPC and tx helpers.

func New

func New(ctx context.Context, cfg Config, kr keyring.Keyring, keyName string) (*Client, error)

New creates a base blockchain client with a gRPC connection.

func (*Client) Broadcast

func (c *Client) Broadcast(ctx context.Context, txBytes []byte, mode txtypes.BroadcastMode) (string, error)

Broadcast broadcasts a signed transaction with a chosen broadcast mode.

func (*Client) BroadcastAndWait added in v1.2.0

func (c *Client) BroadcastAndWait(ctx context.Context, txBytes []byte, mode txtypes.BroadcastMode) (string, *txtypes.GetTxResponse, error)

BroadcastAndWait broadcasts signed tx bytes, then waits for final inclusion.

func (*Client) BuildAndSignTx

func (c *Client) BuildAndSignTx(ctx context.Context, msg sdk.Msg, memo string) ([]byte, error)

BuildAndSignTx builds a transaction with one message, simulates gas, then signs it.

func (*Client) BuildAndSignTxWithGasAdjustment

func (c *Client) BuildAndSignTxWithGasAdjustment(ctx context.Context, msg sdk.Msg, memo string, gasAdjustment float64) ([]byte, error)

BuildAndSignTxWithGasAdjustment builds a transaction with one message, simulates gas, applies a custom adjustment factor, then signs it.

func (*Client) BuildAndSignTxWithOptions added in v1.2.0

func (c *Client) BuildAndSignTxWithOptions(ctx context.Context, opts TxBuildOptions) ([]byte, error)

BuildAndSignTxWithOptions builds and signs a transaction using explicit options.

func (*Client) Cfg added in v1.2.0

func (c *Client) Cfg() Config

Cfg returns a copy of the base client configuration.

func (*Client) Close

func (c *Client) Close() error

Close closes the underlying gRPC connection.

func (*Client) ExtractEventAttribute

func (c *Client) ExtractEventAttribute(tx *txtypes.GetTxResponse, eventType, attrKey string) (string, error)

ExtractEventAttribute extracts an attribute value from transaction events. It searches through TxResponse.Events for the first event matching eventType, then returns the value of the first attribute matching attrKey. Returns an error if the transaction, events, or matching event/attribute are not found.

func (*Client) GRPCConn

func (c *Client) GRPCConn() *grpc.ClientConn

GRPCConn exposes the underlying gRPC connection for specialized queries.

func (*Client) GetTx

func (c *Client) GetTx(ctx context.Context, hash string) (*txtypes.GetTxResponse, error)

GetTx fetches a transaction by hash via the tx service.

func (*Client) GetTxsByEvents

func (c *Client) GetTxsByEvents(ctx context.Context, events []string, page, limit uint64) (*txtypes.GetTxsEventResponse, error)

GetTxsByEvents searches for transactions matching event filters.

func (*Client) KeyName added in v1.2.0

func (c *Client) KeyName() string

KeyName returns the key uid used for signing.

func (*Client) Keyring added in v1.2.0

func (c *Client) Keyring() keyring.Keyring

Keyring returns the keyring used for signing.

func (*Client) PrepareTx added in v1.2.0

PrepareTx builds an unsigned tx builder and resolves the signer metadata.

func (*Client) SignPreparedTx added in v1.2.0

func (c *Client) SignPreparedTx(ctx context.Context, txCfg client.TxConfig, builder client.TxBuilder, signerInfo TxSignerInfo) ([]byte, error)

SignPreparedTx signs a prepared tx builder using explicit signer info.

func (*Client) Simulate

func (c *Client) Simulate(ctx context.Context, txBytes []byte) (uint64, error)

Simulate runs a gas simulation for a provided tx bytes.

func (*Client) WaitForTxInclusion

func (c *Client) WaitForTxInclusion(ctx context.Context, txHash string) (*txtypes.GetTxResponse, error)

WaitForTxInclusion waits for a transaction to reach a final state using a websocket subscriber when possible and falling back to periodic gRPC polling. A new waiter (and therefore a new websocket subscription) is created for each invocation, so sequential callers should expect a new CometBFT RPC client per call. Timeouts are driven entirely by the caller-provided context (the waiter timeout argument remains zero intentionally). It respects the context for cancellation or deadlines.

type Config

type Config struct {
	ChainID        string
	GRPCAddr       string
	RPCEndpoint    string
	AccountHRP     string
	FeeDenom       string
	GasPrice       sdkmath.LegacyDec
	Timeout        time.Duration
	MaxRecvMsgSize int
	MaxSendMsgSize int
	InsecureGRPC   bool
	WaitTx         clientconfig.WaitTxConfig

	// EVMChainID is the EIP-155 chain ID for Ethereum-format transactions.
	// Distinct from the Cosmos ChainID. Nil disables EVM-tx helpers.
	EVMChainID *big.Int

	// EVMNativeDenom is the cosmos/evm `evm_denom` parameter — the bank denom
	// fees are deducted in (Lumera: "ulume"). Used by
	// MsgEthereumTx.BuildTxWithEvmParams when constructing the cosmos fee coin
	// from the inner Ethereum tx.
	EVMNativeDenom string

	// EVMExtendedDenom is the 18-decimal precisebank denom (Lumera: "alume").
	// Ethereum tx value, fee caps, balances, and receipts use this denom's
	// integer "wei-like" representation.
	EVMExtendedDenom string

	// EVMGasTipCap and EVMGasFeeCap are optional defaults (in the extended
	// denom's integer unit) for EIP-1559 gas pricing. Nil means "fetch from
	// chain state".
	EVMGasTipCap *big.Int
	EVMGasFeeCap *big.Int
}

Config captures shared Cosmos SDK chain settings for gRPC + tx workflows.

type TxBuildOptions added in v1.2.0

type TxBuildOptions struct {
	Messages       []sdk.Msg
	Memo           string
	GasAdjustment  float64
	GasLimit       uint64
	SkipSimulation bool
	AccountNumber  *uint64
	Sequence       *uint64
	FeeAmount      sdk.Coins
	ZeroFee        bool
}

TxBuildOptions controls how a transaction is assembled and signed.

type TxSignerInfo added in v1.2.0

type TxSignerInfo struct {
	AccountNumber uint64
	Sequence      uint64
}

TxSignerInfo contains the signer account metadata used for signing.

Jump to

Keyboard shortcuts

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