From 0144a45a9d2674b4933b9edcf886e7c9bd94fd2b Mon Sep 17 00:00:00 2001 From: Rupato Date: Tue, 3 Dec 2024 20:43:01 +0800 Subject: [PATCH 1/4] fix: currency for on trade definition block --- .../Binary/Trade Definition/trade_definition_tradeoptions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/external/bot-skeleton/scratch/blocks/Binary/Trade Definition/trade_definition_tradeoptions.js b/src/external/bot-skeleton/scratch/blocks/Binary/Trade Definition/trade_definition_tradeoptions.js index eef8abe4..f2fc9156 100755 --- a/src/external/bot-skeleton/scratch/blocks/Binary/Trade Definition/trade_definition_tradeoptions.js +++ b/src/external/bot-skeleton/scratch/blocks/Binary/Trade Definition/trade_definition_tradeoptions.js @@ -527,7 +527,7 @@ window.Blockly.Blocks.trade_definition_tradeoptions = { setCurrency() { const currency_field = this.getField('CURRENCY_LIST'); const { currency } = DBotStore.instance.client; - currency_field?.setText(getCurrencyDisplayCode(currency)); + currency_field.setValue(getCurrencyDisplayCode(currency)); }, restricted_parents: ['trade_definition'], getRequiredValueInputs() { From 844934e7fd414a1c07d483e31c1830e2e48a6374 Mon Sep 17 00:00:00 2001 From: Rupato Braganza Date: Mon, 9 Dec 2024 11:21:44 +0800 Subject: [PATCH 2/4] fix: for ternary operator --- .../Binary/Trade Definition/trade_definition_tradeoptions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/external/bot-skeleton/scratch/blocks/Binary/Trade Definition/trade_definition_tradeoptions.js b/src/external/bot-skeleton/scratch/blocks/Binary/Trade Definition/trade_definition_tradeoptions.js index f2fc9156..8f88f706 100755 --- a/src/external/bot-skeleton/scratch/blocks/Binary/Trade Definition/trade_definition_tradeoptions.js +++ b/src/external/bot-skeleton/scratch/blocks/Binary/Trade Definition/trade_definition_tradeoptions.js @@ -527,7 +527,7 @@ window.Blockly.Blocks.trade_definition_tradeoptions = { setCurrency() { const currency_field = this.getField('CURRENCY_LIST'); const { currency } = DBotStore.instance.client; - currency_field.setValue(getCurrencyDisplayCode(currency)); + currency_field?.setValue(getCurrencyDisplayCode(currency)); }, restricted_parents: ['trade_definition'], getRequiredValueInputs() { From c9f6f52e06c4fce0608da0caa3960372dd0237b4 Mon Sep 17 00:00:00 2001 From: Rupato Braganza Date: Thu, 12 Dec 2024 13:29:42 +0800 Subject: [PATCH 3/4] fix: added currency changes to take profit/loss blocks --- .../Binary/Trade Definition/accumulator_take_profit.js | 8 ++++---- .../Binary/Trade Definition/multiplier_stop_loss.js | 8 ++++---- .../Binary/Trade Definition/multiplier_take_profit.js | 8 ++++---- .../Trade Definition/trade_definition_accumulator.js | 7 +++---- .../Trade Definition/trade_definition_multiplier.js | 7 +++---- .../Trade Definition/trade_definition_tradeoptions.js | 9 ++------- src/external/bot-skeleton/scratch/utils/index.js | 7 +++++++ src/stores/app-store.ts | 5 +++-- 8 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/external/bot-skeleton/scratch/blocks/Binary/Trade Definition/accumulator_take_profit.js b/src/external/bot-skeleton/scratch/blocks/Binary/Trade Definition/accumulator_take_profit.js index 7c361ff2..4a0038e7 100644 --- a/src/external/bot-skeleton/scratch/blocks/Binary/Trade Definition/accumulator_take_profit.js +++ b/src/external/bot-skeleton/scratch/blocks/Binary/Trade Definition/accumulator_take_profit.js @@ -1,7 +1,7 @@ import { getCurrencyDisplayCode } from '@/components/shared'; import { localize } from '@deriv-com/translations'; import { config } from '../../../../constants/config'; -import { excludeOptionFromContextMenu, modifyContextMenu } from '../../../utils'; +import { excludeOptionFromContextMenu, modifyContextMenu, setCurrency } from '../../../utils'; const description = localize( 'Your contract is closed automatically when your profit is more than or equals to this amount. This block can only be used with the accumulator trade type.' @@ -50,9 +50,10 @@ window.Blockly.Blocks.accumulator_take_profit = { } if ( (event.type === window.Blockly.Events.BLOCK_CREATE && event.ids.includes(this.id)) || - (event.type === window.Blockly.Events.BLOCK_DRAG && !event.isStart) + (event.type === window.Blockly.Events.BLOCK_DRAG && !event.isStart) || + (event.type === window.Blockly.Events.BLOCK_CHANGE && !event.isStart) ) { - this.setCurrency(); + setCurrency(this); } }, customContextMenu(menu) { @@ -61,7 +62,6 @@ window.Blockly.Blocks.accumulator_take_profit = { modifyContextMenu(menu); }, restricted_parents: ['trade_definition_accumulator'], - setCurrency: window.Blockly.Blocks.trade_definition_tradeoptions.setCurrency, getRequiredValueInputs() { const field_input = this.getInput('AMOUNT'); if (field_input.connection.targetBlock()) { diff --git a/src/external/bot-skeleton/scratch/blocks/Binary/Trade Definition/multiplier_stop_loss.js b/src/external/bot-skeleton/scratch/blocks/Binary/Trade Definition/multiplier_stop_loss.js index 97f1180f..08c0c480 100644 --- a/src/external/bot-skeleton/scratch/blocks/Binary/Trade Definition/multiplier_stop_loss.js +++ b/src/external/bot-skeleton/scratch/blocks/Binary/Trade Definition/multiplier_stop_loss.js @@ -1,7 +1,7 @@ import { getCurrencyDisplayCode } from '@/components/shared'; import { localize } from '@deriv-com/translations'; import { config } from '../../../../constants/config'; -import { modifyContextMenu } from '../../../utils'; +import { modifyContextMenu, setCurrency } from '../../../utils'; const description = localize( 'Your contract is closed automatically when your loss is more than or equals to this amount. This block can only be used with the multipliers trade type.' @@ -53,13 +53,13 @@ window.Blockly.Blocks.multiplier_stop_loss = { } if ( (event.type === window.Blockly.Events.BLOCK_CREATE && event.ids.includes(this.id)) || - (event.type === window.Blockly.Events.BLOCK_DRAG && !event.isStart) + (event.type === window.Blockly.Events.BLOCK_DRAG && !event.isStart) || + (event.type === window.Blockly.Events.BLOCK_CHANGE && !event.isStart) ) { - this.setCurrency(); + setCurrency(this); } }, restricted_parents: ['trade_definition_multiplier'], - setCurrency: window.Blockly.Blocks.trade_definition_tradeoptions.setCurrency, getRequiredValueInputs() { const field_input = this.getInput('AMOUNT'); if (field_input.connection.targetBlock()) { diff --git a/src/external/bot-skeleton/scratch/blocks/Binary/Trade Definition/multiplier_take_profit.js b/src/external/bot-skeleton/scratch/blocks/Binary/Trade Definition/multiplier_take_profit.js index cf7badea..b458edc3 100644 --- a/src/external/bot-skeleton/scratch/blocks/Binary/Trade Definition/multiplier_take_profit.js +++ b/src/external/bot-skeleton/scratch/blocks/Binary/Trade Definition/multiplier_take_profit.js @@ -1,7 +1,7 @@ import { getCurrencyDisplayCode } from '@/components/shared'; import { localize } from '@deriv-com/translations'; import { config } from '../../../../constants/config'; -import { modifyContextMenu } from '../../../utils'; +import { modifyContextMenu, setCurrency } from '../../../utils'; const description = localize( 'Your contract is closed automatically when your profit is more than or equals to this amount. This block can only be used with the multipliers trade type.' @@ -53,13 +53,13 @@ window.Blockly.Blocks.multiplier_take_profit = { } if ( (event.type === window.Blockly.Events.BLOCK_CREATE && event.ids.includes(this.id)) || - (event.type === window.Blockly.Events.BLOCK_DRAG && !event.isStart) + (event.type === window.Blockly.Events.BLOCK_DRAG && !event.isStart) || + (event.type === window.Blockly.Events.BLOCK_CHANGE && !event.isStart) ) { - this.setCurrency(); + setCurrency(this); } }, restricted_parents: ['trade_definition_multiplier'], - setCurrency: window.Blockly.Blocks.trade_definition_tradeoptions.setCurrency, getRequiredValueInputs() { const field_input = this.getInput('AMOUNT'); if (field_input.connection.targetBlock()) { diff --git a/src/external/bot-skeleton/scratch/blocks/Binary/Trade Definition/trade_definition_accumulator.js b/src/external/bot-skeleton/scratch/blocks/Binary/Trade Definition/trade_definition_accumulator.js index d13cd498..6eab31f6 100644 --- a/src/external/bot-skeleton/scratch/blocks/Binary/Trade Definition/trade_definition_accumulator.js +++ b/src/external/bot-skeleton/scratch/blocks/Binary/Trade Definition/trade_definition_accumulator.js @@ -4,7 +4,7 @@ import { config } from '../../../../constants/config'; import ApiHelpers from '../../../../services/api/api-helpers'; import { handleProposalRequestForAccumulators } from '../../../accumulators-proposal-handler'; import DBotStore from '../../../dbot-store'; -import { modifyContextMenu, runGroupedEvents, runIrreversibleEvents } from '../../../utils'; +import { modifyContextMenu, runGroupedEvents, runIrreversibleEvents, setCurrency } from '../../../utils'; window.Blockly.Blocks.trade_definition_accumulator = { init() { @@ -127,7 +127,7 @@ window.Blockly.Blocks.trade_definition_accumulator = { const is_load_event = /^dbot-load/.test(event.group); if (event.type === window.Blockly.Events.BLOCK_CREATE && event.ids.includes(this.id)) { - this.setCurrency(); + setCurrency(this); if (is_load_event) { // Do NOT touch any values when a strategy is being loaded. this.updateAccumulatorInput(false); @@ -138,6 +138,7 @@ window.Blockly.Blocks.trade_definition_accumulator = { } if (event.type === window.Blockly.Events.BLOCK_CHANGE) { + setCurrency(this); this.validateBlocksInStatement(); if (is_load_event) { if (event.name === 'TRADETYPE_LIST') { @@ -159,7 +160,6 @@ window.Blockly.Blocks.trade_definition_accumulator = { } if (event.type === window.Blockly.Events.BLOCK_DRAG && !event.isStart) { - this.setCurrency(); this.validateBlocksInStatement(); if (event.blockId === this.id) { // Ensure this block is populated after initial drag from flyout. @@ -238,7 +238,6 @@ window.Blockly.Blocks.trade_definition_accumulator = { customContextMenu(menu) { modifyContextMenu(menu); }, - setCurrency: window.Blockly.Blocks.trade_definition_tradeoptions.setCurrency, restricted_parents: ['trade_definition'], getRequiredValueInputs() { return { diff --git a/src/external/bot-skeleton/scratch/blocks/Binary/Trade Definition/trade_definition_multiplier.js b/src/external/bot-skeleton/scratch/blocks/Binary/Trade Definition/trade_definition_multiplier.js index e673daa5..007dfe88 100644 --- a/src/external/bot-skeleton/scratch/blocks/Binary/Trade Definition/trade_definition_multiplier.js +++ b/src/external/bot-skeleton/scratch/blocks/Binary/Trade Definition/trade_definition_multiplier.js @@ -3,7 +3,7 @@ import { localize } from '@deriv-com/translations'; import { config } from '../../../../constants/config'; import ApiHelpers from '../../../../services/api/api-helpers'; import DBotStore from '../../../dbot-store'; -import { modifyContextMenu, runGroupedEvents, runIrreversibleEvents } from '../../../utils'; +import { modifyContextMenu, runGroupedEvents, runIrreversibleEvents, setCurrency } from '../../../utils'; window.Blockly.Blocks.trade_definition_multiplier = { init() { @@ -134,7 +134,7 @@ window.Blockly.Blocks.trade_definition_multiplier = { const is_load_event = /^dbot-load/.test(event.group); if (event.type === window.Blockly.Events.BLOCK_CREATE && event.ids.includes(this.id)) { - this.setCurrency(); + setCurrency(this); if (is_load_event) { // Do NOT touch any values when a strategy is being loaded. this.updateMultiplierInput(false); @@ -145,6 +145,7 @@ window.Blockly.Blocks.trade_definition_multiplier = { } if (event.type === window.Blockly.Events.BLOCK_CHANGE) { + setCurrency(this); this.validateBlocksInStatement(); if (is_load_event) { if (event.name === 'TRADETYPE_LIST') { @@ -166,7 +167,6 @@ window.Blockly.Blocks.trade_definition_multiplier = { } if (event.type === window.Blockly.Events.BLOCK_DRAG && !event.isStart) { - this.setCurrency(); this.validateBlocksInStatement(); if (event.blockId === this.id) { // Ensure this block is populated after initial drag from flyout. @@ -245,7 +245,6 @@ window.Blockly.Blocks.trade_definition_multiplier = { customContextMenu(menu) { modifyContextMenu(menu); }, - setCurrency: window.Blockly.Blocks.trade_definition_tradeoptions.setCurrency, restricted_parents: ['trade_definition'], getRequiredValueInputs() { return { diff --git a/src/external/bot-skeleton/scratch/blocks/Binary/Trade Definition/trade_definition_tradeoptions.js b/src/external/bot-skeleton/scratch/blocks/Binary/Trade Definition/trade_definition_tradeoptions.js index 8f88f706..d7680873 100755 --- a/src/external/bot-skeleton/scratch/blocks/Binary/Trade Definition/trade_definition_tradeoptions.js +++ b/src/external/bot-skeleton/scratch/blocks/Binary/Trade Definition/trade_definition_tradeoptions.js @@ -4,7 +4,7 @@ import { localize } from '@deriv-com/translations'; import { config } from '../../../../constants/config'; import ApiHelpers from '../../../../services/api/api-helpers'; import DBotStore from '../../../dbot-store'; -import { modifyContextMenu, runGroupedEvents, runIrreversibleEvents } from '../../../utils'; +import { modifyContextMenu, runGroupedEvents, runIrreversibleEvents, setCurrency } from '../../../utils'; window.Blockly.Blocks.trade_definition_tradeoptions = { durations: [], @@ -119,7 +119,7 @@ window.Blockly.Blocks.trade_definition_tradeoptions = { (event.type === window.Blockly.Events.BLOCK_CREATE && event.ids.includes(this.id)) || (event.type === window.Blockly.Events.BLOCK_DRAG && !event.isStart) ) { - this.setCurrency(); + setCurrency(this); this.updateAmountLimits(); } @@ -524,11 +524,6 @@ window.Blockly.Blocks.trade_definition_tradeoptions = { return container; }, - setCurrency() { - const currency_field = this.getField('CURRENCY_LIST'); - const { currency } = DBotStore.instance.client; - currency_field?.setValue(getCurrencyDisplayCode(currency)); - }, restricted_parents: ['trade_definition'], getRequiredValueInputs() { return { diff --git a/src/external/bot-skeleton/scratch/utils/index.js b/src/external/bot-skeleton/scratch/utils/index.js index 9d83f9c0..bc486194 100644 --- a/src/external/bot-skeleton/scratch/utils/index.js +++ b/src/external/bot-skeleton/scratch/utils/index.js @@ -1,5 +1,6 @@ import { botNotification } from '@/components/bot-notification/bot-notification'; import { notification_message } from '@/components/bot-notification/bot-notification-utils'; +import { getCurrencyDisplayCode } from '@/components/shared'; import { localize } from '@deriv-com/translations'; import { config } from '../../constants/config'; import { LogTypes } from '../../constants/messages'; @@ -751,3 +752,9 @@ export const appendCollapsedProcedureBlocksFields = instance => { remove_last_input(collapsed_input); } }; + +export const setCurrency = block_instance => { + const currency_field = block_instance.getField('CURRENCY_LIST'); + const { currency } = DBotStore.instance.client; + currency_field?.setValue(getCurrencyDisplayCode(currency)); +}; diff --git a/src/stores/app-store.ts b/src/stores/app-store.ts index a58f82c0..6e2e7f86 100644 --- a/src/stores/app-store.ts +++ b/src/stores/app-store.ts @@ -7,6 +7,7 @@ import { standalone_routes, } from '@/components/shared'; import { api_base, ApiHelpers, DBot, runIrreversibleEvents } from '@/external/bot-skeleton'; +import { setCurrency } from '@/external/bot-skeleton/scratch/utils'; import { TApiHelpersStore } from '@/types/stores.types'; import { localize } from '@deriv-com/translations'; import RootStore from './root-store'; @@ -224,7 +225,7 @@ export default class AppStore { // Syncs all trade options blocks' currency with the client's active currency. this.disposeCurrencyReaction = reaction( () => this.core.client.currency, - currency => { + () => { if (!window.Blockly?.derivWorkspace) return; const trade_options_blocks = window.Blockly?.derivWorkspace @@ -237,7 +238,7 @@ export default class AppStore { (b.isDescendantOf('trade_definition_multiplier') && b.category_ === 'trade_parameters') ); - trade_options_blocks.forEach(trade_options_block => trade_options_block.setCurrency(currency)); + trade_options_blocks.forEach(trade_options_block => setCurrency(trade_options_block)); } ); }; From 4ee7571234a512f275a3c7f69554b91d96d6a160 Mon Sep 17 00:00:00 2001 From: Rupato Braganza Date: Thu, 12 Dec 2024 13:48:14 +0800 Subject: [PATCH 4/4] fix: dalembert media name --- src/constants/quick-strategies/d_alembert.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constants/quick-strategies/d_alembert.ts b/src/constants/quick-strategies/d_alembert.ts index 610d7bda..6872d15e 100644 --- a/src/constants/quick-strategies/d_alembert.ts +++ b/src/constants/quick-strategies/d_alembert.ts @@ -64,7 +64,7 @@ export const D_ALEMBERT = (): TDescriptionItem[] => [ { type: 'media', src: getImageLocation('dalembert.svg'), - alt: localize("An example of D’Alembert's Grind strategy"), + alt: localize('An example of D’Alembert strategy'), }, { type: 'text',