Documentation ¶
Overview ¶
Package rest provides RESTful API services for RFQ
Index ¶
Constants ¶
const ( // QuoteRoute is the API endpoint for handling quote related requests. QuoteRoute = "/quotes" // AckRoute is the API endpoint for handling relay ack related requests. AckRoute = "/ack" )
Variables ¶
This section is empty.
Functions ¶
func EIP191Auth ¶
EIP191Auth implements ethereum signed message authentication middleware for gin rest api For auth, relayer should pass in eth signed message following eip-191 with the message as the current unix timestamp in seconds i.e. signature (hex encoded) = keccak(bytes.concat("\x19Ethereum Signed Message:\n", len(strconv.Itoa(time.Now().Unix()), strconv.Itoa(time.Now().Unix()))) so that full auth header string: auth = strconv.Itoa(time.Now().Unix()) + ":" + signature see: https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sign
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler is the REST API handler.
func (*Handler) GetQuotes ¶
GetQuotes retrieves all quotes from the database. GET /quotes. nolint: cyclop PingExample godoc @Summary Get quotes @Schemes @Param originChainID path int false "origin chain id to filter quotes by" @Param originTokenAddr path string false "origin chain id to filter quotes by" @Param destChainID path int false "destination chain id to filter quotes by" @Param destTokenAddr path string false "destination token address to filter quotes by" @Param relayerAddr path string false "relayer address to filter quotes by" @Description get quotes from all relayers. @Tags quotes @Accept json @Produce json @Success 200 {array} model.GetQuoteResponse @Router /quotes [get].
func (*Handler) ModifyQuote ¶
ModifyQuote upserts a quote
PUT /quotes @dev Protected Method: Authentication is handled through middleware in server.go. nolint: cyclop @Summary Upsert quote @Schemes @Description upsert a quote from relayer. @Param request body model.PutQuoteRequest true "query params" @Tags quotes @Accept json @Produce json @Success 200 @Router /quotes [put].
type QuoterAPIServer ¶ added in v0.0.15
type QuoterAPIServer struct {
// contains filtered or unexported fields
}
QuoterAPIServer 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 NewAPI ¶
func NewAPI( ctx context.Context, cfg config.Config, handler metrics.Handler, omniRPCClient omniClient.RPCClient, store db.APIDB, ) (*QuoterAPIServer, error)
NewAPI 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 (*QuoterAPIServer) AuthMiddleware ¶ added in v0.0.15
func (r *QuoterAPIServer) AuthMiddleware() gin.HandlerFunc
AuthMiddleware is the Gin authentication middleware that authenticates requests using EIP191.
func (*QuoterAPIServer) PutRelayAck ¶ added in v0.22.0
func (r *QuoterAPIServer) PutRelayAck(c *gin.Context)
PutRelayAck checks if a relay is pending or not. Note that the ack is not binding; that is, any relayer can still relay the transaction on chain if they ignore the response to this call. Also, this will not work if the API is run on multiple servers, since there is no inter-server communication to maintain the cache.
PUT /ack. @dev Protected Method: Authentication is handled through middleware in server.go. @Summary Relay ack @Schemes @Description cache an ack request to synchronize relayer actions. @Param request body model.PutQuoteRequest true "query params" @Tags ack @Accept json @Produce json @Success 200 @Router /ack [put].