Documentation ¶
Index ¶
- Constants
- func NewGasEstimator(gasPerByte pack.U256) gas.Estimator
- func NewTxBuilder(options TxBuilderOptions, client *Client) account.TxBuilder
- type Address
- type AddressDecoder
- type AddressEncodeDecoder
- type AddressEncoder
- type Client
- func (client *Client) AccountBalance(ctx context.Context, addr address.Address) (pack.U256, error)
- func (client *Client) AccountNonce(ctx context.Context, addr address.Address) (pack.U256, error)
- func (client *Client) AccountNumber(ctx context.Context, addr address.Address) (pack.U64, error)
- func (client *Client) LatestBlock(ctx context.Context) (pack.U64, error)
- func (client *Client) SubmitTx(ctx context.Context, tx account.Tx) error
- func (client *Client) Tx(ctx context.Context, txHash pack.Bytes) (account.Tx, pack.U64, error)
- type ClientOptions
- func (opts ClientOptions) WithBroadcastMode(broadcastMode pack.String) ClientOptions
- func (opts ClientOptions) WithChainID(chainid pack.String) ClientOptions
- func (opts ClientOptions) WithCoinDenom(coinDenom pack.String) ClientOptions
- func (opts ClientOptions) WithHost(host pack.String) ClientOptions
- func (opts ClientOptions) WithTimeout(timeout time.Duration) ClientOptions
- func (opts ClientOptions) WithTimeoutRetry(timeoutRetry time.Duration) ClientOptions
- type Coin
- type Coins
- type GasEstimator
- type MsgSend
- type Tx
- func (t Tx) From() address.Address
- func (t Tx) Hash() pack.Bytes
- func (t Tx) Nonce() pack.U256
- func (t Tx) Payload() contract.CallData
- func (t Tx) Serialize() (pack.Bytes, error)
- func (t Tx) Sighashes() ([]pack.Bytes32, error)
- func (t *Tx) Sign(signatures []pack.Bytes65, pubKey pack.Bytes) error
- func (t Tx) To() address.Address
- func (t Tx) Value() pack.U256
- type TxBuilderOptions
Constants ¶
const ( // DefaultClientTimeout used by the Client. DefaultClientTimeout = time.Minute // DefaultClientTimeoutRetry used by the Client. DefaultClientTimeoutRetry = time.Second // DefaultClientHost used by the Client. This should only be used for local // deployments of the multichain. DefaultClientHost = pack.String("http://0.0.0.0:26657") // DefaultBroadcastMode configures the behaviour of a cosmos client while it // interacts with the cosmos node. Allowed broadcast modes can be async, sync // and block. "async" returns immediately after broadcasting, "sync" returns // after the transaction has been checked and "block" waits until the // transaction is committed to the chain. DefaultBroadcastMode = pack.String("sync") // DefaultCoinDenom used by the Client. DefaultCoinDenom = pack.String("uluna") )
const ( // DefaultChainID used by the Client. DefaultChainID = pack.String("testnet") // DefaultSignMode used in signing the tx DefaultSignMode = 1 )
Variables ¶
This section is empty.
Functions ¶
func NewGasEstimator ¶
NewGasEstimator returns a simple gas estimator that always returns the same amount of gas-per-byte.
func NewTxBuilder ¶
func NewTxBuilder(options TxBuilderOptions, client *Client) account.TxBuilder
NewTxBuilder returns an implementation of the transaction builder interface from the Cosmos Compat API, and exposes the functionality to build simple Cosmos based transactions.
Types ¶
type Address ¶
type Address sdk.AccAddress
An Address is a public address that can be encoded/decoded to/from strings. Addresses are usually formatted different between different network configurations.
func (Address) AccAddress ¶
func (addr Address) AccAddress() sdk.AccAddress
AccAddress convert Address to sdk.AccAddress
type AddressDecoder ¶
type AddressDecoder struct { }
AddressDecoder implements the address.Decoder interface
func NewAddressDecoder ¶
func NewAddressDecoder() AddressDecoder
NewAddressDecoder creates a new address decoder
func (AddressDecoder) DecodeAddress ¶
func (decoder AddressDecoder) DecodeAddress(addr address.Address) (address.RawAddress, error)
DecodeAddress consumes a human-readable representation of a cosmos compatible address and decodes it to its raw bytes representation.
type AddressEncodeDecoder ¶
type AddressEncodeDecoder struct { AddressEncoder AddressDecoder }
AddressEncodeDecoder encapsulates fields that implement the address.EncodeDecoder interface
func NewAddressEncodeDecoder ¶
func NewAddressEncodeDecoder() AddressEncodeDecoder
NewAddressEncodeDecoder creates a new address encoder-decoder
type AddressEncoder ¶
type AddressEncoder struct { }
AddressEncoder implements the address.Encoder interface
func NewAddressEncoder ¶
func NewAddressEncoder() AddressEncoder
NewAddressEncoder creates a new address encoder
func (AddressEncoder) EncodeAddress ¶
func (encoder AddressEncoder) EncodeAddress(rawAddr address.RawAddress) (address.Address, error)
EncodeAddress consumes raw bytes and encodes them to a human-readable address format.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client interacts with an instance of the Cosmos based network using the REST interface exposed by a lightclient node.
func NewClient ¶
func NewClient(opts ClientOptions, cdc codec.Codec, txConfig cosmClient.TxConfig, interfaceReg codecTypes.InterfaceRegistry, amino *codec.LegacyAmino, hrp string) *Client
NewClient returns a new Client.
func (*Client) AccountBalance ¶ added in v0.2.12
AccountBalance returns the account balancee for a given address.
func (*Client) AccountNonce ¶ added in v0.2.8
AccountNonce returns the current nonce of the account. This is the nonce to be used while building a new transaction.
func (*Client) AccountNumber ¶ added in v0.2.8
AccountNumber returns the account number for a given address.
func (*Client) LatestBlock ¶ added in v0.2.20
LatestBlock returns the most recent block's number.
type ClientOptions ¶
type ClientOptions struct { Timeout time.Duration TimeoutRetry time.Duration Host pack.String BroadcastMode pack.String CoinDenom pack.String ChainID pack.String }
ClientOptions are used to parameterise the behaviour of the Client.
func DefaultClientOptions ¶
func DefaultClientOptions() ClientOptions
DefaultClientOptions returns ClientOptions with the default settings. These settings are valid for use with the default local deployment of the multichain. In production, the host, user, and password should be changed.
func (ClientOptions) WithBroadcastMode ¶ added in v0.2.12
func (opts ClientOptions) WithBroadcastMode(broadcastMode pack.String) ClientOptions
WithBroadcastMode sets the behaviour of the Client when interacting with the underlying node.
func (ClientOptions) WithChainID ¶ added in v0.4.3
func (opts ClientOptions) WithChainID(chainid pack.String) ClientOptions
WithChainID sets the chain id used by the Client.
func (ClientOptions) WithCoinDenom ¶ added in v0.2.12
func (opts ClientOptions) WithCoinDenom(coinDenom pack.String) ClientOptions
WithCoinDenom sets the coin denomination used by the Client.
func (ClientOptions) WithHost ¶
func (opts ClientOptions) WithHost(host pack.String) ClientOptions
WithHost sets the URL of the node.
func (ClientOptions) WithTimeout ¶ added in v0.2.12
func (opts ClientOptions) WithTimeout(timeout time.Duration) ClientOptions
WithTimeout sets the timeout used by the Client.
func (ClientOptions) WithTimeoutRetry ¶ added in v0.2.12
func (opts ClientOptions) WithTimeoutRetry(timeoutRetry time.Duration) ClientOptions
WithTimeoutRetry sets the timeout retry used by the Client.
type GasEstimator ¶
type GasEstimator struct {
// contains filtered or unexported fields
}
A GasEstimator returns the gas-per-byte that is needed in order to confirm transactions with an estimated maximum delay of one block. In distributed networks that collectively build, sign, and submit transactions, it is important that all nodes in the network have reached consensus on the gas-per-byte.
func (*GasEstimator) EstimateGas ¶ added in v0.2.9
EstimateGas returns gas required per byte for Cosmos-compatible chains. This value is used for both the price and cap, because Cosmos-compatible chains do not have a distinct concept of cap.
type MsgSend ¶
type MsgSend struct { FromAddress Address `json:"from_address" yaml:"from_address"` ToAddress Address `json:"to_address" yaml:"to_address"` Amount Coins `json:"amount" yaml:"amount"` }
MsgSend - high level transaction of the coin module
type Tx ¶ added in v0.4.3
type Tx struct {
// contains filtered or unexported fields
}
Tx is a tx.Tx wrapper
func (Tx) Sighashes ¶ added in v0.4.3
Sighashes that need to be signed before this transaction can be submitted.
func (*Tx) Sign ¶ added in v0.4.3
Sign the transaction by injecting signatures and the serialized pubkey of the signer.
type TxBuilderOptions ¶
TxBuilderOptions only contains necessary options to build tx from tx builder
func DefaultTxBuilderOptions ¶ added in v0.2.12
func DefaultTxBuilderOptions() TxBuilderOptions
DefaultTxBuilderOptions returns TxBuilderOptions with the default settings.
func (TxBuilderOptions) WithChainID ¶ added in v0.2.12
func (opts TxBuilderOptions) WithChainID(chainID pack.String) TxBuilderOptions
WithChainID sets the chain ID used by the transaction builder.