Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ The API endpoint is configured using the environment variable
`REACT_APP_ORDER_BOOK_URLS`:

```ini
REACT_APP_ORDER_BOOK_URLS='{"1":"https://YOUR_HOST","100":"https://YOUR_HOST","5":"https://YOUR_HOST"}
REACT_APP_ORDER_BOOK_URLS='{"1":"https://YOUR_HOST","100":"https://YOUR_HOST","5":"https://YOUR_HOST"}'
```

## BFF API Endpoints (Backend for Frontend)
Expand Down
16 changes: 13 additions & 3 deletions apps/cowswap-frontend/src/cowSdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,19 @@ import { EthersV5Adapter } from '@cowprotocol/sdk-ethers-v5-adapter'
import { useWeb3React } from '@web3-react/core'

const chainId = getCurrentChainIdFromUrl()
const prodBaseUrls = process.env.REACT_APP_ORDER_BOOK_URLS
? JSON.parse(process.env.REACT_APP_ORDER_BOOK_URLS)
: undefined

const envBaseUrls = process.env.REACT_APP_ORDER_BOOK_URLS && JSON.parse(process.env.REACT_APP_ORDER_BOOK_URLS)

// To manually set the order book URLs in localStorage, you can use the following command in the browser console:
// localStorage.setItem('orderBookUrls', JSON.stringify({ "1":"https://YOUR_HOST", "100":"https://YOUR_HOST" }))
// To clear it, simply run:
// localStorage.removeItem('orderBookUrls')
const localStorageBaseUrls =
localStorage.getItem('orderBookUrls') && JSON.parse(localStorage.getItem('orderBookUrls') || '{}')

const prodBaseUrls = envBaseUrls || localStorageBaseUrls || undefined

console.log('Order Book URLs:', prodBaseUrls, !!envBaseUrls, !!localStorageBaseUrls)

export const adapter = new EthersV5Adapter({
provider: getRpcProvider(chainId)!,
Expand Down
10 changes: 7 additions & 3 deletions apps/explorer/src/cowSdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ import { MetadataApi } from '@cowprotocol/cow-sdk'
import { OrderBookApi } from '@cowprotocol/cow-sdk'
import { SubgraphApi } from '@cowprotocol/sdk-subgraph'

const prodBaseUrls = process.env.REACT_APP_ORDER_BOOK_URLS
? JSON.parse(process.env.REACT_APP_ORDER_BOOK_URLS)
: undefined
// TODO: why is this duplicated? Can this be shared with the instance from CoW Swap?

const envBaseUrls = process.env.REACT_APP_ORDER_BOOK_URLS && JSON.parse(process.env.REACT_APP_ORDER_BOOK_URLS)
const localStorageBaseUrls =
localStorage.getItem('orderBookUrls') && JSON.parse(localStorage.getItem('orderBookUrls') || '{}')

const prodBaseUrls = envBaseUrls || localStorageBaseUrls || undefined

const apiKey = process.env.THEGRAPH_API_KEY || ''

Expand Down