From 22b6457137c08225b119f6b39e108dba7241dade Mon Sep 17 00:00:00 2001 From: amina-deriv Date: Fri, 6 Oct 2023 14:53:06 +0400 Subject: [PATCH 1/7] fix: test migration --- .../src/components/modals/modal-manager.tsx | 2 +- .../cfd/src/Containers/cfd-password-modal.tsx | 42 +++++- .../mt5-migration-modal.tsx | 4 +- .../cfd/src/Stores/Modules/CFD/cfd-store.js | 121 ++++++++++++++---- .../components/src/components/icon/icons.js | 1 + .../icon/mt5/ic-mt5-migration-success.svg | 1 + packages/components/stories/icon/icons.js | 37 +++--- .../hooks/src/useMT5SVGEligibleToMigrate.ts | 6 +- 8 files changed, 165 insertions(+), 49 deletions(-) create mode 100644 packages/components/src/components/icon/mt5/ic-mt5-migration-success.svg diff --git a/packages/appstore/src/components/modals/modal-manager.tsx b/packages/appstore/src/components/modals/modal-manager.tsx index 6aa6a8ab646e..bcee74ad5f3c 100644 --- a/packages/appstore/src/components/modals/modal-manager.tsx +++ b/packages/appstore/src/components/modals/modal-manager.tsx @@ -152,7 +152,7 @@ const ModalManager = () => { verification_code={trading_platform_dxtrade_password_reset || trading_platform_mt5_password_reset} /> - + {/* */} { + return ( + ]} + /> + ); + }; + const cfd_password_form = ( + {should_show_migration_success && ( + } + icon_size='xlarge' + text_submit={localize('OK')} + has_cancel={false} + has_close_icon={false} + width={isMobile() ? '32.8rem' : 'auto'} + is_medium_button={isMobile()} + /> + )} { const getModalHeight = () => { if (show_modal_front_side) { - return no_of_svg_accounts_to_migrate < 1 ? '54.2rem' : '44rem'; + return no_of_svg_accounts_to_migrate > 1 ? '54.2rem' : '44rem'; } else if (mt5_migration_error) { - return '66rem'; + return 'auto'; } return '61.6rem'; }; diff --git a/packages/cfd/src/Stores/Modules/CFD/cfd-store.js b/packages/cfd/src/Stores/Modules/CFD/cfd-store.js index 92e25cc31536..c93f8b7eea1b 100644 --- a/packages/cfd/src/Stores/Modules/CFD/cfd-store.js +++ b/packages/cfd/src/Stores/Modules/CFD/cfd-store.js @@ -89,6 +89,7 @@ export default class CFDStore extends BaseStore { disableCFDPasswordModal: action.bound, enableCFDPasswordModal: action.bound, getName: action.bound, + MigrateAccounts: action.bound, openMT5Account: action.bound, openCFDAccount: action.bound, beginRealSignupForMt5: action.bound, @@ -374,10 +375,54 @@ export default class CFDStore extends BaseStore { return first_name ? [first_name, title].join(' ') : title; } - openMT5Account(values) { + async MigrateMT5Account(values, actions) { + const account_to_migrate = this.root_store.client.mt5_login_list.filter( + acc => acc.landing_company_short === Jurisdiction.SVG && !!acc.eligible_to_migrate + ); + const promises = account_to_migrate.map(account => { + const { eligible_to_migrate } = account; + const [type, shortcode] = Object.entries(eligible_to_migrate)[0]; + const account_type = { + category: 'real', + type, + }; + return this.MigrateAccounts(values, shortcode, account_type); + }); + + try { + const results = await Promise.all(promises); + const has_error = results.find(result => result.error); + console.log(results); + + if (!has_error) { + actions.setStatus({ success: true }); + actions.setSubmitting(false); + this.setError(false); + this.setCFDSuccessDialog(true); + await this.getAccountStatus(CFD_PLATFORMS.MT5); + + const mt5_login_list_response = await WS.authorized.mt5LoginList(); + this.root_store.client.responseMt5LoginList(mt5_login_list_response); + + WS.transferBetweenAccounts(); // get the list of updated accounts for transfer in cashier1000001 + this.root_store.client.responseMT5TradingServers(await WS.tradingServers(CFD_PLATFORMS.MT5)); + // this.setCFDNewAccount(results.mt5_new_account); // need to check this + } else { + await this.getAccountStatus(CFD_PLATFORMS.MT5); + this.clearCFDError(); + this.setMT5MigrationError(has_error?.error?.message); + this.root_store.ui.toggleMT5MigrationModal(); + } + } catch (error) { + // At least one request has failed + console.error('One or more requests failed:', error); + } + } + + MigrateAccounts(values, shortcode, account_type) { const name = this.getName(); - const leverage = this.mt5_companies[this.account_type.category][this.account_type.type].leverage; - const type_request = getAccountTypeFields(this.account_type); + const leverage = this.mt5_companies[account_type.category][account_type.type].leverage; + const type_request = getAccountTypeFields(account_type); const { address_line_1, address_line_2, address_postcode, address_city, address_state, country_code, phone } = this.root_store.client.account_settings; @@ -392,10 +437,9 @@ export default class CFDStore extends BaseStore { phone, state: address_state, zipCode: address_postcode, - ...(this.account_type.type === 'all' ? { sub_account_category: 'swap_free' } : {}), ...(values.server ? { server: values.server } : {}), - ...(this.jurisdiction_selected_shortcode ? { company: this.jurisdiction_selected_shortcode } : {}), - ...(this.jurisdiction_selected_shortcode !== Jurisdiction.LABUAN + ...(shortcode ? { company: shortcode } : {}), + ...(shortcode !== Jurisdiction.LABUAN ? type_request : { account_type: 'financial', @@ -508,6 +552,36 @@ export default class CFDStore extends BaseStore { return false; } + openMT5Account(values) { + const name = this.getName(); + const leverage = this.mt5_companies[this.account_type.category][this.account_type.type].leverage; + const type_request = getAccountTypeFields(this.account_type); + const { address_line_1, address_line_2, address_postcode, address_city, address_state, country_code, phone } = + this.root_store.client.account_settings; + + return WS.mt5NewAccount({ + mainPassword: values.password, + email: this.root_store.client.email_address, + leverage, + name, + address: address_line_1 || address_line_2, + city: address_city, + country: country_code, + phone, + state: address_state, + zipCode: address_postcode, + ...(this.account_type.type === 'all' ? { sub_account_category: 'swap_free' } : {}), + ...(values.server ? { server: values.server } : {}), + ...(this.jurisdiction_selected_shortcode ? { company: this.jurisdiction_selected_shortcode } : {}), + ...(this.jurisdiction_selected_shortcode !== Jurisdiction.LABUAN + ? type_request + : { + account_type: 'financial', + mt5_account_type: 'financial_stp', + }), + }); + } + async submitMt5Password(values, actions) { if (this.root_store.client.is_mt5_password_not_set) { const has_error = await this.creatMT5Password(values, actions); @@ -515,28 +589,25 @@ export default class CFDStore extends BaseStore { } this.resetFormErrors(); - const response = await this.openMT5Account(values); - if (!response.error) { - actions.setStatus({ success: true }); - actions.setSubmitting(false); - this.setError(false); - this.setCFDSuccessDialog(true); - await this.getAccountStatus(CFD_PLATFORMS.MT5); - - const mt5_login_list_response = await WS.authorized.mt5LoginList(); - this.root_store.client.responseMt5LoginList(mt5_login_list_response); - - WS.transferBetweenAccounts(); // get the list of updated accounts for transfer in cashier - this.root_store.client.responseMT5TradingServers(await WS.tradingServers(CFD_PLATFORMS.MT5)); - this.setCFDNewAccount(response.mt5_new_account); + if (this.root_store.ui.is_mt5_migration_modal_enabled) { + await this.MigrateMT5Account(values, actions); } else { - await this.getAccountStatus(CFD_PLATFORMS.MT5); + const response = await this.openMT5Account(values); + if (!response.error) { + actions.setStatus({ success: true }); + actions.setSubmitting(false); + this.setError(false); + this.setCFDSuccessDialog(true); + await this.getAccountStatus(CFD_PLATFORMS.MT5); - if (this.root_store.ui.is_mt5_migration_modal_enabled) { - this.clearCFDError(); - this.setMT5MigrationError(response?.error?.message); - this.root_store.ui.toggleMT5MigrationModal(); + const mt5_login_list_response = await WS.authorized.mt5LoginList(); + this.root_store.client.responseMt5LoginList(mt5_login_list_response); + + WS.transferBetweenAccounts(); // get the list of updated accounts for transfer in cashier + this.root_store.client.responseMT5TradingServers(await WS.tradingServers(CFD_PLATFORMS.MT5)); + this.setCFDNewAccount(response.mt5_new_account); } else { + await this.getAccountStatus(CFD_PLATFORMS.MT5); this.setError(true, response.error); actions.resetForm({}); actions.setSubmitting(false); diff --git a/packages/components/src/components/icon/icons.js b/packages/components/src/components/icon/icons.js index 6819299082b8..4ef484effe9c 100644 --- a/packages/components/src/components/icon/icons.js +++ b/packages/components/src/components/icon/icons.js @@ -699,6 +699,7 @@ import './mt5/ic-mt5-high-leverage.svg'; import './mt5/ic-mt5-liquid-risk.svg'; import './mt5/ic-mt5-logo.svg'; import './mt5/ic-mt5-margin-trading.svg'; +import './mt5/ic-mt5-migration-success.svg'; import './mt5/ic-mt5-one-password.svg'; import './mt5/ic-mt5-open-markets.svg'; import './mt5/ic-mt5-password-updated.svg'; diff --git a/packages/components/src/components/icon/mt5/ic-mt5-migration-success.svg b/packages/components/src/components/icon/mt5/ic-mt5-migration-success.svg new file mode 100644 index 000000000000..bd8b24ffb135 --- /dev/null +++ b/packages/components/src/components/icon/mt5/ic-mt5-migration-success.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/packages/components/stories/icon/icons.js b/packages/components/stories/icon/icons.js index 3205cd39dc8d..725b829de83a 100644 --- a/packages/components/stories/icon/icons.js +++ b/packages/components/stories/icon/icons.js @@ -54,7 +54,7 @@ export const icons = 'IcAppstoreWalletUsdLight', 'IcAppstoreWalletUsdcLight', 'IcAppstoreWalletUsdtLight', - 'IcAppstoreWarning', + 'IcAppstoreWarning' ], 'brand': [ 'IcBrandCtraderWordmark', @@ -66,7 +66,7 @@ export const icons = 'IcBrandDmt5FinancialStp', 'IcBrandDmt5Financial', 'IcBrandDmt5Synthetics', - 'IcBrandDxtradeWordmark', + 'IcBrandDxtradeWordmark' ], 'cashier': [ 'IcCashierAdd', @@ -241,7 +241,7 @@ export const icons = 'IcCashierWyreLight', 'IcCashierZenithbankDark', 'IcCashierZenithbankLight', - 'IcCashier', + 'IcCashier' ], 'common': [ 'IcAccountCross', @@ -620,7 +620,7 @@ export const icons = 'IcWip', 'IcZingpay', 'IcZoomIn', - 'IcZoomOut', + 'IcZoomOut' ], 'contract': [ 'IcContractBarrier', @@ -638,7 +638,7 @@ export const icons = 'IcContractStartTimeCircle', 'IcContractStartTime', 'IcContractStrike', - 'IcContractTarget', + 'IcContractTarget' ], 'currency': [ 'IcCurrencyAud', @@ -662,10 +662,10 @@ export const icons = 'IcCurrencyUsdc', 'IcCurrencyUsdk', 'IcCurrencyUst', - 'IcCurrencyVirtual', + 'IcCurrencyVirtual' ], 'derivez': [ - 'IcDerivez', + 'IcDerivez' ], 'dxtrade': [ 'IcDxtradeDerivX', @@ -682,7 +682,7 @@ export const icons = 'IcDxtradeFinancialPlatform', 'IcDxtradeFinancial', 'IcDxtradeOnePassword', - 'IcDxtradeSyntheticPlatform', + 'IcDxtradeSyntheticPlatform' ], 'flag': [ 'IcFlagDe', @@ -699,7 +699,7 @@ export const icons = 'IcFlagUk', 'IcFlagVi', 'IcFlagZhCn', - 'IcFlagZhTw', + 'IcFlagZhTw' ], 'mt5': [ 'IcMt5BviDerived', @@ -720,6 +720,7 @@ export const icons = 'IcMt5LiquidRisk', 'IcMt5Logo', 'IcMt5MarginTrading', + 'IcMt5MigrationSuccess', 'IcMt5OnePassword', 'IcMt5OpenMarkets', 'IcMt5PasswordUpdated', @@ -733,7 +734,7 @@ export const icons = 'IcMt5SyntheticPlatform', 'IcMt5TradeTypes', 'IcMt5VanuatuDerived', - 'IcMt5VanuatuFinancial', + 'IcMt5VanuatuFinancial' ], 'option': [ 'IcOptionAccumulators', @@ -751,7 +752,7 @@ export const icons = 'IcOptionOverUnder', 'IcOptionRaiseFall', 'IcOptionTouchNotouch', - 'IcOptionUpDownAsian', + 'IcOptionUpDownAsian' ], 'rebranding': [ 'IcRebrandingBinaryBot', @@ -773,7 +774,7 @@ export const icons = 'IcRebrandingDxtrade', 'IcRebrandingMt5Logo', 'IcRebrandingSmarttraderDashboard', - 'IcRebrandingSmarttrader', + 'IcRebrandingSmarttrader' ], 'stock': [ 'IcStockAdidasSalomon', @@ -823,7 +824,7 @@ export const icons = 'IcStockVisa', 'IcStockWallMart', 'IcStockWaltDisney', - 'IcStockZoom', + 'IcStockZoom' ], 'tradetype': [ 'IcTradetypeAccu', @@ -862,7 +863,7 @@ export const icons = 'IcTradetypeTurbosshort', 'IcTradetypeUpordown', 'IcTradetypeVanillaLongCall', - 'IcTradetypeVanillaLongPut', + 'IcTradetypeVanillaLongPut' ], 'underlying': [ 'IcUnderlying1HZ100V', @@ -1021,7 +1022,7 @@ export const icons = 'IcUnderlyingWLDEUR', 'IcUnderlyingWLDGBP', 'IcUnderlyingWLDUSD', - 'IcUnderlyingWLDXAU', + 'IcUnderlyingWLDXAU' ], 'wallet': [ 'IcWalletClearFunds', @@ -1057,6 +1058,6 @@ export const icons = 'IcWalletWebmoneyLight', 'IcWalletWebmoney', 'IcWalletZingpayDark', - 'IcWalletZingpayLight', - ], -} + 'IcWalletZingpayLight' + ] +} \ No newline at end of file diff --git a/packages/hooks/src/useMT5SVGEligibleToMigrate.ts b/packages/hooks/src/useMT5SVGEligibleToMigrate.ts index 4a2d9c18271f..dca2669886a6 100644 --- a/packages/hooks/src/useMT5SVGEligibleToMigrate.ts +++ b/packages/hooks/src/useMT5SVGEligibleToMigrate.ts @@ -1,9 +1,11 @@ import React from 'react'; -import { useMT5AccountsList } from '@deriv/api'; +// import { useMT5AccountsList } from '@deriv/api'; +import { useStore } from '@deriv/stores'; import { Jurisdiction, getFormattedJurisdictionCode } from '@deriv/shared'; const useMT5SVGEligibleToMigrate = () => { - const { data: mt5_login_list = [] } = useMT5AccountsList(); + const { client } = useStore(); + const { mt5_login_list } = client; const mt5_migration_config = React.useMemo(() => { const svg_accounts_to_migrate = mt5_login_list.filter( From 8388f55ff1044837df1e8c514f9c02149eac0514 Mon Sep 17 00:00:00 2001 From: amina-deriv Date: Wed, 11 Oct 2023 18:58:04 +0400 Subject: [PATCH 2/7] fix: migration --- .../src/components/modals/modal-manager.tsx | 2 +- .../cfd/src/Containers/cfd-password-modal.tsx | 30 ++++++++-- .../cfd/src/Stores/Modules/CFD/cfd-store.js | 15 +++-- packages/cfd/src/types/cfd-store.types.ts | 1 + packages/components/stories/icon/icons.js | 55 +++++++------------ packages/stores/src/mockStore.ts | 1 + 6 files changed, 59 insertions(+), 45 deletions(-) diff --git a/packages/appstore/src/components/modals/modal-manager.tsx b/packages/appstore/src/components/modals/modal-manager.tsx index e7f633524400..ab02d477e548 100644 --- a/packages/appstore/src/components/modals/modal-manager.tsx +++ b/packages/appstore/src/components/modals/modal-manager.tsx @@ -158,7 +158,7 @@ const ModalManager = () => { verification_code={trading_platform_dxtrade_password_reset || trading_platform_mt5_password_reset} /> - {/* */} + { + // { + // "financial": "vanuatu" + // }, + // { + // "synthetic": "vanuatu" + // } + // ] + + const list = migrate_mt5_accounts.map(account => { + const [to_account_type] = Object.keys(account); + + const [to_accounts] = Object.values(account); + const to_account_type_label = to_account_type === 'synthetic' ? 'derived' : to_account_type; + + return `${getCFDPlatformNames(CFD_PLATFORMS.MT5)} ${getFormattedJurisdictionMarketTypes( + to_account_type_label + )} ${getFormattedJurisdictionCode(to_accounts)}`; + }); + return ( Object.values(account))[0] + ), + migrated_accounts: list.join(' and '), // [MT5 Derived Vanuatu and MT5 Financial Vanuatu] }} components={[]} /> diff --git a/packages/cfd/src/Stores/Modules/CFD/cfd-store.js b/packages/cfd/src/Stores/Modules/CFD/cfd-store.js index b30448628d43..0c58d39d3288 100644 --- a/packages/cfd/src/Stores/Modules/CFD/cfd-store.js +++ b/packages/cfd/src/Stores/Modules/CFD/cfd-store.js @@ -49,6 +49,8 @@ export default class CFDStore extends BaseStore { real_financial_accounts_existing_data = []; real_swapfree_accounts_existing_data = []; + migrate_mt5_accounts = []; + constructor({ root_store }) { super({ root_store }); @@ -75,6 +77,7 @@ export default class CFDStore extends BaseStore { dxtrade_tokens: observable, ctrader_tokens: observable, derivez_tokens: observable, + migrate_mt5_accounts: observable, account_title: computed, current_list: computed, has_created_account_for_selected_jurisdiction: computed, @@ -89,7 +92,7 @@ export default class CFDStore extends BaseStore { disableCFDPasswordModal: action.bound, enableCFDPasswordModal: action.bound, getName: action.bound, - MigrateAccounts: action.bound, + MigrateMT5Accounts: action.bound, openMT5Account: action.bound, openCFDAccount: action.bound, beginRealSignupForMt5: action.bound, @@ -375,7 +378,7 @@ export default class CFDStore extends BaseStore { return first_name ? [first_name, title].join(' ') : title; } - async MigrateMT5Account(values, actions) { + async MigrateMT5Accounts(values, actions) { const account_to_migrate = this.root_store.client.mt5_login_list.filter( acc => acc.landing_company_short === Jurisdiction.SVG && !!acc.eligible_to_migrate ); @@ -386,12 +389,14 @@ export default class CFDStore extends BaseStore { category: 'real', type, }; - return this.MigrateAccounts(values, shortcode, account_type); + this.migrate_mt5_accounts = [...this.migrate_mt5_accounts, { ...eligible_to_migrate }]; + return this.MigrateAccount(values, shortcode, account_type); }); try { const results = await Promise.all(promises); const has_error = results.find(result => result.error); + if (!has_error) { actions.setStatus({ success: true }); actions.setSubmitting(false); @@ -418,7 +423,7 @@ export default class CFDStore extends BaseStore { } } - MigrateAccounts(values, shortcode, account_type) { + MigrateAccount(values, shortcode, account_type) { const name = this.getName(); const leverage = this.mt5_companies[account_type.category][account_type.type].leverage; const type_request = getAccountTypeFields(account_type); @@ -589,7 +594,7 @@ export default class CFDStore extends BaseStore { this.resetFormErrors(); if (this.root_store.ui.is_mt5_migration_modal_enabled) { - await this.MigrateMT5Account(values, actions); + await this.MigrateMT5Accounts(values, actions); } else { const response = await this.openMT5Account(values); if (!response.error) { diff --git a/packages/cfd/src/types/cfd-store.types.ts b/packages/cfd/src/types/cfd-store.types.ts index ac950eb54b2c..1aa22e64cb95 100644 --- a/packages/cfd/src/types/cfd-store.types.ts +++ b/packages/cfd/src/types/cfd-store.types.ts @@ -51,6 +51,7 @@ export type TCFDStore = { }; sendVerifyEmail: () => Promise; account_title: string; + migrate_mt5_accounts: Record[]; disableCFDPasswordModal: () => void; error_message: string; error_type?: string; diff --git a/packages/components/stories/icon/icons.js b/packages/components/stories/icon/icons.js index effa857fe4fd..3ee963b22c78 100644 --- a/packages/components/stories/icon/icons.js +++ b/packages/components/stories/icon/icons.js @@ -56,9 +56,8 @@ export const icons = 'IcAppstoreWalletUsdLight', 'IcAppstoreWalletUsdcLight', 'IcAppstoreWalletUsdtLight', - 'IcAppstoreWarning', 'IcAppstoreWalletsLink', - 'IcAppstoreWarning', + 'IcAppstoreWarning' ], 'brand': [ 'IcBrandCtraderWordmark', @@ -70,7 +69,7 @@ export const icons = 'IcBrandDmt5FinancialStp', 'IcBrandDmt5Financial', 'IcBrandDmt5Synthetics', - 'IcBrandDxtradeWordmark', + 'IcBrandDxtradeWordmark' ], 'cashier': [ 'IcCashierAdd', @@ -247,7 +246,7 @@ export const icons = 'IcCashierWyreLight', 'IcCashierZenithbankDark', 'IcCashierZenithbankLight', - 'IcCashier', + 'IcCashier' ], 'common': [ 'IcAccountCross', @@ -630,7 +629,7 @@ export const icons = 'IcWithdrawRequestVerification', 'IcZingpay', 'IcZoomIn', - 'IcZoomOut', + 'IcZoomOut' ], 'contract': [ 'IcContractBarrier', @@ -648,7 +647,7 @@ export const icons = 'IcContractStartTimeCircle', 'IcContractStartTime', 'IcContractStrike', - 'IcContractTarget', + 'IcContractTarget' ], 'currency': [ 'IcCurrencyAud', @@ -672,10 +671,10 @@ export const icons = 'IcCurrencyUsdc', 'IcCurrencyUsdk', 'IcCurrencyUst', - 'IcCurrencyVirtual', + 'IcCurrencyVirtual' ], 'derivez': [ - 'IcDerivez', + 'IcDerivez' ], 'dxtrade': [ 'IcDxtradeDerivX', @@ -692,7 +691,7 @@ export const icons = 'IcDxtradeFinancialPlatform', 'IcDxtradeFinancial', 'IcDxtradeOnePassword', - 'IcDxtradeSyntheticPlatform', + 'IcDxtradeSyntheticPlatform' ], 'flag': [ 'IcFlagDe', @@ -709,7 +708,7 @@ export const icons = 'IcFlagUk', 'IcFlagVi', 'IcFlagZhCn', - 'IcFlagZhTw', + 'IcFlagZhTw' ], 'mt5': [ 'IcMt5BviDerived', @@ -739,12 +738,14 @@ export const icons = 'IcMt5SvgDerived', 'IcMt5SvgFinancial', 'IcMt5SwapFreePlatform', + 'IcMt5SwapFree', 'IcMt5SyntheticDashboard', 'IcMt5SyntheticIndices', 'IcMt5SyntheticPlatform', + 'IcMt5Synthetic', 'IcMt5TradeTypes', 'IcMt5VanuatuDerived', - 'IcMt5VanuatuFinancial', + 'IcMt5VanuatuFinancial' ], 'option': [ 'IcOptionAccumulators', @@ -762,7 +763,7 @@ export const icons = 'IcOptionOverUnder', 'IcOptionRaiseFall', 'IcOptionTouchNotouch', - 'IcOptionUpDownAsian', + 'IcOptionUpDownAsian' ], 'rebranding': [ 'IcRebrandingBinaryBot', @@ -788,7 +789,7 @@ export const icons = 'IcRebrandingMt5Logo', 'IcRebrandingMt5SwapFree', 'IcRebrandingSmarttraderDashboard', - 'IcRebrandingSmarttrader', + 'IcRebrandingSmarttrader' ], 'stock': [ 'IcStockAdidasSalomon', @@ -838,7 +839,7 @@ export const icons = 'IcStockVisa', 'IcStockWallMart', 'IcStockWaltDisney', - 'IcStockZoom', + 'IcStockZoom' ], 'tradetype': [ 'IcTradetypeAccu', @@ -877,7 +878,7 @@ export const icons = 'IcTradetypeTurbosshort', 'IcTradetypeUpordown', 'IcTradetypeVanillaLongCall', - 'IcTradetypeVanillaLongPut', + 'IcTradetypeVanillaLongPut' ], 'underlying': [ 'IcUnderlying1HZ100V', @@ -1036,7 +1037,7 @@ export const icons = 'IcUnderlyingWLDEUR', 'IcUnderlyingWLDGBP', 'IcUnderlyingWLDUSD', - 'IcUnderlyingWLDXAU', + 'IcUnderlyingWLDXAU' ], 'wallet': [ 'IcWalletBitcoinDark', @@ -1063,24 +1064,10 @@ export const icons = 'IcWalletOptionsLight', 'IcWalletPaymentAgentDark', 'IcWalletPaymentAgentLight', - 'IcWalletPaytrustDark', - 'IcWalletPaytrustLight', - 'IcWalletPlatforms', - 'IcWalletSkrillDark', - 'IcWalletSkrillLight', - 'IcWalletSticpayDark', - 'IcWalletSticpayLight', - 'IcWalletSticpay', - 'IcWalletTradeTypes', - 'IcWalletTransactionsEmpty', - 'IcWalletWallets', - 'IcWalletWebmoneyLight', - 'IcWalletWebmoney', - 'IcWalletZingpayDark', - 'IcWalletZingpayLight', + 'IcWalletSuccessMessage', 'IcWalletTetherDark', 'IcWalletTetherLight', 'IcWalletUsdCoinDark', - 'IcWalletUsdCoinLight', - ], -} + 'IcWalletUsdCoinLight' + ] +} \ No newline at end of file diff --git a/packages/stores/src/mockStore.ts b/packages/stores/src/mockStore.ts index 90b5336b720a..26e564e323ce 100644 --- a/packages/stores/src/mockStore.ts +++ b/packages/stores/src/mockStore.ts @@ -554,6 +554,7 @@ const mock = (): TStores & { is_mock: boolean } => { modules: { cfd: { setMT5MigrationError: jest.fn(), + migrate_mt5_accounts: [], }, }, exchange_rates: { From 5565fb7c57ceeefe850465defc3920fefd650e64 Mon Sep 17 00:00:00 2001 From: amina-deriv Date: Fri, 13 Oct 2023 13:58:06 +0400 Subject: [PATCH 3/7] fix: unrelated_file_changes --- packages/bot-skeleton/src/scratch/dbot.js | 2 +- .../cfd/src/Stores/Modules/CFD/cfd-store.js | 1 + packages/components/stories/icon/icons.js | 39 +++++++++---------- .../account-signup-modal.jsx | 2 +- .../password-selection-modal.jsx | 2 +- .../RealAccountSignup/real-account-signup.jsx | 4 +- packages/core/src/Stores/base-store.js | 2 +- .../p2p/src/pages/buy-sell/buy-sell-row.jsx | 2 +- packages/p2p/src/stores/general-store.js | 4 +- packages/reports/src/Stores/base-store.js | 2 +- .../TradeParams/Multiplier/cancel-deal.jsx | 2 +- 11 files changed, 30 insertions(+), 32 deletions(-) diff --git a/packages/bot-skeleton/src/scratch/dbot.js b/packages/bot-skeleton/src/scratch/dbot.js index 822d93b96827..312aef9128ef 100644 --- a/packages/bot-skeleton/src/scratch/dbot.js +++ b/packages/bot-skeleton/src/scratch/dbot.js @@ -3,7 +3,7 @@ import { config } from '../constants/config'; import { api_base } from '../services/api/api-base'; import ApiHelpers from '../services/api/api-helpers'; import Interpreter from '../services/tradeEngine/utils/interpreter'; -import { compareXml, observer as globalObserver } from '../utils'; +import { compareXml,observer as globalObserver } from '../utils'; import { getSavedWorkspaces, saveWorkspaceToRecent } from '../utils/local-storage'; import main_xml from './xml/main.xml'; diff --git a/packages/cfd/src/Stores/Modules/CFD/cfd-store.js b/packages/cfd/src/Stores/Modules/CFD/cfd-store.js index 0c58d39d3288..e2e98650216b 100644 --- a/packages/cfd/src/Stores/Modules/CFD/cfd-store.js +++ b/packages/cfd/src/Stores/Modules/CFD/cfd-store.js @@ -441,6 +441,7 @@ export default class CFDStore extends BaseStore { phone, state: address_state, zipCode: address_postcode, + migrate: 1, ...(values.server ? { server: values.server } : {}), ...(shortcode ? { company: shortcode } : {}), ...(shortcode !== Jurisdiction.LABUAN diff --git a/packages/components/stories/icon/icons.js b/packages/components/stories/icon/icons.js index 3ee963b22c78..d9febc29e5fb 100644 --- a/packages/components/stories/icon/icons.js +++ b/packages/components/stories/icon/icons.js @@ -57,7 +57,7 @@ export const icons = 'IcAppstoreWalletUsdcLight', 'IcAppstoreWalletUsdtLight', 'IcAppstoreWalletsLink', - 'IcAppstoreWarning' + 'IcAppstoreWarning', ], 'brand': [ 'IcBrandCtraderWordmark', @@ -69,7 +69,7 @@ export const icons = 'IcBrandDmt5FinancialStp', 'IcBrandDmt5Financial', 'IcBrandDmt5Synthetics', - 'IcBrandDxtradeWordmark' + 'IcBrandDxtradeWordmark', ], 'cashier': [ 'IcCashierAdd', @@ -246,7 +246,7 @@ export const icons = 'IcCashierWyreLight', 'IcCashierZenithbankDark', 'IcCashierZenithbankLight', - 'IcCashier' + 'IcCashier', ], 'common': [ 'IcAccountCross', @@ -629,7 +629,7 @@ export const icons = 'IcWithdrawRequestVerification', 'IcZingpay', 'IcZoomIn', - 'IcZoomOut' + 'IcZoomOut', ], 'contract': [ 'IcContractBarrier', @@ -647,7 +647,7 @@ export const icons = 'IcContractStartTimeCircle', 'IcContractStartTime', 'IcContractStrike', - 'IcContractTarget' + 'IcContractTarget', ], 'currency': [ 'IcCurrencyAud', @@ -671,10 +671,10 @@ export const icons = 'IcCurrencyUsdc', 'IcCurrencyUsdk', 'IcCurrencyUst', - 'IcCurrencyVirtual' + 'IcCurrencyVirtual', ], 'derivez': [ - 'IcDerivez' + 'IcDerivez', ], 'dxtrade': [ 'IcDxtradeDerivX', @@ -691,7 +691,7 @@ export const icons = 'IcDxtradeFinancialPlatform', 'IcDxtradeFinancial', 'IcDxtradeOnePassword', - 'IcDxtradeSyntheticPlatform' + 'IcDxtradeSyntheticPlatform', ], 'flag': [ 'IcFlagDe', @@ -708,7 +708,7 @@ export const icons = 'IcFlagUk', 'IcFlagVi', 'IcFlagZhCn', - 'IcFlagZhTw' + 'IcFlagZhTw', ], 'mt5': [ 'IcMt5BviDerived', @@ -729,7 +729,6 @@ export const icons = 'IcMt5LiquidRisk', 'IcMt5Logo', 'IcMt5MarginTrading', - 'IcMt5MigrationSuccess', 'IcMt5OnePassword', 'IcMt5OpenMarkets', 'IcMt5PasswordUpdated', @@ -738,14 +737,12 @@ export const icons = 'IcMt5SvgDerived', 'IcMt5SvgFinancial', 'IcMt5SwapFreePlatform', - 'IcMt5SwapFree', 'IcMt5SyntheticDashboard', 'IcMt5SyntheticIndices', 'IcMt5SyntheticPlatform', - 'IcMt5Synthetic', 'IcMt5TradeTypes', 'IcMt5VanuatuDerived', - 'IcMt5VanuatuFinancial' + 'IcMt5VanuatuFinancial', ], 'option': [ 'IcOptionAccumulators', @@ -763,7 +760,7 @@ export const icons = 'IcOptionOverUnder', 'IcOptionRaiseFall', 'IcOptionTouchNotouch', - 'IcOptionUpDownAsian' + 'IcOptionUpDownAsian', ], 'rebranding': [ 'IcRebrandingBinaryBot', @@ -789,7 +786,7 @@ export const icons = 'IcRebrandingMt5Logo', 'IcRebrandingMt5SwapFree', 'IcRebrandingSmarttraderDashboard', - 'IcRebrandingSmarttrader' + 'IcRebrandingSmarttrader', ], 'stock': [ 'IcStockAdidasSalomon', @@ -839,7 +836,7 @@ export const icons = 'IcStockVisa', 'IcStockWallMart', 'IcStockWaltDisney', - 'IcStockZoom' + 'IcStockZoom', ], 'tradetype': [ 'IcTradetypeAccu', @@ -878,7 +875,7 @@ export const icons = 'IcTradetypeTurbosshort', 'IcTradetypeUpordown', 'IcTradetypeVanillaLongCall', - 'IcTradetypeVanillaLongPut' + 'IcTradetypeVanillaLongPut', ], 'underlying': [ 'IcUnderlying1HZ100V', @@ -1037,7 +1034,7 @@ export const icons = 'IcUnderlyingWLDEUR', 'IcUnderlyingWLDGBP', 'IcUnderlyingWLDUSD', - 'IcUnderlyingWLDXAU' + 'IcUnderlyingWLDXAU', ], 'wallet': [ 'IcWalletBitcoinDark', @@ -1068,6 +1065,6 @@ export const icons = 'IcWalletTetherDark', 'IcWalletTetherLight', 'IcWalletUsdCoinDark', - 'IcWalletUsdCoinLight' - ] -} \ No newline at end of file + 'IcWalletUsdCoinLight', + ], +} diff --git a/packages/core/src/App/Containers/AccountSignupModal/account-signup-modal.jsx b/packages/core/src/App/Containers/AccountSignupModal/account-signup-modal.jsx index 172e2e200d5a..db7e32bf388b 100644 --- a/packages/core/src/App/Containers/AccountSignupModal/account-signup-modal.jsx +++ b/packages/core/src/App/Containers/AccountSignupModal/account-signup-modal.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Form, Formik } from 'formik'; +import { Form,Formik } from 'formik'; import PropTypes from 'prop-types'; import { Button, Checkbox, Dialog, Loading, Text } from '@deriv/components'; diff --git a/packages/core/src/App/Containers/PasswordSelectionModal/password-selection-modal.jsx b/packages/core/src/App/Containers/PasswordSelectionModal/password-selection-modal.jsx index 2574efdbb8fa..a5244400cbd4 100644 --- a/packages/core/src/App/Containers/PasswordSelectionModal/password-selection-modal.jsx +++ b/packages/core/src/App/Containers/PasswordSelectionModal/password-selection-modal.jsx @@ -5,7 +5,7 @@ import { Field } from 'formik'; import { Button, PasswordInput, PasswordMeter, Text } from '@deriv/components'; import { getErrorMessages, redirectToSignUp } from '@deriv/shared'; import { observer, useStore } from '@deriv/stores'; -import { Localize, localize } from '@deriv/translations'; +import { Localize,localize } from '@deriv/translations'; import SignupSeparatorContainer from '../AccountSignupModal/signup-separator-container.jsx'; diff --git a/packages/core/src/App/Containers/RealAccountSignup/real-account-signup.jsx b/packages/core/src/App/Containers/RealAccountSignup/real-account-signup.jsx index 2209bce5e940..22a7b14354fc 100644 --- a/packages/core/src/App/Containers/RealAccountSignup/real-account-signup.jsx +++ b/packages/core/src/App/Containers/RealAccountSignup/real-account-signup.jsx @@ -4,9 +4,9 @@ import { withRouter } from 'react-router-dom'; import classNames from 'classnames'; import { RiskToleranceWarningModal, TestWarningModal } from '@deriv/account'; -import { Button, DesktopWrapper, MobileDialog, MobileWrapper, Modal, Text } from '@deriv/components'; +import { Button, DesktopWrapper, MobileDialog, MobileWrapper,Modal, Text } from '@deriv/components'; import { routes } from '@deriv/shared'; -import { Localize, localize } from '@deriv/translations'; +import { Localize,localize } from '@deriv/translations'; import { connect } from 'Stores/connect'; diff --git a/packages/core/src/Stores/base-store.js b/packages/core/src/Stores/base-store.js index 5c4ee6395013..9fe9159f7a47 100644 --- a/packages/core/src/Stores/base-store.js +++ b/packages/core/src/Stores/base-store.js @@ -1,4 +1,4 @@ -import { action, intercept, makeObservable, observable, reaction, toJS, when } from 'mobx'; +import { action, intercept, makeObservable,observable, reaction, toJS, when } from 'mobx'; import { isEmptyObject, isProduction, Validator } from '@deriv/shared'; diff --git a/packages/p2p/src/pages/buy-sell/buy-sell-row.jsx b/packages/p2p/src/pages/buy-sell/buy-sell-row.jsx index f402070d36a6..1d924ea094ea 100644 --- a/packages/p2p/src/pages/buy-sell/buy-sell-row.jsx +++ b/packages/p2p/src/pages/buy-sell/buy-sell-row.jsx @@ -3,7 +3,7 @@ import { useHistory } from 'react-router-dom'; import classNames from 'classnames'; import PropTypes from 'prop-types'; -import { Button, Icon, Table, Text } from '@deriv/components'; +import { Button, Icon,Table, Text } from '@deriv/components'; import { useExchangeRate } from '@deriv/hooks'; import { isMobile, routes } from '@deriv/shared'; import { observer, useStore } from '@deriv/stores'; diff --git a/packages/p2p/src/stores/general-store.js b/packages/p2p/src/stores/general-store.js index 36f22af02415..50b587ce8cd7 100644 --- a/packages/p2p/src/stores/general-store.js +++ b/packages/p2p/src/stores/general-store.js @@ -1,9 +1,9 @@ import React from 'react'; -import { action, computed, makeObservable, observable, reaction } from 'mobx'; +import { action, computed, makeObservable,observable, reaction } from 'mobx'; import { isEmptyObject, isMobile, routes, toMoment } from '@deriv/shared'; -import { Localize, localize } from 'Components/i18next'; +import { Localize,localize } from 'Components/i18next'; import { api_error_codes } from 'Constants/api-error-codes'; import { buy_sell } from 'Constants/buy-sell'; import { order_list } from 'Constants/order-list'; diff --git a/packages/reports/src/Stores/base-store.js b/packages/reports/src/Stores/base-store.js index a5f23da8145f..9dd1131f5da7 100644 --- a/packages/reports/src/Stores/base-store.js +++ b/packages/reports/src/Stores/base-store.js @@ -1,4 +1,4 @@ -import { action, intercept, makeObservable, observable, reaction, toJS, when } from 'mobx'; +import { action, intercept, makeObservable,observable, reaction, toJS, when } from 'mobx'; import { isEmptyObject, isProduction, Validator } from '@deriv/shared'; diff --git a/packages/trader/src/Modules/Trading/Components/Form/TradeParams/Multiplier/cancel-deal.jsx b/packages/trader/src/Modules/Trading/Components/Form/TradeParams/Multiplier/cancel-deal.jsx index 5fea303c358a..42ffac9e2b05 100644 --- a/packages/trader/src/Modules/Trading/Components/Form/TradeParams/Multiplier/cancel-deal.jsx +++ b/packages/trader/src/Modules/Trading/Components/Form/TradeParams/Multiplier/cancel-deal.jsx @@ -5,7 +5,7 @@ import { observer, useStore } from '@deriv/stores'; import { localize } from '@deriv/translations'; import Fieldset from 'App/Components/Form/fieldset'; -import { onChangeCancellationDuration, onToggleCancellation } from 'Stores/Modules/Trading/Helpers/multiplier'; +import { onChangeCancellationDuration,onToggleCancellation } from 'Stores/Modules/Trading/Helpers/multiplier'; import { useTraderStore } from 'Stores/useTraderStores'; const CancelDeal = observer(() => { From 84c45c79c462cbaf2d77a95eda4f0f0108944c35 Mon Sep 17 00:00:00 2001 From: amina-deriv Date: Tue, 17 Oct 2023 15:28:52 +0400 Subject: [PATCH 4/7] fix: eslint --- .../cfd/src/Stores/Modules/CFD/cfd-store.js | 1 - packages/cfd/src/Stores/base-store.js | 2 +- .../icon/mt5/ic-mt5-migration-success.svg | 2 +- packages/components/stories/icon/icons.js | 29 ++++++++++--------- .../SetResidenceModal/set-residence-modal.jsx | 2 +- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/packages/cfd/src/Stores/Modules/CFD/cfd-store.js b/packages/cfd/src/Stores/Modules/CFD/cfd-store.js index e2e98650216b..4b798a5d2e7b 100644 --- a/packages/cfd/src/Stores/Modules/CFD/cfd-store.js +++ b/packages/cfd/src/Stores/Modules/CFD/cfd-store.js @@ -409,7 +409,6 @@ export default class CFDStore extends BaseStore { WS.transferBetweenAccounts(); // get the list of updated accounts for transfer in cashier1000001 this.root_store.client.responseMT5TradingServers(await WS.tradingServers(CFD_PLATFORMS.MT5)); - // this.setCFDNewAccount(results.mt5_new_account); // need to check this } else { await this.getAccountStatus(CFD_PLATFORMS.MT5); this.clearCFDError(); diff --git a/packages/cfd/src/Stores/base-store.js b/packages/cfd/src/Stores/base-store.js index a5f23da8145f..9dd1131f5da7 100644 --- a/packages/cfd/src/Stores/base-store.js +++ b/packages/cfd/src/Stores/base-store.js @@ -1,4 +1,4 @@ -import { action, intercept, makeObservable, observable, reaction, toJS, when } from 'mobx'; +import { action, intercept, makeObservable,observable, reaction, toJS, when } from 'mobx'; import { isEmptyObject, isProduction, Validator } from '@deriv/shared'; diff --git a/packages/components/src/components/icon/mt5/ic-mt5-migration-success.svg b/packages/components/src/components/icon/mt5/ic-mt5-migration-success.svg index bd8b24ffb135..a2544e0bb5e6 100644 --- a/packages/components/src/components/icon/mt5/ic-mt5-migration-success.svg +++ b/packages/components/src/components/icon/mt5/ic-mt5-migration-success.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/components/stories/icon/icons.js b/packages/components/stories/icon/icons.js index d9febc29e5fb..834f63051a48 100644 --- a/packages/components/stories/icon/icons.js +++ b/packages/components/stories/icon/icons.js @@ -57,7 +57,7 @@ export const icons = 'IcAppstoreWalletUsdcLight', 'IcAppstoreWalletUsdtLight', 'IcAppstoreWalletsLink', - 'IcAppstoreWarning', + 'IcAppstoreWarning' ], 'brand': [ 'IcBrandCtraderWordmark', @@ -69,7 +69,7 @@ export const icons = 'IcBrandDmt5FinancialStp', 'IcBrandDmt5Financial', 'IcBrandDmt5Synthetics', - 'IcBrandDxtradeWordmark', + 'IcBrandDxtradeWordmark' ], 'cashier': [ 'IcCashierAdd', @@ -246,7 +246,7 @@ export const icons = 'IcCashierWyreLight', 'IcCashierZenithbankDark', 'IcCashierZenithbankLight', - 'IcCashier', + 'IcCashier' ], 'common': [ 'IcAccountCross', @@ -629,7 +629,7 @@ export const icons = 'IcWithdrawRequestVerification', 'IcZingpay', 'IcZoomIn', - 'IcZoomOut', + 'IcZoomOut' ], 'contract': [ 'IcContractBarrier', @@ -647,7 +647,7 @@ export const icons = 'IcContractStartTimeCircle', 'IcContractStartTime', 'IcContractStrike', - 'IcContractTarget', + 'IcContractTarget' ], 'currency': [ 'IcCurrencyAud', @@ -729,6 +729,7 @@ export const icons = 'IcMt5LiquidRisk', 'IcMt5Logo', 'IcMt5MarginTrading', + 'IcMt5MigrationSuccess', 'IcMt5OnePassword', 'IcMt5OpenMarkets', 'IcMt5PasswordUpdated', @@ -742,7 +743,7 @@ export const icons = 'IcMt5SyntheticPlatform', 'IcMt5TradeTypes', 'IcMt5VanuatuDerived', - 'IcMt5VanuatuFinancial', + 'IcMt5VanuatuFinancial' ], 'option': [ 'IcOptionAccumulators', @@ -760,7 +761,7 @@ export const icons = 'IcOptionOverUnder', 'IcOptionRaiseFall', 'IcOptionTouchNotouch', - 'IcOptionUpDownAsian', + 'IcOptionUpDownAsian' ], 'rebranding': [ 'IcRebrandingBinaryBot', @@ -786,7 +787,7 @@ export const icons = 'IcRebrandingMt5Logo', 'IcRebrandingMt5SwapFree', 'IcRebrandingSmarttraderDashboard', - 'IcRebrandingSmarttrader', + 'IcRebrandingSmarttrader' ], 'stock': [ 'IcStockAdidasSalomon', @@ -836,7 +837,7 @@ export const icons = 'IcStockVisa', 'IcStockWallMart', 'IcStockWaltDisney', - 'IcStockZoom', + 'IcStockZoom' ], 'tradetype': [ 'IcTradetypeAccu', @@ -875,7 +876,7 @@ export const icons = 'IcTradetypeTurbosshort', 'IcTradetypeUpordown', 'IcTradetypeVanillaLongCall', - 'IcTradetypeVanillaLongPut', + 'IcTradetypeVanillaLongPut' ], 'underlying': [ 'IcUnderlying1HZ100V', @@ -1034,7 +1035,7 @@ export const icons = 'IcUnderlyingWLDEUR', 'IcUnderlyingWLDGBP', 'IcUnderlyingWLDUSD', - 'IcUnderlyingWLDXAU', + 'IcUnderlyingWLDXAU' ], 'wallet': [ 'IcWalletBitcoinDark', @@ -1065,6 +1066,6 @@ export const icons = 'IcWalletTetherDark', 'IcWalletTetherLight', 'IcWalletUsdCoinDark', - 'IcWalletUsdCoinLight', - ], -} + 'IcWalletUsdCoinLight' + ] +} \ No newline at end of file diff --git a/packages/core/src/App/Containers/SetResidenceModal/set-residence-modal.jsx b/packages/core/src/App/Containers/SetResidenceModal/set-residence-modal.jsx index 3d8afe156d67..659c037224aa 100644 --- a/packages/core/src/App/Containers/SetResidenceModal/set-residence-modal.jsx +++ b/packages/core/src/App/Containers/SetResidenceModal/set-residence-modal.jsx @@ -1,6 +1,6 @@ import React from 'react'; import classNames from 'classnames'; -import { Form, Formik } from 'formik'; +import { Form,Formik } from 'formik'; import PropTypes from 'prop-types'; import { Button, Dialog, Text } from '@deriv/components'; From 92fa0987f0532e4808d65f26f11e7fb92435daf8 Mon Sep 17 00:00:00 2001 From: amina-deriv Date: Tue, 17 Oct 2023 16:01:47 +0400 Subject: [PATCH 5/7] fix: eslint fix --- .../cfd/src/Containers/cfd-password-modal.tsx | 14 +--- .../cfd/src/Stores/Modules/CFD/cfd-store.js | 79 +++++++++---------- packages/cfd/src/types/cfd-store.types.ts | 2 +- .../hooks/src/useMT5SVGEligibleToMigrate.ts | 6 +- packages/stores/src/mockStore.ts | 2 +- 5 files changed, 46 insertions(+), 57 deletions(-) diff --git a/packages/cfd/src/Containers/cfd-password-modal.tsx b/packages/cfd/src/Containers/cfd-password-modal.tsx index 3525fd4a616c..c4eedee3b35c 100644 --- a/packages/cfd/src/Containers/cfd-password-modal.tsx +++ b/packages/cfd/src/Containers/cfd-password-modal.tsx @@ -660,7 +660,7 @@ const CFDPasswordModal = observer(({ form_error, platform }: TCFDPasswordModalPr submitMt5Password, submitCFDPassword, new_account_response, - migrate_mt5_accounts, + migrated_mt5_accounts, } = useCfdStore(); const history = useHistory(); @@ -933,15 +933,7 @@ const CFDPasswordModal = observer(({ form_error, platform }: TCFDPasswordModalPr }; const getMigrationSubmitText = () => { - // { - // "financial": "vanuatu" - // }, - // { - // "synthetic": "vanuatu" - // } - // ] - - const list = migrate_mt5_accounts.map(account => { + const list = migrated_mt5_accounts.map(account => { const [to_account_type] = Object.keys(account); const [to_accounts] = Object.values(account); @@ -957,7 +949,7 @@ const CFDPasswordModal = observer(({ form_error, platform }: TCFDPasswordModalPr i18n_default_text="We've upgraded your MT5 account(s) by moving them to the {{eligible_account_migrate}} jurisdiction. Use your <0>{{migrated_accounts}} new login ID and MT5 password to start trading." values={{ eligible_account_migrate: getFormattedJurisdictionCode( - migrate_mt5_accounts.map(account => Object.values(account))[0] + migrated_mt5_accounts.map(account => Object.values(account))[0] ), migrated_accounts: list.join(' and '), // [MT5 Derived Vanuatu and MT5 Financial Vanuatu] }} diff --git a/packages/cfd/src/Stores/Modules/CFD/cfd-store.js b/packages/cfd/src/Stores/Modules/CFD/cfd-store.js index 4b798a5d2e7b..7c2c47f930b5 100644 --- a/packages/cfd/src/Stores/Modules/CFD/cfd-store.js +++ b/packages/cfd/src/Stores/Modules/CFD/cfd-store.js @@ -49,7 +49,7 @@ export default class CFDStore extends BaseStore { real_financial_accounts_existing_data = []; real_swapfree_accounts_existing_data = []; - migrate_mt5_accounts = []; + migrated_mt5_accounts = []; constructor({ root_store }) { super({ root_store }); @@ -77,7 +77,7 @@ export default class CFDStore extends BaseStore { dxtrade_tokens: observable, ctrader_tokens: observable, derivez_tokens: observable, - migrate_mt5_accounts: observable, + migrated_mt5_accounts: observable, account_title: computed, current_list: computed, has_created_account_for_selected_jurisdiction: computed, @@ -92,7 +92,7 @@ export default class CFDStore extends BaseStore { disableCFDPasswordModal: action.bound, enableCFDPasswordModal: action.bound, getName: action.bound, - MigrateMT5Accounts: action.bound, + migrateMT5Accounts: action.bound, openMT5Account: action.bound, openCFDAccount: action.bound, beginRealSignupForMt5: action.bound, @@ -377,8 +377,7 @@ export default class CFDStore extends BaseStore { // First name is not set when user has no real account return first_name ? [first_name, title].join(' ') : title; } - - async MigrateMT5Accounts(values, actions) { + async migrateMT5Accounts(values, actions) { const account_to_migrate = this.root_store.client.mt5_login_list.filter( acc => acc.landing_company_short === Jurisdiction.SVG && !!acc.eligible_to_migrate ); @@ -389,8 +388,8 @@ export default class CFDStore extends BaseStore { category: 'real', type, }; - this.migrate_mt5_accounts = [...this.migrate_mt5_accounts, { ...eligible_to_migrate }]; - return this.MigrateAccount(values, shortcode, account_type); + this.migrated_mt5_accounts = [...this.migrated_mt5_accounts, { ...eligible_to_migrate }]; + return this.requestMigrateAccount(values, shortcode, account_type); }); try { @@ -407,7 +406,7 @@ export default class CFDStore extends BaseStore { const mt5_login_list_response = await WS.authorized.mt5LoginList(); this.root_store.client.responseMt5LoginList(mt5_login_list_response); - WS.transferBetweenAccounts(); // get the list of updated accounts for transfer in cashier1000001 + WS.transferBetweenAccounts(); this.root_store.client.responseMT5TradingServers(await WS.tradingServers(CFD_PLATFORMS.MT5)); } else { await this.getAccountStatus(CFD_PLATFORMS.MT5); @@ -422,7 +421,7 @@ export default class CFDStore extends BaseStore { } } - MigrateAccount(values, shortcode, account_type) { + requestMigrateAccount(values, shortcode, account_type) { const name = this.getName(); const leverage = this.mt5_companies[account_type.category][account_type.type].leverage; const type_request = getAccountTypeFields(account_type); @@ -452,6 +451,36 @@ export default class CFDStore extends BaseStore { }); } + openMT5Account(values) { + const name = this.getName(); + const leverage = this.mt5_companies[this.account_type.category][this.account_type.type].leverage; + const type_request = getAccountTypeFields(this.account_type); + const { address_line_1, address_line_2, address_postcode, address_city, address_state, country_code, phone } = + this.root_store.client.account_settings; + + return WS.mt5NewAccount({ + mainPassword: values.password, + email: this.root_store.client.email_address, + leverage, + name, + address: address_line_1 || address_line_2, + city: address_city, + country: country_code, + phone, + state: address_state, + zipCode: address_postcode, + ...(this.account_type.type === 'all' ? { sub_account_category: 'swap_free' } : {}), + ...(values.server ? { server: values.server } : {}), + ...(this.jurisdiction_selected_shortcode ? { company: this.jurisdiction_selected_shortcode } : {}), + ...(this.jurisdiction_selected_shortcode !== Jurisdiction.LABUAN + ? type_request + : { + account_type: 'financial', + mt5_account_type: 'financial_stp', + }), + }); + } + openCFDAccount(values) { return WS.tradingPlatformNewAccount({ password: CFD_PLATFORMS.DXTRADE ? values.password : '', @@ -556,36 +585,6 @@ export default class CFDStore extends BaseStore { return false; } - openMT5Account(values) { - const name = this.getName(); - const leverage = this.mt5_companies[this.account_type.category][this.account_type.type].leverage; - const type_request = getAccountTypeFields(this.account_type); - const { address_line_1, address_line_2, address_postcode, address_city, address_state, country_code, phone } = - this.root_store.client.account_settings; - - return WS.mt5NewAccount({ - mainPassword: values.password, - email: this.root_store.client.email_address, - leverage, - name, - address: address_line_1 || address_line_2, - city: address_city, - country: country_code, - phone, - state: address_state, - zipCode: address_postcode, - ...(this.account_type.type === 'all' ? { sub_account_category: 'swap_free' } : {}), - ...(values.server ? { server: values.server } : {}), - ...(this.jurisdiction_selected_shortcode ? { company: this.jurisdiction_selected_shortcode } : {}), - ...(this.jurisdiction_selected_shortcode !== Jurisdiction.LABUAN - ? type_request - : { - account_type: 'financial', - mt5_account_type: 'financial_stp', - }), - }); - } - async submitMt5Password(values, actions) { if (this.root_store.client.is_mt5_password_not_set) { const has_error = await this.creatMT5Password(values, actions); @@ -594,7 +593,7 @@ export default class CFDStore extends BaseStore { this.resetFormErrors(); if (this.root_store.ui.is_mt5_migration_modal_enabled) { - await this.MigrateMT5Accounts(values, actions); + await this.migrateMT5Accounts(values, actions); } else { const response = await this.openMT5Account(values); if (!response.error) { diff --git a/packages/cfd/src/types/cfd-store.types.ts b/packages/cfd/src/types/cfd-store.types.ts index 1aa22e64cb95..d889af41917b 100644 --- a/packages/cfd/src/types/cfd-store.types.ts +++ b/packages/cfd/src/types/cfd-store.types.ts @@ -51,7 +51,7 @@ export type TCFDStore = { }; sendVerifyEmail: () => Promise; account_title: string; - migrate_mt5_accounts: Record[]; + migrated_mt5_accounts: Record[]; disableCFDPasswordModal: () => void; error_message: string; error_type?: string; diff --git a/packages/hooks/src/useMT5SVGEligibleToMigrate.ts b/packages/hooks/src/useMT5SVGEligibleToMigrate.ts index dca2669886a6..4a2d9c18271f 100644 --- a/packages/hooks/src/useMT5SVGEligibleToMigrate.ts +++ b/packages/hooks/src/useMT5SVGEligibleToMigrate.ts @@ -1,11 +1,9 @@ import React from 'react'; -// import { useMT5AccountsList } from '@deriv/api'; -import { useStore } from '@deriv/stores'; +import { useMT5AccountsList } from '@deriv/api'; import { Jurisdiction, getFormattedJurisdictionCode } from '@deriv/shared'; const useMT5SVGEligibleToMigrate = () => { - const { client } = useStore(); - const { mt5_login_list } = client; + const { data: mt5_login_list = [] } = useMT5AccountsList(); const mt5_migration_config = React.useMemo(() => { const svg_accounts_to_migrate = mt5_login_list.filter( diff --git a/packages/stores/src/mockStore.ts b/packages/stores/src/mockStore.ts index 26e564e323ce..caa56b0108bf 100644 --- a/packages/stores/src/mockStore.ts +++ b/packages/stores/src/mockStore.ts @@ -554,7 +554,7 @@ const mock = (): TStores & { is_mock: boolean } => { modules: { cfd: { setMT5MigrationError: jest.fn(), - migrate_mt5_accounts: [], + migrated_mt5_accounts: [], }, }, exchange_rates: { From 8fd7ea436951d7e9908e292baf6bacf8473079e1 Mon Sep 17 00:00:00 2001 From: amina-deriv Date: Tue, 17 Oct 2023 16:33:01 +0400 Subject: [PATCH 6/7] fix: icons --- packages/components/stories/icon/icons.js | 28 +++++++++++------------ 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/components/stories/icon/icons.js b/packages/components/stories/icon/icons.js index 834f63051a48..98f9bbce79dc 100644 --- a/packages/components/stories/icon/icons.js +++ b/packages/components/stories/icon/icons.js @@ -57,7 +57,7 @@ export const icons = 'IcAppstoreWalletUsdcLight', 'IcAppstoreWalletUsdtLight', 'IcAppstoreWalletsLink', - 'IcAppstoreWarning' + 'IcAppstoreWarning', ], 'brand': [ 'IcBrandCtraderWordmark', @@ -69,7 +69,7 @@ export const icons = 'IcBrandDmt5FinancialStp', 'IcBrandDmt5Financial', 'IcBrandDmt5Synthetics', - 'IcBrandDxtradeWordmark' + 'IcBrandDxtradeWordmark', ], 'cashier': [ 'IcCashierAdd', @@ -246,7 +246,7 @@ export const icons = 'IcCashierWyreLight', 'IcCashierZenithbankDark', 'IcCashierZenithbankLight', - 'IcCashier' + 'IcCashier', ], 'common': [ 'IcAccountCross', @@ -629,7 +629,7 @@ export const icons = 'IcWithdrawRequestVerification', 'IcZingpay', 'IcZoomIn', - 'IcZoomOut' + 'IcZoomOut', ], 'contract': [ 'IcContractBarrier', @@ -647,7 +647,7 @@ export const icons = 'IcContractStartTimeCircle', 'IcContractStartTime', 'IcContractStrike', - 'IcContractTarget' + 'IcContractTarget', ], 'currency': [ 'IcCurrencyAud', @@ -743,7 +743,7 @@ export const icons = 'IcMt5SyntheticPlatform', 'IcMt5TradeTypes', 'IcMt5VanuatuDerived', - 'IcMt5VanuatuFinancial' + 'IcMt5VanuatuFinancial', ], 'option': [ 'IcOptionAccumulators', @@ -761,7 +761,7 @@ export const icons = 'IcOptionOverUnder', 'IcOptionRaiseFall', 'IcOptionTouchNotouch', - 'IcOptionUpDownAsian' + 'IcOptionUpDownAsian', ], 'rebranding': [ 'IcRebrandingBinaryBot', @@ -787,7 +787,7 @@ export const icons = 'IcRebrandingMt5Logo', 'IcRebrandingMt5SwapFree', 'IcRebrandingSmarttraderDashboard', - 'IcRebrandingSmarttrader' + 'IcRebrandingSmarttrader', ], 'stock': [ 'IcStockAdidasSalomon', @@ -837,7 +837,7 @@ export const icons = 'IcStockVisa', 'IcStockWallMart', 'IcStockWaltDisney', - 'IcStockZoom' + 'IcStockZoom', ], 'tradetype': [ 'IcTradetypeAccu', @@ -876,7 +876,7 @@ export const icons = 'IcTradetypeTurbosshort', 'IcTradetypeUpordown', 'IcTradetypeVanillaLongCall', - 'IcTradetypeVanillaLongPut' + 'IcTradetypeVanillaLongPut', ], 'underlying': [ 'IcUnderlying1HZ100V', @@ -1035,7 +1035,7 @@ export const icons = 'IcUnderlyingWLDEUR', 'IcUnderlyingWLDGBP', 'IcUnderlyingWLDUSD', - 'IcUnderlyingWLDXAU' + 'IcUnderlyingWLDXAU', ], 'wallet': [ 'IcWalletBitcoinDark', @@ -1066,6 +1066,6 @@ export const icons = 'IcWalletTetherDark', 'IcWalletTetherLight', 'IcWalletUsdCoinDark', - 'IcWalletUsdCoinLight' - ] -} \ No newline at end of file + 'IcWalletUsdCoinLight', + ], +} From 991fd8f3bcc9fa0042bc2d11189a48e6cc0cd8ff Mon Sep 17 00:00:00 2001 From: amina-deriv Date: Tue, 17 Oct 2023 18:20:51 +0400 Subject: [PATCH 7/7] fix: config --- packages/cfd/src/Containers/cfd-password-modal.tsx | 8 +++----- packages/cfd/src/Stores/Modules/CFD/cfd-store.js | 11 +++++++++-- .../src/utils/constants/jurisdictions-config.ts | 1 + 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/cfd/src/Containers/cfd-password-modal.tsx b/packages/cfd/src/Containers/cfd-password-modal.tsx index c4eedee3b35c..10bc850e77c0 100644 --- a/packages/cfd/src/Containers/cfd-password-modal.tsx +++ b/packages/cfd/src/Containers/cfd-password-modal.tsx @@ -935,13 +935,11 @@ const CFDPasswordModal = observer(({ form_error, platform }: TCFDPasswordModalPr const getMigrationSubmitText = () => { const list = migrated_mt5_accounts.map(account => { const [to_account_type] = Object.keys(account); - - const [to_accounts] = Object.values(account); - const to_account_type_label = to_account_type === 'synthetic' ? 'derived' : to_account_type; + const [to_jurisdiction] = Object.values(account); return `${getCFDPlatformNames(CFD_PLATFORMS.MT5)} ${getFormattedJurisdictionMarketTypes( - to_account_type_label - )} ${getFormattedJurisdictionCode(to_accounts)}`; + to_account_type + )} ${getFormattedJurisdictionCode(to_jurisdiction)}`; }); return ( diff --git a/packages/cfd/src/Stores/Modules/CFD/cfd-store.js b/packages/cfd/src/Stores/Modules/CFD/cfd-store.js index 7c2c47f930b5..b92a9e287490 100644 --- a/packages/cfd/src/Stores/Modules/CFD/cfd-store.js +++ b/packages/cfd/src/Stores/Modules/CFD/cfd-store.js @@ -1,5 +1,12 @@ import { action, computed, observable, reaction, runInAction, makeObservable, override } from 'mobx'; -import { getAccountListKey, getAccountTypeFields, CFD_PLATFORMS, WS, Jurisdiction } from '@deriv/shared'; +import { + getAccountListKey, + getAccountTypeFields, + CFD_PLATFORMS, + WS, + Jurisdiction, + JURISDICTION_MARKET_TYPES, +} from '@deriv/shared'; import BaseStore from '../../base-store'; import { getDxCompanies, getMtCompanies, getDerivezCompanies } from './Helpers/cfd-config'; @@ -445,7 +452,7 @@ export default class CFDStore extends BaseStore { ...(shortcode !== Jurisdiction.LABUAN ? type_request : { - account_type: 'financial', + account_type: JURISDICTION_MARKET_TYPES.FINANCIAL, mt5_account_type: 'financial_stp', }), }); diff --git a/packages/shared/src/utils/constants/jurisdictions-config.ts b/packages/shared/src/utils/constants/jurisdictions-config.ts index 2ff18e317dec..029e1063050b 100644 --- a/packages/shared/src/utils/constants/jurisdictions-config.ts +++ b/packages/shared/src/utils/constants/jurisdictions-config.ts @@ -60,6 +60,7 @@ export const getFormattedJurisdictionMarketTypes = (jurisdiction_market_type: st let formatted_market_type = ''; switch (jurisdiction_market_type) { + case 'synthetic': // need to remove this once we have the correct market type from BE case JURISDICTION_MARKET_TYPES.DERIVED: formatted_market_type = localize('Derived'); break;