From 71ec4ebc3dfb02d6cd079e4d3c8c4726d9173b6f Mon Sep 17 00:00:00 2001 From: Alfetopito Date: Wed, 12 Jul 2023 14:40:09 +0100 Subject: [PATCH] fix(twap): avoid sending `env` as `undefined` to getOrder query Without this, instead of the default behaviour, the SDK defaults to `barn` endpoint --- src/api/gnosisProtocol/api.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/api/gnosisProtocol/api.ts b/src/api/gnosisProtocol/api.ts index 6f8ba50ed0..f2d223d54d 100644 --- a/src/api/gnosisProtocol/api.ts +++ b/src/api/gnosisProtocol/api.ts @@ -152,7 +152,18 @@ export async function getQuote(params: FeeQuoteParams): Promise { - return orderBookApi.getOrder(orderId, { chainId, env }) + const contextOverride = { + chainId, + // To avoid passing `undefined` and unintentionally setting the `env` to `barn` + // we check if the `env` is `undefined` and if it is we don't include it in the contextOverride + ...(env + ? { + env, + } + : undefined), + } + + return orderBookApi.getOrder(orderId, contextOverride) } export async function getOrders(