From 13d978c6a5236e2ea564804b23f10ad79fe5620e Mon Sep 17 00:00:00 2001 From: Daniel Wasserman Date: Mon, 18 Nov 2024 15:12:00 -0600 Subject: [PATCH] Feat: check both quoter role and relayer role --- services/rfq/api/rest/server.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/services/rfq/api/rest/server.go b/services/rfq/api/rest/server.go index d748e55295..97f841ca8b 100644 --- a/services/rfq/api/rest/server.go +++ b/services/rfq/api/rest/server.go @@ -329,7 +329,6 @@ func (r *QuoterAPIServer) checkRole(c *gin.Context, destChainID uint32) (address } ops := &bind.CallOpts{Context: c} - relayerRole := crypto.Keccak256Hash([]byte("RELAYER_ROLE")) // authenticate relayer signature with EIP191 deadline := time.Now().Unix() - 1000 // TODO: Replace with some type of r.cfg.AuthExpiryDelta @@ -345,9 +344,14 @@ func (r *QuoterAPIServer) checkRole(c *gin.Context, destChainID uint32) (address if cachedRoleItem == nil || cachedRoleItem.IsExpired() { // Cache miss or expired, check on-chain - hasRole, err = bridge.HasRole(ops, relayerRole, addressRecovered) + quoterRole := crypto.Keccak256Hash([]byte("QUOTER_ROLE")) + hasRole, err = bridge.HasRole(ops, quoterRole, addressRecovered) if err != nil { - return addressRecovered, fmt.Errorf("unable to check relayer role on-chain: %w", err) + relayerRole := crypto.Keccak256Hash([]byte("RELAYER_ROLE")) + hasRole, err = bridge.HasRole(ops, relayerRole, addressRecovered) + if err != nil { + return addressRecovered, fmt.Errorf("unable to check relayer role on-chain: %w", err) + } } // Update cache r.roleCache[destChainID].Set(addressRecovered.Hex(), hasRole, cacheInterval)