Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7fa9c06
chore: replace useDTraderQuery with useQuery and update it's usage ac…
nijil-deriv Oct 21, 2025
6e758a9
chore: remove unclosed AI tag
nijil-deriv Oct 21, 2025
1f31a67
fix: test case failure
nijil-deriv Oct 22, 2025
419bded
fix: infinite state update issue
nijil-deriv Oct 22, 2025
ae05c5c
fix: disable refetchOnWindowFocus for useContractsFor hook
nijil-deriv Oct 22, 2025
6ccb372
chore: cache configuration for active symbols query
nijil-deriv Oct 22, 2025
dffeb40
Merge branch 'master' into refactor/remove-useDtraderQuery
nijil-deriv Oct 22, 2025
172e94f
fix: test failures
nijil-deriv Oct 22, 2025
2aa44cf
chore: add more tests to useProposal
nijil-deriv Oct 22, 2025
4a74604
chore: add memoization in useProposal hook
nijil-deriv Oct 22, 2025
6f0df54
chore: always fetch fresh active_symbols list
nijil-deriv Oct 22, 2025
e4dd865
chore: error snackbar showing symbol is unavailable error when switch…
nijil-deriv Oct 22, 2025
089a49a
chore: fix useActiveSymbols test failures
nijil-deriv Oct 22, 2025
5ff12e1
Merge branch 'master' into refactor/remove-useDtraderQuery
nijil-deriv Oct 28, 2025
a4a5b39
fix: socket error reponse return type in useQuery hook
nijil-deriv Oct 28, 2025
7a41781
chore: remove app_id param from ws url
nijil-deriv Oct 28, 2025
8cc7bcd
Merge branch 'master' into refactor/remove-useDtraderQuery
nijil-deriv Oct 28, 2025
e0b2945
fix: test failure
nijil-deriv Oct 28, 2025
24c0d09
chore: remove logging from QueryClient
nijil-deriv Oct 29, 2025
7fe27ad
fix: handle cases for Turbos where barrier_spot_distance in proposal …
nijil-deriv Oct 30, 2025
23b1ac1
Merge branch 'master' into refactor/remove-useDtraderQuery
nijil-deriv Oct 31, 2025
6d90e45
fix: disable save button if stake field is 0 or empty
nijil-deriv Oct 31, 2025
82dae1a
chore: remove disable logic for save button in payout per point actio…
nijil-deriv Oct 31, 2025
928273a
Merge branch 'master' into refactor/remove-useDtraderQuery
nijil-deriv Nov 5, 2025
57dfcf5
chore: use barrier_spot_distance inside contract_details in proposal …
nijil-deriv Nov 5, 2025
5f28694
fix: should not call proposal if stake field is empty
nijil-deriv Nov 5, 2025
216d433
Merge branch 'master' into refactor/remove-useDtraderQuery
nijil-deriv Nov 6, 2025
277ded0
fix: fix issue where proposal request was not being made when switchi…
nijil-deriv Nov 6, 2025
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
8 changes: 6 additions & 2 deletions packages/api-v2/src/APIProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ type APIContextData = {
* @returns {string} The WebSocket URL.
*/
const getWebSocketURL = (endpoint: string) => {
// TODO remove hardcoded app_id in future
return `wss://${endpoint}/websockets/v3?app_id=16929&brand=${getBrandName().toLowerCase()}`;
return `wss://${endpoint}/websockets/v3?brand=${getBrandName().toLowerCase()}`;
};

const APIContext = createContext<APIContextData | null>(null);
Expand Down Expand Up @@ -97,6 +96,11 @@ const APIProvider = ({ children }: PropsWithChildren) => {
refetchOnReconnect: false,
},
},
logger: {
log: () => {},
warn: () => {},
error: () => {},
},
});
}

Expand Down
4 changes: 2 additions & 2 deletions packages/api-v2/src/AuthProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ const AuthProvider = ({ loginIDKey, children, cookieTimeout, selectDefaultAccoun
setLoginid(res?.authorize?.loginid ?? '');
})
.catch(async (e: TAuthorizeError) => {
if (e?.error.code === API_ERROR_CODES.DISABLED_ACCOUNT) {
if (e?.code === API_ERROR_CODES.DISABLED_ACCOUNT) {
await logout?.();
}
setIsLoading(false);
Expand Down Expand Up @@ -248,7 +248,7 @@ const AuthProvider = ({ loginIDKey, children, cookieTimeout, selectDefaultAccoun
setLoginid(newLoginId);
processAuthorizeResponse(authorizeResponse);
} catch (e: unknown) {
if (typeof e === 'object' && (e as TAuthorizeError)?.error.code === API_ERROR_CODES.DISABLED_ACCOUNT) {
if (typeof e === 'object' && (e as TAuthorizeError)?.code === API_ERROR_CODES.DISABLED_ACCOUNT) {
await logout?.();
}
} finally {
Expand Down
10 changes: 1 addition & 9 deletions packages/api-v2/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,4 @@ export { default as useRemoteConfig } from './hooks/useRemoteConfig';
export { default as useTrackJS } from './hooks/useTrackJS';
export * from './hooks';

export {
useInfiniteQuery,
useMutation,
useQuery,
/** @deprecated use `useQuery` instead */
useQuery as useFetch,
/** @deprecated use `useMutation` instead */
useMutation as useRequest,
};
export { useInfiniteQuery, useMutation, useQuery };
2 changes: 1 addition & 1 deletion packages/api-v2/src/useAuthorizedQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const useAuthorizedQuery = <T extends TSocketEndpointNames>(

const isEnabled = typeof options?.enabled === 'boolean' ? options.enabled : true;

return _useQuery<TSocketResponseData<T>, TSocketError<T>>(keys, () => send(name, payload), {
return _useQuery<TSocketResponseData<T>, TSocketError<T>['error']>(keys, () => send(name, payload), {
...options,
enabled: !!(isSuccess && !isLoading && loginid && isEnabled),
});
Expand Down
2 changes: 1 addition & 1 deletion packages/api-v2/src/useInfiniteQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const useInfiniteQuery = <T extends TSocketPaginateableEndpointNames>(
const initial_offset = payload?.offset || 0;
const limit = payload?.limit || 50;

return _useInfiniteQuery<TSocketResponseData<T>, TSocketError<T>>(
return _useInfiniteQuery<TSocketResponseData<T>, TSocketError<T>['error']>(
getQueryKeys(name, payload),

({ pageParam = 0 }) =>
Expand Down
2 changes: 1 addition & 1 deletion packages/api-v2/src/useMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const useMutation = <T extends TSocketEndpointNames>(name: T, options?: TSocketR
mutate: _mutate,
mutateAsync: _mutateAsync,
...rest
} = _useMutation<TSocketResponseData<T>, TSocketError<T>, TSocketAcceptableProps<T>>(props => {
} = _useMutation<TSocketResponseData<T>, TSocketError<T>['error'], TSocketAcceptableProps<T>>(props => {
const prop = props?.[0];
const payload = prop && 'payload' in prop ? (prop.payload as TSocketRequestPayload<T>['payload']) : undefined;

Expand Down
2 changes: 1 addition & 1 deletion packages/api-v2/src/useQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const useQuery = <T extends TSocketEndpointNames>(name: T, ...props: TSocketAcce
const options = prop && 'options' in prop ? (prop.options as TSocketRequestQueryOptions<T>) : undefined;
const { send } = useAPI();

return _useQuery<TSocketResponseData<T>, TSocketError<T>>(
return _useQuery<TSocketResponseData<T>, TSocketError<T>['error']>(
getQueryKeys(name, payload),
() => send(name, payload),
options
Expand Down
6 changes: 3 additions & 3 deletions packages/api-v2/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,15 +453,15 @@ export type TSocketRequestPayload<
};

export type TSocketRequestQueryOptions<T extends TSocketEndpointNames> = Parameters<
typeof useQuery<TSocketResponseData<T>, TSocketError<T>>
typeof useQuery<TSocketResponseData<T>, TSocketError<T>['error']>
>[2];

export type TSocketRequestInfiniteQueryOptions<T extends TSocketEndpointNames> = Parameters<
typeof useInfiniteQuery<TSocketResponseData<T>, TSocketError<T>>
typeof useInfiniteQuery<TSocketResponseData<T>, TSocketError<T>['error']>
>[2];

export type TSocketRequestMutationOptions<T extends TSocketEndpointNames> = Parameters<
typeof useMutation<TSocketResponseData<T>, TSocketError<T>, TSocketAcceptableProps<T>>
typeof useMutation<TSocketResponseData<T>, TSocketError<T>['error'], TSocketAcceptableProps<T>>
>[2];

type TSocketRequestWithOptions<
Expand Down
14 changes: 13 additions & 1 deletion packages/api/src/APIProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,19 @@ declare global {
// This is a temporary workaround to share a single `QueryClient` instance between all the packages.
const getSharedQueryClientContext = (): QueryClient => {
if (!window.ReactQueryClient) {
window.ReactQueryClient = new QueryClient();
window.ReactQueryClient = new QueryClient({
defaultOptions: {
queries: {
refetchOnWindowFocus: false,
refetchOnReconnect: false,
},
},
logger: {
log: () => {},
warn: () => {},
error: () => {},
},
});
}

return window.ReactQueryClient;
Expand Down
10 changes: 1 addition & 9 deletions packages/api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,7 @@ export { default as useRemoteConfig } from './hooks/useRemoteConfig';
export { default as useTrackJS } from './hooks/useTrackJS';
export * from './hooks';

export {
useInfiniteQuery,
useMutation,
useQuery,
/** @deprecated use `useQuery` instead */
useQuery as useFetch,
/** @deprecated use `useMutation` instead */
useMutation as useRequest,
};
export { useInfiniteQuery, useMutation, useQuery };

// Export types from types.ts
export type {
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/useInfiniteQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const useInfiniteQuery = <T extends TSocketPaginateableEndpointNames>(
const initial_offset = payload?.offset || 0;
const limit = payload?.limit || 50;

return _useInfiniteQuery<TSocketResponseData<T>, TSocketError<T>>(
return _useInfiniteQuery<TSocketResponseData<T>, TSocketError<T>['error']>(
getQueryKeys(name, payload),

({ pageParam = 0 }) =>
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/useMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const useMutation = <T extends TSocketEndpointNames>(name: T, options?: TSocketR
mutate: _mutate,
mutateAsync: _mutateAsync,
...rest
} = _useMutation<TSocketResponseData<T>, TSocketError<T>, TSocketAcceptableProps<T>>(props => {
} = _useMutation<TSocketResponseData<T>, TSocketError<T>['error'], TSocketAcceptableProps<T>>(props => {
const prop = props?.[0];
const payload = prop && 'payload' in prop ? (prop.payload as TSocketRequestPayload<T>) : undefined;

Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/useQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const useQuery = <T extends TSocketEndpointNames>(name: T, ...props: TSocketAcce
const options = prop && 'options' in prop ? (prop.options as TSocketRequestQueryOptions<T>) : undefined;
const { send } = useAPI();

return _useQuery<TSocketResponseData<T>, TSocketError<T>>(
return _useQuery<TSocketResponseData<T>, TSocketError<T>['error']>(
getQueryKeys(name, payload),
() => send(name, payload),
options
Expand Down
10 changes: 6 additions & 4 deletions packages/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ type PriceProposalRequest = Omit<
};

type PriceProposalResponse = Omit<BasePriceProposalResponse, 'proposal'> & {
proposal?: Omit<NonNullable<BasePriceProposalResponse['proposal']>, 'display_value'>;
proposal?: Omit<NonNullable<BasePriceProposalResponse['proposal']>, 'display_value'> & {
payout_choices?: string[];
};
};

type BuyContractRequest = Omit<BaseBuyContractRequest, 'loginid' | 'parameters'> & {
Expand Down Expand Up @@ -502,15 +504,15 @@ export type TSocketRequestPayload<
};

export type TSocketRequestQueryOptions<T extends TSocketEndpointNames> = Parameters<
typeof useQuery<TSocketResponseData<T>, TSocketError<T>>
typeof useQuery<TSocketResponseData<T>, TSocketError<T>['error']>
>[2];

export type TSocketRequestInfiniteQueryOptions<T extends TSocketEndpointNames> = Parameters<
typeof useInfiniteQuery<TSocketResponseData<T>, TSocketError<T>>
typeof useInfiniteQuery<TSocketResponseData<T>, TSocketError<T>['error']>
>[2];

export type TSocketRequestMutationOptions<T extends TSocketEndpointNames> = Parameters<
typeof useMutation<TSocketResponseData<T>, TSocketError<T>, TSocketAcceptableProps<T>>
typeof useMutation<TSocketResponseData<T>, TSocketError<T>['error'], TSocketAcceptableProps<T>>
>[2];

type TSocketRequestWithOptions<
Expand Down
28 changes: 0 additions & 28 deletions packages/core/src/Stores/active-symbols-store.js

This file was deleted.

2 changes: 0 additions & 2 deletions packages/core/src/Stores/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import GTMStore from './gtm-store';
import ModulesStore from './Modules';
import NotificationStore from './notification-store';
import UIStore from './ui-store';
import ActiveSymbolsStore from './active-symbols-store';
import PortfolioStore from './portfolio-store';
import ContractReplayStore from './contract-replay-store';
import ContractTradeStore from './contract-trade-store';
Expand All @@ -19,7 +18,6 @@ export default class RootStore {
this.ui = new UIStore(this);
this.gtm = new GTMStore(this);
this.notifications = new NotificationStore(this);
this.active_symbols = new ActiveSymbolsStore(this);
this.portfolio = new PortfolioStore(this);
this.contract_replay = new ContractReplayStore(this);
this.contract_trade = new ContractTradeStore(this);
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/_common/base/socket_base.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ const BinarySocketBase = (() => {
if (is_mock_server) {
return 'ws://127.0.0.1:42069';
}
// TODO remove hardcoded app_id in future
return `wss://${getSocketURL()}/websockets/v3?app_id=16929&brand=${getBrandName().toLowerCase()}`;
return `wss://${getSocketURL()}/websockets/v3?brand=${getBrandName().toLowerCase()}`;
};

const isReady = () => hasReadyState(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ import React from 'react';
import clsx from 'clsx';

import { TTradingTimesRequest } from '@deriv/api';
import { isMarketClosed, toMoment, useIsMounted, WS, mapErrorMessage } from '@deriv/shared';
import { toMoment, useIsMounted, WS, mapErrorMessage } from '@deriv/shared';
import { observer, useStore } from '@deriv/stores';
import { Localize } from '@deriv-com/translations';
import { CaptionText } from '@deriv-com/quill-ui';

import useActiveSymbols from 'AppV2/Hooks/useActiveSymbols';
import { calculateTimeLeft, getSymbol } from 'AppV2/Utils/closed-market-message-utils';
import { useTraderStore } from 'Stores/useTraderStores';

Expand All @@ -34,7 +33,6 @@ const ClosedMarketMessage = observer(() => {
const { common } = useStore();
const { current_language } = common;
const { symbol, prepareTradeStore, is_market_closed } = useTraderStore();
const { activeSymbols } = useActiveSymbols();

const isMounted = useIsMounted();
const [when_market_opens, setWhenMarketOpens] = React.useState<TWhenMarketOpens>({} as TWhenMarketOpens);
Expand Down Expand Up @@ -84,7 +82,7 @@ const ClosedMarketMessage = observer(() => {
setTimeLeft({});
setWhenMarketOpens({} as TWhenMarketOpens);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [activeSymbols, symbol]);
}, [symbol, is_market_closed]);

React.useEffect(() => {
let timer: ReturnType<typeof setTimeout>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
&__container {
padding: 0 var(--core-spacing-800);
}
&__skeleton {
padding: 0 var(--semantic-spacing-general-sm);
}
&-info {
display: flex;
flex-direction: column;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import SymbolIconsMapper from '../SymbolIconsMapper/symbol-icons-mapper';

const MarketSelector = observer(() => {
const [isOpen, setIsOpen] = useState(false);
const { activeSymbols } = useActiveSymbols();
const { activeSymbols, isLoading } = useActiveSymbols();
const { symbol: storeSymbol, tick_data, is_market_closed, contract_type } = useTraderStore();
const { addSnackbar } = useSnackbar();
const { trade_types } = useContractsFor();
Expand All @@ -23,7 +23,7 @@ const MarketSelector = observer(() => {
const contract_name = trade_types?.find((item: TContractType) => item.value === contract_type)?.text;

useEffect(() => {
if (!currentSymbol) {
if (!currentSymbol && !isLoading) {
const symbol_name = getMarketNamesMap()[storeSymbol as keyof typeof getMarketNamesMap] || storeSymbol;
const message = contract_name ? (
<Localize
Expand Down Expand Up @@ -115,7 +115,11 @@ const MarketSelector = observer(() => {

// Show skeleton loader for a reasonable time, then fallback to basic UI
if (typeof currentSymbol?.exchange_is_open === 'undefined' && !showFallback) {
return <Skeleton.Square height={42} width={240} rounded />;
return (
<div className='market-selector__skeleton'>
<Skeleton.Square width={200} height={42} rounded />
</div>
);
}

// Fallback UI when data is not available after timeout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ jest.mock('@deriv/shared', () => ({
})),
}));

jest.mock('../day', () => ({
__esModule: true,
default: jest.fn(() => <div>Mocked DayInput</div>),
}));

describe('Duration', () => {
let default_trade_store: TCoreStores, mockOnChangeMultiple: jest.Mock;

Expand Down
Loading
Loading