client

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BroadcastTx

func BroadcastTx(clientCtx client.Context, txf tx.Factory, msgs ...sdk.Msg) (*sdk.TxResponse, error)

BroadcastTx attempts to generate, sign and broadcast a transaction with the given set of messages. It will also simulate gas requirements if necessary. It will return an error upon failure.

Note, BroadcastTx is copied from the SDK except it removes a few unnecessary things like prompting for confirmation and printing the response. Instead, we return the TxResponse.

Types

type ChainHeight

type ChainHeight struct {
	Logger zerolog.Logger
	// contains filtered or unexported fields
}

ChainHeight is used to cache the chain height of the current node which is being updated each time the node sends an event of EventNewBlockHeader. It starts a goroutine to subscribe to blockchain new block event and update the cached height.

func NewChainHeight

func NewChainHeight(
	ctx context.Context,
	rpcClient tmrpcclient.Client,
	logger zerolog.Logger,
	initialHeight int64,
) (*ChainHeight, error)

NewChainHeight returns a new ChainHeight struct that starts a new goroutine subscribed to EventNewBlockHeader.

func (*ChainHeight) GetChainHeight

func (chainHeight *ChainHeight) GetChainHeight() (int64, error)

GetChainHeight returns the last chain height available.

type OracleClient

type OracleClient struct {
	Logger              zerolog.Logger
	ChainID             string
	KeyringBackend      string
	KeyringDir          string
	KeyringPass         string
	TMRPC               string
	RPCTimeout          time.Duration
	OracleAddr          sdk.AccAddress
	OracleAddrString    string
	ValidatorAddr       sdk.ValAddress
	ValidatorAddrString string
	Encoding            umeeparams.EncodingConfig
	GasPrices           string
	GasAdjustment       float64
	GRPCEndpoint        string
	KeyringPassphrase   string
	ChainHeight         *ChainHeight
}

OracleClient defines a structure that interfaces with the Umee node.

func NewOracleClient

func NewOracleClient(
	ctx context.Context,
	logger zerolog.Logger,
	chainID string,
	keyringBackend string,
	keyringDir string,
	keyringPass string,
	tmRPC string,
	rpcTimeout time.Duration,
	oracleAddrString string,
	validatorAddrString string,
	grpcEndpoint string,
	gasAdjustment float64,
) (OracleClient, error)

func (OracleClient) BroadcastTx

func (oc OracleClient) BroadcastTx(nextBlockHeight, timeoutHeight int64, msgs ...sdk.Msg) error

BroadcastTx attempts to broadcast a signed transaction. If it fails, a few re-attempts will be made until the transaction succeeds or ultimately times out or fails. Ref: https://github.com/terra-money/oracle-feeder/blob/baef2a4a02f57a2ffeaa207932b2e03d7fb0fb25/feeder/src/vote.ts#L230

func (OracleClient) CreateClientContext

func (oc OracleClient) CreateClientContext() (client.Context, error)

CreateClientContext creates an SDK client Context instance used for transaction generation, signing and broadcasting.

func (OracleClient) CreateTxFactory

func (oc OracleClient) CreateTxFactory() (tx.Factory, error)

CreateTxFactory creates an SDK Factory instance used for transaction generation, signing and broadcasting.

Jump to

Keyboard shortcuts

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