cosmos

package
v0.0.0-...-b63df41 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: MIT Imports: 30 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DEFAULT_GAS_ADJUSTMENT = 1.2
)

Variables

This section is empty.

Functions

func CreateAccountFromMnemonic

func CreateAccountFromMnemonic(mnemonic string, bip44Path string) (*secp256k1.PrivKey, types.AccAddress, error)

func CreateClientContext

func CreateClientContext(config *CosmosNetworkConfig) (*client.Context, error)

func CreateClientContextWithOptions

func CreateClientContextWithOptions(config *CosmosNetworkConfig, opts ...ClientContextOption) (*client.Context, error)

Types

type ClientContextOption

type ClientContextOption func(*client.Context) error

func WithRpcClientCtx

func WithRpcClientCtx(rpcUrl string) ClientContextOption

type CosmosNetworkConfig

type CosmosNetworkConfig struct {
	ChainID       uint64   `mapstructure:"chain_id"`
	ID            string   `mapstructure:"id"`
	Name          string   `mapstructure:"name"`
	RPCUrl        string   `mapstructure:"rpc_url"`
	LCDUrl        string   `mapstructure:"lcd_url"`
	WSUrl         string   `mapstructure:"ws_url"`
	Denom         string   `mapstructure:"denom"`
	Mnemonic      string   `mapstructure:"mnemonic"`
	Bip44Path     string   `mapstructure:"bip44path"`
	GasPrice      float64  `mapstructure:"gas_price"`
	BroadcastMode string   `mapstructure:"broadcast_mode"`
	MaxRetries    int      `mapstructure:"max_retries"`
	RetryInterval int64    `mapstructure:"retry_interval"` //milliseconds
	BlockTime     int64    `mapstructure:"block_time"`     //seconds
	PrivateKeys   []string `mapstructure:"private_keys"`
	PublicKeys    []string `mapstructure:"public_keys"`
	SignerNetwork string   `mapstructure:"signer_network"`
}

func (*CosmosNetworkConfig) GetChainId

func (c *CosmosNetworkConfig) GetChainId() uint64

func (*CosmosNetworkConfig) GetFamily

func (c *CosmosNetworkConfig) GetFamily() string

func (*CosmosNetworkConfig) GetId

func (c *CosmosNetworkConfig) GetId() string

func (*CosmosNetworkConfig) GetName

func (c *CosmosNetworkConfig) GetName() string

type NetworkClient

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

func NewNetworkClient

func NewNetworkClient(config *CosmosNetworkConfig, queryClient *QueryClient, txConfig client.TxConfig) (*NetworkClient, error)

func NewNetworkClientWithOptions

func NewNetworkClientWithOptions(config *CosmosNetworkConfig, queryClient *QueryClient, txConfig client.TxConfig, opts ...NetworkClientOption) (*NetworkClient, error)

func (*NetworkClient) BroadcastTx

func (c *NetworkClient) BroadcastTx(ctx context.Context, txBytes []byte) (*sdk.TxResponse, error)

func (*NetworkClient) BroadcastTxAsync

func (c *NetworkClient) BroadcastTxAsync(ctx context.Context, txBytes []byte) (*sdk.TxResponse, error)

func (*NetworkClient) BroadcastTxCommit

func (c *NetworkClient) BroadcastTxCommit(ctx context.Context, txBytes []byte) (*sdk.TxResponse, error)

func (*NetworkClient) BroadcastTxSync

func (c *NetworkClient) BroadcastTxSync(ctx context.Context, txBytes []byte) (*sdk.TxResponse, error)

func (*NetworkClient) CreatePendingTransfersRequest

func (c *NetworkClient) CreatePendingTransfersRequest(ctx context.Context, chain string) (*sdk.TxResponse, error)

func (*NetworkClient) CreateTxBuilder

func (c *NetworkClient) CreateTxBuilder(ctx context.Context, msgs ...sdk.Msg) (client.TxBuilder, error)

func (*NetworkClient) CreateTxFactory

func (c *NetworkClient) CreateTxFactory(ctx context.Context) tx.Factory

Inject account number and sequence number into txFactory for signing

func (*NetworkClient) GetAddress

func (c *NetworkClient) GetAddress() sdk.AccAddress

Get Broadcast Address from config (privatekey or mnemonic)

func (*NetworkClient) GetPubkey

func (c *NetworkClient) GetPubkey() cryptotypes.PubKey

func (*NetworkClient) GetQueryClient

func (c *NetworkClient) GetQueryClient() *QueryClient

func (*NetworkClient) GetRpcClient

func (c *NetworkClient) GetRpcClient() (rpcclient.Client, error)

func (*NetworkClient) GetSequenceNumber

func (c *NetworkClient) GetSequenceNumber() uint64

Add method to safely get sequence number

func (*NetworkClient) IncrementSequenceNumber

func (c *NetworkClient) IncrementSequenceNumber()

Add method to safely increment sequence number

func (*NetworkClient) RemoveRpcClient

func (c *NetworkClient) RemoveRpcClient()

This function is call when the connection with current rpc client is lost

func (*NetworkClient) SendRouteMessageRequest

func (c *NetworkClient) SendRouteMessageRequest(ctx context.Context, id string, payload string) (*sdk.TxResponse, error)

func (*NetworkClient) SetSequenceNumber

func (c *NetworkClient) SetSequenceNumber(seq uint64)

Add method to safely set sequence number

func (*NetworkClient) SetTxFactory

func (c *NetworkClient) SetTxFactory(txFactory tx.Factory)

func (*NetworkClient) SignAndBroadcastMsgs

func (c *NetworkClient) SignAndBroadcastMsgs(ctx context.Context, msgs ...sdk.Msg) (*sdk.TxResponse, error)

func (*NetworkClient) SignBtcCommandsRequest

func (c *NetworkClient) SignBtcCommandsRequest(ctx context.Context, destinationChain string, psbt covtypes.Psbt) (*sdk.TxResponse, error)

func (*NetworkClient) SignCommandsRequests

func (c *NetworkClient) SignCommandsRequests(ctx context.Context, destinationChains []string) (*sdk.TxResponse, error)

func (*NetworkClient) SignEvmCommandsRequest

func (c *NetworkClient) SignEvmCommandsRequest(ctx context.Context, destinationChain string) (*sdk.TxResponse, error)

func (*NetworkClient) SignTx

func (c *NetworkClient) SignTx(txf tx.Factory, txBuilder client.TxBuilder, overwriteSig bool) error

func (*NetworkClient) Start

func (c *NetworkClient) Start() (rpcclient.Client, error)

Start connections: rpc, websocket...

func (*NetworkClient) Subscribe

func (c *NetworkClient) Subscribe(ctx context.Context, subscriber string, query string) (<-chan ctypes.ResultEvent, error)

func (*NetworkClient) UnSubscribe

func (c *NetworkClient) UnSubscribe(ctx context.Context, subscriber string, query string) error

func (*NetworkClient) UnSubscribeAll

func (c *NetworkClient) UnSubscribeAll(ctx context.Context, subscriber string) error

type NetworkClientOption

type NetworkClientOption func(*NetworkClient)

func WithAccount

func WithAccount(privKey *secp256k1.PrivKey, addr sdk.AccAddress) NetworkClientOption

func WithQueryClient

func WithQueryClient(queryClient *QueryClient) NetworkClientOption

func WithRpcClient

func WithRpcClient(rpcClient rpcclient.Client) NetworkClientOption

func WithTxConfig

func WithTxConfig(txConfig client.TxConfig) NetworkClientOption

func WithTxFactory

func WithTxFactory(txFactory tx.Factory) NetworkClientOption

type QueryClient

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

func NewQueryClient

func NewQueryClient(clientCtx *client.Context) *QueryClient

func (*QueryClient) GetAuthQueryClient

func (c *QueryClient) GetAuthQueryClient() (auth.QueryClient, error)

func (*QueryClient) GetChainQueryServiceClient

func (c *QueryClient) GetChainQueryServiceClient() (chainstypes.QueryServiceClient, error)

func (*QueryClient) GetClientCtx

func (c *QueryClient) GetClientCtx() (*client.Context, error)

func (*QueryClient) GetMsgServiceClient

func (c *QueryClient) GetMsgServiceClient() (scalartypes.MsgServiceClient, error)

func (*QueryClient) GetProtocolQueryClient

func (c *QueryClient) GetProtocolQueryClient() (protypes.QueryClient, error)

func (*QueryClient) GetScalarnetQueryClient

func (c *QueryClient) GetScalarnetQueryClient() (scalartypes.QueryServiceClient, error)

func (*QueryClient) GetTxServiceClient

func (c *QueryClient) GetTxServiceClient() (tx.ServiceClient, error)

func (*QueryClient) QueryAccount

func (c *QueryClient) QueryAccount(ctx context.Context, address sdk.AccAddress) (*auth.BaseAccount, error)

func (*QueryClient) QueryActivedChains

func (c *QueryClient) QueryActivedChains(ctx context.Context) ([]string, error)

func (*QueryClient) QueryBatchedCommands

func (c *QueryClient) QueryBatchedCommands(ctx context.Context, destinationChain string, batchedCommandId string) (*chainstypes.BatchedCommandsResponse, error)

func (*QueryClient) QueryPendingCommands

func (c *QueryClient) QueryPendingCommands(ctx context.Context, destinationChain string) ([]chainstypes.QueryCommandResponse, error)

func (*QueryClient) QueryRouteMessageRequest

func (c *QueryClient) QueryRouteMessageRequest(ctx context.Context, sender sdk.AccAddress, feegranter sdk.AccAddress, id string, payload string) (*scalartypes.RouteMessageResponse, error)

func (*QueryClient) QueryTx

func (c *QueryClient) QueryTx(ctx context.Context, txHash string) (*sdk.TxResponse, error)

func (*QueryClient) UnmarshalAccount

func (c *QueryClient) UnmarshalAccount(resp *auth.QueryAccountResponse, account *auth.BaseAccount) error

Todo: Add code for more correct unmarshal

Jump to

Keyboard shortcuts

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