connection

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: May 6, 2025 License: Apache-2.0, MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BroadcastShortTermOrder

func BroadcastShortTermOrder(ctx context.Context, l *zap.Logger, cosmosClient *cosmosclient.Client, account cosmosaccount.Account, msgs ...sdk.Msg) error

BroadcastShortTermOrder broadcasts a transaction and checks for immediate errors, specifically designed for dYdX short-term orders which don't get included in blocks

func BroadcastWithRetry

func BroadcastWithRetry(ctx context.Context, l *zap.Logger, cosmosClient *cosmosclient.Client, account cosmosaccount.Account, cfg *types.Config, msgs ...sdk.Msg) error

func BroadcastWithRetryAndResponse

func BroadcastWithRetryAndResponse(ctx context.Context, l *zap.Logger, cosmosClient *cosmosclient.Client, account cosmosaccount.Account, cfg *types.Config, msgs ...sdk.Msg) (*cosmosclient.Response, error)

func GetBlockHeight

func GetBlockHeight(ctx context.Context, l *zap.Logger, rpcServerAddress, prefix string) (*int64, error)

func GetGranteeAccount

func GetGranteeAccount(c *cosmosclient.Client, signer, prefix string) (cosmosaccount.Account, error)

func GetGranteeAddress

func GetGranteeAddress(c *cosmosclient.Client, signer, prefix string) (string, error)

func GetSignerAccountAndAddress

func GetSignerAccountAndAddress(c *cosmosclient.Client, signer, prefix string) (*cosmosaccount.Account, string, error)

Define a function to get the signer account and address

func GetTendermintClient

func GetTendermintClient(l *zap.Logger, rpchttp *http.HTTP) cometbft.CometRPC

func InitCosmosClient

func InitCosmosClient(ctx context.Context, l *zap.Logger, chain *types.Chain, key *types.SigningKey) (*cosmosclient.Client, error)

InitCosmosClient initializes a Cosmos client with retry logic

func InitCosmosQueryClient

func InitCosmosQueryClient(ctx context.Context, l *zap.Logger, serverAddress, addressPrefix string) (*cosmosclient.Client, error)

InitCosmosQueryClient initialises a cosmosclient for querying which is lightweight and can be disposed of after use.

func InitFeeClient

func InitFeeClient(ctx context.Context, l *zap.Logger, chain *types.Chain, key *types.SigningKey) (*cosmosclient.Client, error)

InitFeeClient initialises a cosmosclient for executing transactions.

func InitRPCClient

func InitRPCClient(logger *zap.Logger, serverAddress, websocketPath string) (*rpchttp.HTTP, cometbft.CometRPC, error)

InitRPCClient initialises a RPC client.

func SendMessages

func SendMessages(
	ctx context.Context, l *zap.Logger,
	clientRegistry *ClientRegistry,
	chainMsg ChainMessage,
	messageSender MessageSender,
	cfg *types.Config,
	isDryRun, isFeeClient, wrapAuthz bool,
) (*cosmosclient.Response, error)

Types

type ChainMessage

type ChainMessage struct {
	ChainID     string    // Chain ID where this message should be executed
	Messages    []sdk.Msg // Messages to be executed on the source chain
	IsFeeClient bool      // Whether to use the fee client
	WrapAuthz   bool      // Whether to wrap the messages in an Authz MsgExec
}

ChainMessage wraps a message with its source chain information for proper routing

func NewAuthzChainMsg

func NewAuthzChainMsg(chainID string, msgs []sdk.Msg) ChainMessage

NewAuthzChainMsg creates a new ChainMessage with WrapAuthz set to true

func NewChainMsg

func NewChainMsg(chainID string, msgs []sdk.Msg) ChainMessage

NewChainMsg creates a new ChainMessage with WrapAuthz set to false

type ClientEntry

type ClientEntry struct {
	Chain *types.Chain
	Key   *types.SigningKey
}

ClientEntry represents a registered chain with its client and configuration

type ClientInstance

type ClientInstance struct {
	Client *cosmosclient.Client
	Chain  *types.Chain
	Key    *types.SigningKey
}

ClientInstance represents a registered chain with its client and configuration

type ClientRegistry

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

ClientRegistry manages connections to multiple chains

func NewClientRegistry

func NewClientRegistry(logger *zap.Logger, signerAccount string) *ClientRegistry

NewClientRegistry creates a new chain registry

func (*ClientRegistry) Close

func (r *ClientRegistry) Close()

Close closes all clients

func (*ClientRegistry) GetBalance

func (r *ClientRegistry) GetBalance(ctx context.Context, chainID, signerAccount, denom string) (*sdkmath.Int, error)

GetBalance retrieves the balance of an account on a chain by its ID

func (*ClientRegistry) GetClient

func (r *ClientRegistry) GetClient(chainID string, isFeeClient bool) (*ClientInstance, error)

GetClient retrieves a chain client entry by its ID

func (*ClientRegistry) GetHeight

func (r *ClientRegistry) GetHeight(ctx context.Context, chainID string) (*int64, error)

Getheight retrieves the blockheigh of a chain by its ID

func (*ClientRegistry) GetSignerAccountAndAddress

func (r *ClientRegistry) GetSignerAccountAndAddress(signerAccount, chainID string) (*cosmosaccount.Account, string, error)

GetSignerAccountAndAddress retrieves the account and address for a specific chain

func (*ClientRegistry) HasClient

func (r *ClientRegistry) HasClient(chainID string) bool

HasClient checks if a client is registered

func (*ClientRegistry) RegisterClient

func (r *ClientRegistry) RegisterClient(chain *types.Chain, key *types.SigningKey) error

RegisterClient adds a new chain client to the registry

type DefaultMessageSender

type DefaultMessageSender struct{}

DefaultMessageSender is a default implementation of the MessageSender interface

func (*DefaultMessageSender) SendAuthzMessages

func (*DefaultMessageSender) SendAuthzMessages(ctx context.Context, l *zap.Logger, c *cosmosclient.Client, cfg *types.Config, msgs ...sdk.Msg) error

SendAuthzMessages sends the given messages using the cosmos client and grantee information. It returns an error if any step fails.

func (*DefaultMessageSender) SendAuthzMessagesWithResponse

func (*DefaultMessageSender) SendAuthzMessagesWithResponse(ctx context.Context, l *zap.Logger, c *cosmosclient.Client, cfg *types.Config, msgs ...sdk.Msg) (*cosmosclient.Response, error)

SendAuthzMessagesWithResponse sends the given messages using the cosmos client and grantee information. It returns an error if any step fails.

func (*DefaultMessageSender) SendMessages

func (*DefaultMessageSender) SendMessages(ctx context.Context, l *zap.Logger, c *cosmosclient.Client, cfg *types.Config, msgs ...sdk.Msg) error

SendMessages sends the given messages using the cosmos client and grantee information. It returns an error if any step fails.

func (*DefaultMessageSender) SendMessagesWithResponse

func (*DefaultMessageSender) SendMessagesWithResponse(ctx context.Context, l *zap.Logger, c *cosmosclient.Client, cfg *types.Config, msgs ...sdk.Msg) (*cosmosclient.Response, error)

SendMessages sends the given messages using the cosmos client and grantee information. It returns an error if any step fails.

func (*DefaultMessageSender) SendShortTermMessage

func (*DefaultMessageSender) SendShortTermMessage(ctx context.Context, l *zap.Logger, c *cosmosclient.Client, cfg *types.Config, msgs ...sdk.Msg) error

SendMessages sends the given messages using the cosmos client and grantee information. It returns an error if any step fails.

type MessageSender

type MessageSender interface {
	SendAuthzMessages(ctx context.Context, l *zap.Logger, c *cosmosclient.Client, cfg *types.Config, msgs ...sdk.Msg) error
	SendAuthzMessagesWithResponse(ctx context.Context, l *zap.Logger, c *cosmosclient.Client, cfg *types.Config, msgs ...sdk.Msg) (*cosmosclient.Response, error)
	SendMessages(ctx context.Context, l *zap.Logger, c *cosmosclient.Client, cfg *types.Config, msgs ...sdk.Msg) error
	SendMessagesWithResponse(ctx context.Context, l *zap.Logger, c *cosmosclient.Client, cfg *types.Config, msgs ...sdk.Msg) (*cosmosclient.Response, error)
}

MessageSender defines an interface for sending messages using the cosmos client

Jump to

Keyboard shortcuts

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