grpc

package
v3.0.0-...-e8b7a4c Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: GPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Sign = tx.Sign

Sign signs a given tx with a named key. The bytes signed over are canonical. The resulting signature will be added to the transaction builder overwriting the previous ones if overwrite=true (otherwise, the signature will be appended). Signing a transaction with mutltiple signers in the DIRECT mode is not supprted and will return an error. An error is returned upon failure. https://github.com/cosmos/cosmos-sdk/blob/v0.45.2/client/tx/tx.go

Functions

func AwaitNextBlocks

func AwaitNextBlocks(
	ctx context.Context,
	clientCtx ClientContext,
	nextBlocks int64,
) error

AwaitNextBlocks waits for next blocks.

func AwaitTx

func AwaitTx(
	ctx context.Context,
	clientCtx ClientContext,
	txHash string,
) (resultTx *coretypes.ResultTx, err error)

AwaitTx awaits until a signed transaction is included in a block, returning the result.

func BroadcastRawTx

func BroadcastRawTx(ctx context.Context, clientCtx ClientContext, txBytes []byte) (*sdk.TxResponse, error)

BroadcastRawTx broadcast the txBytes using the clientCtx and set BroadcastMode.

func BroadcastTx

func BroadcastTx(ctx context.Context, clientCtx ClientContext, txf Factory, msgs ...sdk.Msg) (*sdk.TxResponse, error)

BroadcastTx attempts to generate, sign and broadcast a transaction with the given set of messages. It will return an error upon failure. NOTE: copied from the link below and made some changes. the main idea is to add context.Context to the signature and use it https://github.com/cosmos/cosmos-sdk/blob/v0.45.2/client/tx/tx.go TODO: add test to check if client respects ctx.

func CalculateGas

func CalculateGas(ctx context.Context, clientCtx ClientContext, txf Factory, msgs ...sdk.Msg) (*sdktx.SimulateResponse, uint64, error)

CalculateGas simulates the execution of a transaction and returns the simulation response obtained by the query and the adjusted gas amount.

func GetAccountInfo

func GetAccountInfo(
	ctx context.Context,
	clientCtx ClientContext,
	address string,
) (authtypes.AccountI, error)

GetAccountInfo returns account number and account sequence for provided address

func GetChainID

func GetChainID(ctx context.Context, clientCtx ClientContext) (string, error)

func GetDenomBalance

func GetDenomBalance(
	ctx context.Context,
	clientCtx ClientContext,
	address, denom string,
) (sdk.Int, error)

func GetGasPrice

func GetGasPrice(
	ctx context.Context,
	clientCtx ClientContext,
) (sdk.DecCoin, error)

GetGasPrice returns the current gas price of the chain

func GetLatestBlockNumber

func GetLatestBlockNumber(ctx context.Context, clientCtx ClientContext) (uint64, error)

func GetTransactionByHash

func GetTransactionByHash(ctx context.Context, clientCtx ClientContext, txHash string) (*sdk.TxResponse, error)

func SimulateTx

func SimulateTx(ctx context.Context, clientCtx ClientContext, txBytes []byte) (*sdktx.SimulateResponse, error)

Types

type ClientContext

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

ClientContext exposes the functionality of SDK context in a way where we may intercept GRPC-related method (Invoke) to provide better implementation

func NewClientContext

func NewClientContext(clientCtx client.Context) ClientContext

NewClientContext returns new context

func (ClientContext) BroadcastMode

func (c ClientContext) BroadcastMode() string

BroadcastMode returns configured tx broadcast mode

func (ClientContext) ChainID

func (c ClientContext) ChainID() string

ChainID returns chain ID

func (ClientContext) Client

func (c ClientContext) Client() rpcclient.Client

Client returns RPC client

func (ClientContext) FeeGranterAddress

func (c ClientContext) FeeGranterAddress() sdk.AccAddress

FeeGranterAddress returns the fee granter address from the context

func (ClientContext) FromAddress

func (c ClientContext) FromAddress() sdk.AccAddress

FromAddress returns the from address from the context's name.

func (ClientContext) FromName

func (c ClientContext) FromName() string

FromName returns the key name for the current context.

func (ClientContext) InterfaceRegistry

func (c ClientContext) InterfaceRegistry() codectypes.InterfaceRegistry

InterfaceRegistry returns interface registry of SDK context

func (ClientContext) Invoke

func (c ClientContext) Invoke(ctx context.Context, method string, req, reply interface{}, opts ...grpc.CallOption) (err error)

Invoke invokes GRPC method

func (ClientContext) Keyring

func (c ClientContext) Keyring() keyring.Keyring

Keyring returns keyring

func (ClientContext) NewStream

func (c ClientContext) NewStream(ctx context.Context, desc *grpc.StreamDesc, method string, opts ...grpc.CallOption) (grpc.ClientStream, error)

NewStream implements the grpc ClientConn.NewStream method

func (ClientContext) TxConfig

func (c ClientContext) TxConfig() client.TxConfig

TxConfig returns TxConfig of SDK context

func (ClientContext) WithBroadcastMode

func (c ClientContext) WithBroadcastMode(mode string) ClientContext

WithBroadcastMode returns a copy of the context with an updated broadcast mode.

func (ClientContext) WithChainID

func (c ClientContext) WithChainID(chainID string) ClientContext

WithChainID returns a copy of the context with an updated chain ID

func (ClientContext) WithClient

func (c ClientContext) WithClient(client rpcclient.Client) ClientContext

WithClient returns a copy of the context with an updated RPC client instance

func (ClientContext) WithFromAddress

func (c ClientContext) WithFromAddress(addr sdk.AccAddress) ClientContext

WithFromAddress returns a copy of the context with an updated from account address

func (ClientContext) WithFromName

func (c ClientContext) WithFromName(name string) ClientContext

WithFromName returns a copy of the context with an updated from account name

func (ClientContext) WithKeyring

func (c ClientContext) WithKeyring(k keyring.Keyring) ClientContext

WithKeyring returns a copy of the context with an updated keyring

type Factory

type Factory = tx.Factory

Factory is a re-export of the cosmos sdk tx.Factory type, to make usage of this package more convenient. It will help users by removing the need to import tx package from cosmos sdk and help avoid package name collision.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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