Skip to content
This repository was archived by the owner on Jun 12, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions src/api/new_account_wallet.api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { InterceptedAPIHandler } from '../types/base.type';
import { NewAccountWalletRequest } from '../types/new_account_wallet.type';

export const newAccountWallet = ({ data, ws, session }: InterceptedAPIHandler) => {
const {
new_account_wallet,
req_id,
account_type,
currency,
address_city,
address_line_1,
address_line_2,
address_postcode,
date_of_birth,
first_name,
last_name,
phone,
non_pep_declaration,
} = data as NewAccountWalletRequest;

const response = {
echo_req: {
new_account_wallet,
req_id,
account_type,
currency,
address_city,
address_line_1,
address_line_2,
address_postcode,
date_of_birth,
first_name,
last_name,
phone,
non_pep_declaration,
},
msg_type: 'new_account_wallet',
new_account_wallet: {
client_id: 'CRW123129',
currency,
landing_company: 'Deriv (SVG) LLC',
landing_company_short: 'svg',
landing_company_shortcode: 'svg',
oauth_token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will trip up some checks. 👀 can u use token from the accounts?

},
req_id,
};
// add the new account wallet to the session
session.accounts = [
...session.accounts,
{
account_category: 'wallet',
account_type,
created_at: 1664784824,
currency,
balance: Math.floor(Math.random() * 100),
is_disabled: 0,
is_virtual: 0,
landing_company_name: 'svg',
landing_company_shortcode: 'svg',
loginid: `CRW${Math.floor(Math.random() * 100000)}`,
trading: {},
email: 'example@test.com',
platform: 'deriv',
excluded_until: 0,
},
];
return ws.send(JSON.stringify(response));
};
6 changes: 5 additions & 1 deletion src/interceptor/mock.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { payoutCurrencies } from '../api/payout-currencies.api';
import { getAccountTypes } from '../api/get-account-types';
import { tradingPlatformAccounts } from '../api/trading-platform-accounts';
import { topupVirtual } from '../api/topup-virtual.api';
import { newAccountWallet } from '../api/new_account_wallet.api';

export const mockInterceptor = async (intercepted_args: InterceptedAPIHandler) => {
const endpoint_type = getFirstMatchingKey(
Expand Down Expand Up @@ -50,18 +51,21 @@ export const mockInterceptor = async (intercepted_args: InterceptedAPIHandler) =
return await payoutCurrencies(intercepted_args);
case 'topup_virtual':
return await topupVirtual(intercepted_args);
case 'new_account_wallet':
return await newAccountWallet(intercepted_args);
case 'account_security':
case 'portfolio':
case 'get_limits':
case 'proposal_open_contract':
case 'new_account_real':
case 'new_account_virtual':
case 'new_account_wallet':

case 'get_self_exclusion':
case 'get_available_accounts_to_transfer':
case 'transfer_between_accounts':
case 'p2p_order_list':
case 'get_financial_assessment':
return;
case 'trading_platform_accounts':
return await tradingPlatformAccounts(intercepted_args);
default:
Expand Down
38 changes: 37 additions & 1 deletion src/mock-store/default/session.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"currency": "USD",
"balance": 40.12,
"is_disabled": 0,
"is_virtual": 0,
"is_virtual": 1,
"landing_company_name": "virtual",
"landing_company_shortcode": "virtual",
"loginid": "VRW142069",
Expand All @@ -37,6 +37,42 @@
"accepted_bch": 0,
"platform": "deriv"
},
{
"account_category": "wallet",
"account_type": "doughflow",
"created_at": 1664784824,
"currency": "USD",
"balance": 790.12,
"is_disabled": 0,
"is_virtual": 0,
"landing_company_name": "svg",
"landing_company_shortcode": "svg",
"loginid": "CRW142069",
"trading": {},
"email": "example@test.com",
"excluded_until": "",
"session_start": 1687144472,
"accepted_bch": 0,
"platform": "deriv"
},
{
"account_category": "wallet",
"account_type": "crypto",
"created_at": 1664784824,
"currency": "LTC",
"balance": 71190.12,
"is_disabled": 0,
"is_virtual": 0,
"landing_company_name": "svg",
"landing_company_shortcode": "svg",
"loginid": "CRW142069",
"trading": {},
"email": "example@test.com",
"excluded_until": "",
"session_start": 1687144472,
"accepted_bch": 0,
"platform": "deriv"
},
{
"account_category": "trading",
"account_type": "standard",
Expand Down
16 changes: 16 additions & 0 deletions src/types/new_account_wallet.type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { GenericRequest } from './base.type';

export interface NewAccountWalletRequest extends GenericRequest {
new_account_wallet: 1;
address_city?: string;
address_line_1?: string;
address_line_2?: string;
address_postcode?: string;
date_of_birth?: string;
first_name?: string;
last_name?: string;
phone?: string;
non_pep_declaration?: string;
account_type: 'doughflow' | 'crypto';
currency: string;
}