Skip to content

Commit 0250eda

Browse files
committed
Merge branch 'TRAH_3476/amina_likhith/add_employment_status_and_tin_to_real_account_signup' into likhith/TRAH-4189/change-fa-employment-status-logic
2 parents 1c84365 + 8128bc3 commit 0250eda

File tree

150 files changed

+1634
-7461
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+1634
-7461
lines changed

packages/account/src/Containers/employment-tax-details-container/employment-tax-details-container.tsx

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from '../../Components/forms/form-fields';
88
import { isFieldImmutable } from '../../Helpers/utils';
99
import { Checkbox, useOnClickOutside } from '@deriv/components';
10-
import { useTranslations } from '@deriv-com/translations';
10+
import { Localize } from '@deriv-com/translations';
1111
import { getLegalEntityName } from '@deriv/shared';
1212
import { useDevice } from '@deriv-com/ui';
1313
import { useResidenceList } from '@deriv/hooks';
@@ -37,7 +37,6 @@ const EmploymentTaxDetailsContainer = observer(
3737
const { values, setFieldValue, touched, errors, setValues } = useFormikContext<FormikValues>();
3838
const { isDesktop } = useDevice();
3939
const { data: residence_list } = useResidenceList();
40-
const { localize } = useTranslations();
4140
const { client } = useStore();
4241

4342
const { is_virtual, account_settings } = client;
@@ -159,7 +158,7 @@ const EmploymentTaxDetailsContainer = observer(
159158
);
160159
}}
161160
value={values.tin_skipped}
162-
label={localize('I do not have tax information')}
161+
label={<Localize i18n_default_text='I do not have tax information' />}
163162
withTabIndex={0}
164163
data-testid='tin_skipped'
165164
label_font_size={!isDesktop ? 'xxs' : 'xs'}
@@ -203,14 +202,16 @@ const EmploymentTaxDetailsContainer = observer(
203202
}
204203
value={values.tax_identification_confirm}
205204
label={
206-
should_display_long_message
207-
? localize(
208-
'I hereby confirm that the tax information provided is true and complete. I will also inform {{legal_entity_name}} about any changes to this information.',
209-
{
210-
legal_entity_name: getLegalEntityName('maltainvest'),
211-
}
212-
)
213-
: localize('I confirm that my tax information is accurate and complete.')
205+
should_display_long_message ? (
206+
<Localize
207+
i18n_default_text='I hereby confirm that the tax information provided is true and complete. I will also inform {{legal_entity_name}} about any changes to this information.'
208+
values={{
209+
legal_entity_name: getLegalEntityName('maltainvest'),
210+
}}
211+
/>
212+
) : (
213+
<Localize i18n_default_text='I confirm that my tax information is accurate and complete.' />
214+
)
214215
}
215216
withTabIndex={0}
216217
data-testid='tax_identification_confirm'

packages/account/src/Helpers/utils.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export const isDocumentTypeValid = (document_type: FormikValues) => {
157157
export const isAdditionalDocumentValid = (document_type: FormikValues, additional_document_value?: string) => {
158158
const error_message = documentAdditionalError(additional_document_value, document_type?.additional);
159159
if (error_message) {
160-
return localize(error_message) + getExampleFormat(document_type?.additional?.example_format);
160+
return error_message + getExampleFormat(document_type?.additional?.example_format);
161161
}
162162
return undefined;
163163
};

packages/account/src/Sections/Profile/PersonalDetails/__tests__/personal-details-form.spec.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ describe('<PersonalDetailsForm />', () => {
4444
place_of_birth: 'Thailand',
4545
citizen: 'Thailand',
4646
email_consent: 1,
47-
last_name: 'Doe',
4847
},
4948
},
5049
});

packages/api-v2/src/AuthProvider.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ type AuthContextType = {
2424
name: T,
2525
payload?: TSocketRequestPayload<T>
2626
) => {
27-
subscribe: (
28-
onData: (response: any) => void,
29-
onError: (response: any) => void
30-
) => Promise<{ unsubscribe: () => Promise<void> }>;
27+
subscribe: (onData: (response: any) => void) => Promise<{ unsubscribe: () => Promise<void> }>;
3128
};
3229
};
3330

packages/api-v2/src/__tests__/useSubscription.spec.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jest.mock('../AuthProvider', () => ({
1212
return {
1313
subscribe() {
1414
return {
15-
subscribe: async (onData: (response: unknown) => void, onError: (response: unknown) => void) => {
15+
subscribe: async (onData: (response: unknown) => void) => {
1616
const delay = (ms: number) => new Promise<never>(resolve => setTimeout(resolve, ms));
1717
await delay(500);
1818
onData({ p2p_order_info: { status: 'pending' } });
@@ -21,8 +21,6 @@ jest.mock('../AuthProvider', () => ({
2121
await delay(500);
2222
onData({ p2p_order_info: { status: 'disputed' } });
2323
await delay(500);
24-
onError({ error: { code: 'Foo', message: 'Error message' } });
25-
await delay(500);
2624
onData({ p2p_order_info: { status: 'completed' } });
2725
return { unsubscribe: () => Promise.resolve() };
2826
},
@@ -58,8 +56,6 @@ describe('useSubscription', () => {
5856
await waitForNextUpdate();
5957
expect(result.current.data?.p2p_order_info).toStrictEqual({ status: 'disputed' });
6058
await waitForNextUpdate();
61-
expect(result.current.error).toStrictEqual({ code: 'Foo', message: 'Error message' });
62-
await waitForNextUpdate();
6359
expect(result.current.data?.p2p_order_info).toStrictEqual({ status: 'completed' });
6460
});
6561
});

packages/api-v2/src/useSubscription.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const useSubscription = <T extends TSocketSubscribableEndpointNames>(name: T, id
1212
const [isLoading, setIsLoading] = useState(false);
1313
const [isSubscribed, setSubscribed] = useState(false);
1414
const [isIdle, setIdle] = useState(false);
15-
const [error, setError] = useState<TSocketError<T>>();
15+
const [error, setError] = useState<TSocketError<T>['error']>();
1616
const [data, setData] = useState<TSocketResponseData<T>>();
1717
const subscriber = useRef<{ unsubscribe?: VoidFunction }>();
1818
const idle_timeout = useRef<NodeJS.Timeout>();
@@ -31,18 +31,12 @@ const useSubscription = <T extends TSocketSubscribableEndpointNames>(name: T, id
3131
}, idle_time);
3232

3333
try {
34-
subscriber.current = await _subscribe(name, payload).subscribe(
35-
response => {
36-
setData(response);
37-
setIsLoading(false);
38-
},
39-
response => {
40-
setError(response.error);
41-
setIsLoading(false);
42-
}
43-
);
34+
subscriber.current = await _subscribe(name, payload).subscribe(response => {
35+
setData(response);
36+
setIsLoading(false);
37+
});
4438
} catch (e) {
45-
setError(e as TSocketError<T>);
39+
setError((e as TSocketError<T>).error);
4640
}
4741
}, []);
4842

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { api_base } from '../services/api';
2+
import DBotStore from './dbot-store';
3+
4+
export const DEFAULT_PROPOSAL_REQUEST = {
5+
amount: undefined,
6+
basis: 'stake',
7+
contract_type: 'ACCU',
8+
currency: undefined,
9+
symbol: undefined,
10+
growth_rate: undefined,
11+
proposal: 1,
12+
subscribe: 1,
13+
};
14+
15+
export const forgetAccumulatorsProposalRequest = async instance => {
16+
if (instance && !instance.is_bot_running) {
17+
await api_base?.api?.send({ forget_all: 'proposal' });
18+
instance.subscription_id_for_accumulators = null;
19+
instance.is_proposal_requested_for_accumulators = false;
20+
window.Blockly.accumulators_request = {};
21+
}
22+
};
23+
24+
export const handleProposalRequestForAccumulators = instance => {
25+
const top_parent_block = instance?.getTopParent();
26+
const market_block = top_parent_block?.getChildByType('trade_definition_market');
27+
const symbol = market_block?.getFieldValue('SYMBOL_LIST');
28+
const currency = DBotStore.instance.client.currency;
29+
const growth_rate = instance?.getFieldValue('GROWTHRATE_LIST') || 0.01;
30+
const amount = instance?.childBlocks_?.[0]?.getField('NUM')?.getValue() || 0;
31+
const proposal_request = {
32+
...DEFAULT_PROPOSAL_REQUEST,
33+
amount,
34+
currency,
35+
symbol,
36+
growth_rate,
37+
};
38+
window.Blockly.accumulators_request = proposal_request;
39+
};

packages/bot-skeleton/src/scratch/blocks/Binary/Tick Analysis/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ import './check_direction';
88
import './tick_analysis';
99
import './last_digit';
1010
import './lastDigitList';
11+
import './stat';
12+
import './stat_list';
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { localize } from '@deriv/translations';
2+
import { modifyContextMenu } from '../../../utils';
3+
4+
Blockly.Blocks.stat = {
5+
init() {
6+
this.jsonInit(this.definition());
7+
},
8+
definition() {
9+
return {
10+
message0: localize('Current Stat'),
11+
output: 'Number',
12+
outputShape: Blockly.OUTPUT_SHAPE_ROUND,
13+
colour: Blockly.Colours.Base.colour,
14+
colourSecondary: Blockly.Colours.Base.colourSecondary,
15+
colourTertiary: Blockly.Colours.Base.colourTertiary,
16+
tooltip: localize('Returns the Current Stat'),
17+
category: Blockly.Categories.Tick_Analysis,
18+
};
19+
},
20+
meta() {
21+
return {
22+
display_name: localize('Current Stat'),
23+
description: localize('This block gives you the Current Stat value.'),
24+
};
25+
},
26+
customContextMenu(menu) {
27+
modifyContextMenu(menu);
28+
},
29+
};
30+
31+
Blockly.JavaScript.javascriptGenerator.forBlock.stat = () => [
32+
'Bot.getCurrentStat()',
33+
Blockly.JavaScript.javascriptGenerator.ORDER_ATOMIC,
34+
];
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { localize } from '@deriv/translations';
2+
import { modifyContextMenu } from '../../../utils';
3+
4+
Blockly.Blocks.stat_list = {
5+
init() {
6+
this.jsonInit(this.definition());
7+
},
8+
definition() {
9+
return {
10+
message0: localize('Current stat list'),
11+
output: 'Array',
12+
outputShape: Blockly.OUTPUT_SHAPE_ROUND,
13+
colour: Blockly.Colours.Base.colour,
14+
colourSecondary: Blockly.Colours.Base.colourSecondary,
15+
colourTertiary: Blockly.Colours.Base.colourTertiary,
16+
tooltip: localize('Returns the list of last digits of 1000 recent tick values'),
17+
category: Blockly.Categories.Tick_Analysis,
18+
};
19+
},
20+
meta() {
21+
return {
22+
display_name: localize('Current stat list'),
23+
description: localize('This block gives you a list of the cuurent stats of the last 1000 tick values.'),
24+
};
25+
},
26+
customContextMenu(menu) {
27+
modifyContextMenu(menu);
28+
},
29+
};
30+
31+
Blockly.JavaScript.javascriptGenerator.forBlock.stat_list = () => [
32+
'Bot.getStatList()',
33+
Blockly.JavaScript.javascriptGenerator.ORDER_ATOMIC,
34+
];

packages/bot-skeleton/src/scratch/blocks/Binary/Tools/Time/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ import './epoch';
22
import './timeout';
33
import './todatetime';
44
import './totimestamp';
5+
import './tickdelay';
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import { localize } from '@deriv/translations';
2+
import { modifyContextMenu, evaluateExpression } from '../../../../utils';
3+
import DBotStore from '../../../../dbot-store';
4+
5+
Blockly.Blocks.tick_delay = {
6+
init() {
7+
this.jsonInit(this.definition());
8+
const { client } = DBotStore.instance;
9+
if (client && client.is_logged_in) {
10+
this.workspace_to_code = Blockly.JavaScript.javascriptGenerator.workspaceToCode(Blockly.derivWorkspace);
11+
}
12+
},
13+
definition() {
14+
return {
15+
message0: localize('{{ stack_input }} Run after {{ number }} tick(s)', {
16+
stack_input: '%1',
17+
number: '%2',
18+
}),
19+
args0: [
20+
{
21+
type: 'input_statement',
22+
name: 'TICKDELAYSTACK',
23+
},
24+
{
25+
type: 'input_value',
26+
name: 'TICKDELAYVALUE',
27+
},
28+
],
29+
colour: Blockly.Colours.Base.colour,
30+
colourSecondary: Blockly.Colours.Base.colourSecondary,
31+
colourTertiary: Blockly.Colours.Base.colourTertiary,
32+
previousStatement: null,
33+
nextStatement: null,
34+
tooltip: localize('Run the blocks inside after a given number of ticks'),
35+
category: Blockly.Categories.Time,
36+
};
37+
},
38+
meta() {
39+
return {
40+
display_name: localize('Tick Delayed run'),
41+
description: localize(
42+
'This block delays execution for a given number of ticks. You can place any blocks within this block. The execution of other blocks in your strategy will be paused until the instructions in this block are carried out.'
43+
),
44+
};
45+
},
46+
customContextMenu(menu) {
47+
modifyContextMenu(menu);
48+
},
49+
getRequiredValueInputs() {
50+
return {
51+
TICKDELAYVALUE: input_value => {
52+
const evaluated_result = evaluateExpression(input_value);
53+
if (evaluated_result === 'invalid_input') {
54+
// this was done to check if any equation or varible assignment is present in the code.
55+
if (this.workspace_to_code && this.workspace_to_code.includes(input_value)) {
56+
return false;
57+
}
58+
this.error_message = localize('Invalid Input {{ input_value }}.', { input_value });
59+
return true;
60+
}
61+
62+
if (evaluated_result < 0) {
63+
this.error_message = localize('Values cannot be negative. Provided value: {{ input_value }}.', {
64+
input_value,
65+
});
66+
return true;
67+
}
68+
},
69+
};
70+
},
71+
};
72+
73+
Blockly.JavaScript.javascriptGenerator.forBlock.tick_delay = block => {
74+
const stack = Blockly.JavaScript.javascriptGenerator.statementToCode(block, 'TICKDELAYSTACK');
75+
const ticks_value =
76+
Blockly.JavaScript.javascriptGenerator.valueToCode(
77+
block,
78+
'TICKDELAYVALUE',
79+
Blockly.JavaScript.javascriptGenerator.ORDER_ATOMIC
80+
) || '1';
81+
82+
const code = `Bot.getDelayTickValue(${ticks_value})\n${stack}\n`;
83+
return code;
84+
};

packages/bot-skeleton/src/scratch/blocks/Binary/Trade Definition/trade_definition_accumulator.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import DBotStore from '../../../dbot-store';
44
import { modifyContextMenu, runGroupedEvents, runIrreversibleEvents } from '../../../utils';
55
import { config } from '../../../../constants/config';
66
import ApiHelpers from '../../../../services/api/api-helpers';
7+
import { handleProposalRequestForAccumulators } from '../../../accumulators-proposal-handler';
78

89
Blockly.Blocks.trade_definition_accumulator = {
910
init() {
@@ -101,7 +102,7 @@ Blockly.Blocks.trade_definition_accumulator = {
101102
if (!this.workspace || Blockly.derivWorkspace.isFlyoutVisible || this.workspace.isDragging()) {
102103
return;
103104
}
104-
105+
handleProposalRequestForAccumulators(this);
105106
const trade_definition_block = this.workspace
106107
.getAllBlocks(true)
107108
.find(block => block.type === 'trade_definition');

0 commit comments

Comments
 (0)