From 2494ba2022811dda18ab1484bd72857001d72d49 Mon Sep 17 00:00:00 2001 From: tjs Date: Wed, 3 May 2023 14:26:26 -0400 Subject: [PATCH] fix datafeed crash --- apis/datafeed.ts | 2 +- components/trade/TradingViewChart.tsx | 24 ++++++------------------ 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/apis/datafeed.ts b/apis/datafeed.ts index 8f7b0327..226b4f98 100644 --- a/apis/datafeed.ts +++ b/apis/datafeed.ts @@ -212,7 +212,7 @@ export default { } } const ticker = mangoStore.getState().selectedMarket.name - console.log('ticker', ticker, mangoStore.getState().group) + console.log('ticker, symbolAddress', ticker, symbolAddress) const symbolInfo: SymbolInfo = { address: symbolItem.address, diff --git a/components/trade/TradingViewChart.tsx b/components/trade/TradingViewChart.tsx index fe29bc5e..1d9a6b62 100644 --- a/components/trade/TradingViewChart.tsx +++ b/components/trade/TradingViewChart.tsx @@ -77,7 +77,6 @@ const TradingViewChart = () => { const { width } = useViewport() const [chartReady, setChartReady] = useState(false) const [headerReady, setHeaderReady] = useState(false) - const [spotOrPerp, setSpotOrPerp] = useState('spot') const [showOrderLinesLocalStorage, toggleShowOrderLinesLocalStorage] = useLocalStorageState(SHOW_ORDER_LINES_KEY, true) const [showOrderLines, toggleShowOrderLines] = useState( @@ -111,7 +110,6 @@ const TradingViewChart = () => { chartsStorageUrl: 'https://tv-backend-v4.herokuapp.com', chartsStorageApiVersion: '1.1' as AvailableSaveloadVersions, clientId: 'mango.markets', - userId: '', fullscreen: false, autosize: true, studiesOverrides: { @@ -158,20 +156,6 @@ const TradingViewChart = () => { } }, [selectedMarket, chartReady]) - useEffect(() => { - if ( - selectedMarketName?.toLowerCase().includes('perp') && - spotOrPerp !== 'perp' - ) { - setSpotOrPerp('perp') - } else if ( - !selectedMarketName?.toLowerCase().includes('perp') && - spotOrPerp !== 'spot' - ) { - setSpotOrPerp('spot') - } - }, [selectedMarketName, spotOrPerp]) - useEffect(() => { if (showStablePrice !== showStablePriceLocalStorage) { toggleShowStablePriceLocalStorage(showStablePrice) @@ -735,9 +719,13 @@ const TradingViewChart = () => { [`mainSeriesProperties.${prop}.wickDownColor`]: COLORS.DOWN[theme], } }) + const mkt = mangoStore.getState().selectedMarket.current const marketAddress = - mangoStore.getState().selectedMarket.current?.publicKey.toString() || + (mkt instanceof Serum3Market + ? mkt?.serumMarketExternal.toString() + : mkt?.publicKey.toString()) || '8BnEgHoWFysVcuFFX7QztDmzuH8r5ZFvyP3sYwn1XTh6' + const widgetOptions: ChartingLibraryWidgetOptions = { // debug: true, symbol: marketAddress, @@ -787,7 +775,7 @@ const TradingViewChart = () => { charts_storage_url: defaultProps.chartsStorageUrl, charts_storage_api_version: defaultProps.chartsStorageApiVersion, client_id: defaultProps.clientId, - user_id: userId ? userId : defaultProps.userId, + user_id: userId ? userId : undefined, fullscreen: defaultProps.fullscreen, autosize: defaultProps.autosize, studies_overrides: defaultProps.studiesOverrides,