Skip to content

Commit

Permalink
FRO-43: market switcher feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
tomeq93 committed Sep 21, 2023
1 parent 9125653 commit 78bc874
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
1 change: 1 addition & 0 deletions custom.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ namespace NodeJS {
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID: string;
NEXT_PUBLIC_VPN_PROTECTION: string;
NEXT_PUBLIC_DISABLE_SDAI_MARKET?: '1' | '0';
NEXT_PUBLIC_ENABLE_GNOSIS?: '1' | '0';
}
}
2 changes: 2 additions & 0 deletions src/components/MarketSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ export const MarketSwitcher = () => {
const upToLG = useMediaQuery(theme.breakpoints.up('lg'));
const downToXSM = useMediaQuery(theme.breakpoints.down('xsm'));

if (process.env.NEXT_PUBLIC_ENABLE_GNOSIS !== '1') return null;

return (
<TextField
select
Expand Down
30 changes: 16 additions & 14 deletions src/utils/marketsAndNetworksConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,22 @@ export const networkConfigs = Object.keys(_networkConfigs).reduce((acc, value) =
* Generates network configs based on marketsData & fork settings.
* Fork markets are generated for all markets on the underlying base chain.
*/
export const marketsData = Object.keys(_marketsData).reduce((acc, value) => {
acc[value] = _marketsData[value as keyof typeof CustomMarket];
if (
FORK_ENABLED &&
_marketsData[value as keyof typeof CustomMarket].chainId === FORK_BASE_CHAIN_ID
) {
acc[`fork_${value}`] = {
..._marketsData[value as keyof typeof CustomMarket],
chainId: FORK_CHAIN_ID,
isFork: true,
};
}
return acc;
}, {} as { [key: string]: MarketDataType });
export const marketsData = Object.keys(_marketsData)
.filter((m) => m !== CustomMarket.gnosis || process.env.NEXT_PUBLIC_ENABLE_GNOSIS === '1')
.reduce((acc, value) => {
acc[value] = _marketsData[value as keyof typeof CustomMarket];
if (
FORK_ENABLED &&
_marketsData[value as keyof typeof CustomMarket].chainId === FORK_BASE_CHAIN_ID
) {
acc[`fork_${value}`] = {
..._marketsData[value as keyof typeof CustomMarket],
chainId: FORK_CHAIN_ID,
isFork: true,
};
}
return acc;
}, {} as { [key: string]: MarketDataType });

export function getDefaultChainId() {
return marketsData[availableMarkets[0]].chainId;
Expand Down

0 comments on commit 78bc874

Please sign in to comment.