Skip to content

Commit

Permalink
fix(twap): avoid sending env as undefined to getOrder query (#2864)
Browse files Browse the repository at this point in the history
Without this, instead of the default behaviour, the SDK defaults to `barn` endpoint
  • Loading branch information
alfetopito authored Jul 12, 2023
1 parent 2bebaa8 commit 3db9e05
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/api/gnosisProtocol/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,18 @@ export async function getQuote(params: FeeQuoteParams): Promise<OrderQuoteRespon
}

export async function getOrder(chainId: ChainId, orderId: string, env?: CowEnv): Promise<EnrichedOrder | null> {
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(
Expand Down

0 comments on commit 3db9e05

Please sign in to comment.