-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFQ API: add bulk quotes endpoint #2846
Changes from all commits
5837092
0a46d31
bf3a58b
5cce9a1
7eb7089
cc5624c
02ec98b
ebe46d8
5080a00
d95d62e
5fc84a3
562366e
f15ff30
c2c7b6f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,244 @@ | ||
--- | ||
id: upsert-quotes | ||
title: "Upsert quotes" | ||
description: "upsert bulk quotes from relayer." | ||
sidebar_label: "Upsert quotes" | ||
hide_title: true | ||
hide_table_of_contents: true | ||
api: eJyNVMGOmzAQ/RXkc9pEPea4VU89tKo2p3SFBhjAG8DesdkNQvx7ZzDZ0IRFCxIy4+fx87w37lWGLiVtvTaN2qvWOiQfJW11il5a49FFOZk6IqygQ/qqNorwpUXnH0zWqX2vUtN4bLwMwdpKpyCpts9O8vXKpSXWICNLxnJujU7+QnIZaY+1uwcwLx9DbdqQ23cWmZ/zpJtCDZswn5agm1hnM4RmOgXSOyQH/iSkswJjyDJC5z7O580JmxG2iMn1GbM4R1ycreEcG9IFM1rhPSHWmU+gz3Kf4KvsGTZFTPKMqVfXABBBt4QYQl1m/mDpqYssELBmwQuakE/hqcVBAs6axgUJv+12k5KzDL9+hp2gYMzx4oMnLh/60nAmZVvPqS34kn+2YsV4Qm2U2OrP1YA/zlDbCueGOt5Y51KAO8fs1gxys2pe2evUzA7X4IILrpN34u/Wtb5buURkeOJ66iY3l3aEVKwnRdZeiqN4/SuSCwKI8NY4X8PYoA3UAjmExn8v9H+izbr8MzfE5CKPZ7+1FR9VtmypGpt8lPWo5rKy+CUTknDfJ+DwQNUwSHi0G8d5+AqkIZHjHOW8JULGvSJyn5Ah6ntg+OVRNhd41Y7evr2ThrnVfh8eGZtMV1ltMllC8CbW5u9e/eVXqj8WYjT1GO9VBU3RQiH4kFaefxaR3uo= | ||
sidebar_class_name: "put api-method" | ||
custom_edit_url: null | ||
--- | ||
|
||
import ApiTabs from "@theme/ApiTabs"; | ||
import DiscriminatorTabs from "@theme/DiscriminatorTabs"; | ||
import MethodEndpoint from "@theme/ApiExplorer/MethodEndpoint"; | ||
import SecuritySchemes from "@theme/ApiExplorer/SecuritySchemes"; | ||
import MimeTabs from "@theme/MimeTabs"; | ||
import ParamsItem from "@theme/ParamsItem"; | ||
import ResponseSamples from "@theme/ResponseSamples"; | ||
import SchemaItem from "@theme/SchemaItem"; | ||
import SchemaTabs from "@theme/SchemaTabs"; | ||
import Markdown from "@theme/Markdown"; | ||
import Heading from "@theme/Heading"; | ||
import OperationTabs from "@theme/OperationTabs"; | ||
import TabItem from "@theme/TabItem"; | ||
|
||
<Heading | ||
as={"h1"} | ||
className={"openapi__heading"} | ||
children={"Upsert quotes"} | ||
> | ||
</Heading> | ||
|
||
<MethodEndpoint | ||
method={"put"} | ||
path={"/bulk_quotes"} | ||
> | ||
|
||
</MethodEndpoint> | ||
|
||
|
||
|
||
upsert bulk quotes from relayer. | ||
|
||
<Heading | ||
id={"request"} | ||
as={"h2"} | ||
className={"openapi-tabs__heading"} | ||
children={"Request"} | ||
> | ||
</Heading> | ||
|
||
<MimeTabs | ||
className={"openapi-tabs__mime"} | ||
> | ||
<TabItem | ||
label={"application/json"} | ||
value={"application/json-schema"} | ||
> | ||
<details | ||
style={{}} | ||
className={"openapi-markdown__details mime"} | ||
data-collapsed={false} | ||
open={true} | ||
> | ||
<summary | ||
style={{}} | ||
className={"openapi-markdown__details-summary-mime"} | ||
> | ||
<h3 | ||
className={"openapi-markdown__details-summary-header-body"} | ||
> | ||
Body | ||
</h3><strong | ||
className={"openapi-schema__required"} | ||
> | ||
required | ||
</strong> | ||
</summary><div | ||
style={{"textAlign":"left","marginLeft":"1rem"}} | ||
> | ||
<div | ||
style={{"marginTop":"1rem","marginBottom":"1rem"}} | ||
> | ||
|
||
|
||
query params | ||
|
||
|
||
</div> | ||
</div><ul | ||
style={{"marginLeft":"1rem"}} | ||
> | ||
<SchemaItem | ||
collapsible={true} | ||
className={"schemaItem"} | ||
> | ||
<details | ||
style={{}} | ||
className={"openapi-markdown__details"} | ||
> | ||
<summary | ||
style={{}} | ||
> | ||
<span | ||
className={"openapi-schema__container"} | ||
> | ||
<strong | ||
className={"openapi-schema__property"} | ||
> | ||
quotes | ||
</strong><span | ||
className={"openapi-schema__name"} | ||
> | ||
object[] | ||
</span> | ||
</span> | ||
</summary><div | ||
style={{"marginLeft":"1rem"}} | ||
> | ||
<li> | ||
<div | ||
style={{"fontSize":"var(--ifm-code-font-size)","opacity":"0.6","marginLeft":"-.5rem","paddingBottom":".5rem"}} | ||
> | ||
Array [ | ||
</div> | ||
</li><SchemaItem | ||
collapsible={false} | ||
name={"dest_amount"} | ||
required={false} | ||
schemaName={"string"} | ||
qualifierMessage={undefined} | ||
schema={{"type":"string"}} | ||
> | ||
|
||
</SchemaItem><SchemaItem | ||
collapsible={false} | ||
name={"dest_chain_id"} | ||
required={false} | ||
schemaName={"integer"} | ||
qualifierMessage={undefined} | ||
schema={{"type":"integer"}} | ||
> | ||
|
||
</SchemaItem><SchemaItem | ||
collapsible={false} | ||
name={"dest_fast_bridge_address"} | ||
required={false} | ||
schemaName={"string"} | ||
qualifierMessage={undefined} | ||
schema={{"type":"string"}} | ||
> | ||
|
||
</SchemaItem><SchemaItem | ||
collapsible={false} | ||
name={"dest_token_addr"} | ||
required={false} | ||
schemaName={"string"} | ||
qualifierMessage={undefined} | ||
schema={{"type":"string"}} | ||
> | ||
|
||
</SchemaItem><SchemaItem | ||
collapsible={false} | ||
name={"fixed_fee"} | ||
required={false} | ||
schemaName={"string"} | ||
qualifierMessage={undefined} | ||
schema={{"type":"string"}} | ||
> | ||
|
||
</SchemaItem><SchemaItem | ||
collapsible={false} | ||
name={"max_origin_amount"} | ||
required={false} | ||
schemaName={"string"} | ||
qualifierMessage={undefined} | ||
schema={{"type":"string"}} | ||
> | ||
|
||
</SchemaItem><SchemaItem | ||
collapsible={false} | ||
name={"origin_chain_id"} | ||
required={false} | ||
schemaName={"integer"} | ||
qualifierMessage={undefined} | ||
schema={{"type":"integer"}} | ||
> | ||
|
||
</SchemaItem><SchemaItem | ||
collapsible={false} | ||
name={"origin_fast_bridge_address"} | ||
required={false} | ||
schemaName={"string"} | ||
qualifierMessage={undefined} | ||
schema={{"type":"string"}} | ||
> | ||
|
||
</SchemaItem><SchemaItem | ||
collapsible={false} | ||
name={"origin_token_addr"} | ||
required={false} | ||
schemaName={"string"} | ||
qualifierMessage={undefined} | ||
schema={{"type":"string"}} | ||
> | ||
|
||
</SchemaItem><li> | ||
<div | ||
style={{"fontSize":"var(--ifm-code-font-size)","opacity":"0.6","marginLeft":"-.5rem"}} | ||
> | ||
] | ||
</div> | ||
</li> | ||
</div> | ||
</details> | ||
</SchemaItem> | ||
</ul> | ||
</details> | ||
</TabItem> | ||
</MimeTabs><div> | ||
<div> | ||
<ApiTabs | ||
label={undefined} | ||
id={undefined} | ||
> | ||
<TabItem | ||
label={"200"} | ||
value={"200"} | ||
> | ||
<div> | ||
|
||
|
||
OK | ||
|
||
|
||
</div><div> | ||
|
||
</div> | ||
</TabItem> | ||
</ApiTabs> | ||
</div> | ||
</div> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,65 @@ func (c *ClientSuite) TestPutAndGetQuote() { | |
c.Equal(expectedResp, *quotes[0]) | ||
} | ||
|
||
func (c *ClientSuite) TestPutAndGetBulkQuotes() { | ||
req := model.PutBulkQuotesRequest{ | ||
Quotes: []model.PutQuoteRequest{ | ||
{ | ||
OriginChainID: 1, | ||
OriginTokenAddr: "0xOriginTokenAddr", | ||
DestChainID: 42161, | ||
DestTokenAddr: "0xDestTokenAddr", | ||
DestAmount: "100", | ||
MaxOriginAmount: "200", | ||
FixedFee: "10", | ||
}, | ||
{ | ||
OriginChainID: 42161, | ||
OriginTokenAddr: "0xOriginTokenAddr", | ||
DestChainID: 1, | ||
DestTokenAddr: "0xDestTokenAddr", | ||
DestAmount: "100", | ||
MaxOriginAmount: "200", | ||
FixedFee: "10", | ||
}, | ||
}, | ||
} | ||
|
||
err := c.client.PutBulkQuotes(c.GetTestContext(), &req) | ||
c.Require().NoError(err) | ||
|
||
quotes, err := c.client.GetAllQuotes(c.GetTestContext()) | ||
c.Require().NoError(err) | ||
|
||
expectedResp := []model.GetQuoteResponse{ | ||
{ | ||
OriginChainID: 1, | ||
OriginTokenAddr: "0xOriginTokenAddr", | ||
DestChainID: 42161, | ||
DestTokenAddr: "0xDestTokenAddr", | ||
DestAmount: "100", | ||
MaxOriginAmount: "200", | ||
FixedFee: "10", | ||
RelayerAddr: c.testWallet.Address().String(), | ||
UpdatedAt: quotes[0].UpdatedAt, | ||
}, | ||
{ | ||
OriginChainID: 42161, | ||
OriginTokenAddr: "0xOriginTokenAddr", | ||
DestChainID: 1, | ||
DestTokenAddr: "0xDestTokenAddr", | ||
DestAmount: "100", | ||
MaxOriginAmount: "200", | ||
FixedFee: "10", | ||
RelayerAddr: c.testWallet.Address().String(), | ||
UpdatedAt: quotes[0].UpdatedAt, | ||
}, | ||
} | ||
c.Len(quotes, 2) | ||
c.Equal(expectedResp[0], *quotes[0]) | ||
c.Equal(expectedResp[1], *quotes[1]) | ||
} | ||
Comment on lines
+41
to
+98
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Address implicit memory aliasing. The loop in for _, quoteReq := range putRequest.Quotes {
dbQuote, err := parseDBQuote("eReq, relayerAddr)
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid quote request"})
return
}
dbQuotes = append(dbQuotes, dbQuote)
} for i := range putRequest.Quotes {
quoteReq := putRequest.Quotes[i]
dbQuote, err := parseDBQuote("eReq, relayerAddr)
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid quote request"})
return
}
dbQuotes = append(dbQuotes, dbQuote)
} |
||
|
||
func (c *ClientSuite) TestGetSpecificQuote() { | ||
req := model.PutQuoteRequest{ | ||
OriginChainID: 1, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,15 @@ func NewTestClientSuite(tb testing.TB) *ClientSuite { | |
func (c *ClientSuite) SetupTest() { | ||
c.TestSuite.SetupTest() | ||
|
||
metricsHandler := metrics.NewNullHandler() | ||
c.handler = metricsHandler | ||
dbType, err := dbcommon.DBTypeFromString("sqlite") | ||
c.Require().NoError(err) | ||
// TODO use temp file / in memory sqlite3 to not create in directory files | ||
testDB, err := sql.Connect(c.GetSuiteContext(), dbType, filet.TmpDir(c.T(), ""), metricsHandler) | ||
c.Require().NoError(err) | ||
c.database = testDB | ||
Comment on lines
+63
to
+68
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct Initialization of The initialization of - // TODO use temp file / in memory sqlite3 to not create in directory files Consider using a temporary file or in-memory sqlite3 to avoid creating files in the directory.
|
||
|
||
testOmnirpc := omnirpcHelper.NewOmnirpcServer(c.GetTestContext(), c.T(), c.omniRPCTestBackends...) | ||
omniRPCClient := omniClient.NewOmnirpcClient(testOmnirpc, c.handler, omniClient.WithCaptureReqRes()) | ||
c.omniRPCClient = omniRPCClient | ||
|
@@ -175,14 +184,6 @@ func (c *ClientSuite) SetupSuite() { | |
c.T().Fatal(err) | ||
} | ||
|
||
dbType, err := dbcommon.DBTypeFromString("sqlite") | ||
c.Require().NoError(err) | ||
metricsHandler := metrics.NewNullHandler() | ||
c.handler = metricsHandler | ||
// TODO use temp file / in memory sqlite3 to not create in directory files | ||
testDB, err := sql.Connect(c.GetSuiteContext(), dbType, filet.TmpDir(c.T(), ""), metricsHandler) | ||
c.Require().NoError(err) | ||
c.database = testDB | ||
// setup config | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure proper error handling for the response.
The function
PutBulkQuotes
is correctly implemented to handle multiple quotes. However, it would be beneficial to handle the response to check for errors or log relevant information.Committable suggestion