cosmos

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2023 License: Apache-2.0 Imports: 68 Imported by: 0

Documentation

Index

Constants

View Source
const LEN_NATIVE_ASSET = 8

Variables

ModuleBasics defines the module BasicManager is in charge of setting up basic, non-dependant module elements, such as codec registration and genesis verification.

Functions

func CheckError added in v0.3.0

func CheckError(err error) xc.ClientError

func NewAddressBuilder

func NewAddressBuilder(asset xc.ITask) (xc.AddressBuilder, error)

NewAddressBuilder creates a new Cosmos AddressBuilder

func NewSigner

func NewSigner(asset xc.ITask) (xc.Signer, error)

NewSigner creates a new Cosmos Signer

func NewTxBuilder

func NewTxBuilder(asset xc.ITask) (xc.TxBuilder, error)

NewTxBuilder creates a new Cosmos TxBuilder

Types

type AddressBuilder

type AddressBuilder struct {
	Asset *xc.AssetConfig
}

AddressBuilder for Cosmos

func (AddressBuilder) GetAddressFromPublicKey

func (ab AddressBuilder) GetAddressFromPublicKey(publicKeyBytes []byte) (xc.Address, error)

GetAddressFromPublicKey returns an Address given a public key

func (AddressBuilder) GetAllPossibleAddressesFromPublicKey

func (ab AddressBuilder) GetAllPossibleAddressesFromPublicKey(publicKeyBytes []byte) ([]xc.PossibleAddress, error)

GetAllPossibleAddressesFromPublicKey returns all PossubleAddress(es) given a public key

type Client

type Client struct {
	Asset           xc.ITask
	Ctx             client.Context
	Prefix          string
	EstimateGasFunc xc.EstimateGasFunc
}

Client for Cosmos

func NewClient

func NewClient(cfgI xc.ITask) (*Client, error)

NewClient returns a new Client

func (*Client) EstimateGas added in v0.2.0

func (client *Client) EstimateGas(ctx context.Context) (xc.AmountBlockchain, error)

EstimateGas estimates gas price for a Cosmos chain

func (*Client) FetchBalance added in v0.2.0

func (client *Client) FetchBalance(ctx context.Context, address xc.Address) (xc.AmountBlockchain, error)

FetchBalance fetches balance for input asset for a Cosmos address

func (*Client) FetchNativeBalance added in v0.2.0

func (client *Client) FetchNativeBalance(ctx context.Context, address xc.Address) (xc.AmountBlockchain, error)

FetchNativeBalance fetches account balance for a Cosmos address

func (*Client) FetchTxInfo

func (client *Client) FetchTxInfo(ctx context.Context, txHash xc.TxHash) (xc.TxInfo, error)

FetchTxInfo returns tx info for a Cosmos tx

func (*Client) FetchTxInput

func (client *Client) FetchTxInput(ctx context.Context, from xc.Address, _ xc.Address) (xc.TxInput, error)

FetchTxInput returns tx input for a Cosmos tx

func (*Client) GetAccount added in v0.2.0

func (client *Client) GetAccount(ctx context.Context, address xc.Address) (client.Account, error)

GetAccount returns a Cosmos account Equivalent to client.Ctx.AccountRetriever.GetAccount(), but doesn't rely GetConfig()

func (*Client) RegisterEstimateGasCallback added in v0.3.0

func (client *Client) RegisterEstimateGasCallback(fn xc.EstimateGasFunc)

RegisterEstimateGasCallback registers a callback to get gas price

func (*Client) SubmitTx

func (client *Client) SubmitTx(ctx context.Context, txInput xc.Tx) error

SubmitTx submits a Cosmos tx

type EncodingConfig added in v0.3.0

type EncodingConfig struct {
	InterfaceRegistry codectypes.InterfaceRegistry
	Marshaler         codec.Codec
	TxConfig          client.TxConfig
	Amino             *codec.LegacyAmino
}

EncodingConfig specifies the concrete encoding types to use for a given app. This is provided for compatibility between protobuf and amino implementations.

func MakeCosmosConfig added in v0.3.0

func MakeCosmosConfig() EncodingConfig

func MakeEncodingConfig added in v0.3.0

func MakeEncodingConfig() EncodingConfig

MakeEncodingConfig creates an EncodingConfig for testing

func NewEncodingConfig added in v0.3.0

func NewEncodingConfig() EncodingConfig

type Signer

type Signer struct {
	Asset xc.ITask
}

Signer for Cosmos

func (Signer) ImportPrivateKey added in v0.2.0

func (signer Signer) ImportPrivateKey(privateKeyOrMnemonic string) (xc.PrivateKey, error)

ImportPrivateKey imports a Cosmos private key

func (Signer) Sign

func (signer Signer) Sign(privateKeyBytes xc.PrivateKey, data xc.TxDataToSign) (xc.TxSignature, error)

Sign a Cosmos tx

type Tx

type Tx struct {
	CosmosTx        types.Tx
	ParsedTransfers []types.Msg
	// aux fields
	CosmosTxBuilder client.TxBuilder
	CosmosTxEncoder types.TxEncoder
	SigsV2          []signingtypes.SignatureV2
	TxDataToSign    []byte
}

Tx for Cosmos

func (Tx) AddSignatures added in v0.3.0

func (tx Tx) AddSignatures(signatures ...xc.TxSignature) error

AddSignatures adds a signature to Tx

func (Tx) Amount added in v0.2.0

func (tx Tx) Amount() xc.AmountBlockchain

Amount returns the amount of a Tx

func (Tx) ContractAddress added in v0.2.0

func (tx Tx) ContractAddress() xc.ContractAddress

ContractAddress returns the contract address of a Tx, if any

func (Tx) Destinations added in v0.3.0

func (tx Tx) Destinations() []*xc.TxInfoEndpoint

Destinations returns the destinations of a Tx

func (Tx) Fee added in v0.2.0

func (tx Tx) Fee() xc.AmountBlockchain

Fee returns the fee of a Tx

func (Tx) From added in v0.2.0

func (tx Tx) From() xc.Address

From returns the from address of a Tx

func (Tx) Hash

func (tx Tx) Hash() xc.TxHash

Hash returns the tx hash or id

func (*Tx) ParseTransfer added in v0.2.0

func (tx *Tx) ParseTransfer()

ParseTransfer parses a Tx as a transfer Currently only banktypes.MsgSend is implemented, i.e. only native tokens

func (Tx) Serialize added in v0.2.0

func (tx Tx) Serialize() ([]byte, error)

Serialize serializes a Tx

func (Tx) Sighashes added in v0.3.0

func (tx Tx) Sighashes() ([]xc.TxDataToSign, error)

Sighashes returns the tx payload to sign, aka sighash

func (Tx) Sources added in v0.3.0

func (tx Tx) Sources() []*xc.TxInfoEndpoint

Sources returns the sources of a Tx

func (Tx) To added in v0.2.0

func (tx Tx) To() xc.Address

To returns the to address of a Tx

type TxBuilder

type TxBuilder struct {
	xc.TxBuilder
	Asset           xc.ITask
	CosmosTxConfig  client.TxConfig
	CosmosTxBuilder client.TxBuilder
}

TxBuilder for Cosmos

func (TxBuilder) NewNativeTransfer

func (txBuilder TxBuilder) NewNativeTransfer(from xc.Address, to xc.Address, amount xc.AmountBlockchain, input xc.TxInput) (xc.Tx, error)

NewNativeTransfer creates a new transfer for a native asset

func (TxBuilder) NewTokenTransfer

func (txBuilder TxBuilder) NewTokenTransfer(from xc.Address, to xc.Address, amount xc.AmountBlockchain, input xc.TxInput) (xc.Tx, error)

NewTokenTransfer creates a new transfer for a token asset

func (TxBuilder) NewTransfer

func (txBuilder TxBuilder) NewTransfer(from xc.Address, to xc.Address, amount xc.AmountBlockchain, input xc.TxInput) (xc.Tx, error)

NewTransfer creates a new transfer for an Asset, either native or token

type TxInput

type TxInput struct {
	xc.TxInputEnvelope
	AccountNumber uint64
	Sequence      uint64
	GasLimit      uint64
	GasPrice      float64
	Memo          string
	FromPublicKey []byte
}

TxInput for Cosmos

func NewTxInput added in v0.3.0

func NewTxInput() *TxInput

NewTxInput returns a new Cosmos TxInput

func (*TxInput) SetPublicKey added in v0.3.0

func (txInput *TxInput) SetPublicKey(publicKeyBytes xc.PublicKey) error

func (*TxInput) SetPublicKeyFromStr added in v0.3.0

func (txInput *TxInput) SetPublicKeyFromStr(publicKeyStr string) error

Jump to

Keyboard shortcuts

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