Documentation ¶
Overview ¶
Package cosmosclient provides a standalone client to connect to Cosmos SDK chains.
Index ¶
- Variables
- type Client
- func (c Client) Account(accountName string) (cosmosaccount.Account, error)
- func (c Client) Address(accountName string) (sdktypes.AccAddress, error)
- func (c Client) BroadcastTx(accountName string, msgs ...sdktypes.Msg) (Response, error)
- func (c Client) BroadcastTxWithProvision(accountName string, msgs ...sdktypes.Msg) (gas uint64, broadcast func() (Response, error), err error)
- func (c Client) ConsensusInfo(ctx context.Context, height int64) (ConsensusInfo, error)
- func (c Client) Context() client.Context
- func (c Client) Status(ctx context.Context) (*ctypes.ResultStatus, error)
- type ConsensusInfo
- type Option
- func WithAddressPrefix(prefix string) Option
- func WithHome(path string) Option
- func WithKeyringBackend(backend cosmosaccount.KeyringBackend) Option
- func WithKeyringServiceName(name string) Option
- func WithNodeAddress(addr string) Option
- func WithUseFaucet(faucetAddress, denom string, minAmount uint64) Option
- type Response
Constants ¶
This section is empty.
Variables ¶
var FaucetTransferEnsureDuration = time.Second * 40
FaucetTransferEnsureDuration is the duration that BroadcastTx will wait when a faucet transfer is triggered prior to broadcasting but transfer's tx is not committed in the state yet.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // RPC is Tendermint RPC. RPC *rpchttp.HTTP // Factory is a Cosmos SDK tx factory. Factory tx.Factory // AccountRegistry is the retistry to access accounts. AccountRegistry cosmosaccount.Registry // contains filtered or unexported fields }
Client is a client to access your chain by querying and broadcasting transactions.
func (Client) Address ¶
func (c Client) Address(accountName string) (sdktypes.AccAddress, error)
Address returns the account address from account name.
func (Client) BroadcastTx ¶
BroadcastTx creates and broadcasts a tx with given messages for account.
func (Client) BroadcastTxWithProvision ¶
func (Client) ConsensusInfo ¶
ConsensusInfo returns the appropriate tendermint consensus state by given height and the validator set for the next height
type ConsensusInfo ¶
type ConsensusInfo struct { Timestamp string `json:"Timestamp"` Root string `json:"Root"` NextValidatorsHash string `json:"NextValidatorsHash"` ValidatorSet *tmproto.ValidatorSet `json:"ValidatorSet"` }
ConsensusInfo is the validator consensus info
type Option ¶
type Option func(*Client)
Option configures your client.
func WithAddressPrefix ¶
func WithHome ¶
WithHome sets the data dir of your chain. This option is used to access your chain's file based keyring which is only needed when you deal with creating and signing transactions. when it is not provided, your data dir will be assumed as `$HOME/.your-chain-id`.
func WithKeyringBackend ¶
func WithKeyringBackend(backend cosmosaccount.KeyringBackend) Option
WithKeyringBackend sets your keyring backend. By default, it is `test`.
func WithKeyringServiceName ¶
WithKeyringServiceName used as the keyring's name when you are using OS keyring backend. by default it is `cosmos`.
func WithNodeAddress ¶
WithNodeAddress sets the node address of your chain. When this option is not provided `http://localhost:26657` is used as default.
func WithUseFaucet ¶
type Response ¶
type Response struct { Codec codec.Codec // TxResponse is the underlying tx response. *sdktypes.TxResponse }
Response of your broadcasted transaction.
func (Response) Decode ¶
Decode decodes the proto func response defined in your Msg service into your message type. message needs be a pointer. and you need to provide the correct proto message(struct) type to the Decode func.
e.g., for the following CreateChain func the type would be: `types.MsgCreateChainResponse`.
```proto
service Msg { rpc CreateChain(MsgCreateChain) returns (MsgCreateChainResponse); }
```