Skip to content

Commit

Permalink
Merge branch 'master' into likhith/COJ-186/enhance-idv-form-for-uganda
Browse files Browse the repository at this point in the history
  • Loading branch information
likhith-deriv committed Nov 10, 2023
2 parents 94374d8 + 9d02147 commit 231f0ef
Show file tree
Hide file tree
Showing 80 changed files with 16,637 additions and 72,888 deletions.
1 change: 0 additions & 1 deletion nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"default": {
"runner": "@nrwl/nx-cloud",
"options": {
"accessToken": "ZTMzMDk4MmEtNjMyOC00ZjFiLWI5MTktYTc1ODhiOTI0OTJifHJlYWQ=",
"cacheableOperations": [
"build",
"test",
Expand Down
85,340 changes: 12,738 additions & 72,602 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion packages/account/src/Styles/account.scss
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ $MIN_HEIGHT_FLOATING: calc(
overflow: hidden;
}


&-form {
overflow: hidden;
height: 100%;
Expand Down
53 changes: 44 additions & 9 deletions packages/api/src/APIProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { PropsWithChildren } from 'react';
import React, { PropsWithChildren, useEffect } from 'react';
// @ts-expect-error `@deriv/deriv-api` is not in TypeScript, Hence we ignore the TS error.
import DerivAPIBasic from '@deriv/deriv-api/dist/DerivAPIBasic';
import { getAppId, getSocketURL, useWS } from '@deriv/shared';
Expand All @@ -10,6 +10,7 @@ declare global {
interface Window {
ReactQueryClient?: QueryClient;
DerivAPI?: Record<string, DerivAPIBasic>;
WSConnections?: Record<string, WebSocket>;
}
}

Expand All @@ -23,38 +24,72 @@ const getSharedQueryClientContext = (): QueryClient => {
return window.ReactQueryClient;
};

let timer_id: NodeJS.Timer;
/**
* Handles reconnection logic by reinitializing the WebSocket instance if it is in
* closing or closed state.
* @param wss_url WebSocket URL
* @returns
*/
const handleReconnection = (wss_url: string) => {
if (!window.WSConnections) return;
const currentWebsocket = window.WSConnections[wss_url];
if (currentWebsocket instanceof WebSocket && [2, 3].includes(currentWebsocket.readyState)) {
clearTimeout(timer_id);
timer_id = setTimeout(() => {
initializeDerivWS();
}, 500);
}
};

// This is a temporary workaround to share a single `DerivAPIBasic` instance for every unique URL.
// Later once we have each package separated we won't need this anymore and can remove this.
const getDerivAPIInstance = (): DerivAPIBasic => {
const initializeDerivWS = (): DerivAPIBasic => {
if (!window.WSConnections) {
window.WSConnections = {};
}

const endpoint = getSocketURL();
const app_id = getAppId();
const language = 'EN'; // Need to use the language from the app context.
const brand = 'deriv';
const wss = `wss://${endpoint}/websockets/v3?app_id=${app_id}&l=${language}&brand=${brand}`;
const wss_url = `wss://${endpoint}/websockets/v3?app_id=${app_id}&l=${language}&brand=${brand}`;
window.WSConnections[wss_url] = new WebSocket(wss_url);
window.WSConnections[wss_url].addEventListener('close', () => handleReconnection(wss_url));

if (!window.DerivAPI) {
window.DerivAPI = {};
}

if (!window.DerivAPI?.[wss]) {
window.DerivAPI[wss] = new DerivAPIBasic({ connection: new WebSocket(wss) });
if (!window.DerivAPI?.[wss_url]) {
window.DerivAPI[wss_url] = new DerivAPIBasic({ connection: window.WSConnections[wss_url] });
}

return window.DerivAPI?.[wss];
return window.DerivAPI?.[wss_url];
};

const queryClient = getSharedQueryClientContext();

type TProps = {
type TAPIProviderProps = {
/** If set to true, the APIProvider will instantiate it's own socket connection. */
standalone?: boolean;
};

const APIProvider = ({ children, standalone = false }: PropsWithChildren<TProps>) => {
const APIProvider = ({ children, standalone = false }: PropsWithChildren<TAPIProviderProps>) => {
const WS = useWS();
// Use the new API instance if the `standalone` prop is set to true,
// else use the legacy socket connection.
const active_connection = standalone ? getDerivAPIInstance() : WS;
const active_connection = standalone ? initializeDerivWS() : WS;

useEffect(() => {
let interval_id: NodeJS.Timer;

if (standalone) {
interval_id = setInterval(() => active_connection.send({ ping: 1 }), 10000);
}

return () => clearInterval(interval_id);
}, [active_connection, standalone]);

return (
<APIContext.Provider value={active_connection}>
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/hooks/useWalletAccountsList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const useWalletAccountsList = () => {
/** Landing company shortcode the account belongs to. */
landing_company_name: wallet.landing_company_name?.replace('maltainvest', 'malta'),
/** Indicating whether the wallet is a maltainvest wallet. */
is_malta_wallet: wallet.landing_company_name === 'malta',
is_malta_wallet: wallet.landing_company_name === 'maltainvest',
/** The DTrade account ID of this wallet */
dtrade_loginid,
/** Returns if the wallet is a crypto wallet. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -887,9 +887,9 @@
}
}

.upload-layout{
@include desktop{
height: 100%;
.upload-layout {
@include desktop {
height: 100%;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.demo-account-card {
&__title {
&__type {
text-transform: capitalize;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ const DemoAccountCard = observer(() => {
className='demo-account-card'
icon='VIRTUAL'
title={
<Text className='demo-account-card__title' size='xs' line_height='s'>
{localize(selected_account_type)}
</Text>
<BalanceText
currency={platform_demo_account?.currency || default_currency}
balance={platform_demo_account?.balance || 0}
size='xs'
/>
}
actions={
canResetBalance() && (
Expand All @@ -41,11 +43,9 @@ const DemoAccountCard = observer(() => {
)
}
>
<BalanceText
currency={platform_demo_account?.currency || default_currency}
balance={platform_demo_account?.balance || 0}
size='xs'
/>
<Text className='demo-account-card__type' color='primary' size='xs' line_height='s'>
{localize(selected_account_type)}
</Text>
</CurrencySwitcherContainer>
);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { useHistory } from 'react-router';
import { Button, Text } from '@deriv/components';
import { formatMoney, getCurrencyName, routes } from '@deriv/shared';
import { getCurrencyName, routes } from '@deriv/shared';
import { Localize } from '@deriv/translations';
import BalanceText from 'Components/elements/text/balance-text';
import CurrencySwitcherContainer from 'Components/containers/currency-switcher-container';
Expand All @@ -26,16 +26,13 @@ const RealAccountCard = observer(() => {
.map(key => current_list[key])
.some(account => account.landing_company_short === 'maltainvest');

const get_currency = (IsIconCurrency(currency?.toUpperCase()) && currency) || 'USD';
const uppercase_currency = currency?.toUpperCase();
const get_currency = IsIconCurrency(uppercase_currency) ? uppercase_currency : 'USD';

return (
<CurrencySwitcherContainer
className='demo-account-card'
title={
<Text size='xs' line_height='s'>
{getCurrencyName(currency)}
</Text>
}
title={<BalanceText currency={get_currency} balance={Number(balance)} size='xs' />}
icon={get_currency}
onClick={() => {
if (!is_eu_user && !has_mf_mt5_account) {
Expand All @@ -57,7 +54,9 @@ const RealAccountCard = observer(() => {
}
has_interaction
>
<BalanceText currency={get_currency} balance={formatMoney(currency, balance, true)} size='xs' />
<Text color='primary' size='xs' line_height='s'>
{getCurrencyName(currency)}
</Text>
</CurrencySwitcherContainer>
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
}

@include mobile {
width: 90%;
margin-inline: 5%;
width: 90vw;
}

&-wrapper {
Expand Down Expand Up @@ -74,8 +73,15 @@
&__bordered,
&__bordered--with-margin {
@include mobile {
padding: 1.2rem;
padding: 3rem 3rem 15rem;
height: 48vh;
border: none;
overflow-y: scroll;
overflow-x: hidden;

@media (max-height: 680px) {
height: 38vh;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const StaticDashboard = observer(
const compare_accounts_title = eu_user ? localize('Account Information') : localize('Compare accounts');

return (
<ThemedScrollbars height={'calc(100% - 20rem)'} is_bypassed={isMobile()}>
<ThemedScrollbars height={'calc(100% - 25rem)'} is_bypassed={isMobile()}>
<div
data-testid='dt_onboarding_dashboard'
className={classNames('static-dashboard', {
Expand Down
11 changes: 9 additions & 2 deletions packages/appstore/src/modules/onboarding/onboarding.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
display: flex;
flex-direction: column;
gap: 3rem;
background-color: var(--general-hover);
background-color: var(--general-section-1);
height: inherit;

@include mobile {
Expand All @@ -28,7 +28,7 @@
.onboarding-body {
display: flex;
justify-content: center;
color: var(--general-main-1);
background-color: var(--general-section-1);
height: 100%;

@include mobile {
Expand All @@ -46,6 +46,13 @@
bottom: 0;
max-height: 20rem;

@include desktop {
display: flex;
flex-direction: column;
justify-content: end;
max-height: 18rem;
}

&-wrapper {
margin-top: 1rem;
}
Expand Down
18 changes: 6 additions & 12 deletions packages/bot-web-ui/src/components/quick-strategy/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,6 @@ const LABEL_DALEMBERT_UNIT: TConfigItem = {
description: localize("The amount that you may add to your stake if you're losing a trade."),
};

const LABEL_OSCARS_GRIND_UNIT: TConfigItem = {
type: 'label',
label: localize('Unit'),
description: localize('The amount that you may add to your stake after each successful trade.'),
};

const UNIT: TConfigItem = {
type: 'number',
name: 'unit',
Expand Down Expand Up @@ -173,25 +167,25 @@ export const STRATEGIES: TStrategies = {
],
},
D_ALEMBERT: {
name: 'dalembert',
name: 'dalembert_max-stake',
label: localize('D’Alembert'),
description: localize(
"The D'Alembert strategy increases the stake after a losing trade and reduces the stake after a successful trade by the number of units that traders decide. One unit is equal to the amount of the initial stake. To manage risk, set the maximum stake for a single trade. The stake for the next trade will reset to the initial stake if it exceeds the maximum stake."
),
fields: [
[SYMBOL, TRADETYPE_FULL_WIDTH, LABEL_STAKE, STAKE, DURATION_TYPE, DURATION],
[LABEL_PROFIT, PROFIT, LABEL_LOSS, LOSS, LABEL_DALEMBERT_UNIT, UNIT],
[SYMBOL, TRADETYPE, CONTRACT_TYPE, LABEL_STAKE, STAKE, DURATION_TYPE, DURATION],
[LABEL_PROFIT, PROFIT, LABEL_LOSS, LOSS, LABEL_DALEMBERT_UNIT, UNIT, CHECKBOX_MAX_STAKE, MAX_STAKE],
],
},
OSCARS_GRIND: {
name: 'oscars_grind',
name: 'oscars_grind_max-stake',
label: localize('Oscar’s Grind'),
description: localize(
"The Oscar's Grind strategy aims to potentially make one unit of profit per session. A new session starts when the target profit is reached. If a losing trade is followed by a successful one, the stake increases by one unit. In every other scenario, the stake for the next trade will be the same as the previous one. If the stake for the next trade exceeds the gap between the target profit and current loss of the session, it adjusts to the gap size. To manage risk, set the maximum stake for a single trade. The stake for the next trade will reset to the initial stake if it exceeds the maximum stake."
),
fields: [
[SYMBOL, TRADETYPE_FULL_WIDTH, LABEL_STAKE, STAKE, DURATION_TYPE, DURATION],
[LABEL_PROFIT, PROFIT, LABEL_LOSS, LOSS, LABEL_OSCARS_GRIND_UNIT, UNIT],
[SYMBOL, TRADETYPE, CONTRACT_TYPE, LABEL_STAKE, STAKE, DURATION_TYPE, DURATION],
[LABEL_PROFIT, PROFIT, LABEL_LOSS, LOSS, CHECKBOX_MAX_STAKE, MAX_STAKE],
],
},
};
Loading

0 comments on commit 231f0ef

Please sign in to comment.