base

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: Apache-2.0 Imports: 18 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) 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) 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) 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
}

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

Jump to

Keyboard shortcuts

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