relapi

package
v0.34.3 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2024 License: MIT Imports: 27 Imported by: 1

Documentation

Overview

Package relapi provides RESTful API services for the RFQ relayer

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GetQuoteRequestResponse added in v0.29.14

type GetQuoteRequestResponse struct {
	QuoteRequestRaw string `json:"quote_request"`
	OriginChainID   uint32 `json:"origin_chain_id"`
	DestChainID     uint32 `json:"dest_chain_id"`
	OriginToken     string `json:"origin_token"`
	DestToken       string `json:"dest_token"`
}

GetQuoteRequestResponse is the response to a get quote request.

type GetQuoteRequestStatusResponse

type GetQuoteRequestStatusResponse struct {
	Status        string `json:"status"`
	TxID          string `json:"tx_id"`
	OriginTxHash  string `json:"origin_tx_hash"`
	OriginChainID uint32 `json:"origin_chain_id"`
	DestTxHash    string `json:"dest_tx_hash"`
	DestChainID   uint32 `json:"dest_chain_id"`
}

GetQuoteRequestStatusResponse contains the schema for a GET /quote response.

type GetTxByNonceRequest added in v0.30.0

type GetTxByNonceRequest struct {
	ChainID uint32 `json:"chain_id"`
	Nonce   uint64 `json:"nonce"`
}

GetTxByNonceRequest is the request for getting a transaction hash by nonce.

type GetTxRetryResponse

type GetTxRetryResponse struct {
	TxID      string `json:"tx_id"`
	ChainID   uint32 `json:"chain_id"`
	Nonce     uint64 `json:"nonce"`
	GasAmount string `json:"gas_amount"`
}

GetTxRetryResponse contains the schema for a PUT /tx/retry response.

type Handler

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

Handler is the REST API handler.

func NewHandler

func NewHandler(db reldb.Service, chains map[uint32]*chain.Chain, cfg relconfig.Config, txSubmitter submitter.TransactionSubmitter) *Handler

NewHandler creates a new REST API handler.

func (*Handler) GetHealth

func (h *Handler) GetHealth(c *gin.Context)

GetHealth returns a successful response to signify the API is up and running.

func (*Handler) GetQuoteRequestByTxID added in v0.29.14

func (h *Handler) GetQuoteRequestByTxID(c *gin.Context)

GetQuoteRequestByTxID gets the quote request by tx id.

func (*Handler) GetQuoteRequestStatusByTxHash

func (h *Handler) GetQuoteRequestStatusByTxHash(c *gin.Context)

GetQuoteRequestStatusByTxHash gets the status of a quote request, given an origin tx hash.

func (*Handler) GetQuoteRequestStatusByTxID

func (h *Handler) GetQuoteRequestStatusByTxID(c *gin.Context)

GetQuoteRequestStatusByTxID gets the status of a quote request, given a tx id.

func (*Handler) GetTxHashByNonce added in v0.30.0

func (h *Handler) GetTxHashByNonce(c *gin.Context)

GetTxHashByNonce gets the transaction hash by submitter nonce.

func (*Handler) GetTxRetry

func (h *Handler) GetTxRetry(c *gin.Context)

GetTxRetry retries a transaction based on tx hash.

func (*Handler) Withdraw added in v0.29.11

func (h *Handler) Withdraw(c *gin.Context)

Withdraw withdraws tokens from the relayer.

type PutRelayAckResponse added in v0.22.0

type PutRelayAckResponse struct {
	TxID           string `json:"tx_id"`
	ShouldRelay    bool   `json:"should_relay"`
	RelayerAddress string `json:"relayer_address"`
}

PutRelayAckResponse contains the schema for a POST /relay/ack response.

type RelayerAPIServer

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

RelayerAPIServer is a struct that holds the configuration, database connection, gin engine, RPC client, metrics handler, and fast bridge contracts. It is used to initialize and run the API server.

func NewRelayerAPI

func NewRelayerAPI(
	ctx context.Context,
	cfg relconfig.Config,
	handler metrics.Handler,
	omniRPCClient omniClient.RPCClient,
	store reldb.Service,
	submitter submitter.TransactionSubmitter,
) (*RelayerAPIServer, error)

NewRelayerAPI holds the configuration, database connection, gin engine, RPC client, metrics handler, and fast bridge contracts. It is used to initialize and run the API server.

func (*RelayerAPIServer) Run

func (r *RelayerAPIServer) Run(ctx context.Context) error

Run runs the rest api server.

type RelayerClient added in v0.25.7

type RelayerClient interface {
	Health(ctx context.Context) (ok bool, err error)
	GetQuoteRequestStatusByTxHash(ctx context.Context, hash string) (*GetQuoteRequestStatusResponse, error)
	GetQuoteRequestStatusByTxID(ctx context.Context, hash string) (*GetQuoteRequestStatusResponse, error)
	RetryTransaction(ctx context.Context, txhash string) (*GetTxRetryResponse, error)
	Withdraw(ctx context.Context, req *WithdrawRequest) (*WithdrawResponse, error)
	GetTxHashByNonce(ctx context.Context, req *GetTxByNonceRequest) (*TxHashByNonceResponse, error)
	GetQuoteRequestByTXID(ctx context.Context, txid string) (*GetQuoteRequestResponse, error)
}

RelayerClient is the interface for the relayer client.

func NewRelayerClient added in v0.25.7

func NewRelayerClient(handler metrics.Handler, url string) RelayerClient

NewRelayerClient creates a new RelayerClient.

type TxHashByNonceResponse added in v0.30.0

type TxHashByNonceResponse struct {
	Hash string `json:"withdrawTxHash"`
}

TxHashByNonceResponse is the request for getting a transaction hash by nonce.

type WithdrawRequest added in v0.29.11

type WithdrawRequest struct {
	// ChainID is the chain ID of the chain to withdraw from.
	ChainID uint32 `json:"chain_id"`
	// Amount is the amount to withdraw, in wei.
	Amount string `json:"amount"`
	// TokenAddress is the address of the token to withdraw.
	TokenAddress common.Address `json:"token_address"`
	// To is the address to withdraw to.
	To common.Address `json:"to"`
}

WithdrawRequest is the request to withdraw tokens from the relayer.

func (*WithdrawRequest) MarshalJSON added in v0.29.11

func (wr *WithdrawRequest) MarshalJSON() ([]byte, error)

MarshalJSON handles JSON marshaling for WithdrawRequest.

func (*WithdrawRequest) UnmarshalJSON added in v0.29.11

func (wr *WithdrawRequest) UnmarshalJSON(data []byte) error

UnmarshalJSON has JSON unmarshalling for WithdrawRequest.

type WithdrawResponse added in v0.29.11

type WithdrawResponse struct {
	Nonce uint64 `json:"nonce"`
}

WithdrawResponse is the response for the withdraw request.

Jump to

Keyboard shortcuts

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