Skip to content
Draft
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
45 changes: 45 additions & 0 deletions src/api/get-limits.api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { GenericRequest, InterceptedAPIHandler } from '../types/base.type';

export const getLimits = async ({ data, ws }: InterceptedAPIHandler) => {
const { req_id } = data as GenericRequest;

const response = {
get_limits: {
daily_transfers: {
ctrader: {
allowed: '50000.00',
available: '49500.00',
minimum: '0.01',
},
derivez: {
allowed: '10000.00',
available: '9900.00',
limit_type: 'amount',
minimum: '0.01',
},
},
unverified_transfers: {
crypto_to_crypto: {
allowed: '200.00',
available: '100:00',
},
crypto_to_fiat: {
allowed: '500.00',
available: '500:00',
},
fiat_to_crypto: {
allowed: '1000.00',
available: '950.00',
},
},
},
echo_req: {
get_limits: '<not shown>',
req_id,
},
msg_type: 'authorize',
req_id,
};

ws.send(JSON.stringify(response));
};
24 changes: 11 additions & 13 deletions src/api/trading-platform-accounts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@ import tradingPlatformAccountsResponse from '../../response/trading-platform-acc
export const tradingPlatformAccounts = async ({ data, ws }: InterceptedAPIHandler) => {
const { trading_platform_accounts, platform, req_id } = data as TradingPlatformAccountsRequest;

if (platform === 'dxtrade') {
return ws.send(
JSON.stringify({
echo_req: {
trading_platform_accounts,
platform,
req_id,
},
msg_type: 'trading_platform_accounts',
return ws.send(
JSON.stringify({
echo_req: {
trading_platform_accounts,
platform,
req_id,
trading_platform_accounts: tradingPlatformAccountsResponse,
})
);
}
},
msg_type: 'trading_platform_accounts',
req_id,
trading_platform_accounts: tradingPlatformAccountsResponse,
})
);
};
32 changes: 32 additions & 0 deletions src/api/transfer-between-accounts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { GenericRequest, InterceptedAPIHandler } from '../types/base.type';

export const transferBetweenAccounts = async ({ data, ws }: InterceptedAPIHandler) => {
const { req_id } = data as GenericRequest;

const response = {
accounts: [
{
account_type: 'wallet',
balance: '10422.12',
currency: 'USD',
demo_account: 0,
loginid: 'CRW1122',
},
{
account_type: 'trading',
balance: '100',
currency: 'USD',
demo_account: 0,
loginid: 'CR1122',
},
],
echo_req: {
transfer_between_accounts: '0',
req_id,
},
msg_type: 'transfer_between_accounts',
req_id,
};

ws.send(JSON.stringify(response));
};
11 changes: 8 additions & 3 deletions src/interceptor/mock.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ 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 { getLimits } from '../api/get-limits.api';
import { transferBetweenAccounts } from '../api/transfer-between-accounts';

export const mockInterceptor = async (intercepted_args: InterceptedAPIHandler) => {
const endpoint_type = getFirstMatchingKey(
Expand Down Expand Up @@ -50,9 +52,14 @@ export const mockInterceptor = async (intercepted_args: InterceptedAPIHandler) =
return await payoutCurrencies(intercepted_args);
case 'topup_virtual':
return await topupVirtual(intercepted_args);
case 'get_limits':
return await getLimits(intercepted_args);
case 'transfer_between_accounts':
return await transferBetweenAccounts(intercepted_args);
case 'trading_platform_accounts':
return await tradingPlatformAccounts(intercepted_args);
case 'account_security':
case 'portfolio':
case 'get_limits':
case 'proposal_open_contract':
case 'new_account_real':
case 'new_account_virtual':
Expand All @@ -62,8 +69,6 @@ export const mockInterceptor = async (intercepted_args: InterceptedAPIHandler) =
case 'transfer_between_accounts':
case 'p2p_order_list':
case 'get_financial_assessment':
case 'trading_platform_accounts':
return await tradingPlatformAccounts(intercepted_args);
default:
return await proxyInterceptor(intercepted_args);
}
Expand Down
46 changes: 46 additions & 0 deletions src/mock-store/transfer/session.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"session_id": "transfer",
"accounts": [
{
"account_category": "wallet",
"account_type": "doughflow",
"created_at": 1664784824,
"currency": "USD",
"balance": 10422.12,
"is_disabled": 0,
"is_virtual": 0,
"landing_company_name": "SVG",
"landing_company_shortcode": "SVG",
"loginid": "CRW1122",
"linked_to": [{"loginid": "CR1122", "platform": "dtrader" }],
"trading": {},
"email": "example@test.com",
"excluded_until": "",
"session_start": 1687144472,
"accepted_bch": 0,
"platform": "deriv"
},
{
"account_category": "trading",
"account_type": "dtrader",
"created_at": 1664784824,
"currency": "USD",
"balance": 100,
"is_disabled": 0,
"is_virtual": 1,
"landing_company_name": "SVG",
"landing_company_shortcode": "SVG",
"loginid": "CR1122",
"linked_to": [{"loginid": "CRW1122", "platform": "wallet" }],
"trading": {},
"email": "example@test.com",
"excluded_until": "",
"session_start": 1687144472,
"accepted_bch": 0,
"platform": "deriv"
}
],
"wallet_migration_config": {
"status": "migrated"
}
}
4 changes: 1 addition & 3 deletions src/schema/account.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ export type LinkedAccount = z.infer<typeof linked_account_schema>;

export const linked_account_schema = z.object({
loginid: z.string(),
account_category: z.enum(['trading', 'wallet']),
account_type: z.string(),
platform: z.nativeEnum(Platform),
});

Expand All @@ -29,7 +27,7 @@ export const account_schema = z
is_virtual: z.number(),
landing_company_name: z.string().regex(/(bvi|labuan|malta|maltainvest|svg|vanuatu)/),
loginid: z.string().regex(/^(MX|MXW|MF|MFW|VRTC|VRW|MLT|MLTW|CR|CRW|FOG)[0-9]+$/),
linked_account: linked_account_schema,
linked_to: linked_account_schema,
trading: z.any().optional(),
token: z.string().optional(),
// Full Account Details
Expand Down