diff --git a/services/rfq/api/client/suite_test.go b/services/rfq/api/client/suite_test.go index e87436fcca..183cd0b13b 100644 --- a/services/rfq/api/client/suite_test.go +++ b/services/rfq/api/client/suite_test.go @@ -85,7 +85,11 @@ func (c *ClientSuite) SetupTest() { DSN: filet.TmpFile(c.T(), "", "").Name(), }, OmniRPCURL: testOmnirpc, - Bridges: map[uint32]string{ + FastBridgeContractsV1: map[uint32]string{ + 1: ethFastBridgeAddress.Hex(), + 42161: arbFastBridgeAddress.Hex(), + }, + FastBridgeContractsV2: map[uint32]string{ 1: ethFastBridgeAddress.Hex(), 42161: arbFastBridgeAddress.Hex(), }, diff --git a/services/rfq/api/config/config.go b/services/rfq/api/config/config.go index 67ff8c8c6e..51ffcd2541 100644 --- a/services/rfq/api/config/config.go +++ b/services/rfq/api/config/config.go @@ -19,13 +19,13 @@ type DatabaseConfig struct { // Config is the configuration for the RFQ Quoter. type Config struct { - Database DatabaseConfig `yaml:"database"` - OmniRPCURL string `yaml:"omnirpc_url"` - // bridges is a map of chainid->address - Bridges map[uint32]string `yaml:"bridges"` - Port string `yaml:"port"` - RelayAckTimeout time.Duration `yaml:"relay_ack_timeout"` - MaxQuoteAge time.Duration `yaml:"max_quote_age"` + Database DatabaseConfig `yaml:"database"` + OmniRPCURL string `yaml:"omnirpc_url"` + FastBridgeContractsV1 map[uint32]string `yaml:"fast_bridge_contracts_v1"` + FastBridgeContractsV2 map[uint32]string `yaml:"fast_bridge_contracts_v2"` + Port string `yaml:"port"` + RelayAckTimeout time.Duration `yaml:"relay_ack_timeout"` + MaxQuoteAge time.Duration `yaml:"max_quote_age"` } const defaultRelayAckTimeout = 30 * time.Second diff --git a/services/rfq/api/model/response.go b/services/rfq/api/model/response.go index 72c534e91f..918caad48f 100644 --- a/services/rfq/api/model/response.go +++ b/services/rfq/api/model/response.go @@ -41,10 +41,12 @@ type PutRelayAckResponse struct { RelayerAddress string `json:"relayer_address"` } -// GetContractsResponse contains the schema for a GET /contract response. +// GetContractsResponse contains the schema for a GET /contracts response. type GetContractsResponse struct { - // Contracts is a map of chain id to contract address - Contracts map[uint32]string `json:"contracts"` + // ContractsV1 is a map of chain id to contract address for v1 fast bridge contracts + ContractsV1 map[uint32]string `json:"contracts_v1"` + // ContractsV2 is a map of chain id to contract address for v2 fast bridge contracts + ContractsV2 map[uint32]string `json:"contracts_v2"` } // ActiveRFQMessage represents the general structure of WebSocket messages for Active RFQ. diff --git a/services/rfq/api/rest/handler.go b/services/rfq/api/rest/handler.go index c0aa5910e8..6a91267e52 100644 --- a/services/rfq/api/rest/handler.go +++ b/services/rfq/api/rest/handler.go @@ -301,12 +301,10 @@ func dbActiveQuoteRequestToModel(dbQuote *db.ActiveQuoteRequest) *model.GetOpenQ // @Header 200 {string} X-Api-Version "API Version Number - See docs for more info" // @Router /contracts [get]. func (h *Handler) GetContracts(c *gin.Context) { - // Convert quotes from db model to api model - contracts := make(map[uint32]string) - for chainID, address := range h.cfg.Bridges { - contracts[chainID] = address - } - c.JSON(http.StatusOK, model.GetContractsResponse{Contracts: contracts}) + c.JSON(http.StatusOK, model.GetContractsResponse{ + ContractsV1: h.cfg.FastBridgeContractsV1, + ContractsV2: h.cfg.FastBridgeContractsV2, + }) } func filterQuoteAge(cfg config.Config, dbQuotes []*db.Quote) []*db.Quote { diff --git a/services/rfq/api/rest/server.go b/services/rfq/api/rest/server.go index 5470e0d4f0..68a6fd05c3 100644 --- a/services/rfq/api/rest/server.go +++ b/services/rfq/api/rest/server.go @@ -95,14 +95,15 @@ func NewAPI( docs.SwaggerInfo.Title = "RFQ Quoter API" - bridges := make(map[uint32]*fastbridge.FastBridge) + // TODO: allow role checking for v2 vs v1 contracts; for now default to v1 + fastBridgeContracts := make(map[uint32]*fastbridge.FastBridge) roles := make(map[uint32]*ttlcache.Cache[string, bool]) - for chainID, bridge := range cfg.Bridges { + for chainID, contract := range cfg.FastBridgeContractsV1 { chainClient, err := omniRPCClient.GetChainClient(ctx, int(chainID)) if err != nil { return nil, fmt.Errorf("could not create omnirpc client: %w", err) } - bridges[chainID], err = fastbridge.NewFastBridge(common.HexToAddress(bridge), chainClient) + fastBridgeContracts[chainID], err = fastbridge.NewFastBridge(common.HexToAddress(contract), chainClient) if err != nil { return nil, fmt.Errorf("could not create bridge contract: %w", err) } @@ -136,7 +137,7 @@ func NewAPI( omnirpcClient: omniRPCClient, handler: handler, meter: handler.Meter(meterName), - fastBridgeContracts: bridges, + fastBridgeContracts: fastBridgeContracts, roleCache: roles, relayAckCache: relayAckCache, ackMux: sync.Mutex{}, diff --git a/services/rfq/api/rest/server_test.go b/services/rfq/api/rest/server_test.go index c82db8d6fc..27d379b83b 100644 --- a/services/rfq/api/rest/server_test.go +++ b/services/rfq/api/rest/server_test.go @@ -536,5 +536,6 @@ func (c *ServerSuite) TestContracts() { contracts, err := client.GetRFQContracts(c.GetTestContext()) c.Require().NoError(err) - c.Require().Len(contracts.Contracts, 2) + c.Require().Len(contracts.ContractsV1, 2) + c.Require().Len(contracts.ContractsV2, 2) } diff --git a/services/rfq/api/rest/suite_test.go b/services/rfq/api/rest/suite_test.go index 755b4882ca..64454dcc02 100644 --- a/services/rfq/api/rest/suite_test.go +++ b/services/rfq/api/rest/suite_test.go @@ -82,7 +82,11 @@ func (c *ServerSuite) SetupTest() { DSN: filet.TmpFile(c.T(), "", "").Name(), }, OmniRPCURL: testOmnirpc, - Bridges: map[uint32]string{ + FastBridgeContractsV1: map[uint32]string{ + 1: ethFastBridgeAddress.Hex(), + 42161: arbFastBridgeAddress.Hex(), + }, + FastBridgeContractsV2: map[uint32]string{ 1: ethFastBridgeAddress.Hex(), 42161: arbFastBridgeAddress.Hex(), },