@alphapoint/apex-web 5.5.6 → 5.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/apex.integration.test.js +435 -0
- package/lib/apex.js +37 -1
- package/lib/apex.test.js +138 -0
- package/lib/components/2FA/PasskeyOption.js +126 -0
- package/lib/components/2FA/TwoFactorAuthComponent.js +24 -5
- package/lib/components/2FA/TwoFactorAuthComponent.test.js +94 -0
- package/lib/components/2FA/TwoFactorAuthContainer.js +139 -27
- package/lib/components/2FA/TwoFactorAuthContainer.test.js +627 -0
- package/lib/components/AccountsDropdown/AccountsDropdownComponent.css +6 -0
- package/lib/components/AccountsDropdown/AccountsDropdownComponent.js +6 -2
- package/lib/components/AccountsDropdown/AccountsDropdownComponent.test.js +43 -0
- package/lib/components/AccountsDropdown/AccountsDropdownContainer.js +3 -1
- package/lib/components/BalancesList/BalancesListContainer.js +4 -1
- package/lib/components/ConfirmBlockTradeModal/ConfirmBlockTradeModalContainer.js +34 -6
- package/lib/components/ConfirmBlockTradeModal/ConfirmBlockTradeModalContainer.test.js +298 -0
- package/lib/components/ConfirmOrderModal/ConfirmOrderModalComponent.js +26 -4
- package/lib/components/ConfirmOrderModal/ConfirmOrderModalContainer.js +4 -1
- package/lib/components/DigitalAssets/digitalAssetsPriceLabel.test.js +238 -0
- package/lib/components/EnableTwoFactorAuth/Disable2FAForm.js +22 -7
- package/lib/components/EnableTwoFactorAuth/Disable2FAModal.js +15 -5
- package/lib/components/EnableTwoFactorAuth/Disable2FAModal.test.js +460 -0
- package/lib/components/EnableTwoFactorAuth/Disable2FAModalContainer.js +108 -16
- package/lib/components/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.js +7 -0
- package/lib/components/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.test.js +105 -0
- package/lib/components/EnableTwoFactorAuth/EnableTwoFactorAuthContainerFactory.js +15 -3
- package/lib/components/FusionAuth/UnlinkOAuthIdentityModal.css +13 -0
- package/lib/components/FusionAuth/UnlinkOAuthIdentityModal.js +246 -0
- package/lib/components/FusionAuth/UnlinkOAuthIdentityModal.test.js +521 -0
- package/lib/components/InstrumentPositions/InstrumentPositionsContainer.js +4 -1
- package/lib/components/Login/LoginFormComponent.js +1 -1
- package/lib/components/MarginBalances/MarginDepositWithdraw/MarginDepositModal/MarginDepositFormContainer.js +2 -1
- package/lib/components/NoAccountBanner/NoAccountBanner.css +9 -0
- package/lib/components/NoAccountBanner/NoAccountBanner.js +58 -0
- package/lib/components/NoAccountBanner/index.js +16 -0
- package/lib/components/NoAccountPlaceholder/NoAccountPlaceholder.css +31 -0
- package/lib/components/NoAccountPlaceholder/NoAccountPlaceholder.js +33 -0
- package/lib/components/NoAccountPlaceholder/index.js +9 -0
- package/lib/components/OrderEntryComponents/advancedForm/AdvancedOrderFormContainer.js +2 -0
- package/lib/components/OrderEntryComponents/common/FormAmountFields.js +5 -0
- package/lib/components/OrderEntryComponents/common/TwapScheduleFields.js +98 -0
- package/lib/components/OrderEntryComponents/defaultForm/OrderEntryAnchoring.js +86 -39
- package/lib/components/OrderEntryComponents/defaultForm/OrderEntryAnchoring.test.js +326 -0
- package/lib/components/OrderEntryComponents/defaultForm/OrderEntryContainer.js +10 -2
- package/lib/components/OrderHistoryComponents/DepositsStatus/DepositsStatusComponent.js +1 -1
- package/lib/components/OrderHistoryComponents/DepositsStatus/DepositsStatusComponent.test.js +99 -0
- package/lib/components/OrderHistoryComponents/InactiveOrders/InactiveOrdersComponent.js +1 -1
- package/lib/components/OrderHistoryComponents/OpenOrders/OpenOrdersComponent.js +1 -1
- package/lib/components/OrderHistoryComponents/WithdrawStatus/WithdrawStatusComponent.js +1 -1
- package/lib/components/OrderHistoryComponents/WithdrawStatus/WithdrawStatusComponent.test.js +113 -0
- package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/PasskeysSettingsCard.css +108 -0
- package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/PasskeysSettingsCard.test.js +983 -0
- package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/PasskeysSettingsCardComponent.js +500 -0
- package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/index.js +9 -0
- package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/SsoLinkRowComponent.css +4 -0
- package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/SsoLinkRowComponent.js +29 -17
- package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/SsoLinkRowComponent.test.js +135 -0
- package/lib/components/Settings/ProfileAndSecurity/TwoFactorAuthSettingsCard/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.js +12 -4
- package/lib/components/Settings/ProfileAndSecurity/TwoFactorAuthSettingsCard/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.test.js +268 -0
- package/lib/components/TwoFactorAuthForm/TwoFactorAuthForm.test.js +475 -0
- package/lib/components/TwoFactorAuthForm/TwoFactorAuthFormComponent.js +26 -5
- package/lib/components/TwoFactorAuthForm/TwoFactorAuthFormContainer.js +50 -32
- package/lib/components/common/APAutoTabInput/APAutoTabInput.js +5 -2
- package/lib/components/common/APSelect/APSelect.js +3 -1
- package/lib/components/common/ErrorBoundary/ErrorBoundary.css +35 -0
- package/lib/components/common/ErrorBoundary/ErrorBoundary.js +87 -0
- package/lib/config/CONFIG.md +4 -0
- package/lib/config/configDefault.json +2 -1
- package/lib/constants/sendOrder/orderEntryFormConstants.js +23 -4
- package/lib/constants/sendOrder/timeInForceConstants.js +3 -1
- package/lib/constants/sendOrder/twapRejectReasons.js +26 -0
- package/lib/helpers/errorTextFormatter.js +13 -4
- package/lib/helpers/errorTextFormatter.test.js +26 -0
- package/lib/helpers/orderHistoryHelper.js +13 -1
- package/lib/helpers/orderHistoryHelper.test.js +58 -13
- package/lib/helpers/passkeyApi.js +228 -0
- package/lib/helpers/passkeyApi.test.js +171 -0
- package/lib/helpers/placeOrderHelper.js +76 -61
- package/lib/helpers/placeOrderHelper.test.js +169 -10
- package/lib/helpers/recalculateOrderHelper.js +4 -1
- package/lib/helpers/recalculateOrderHelper.test.js +88 -2
- package/lib/helpers/twapOrderHelper.js +265 -0
- package/lib/helpers/twapOrderHelper.test.js +467 -0
- package/lib/helpers/twoFactorAuthCancellation.js +38 -0
- package/lib/helpers/webauthnHelper.js +300 -0
- package/lib/helpers/webauthnHelper.test.js +199 -0
- package/lib/hocs/forAccount.js +33 -0
- package/lib/hocs/forAccount.test.js +50 -0
- package/lib/hocs/forVerified.js +16 -2
- package/lib/hocs/withAuthentication.js +3 -1
- package/lib/hocs/withOneSubmission.js +168 -0
- package/lib/index.js +3 -2
- package/lib/layouts/HeaderLayout/HeaderLayout.js +2 -1
- package/lib/layouts/WalletsLayout/WalletsLayoutContainer.js +3 -1
- package/lib/layouts/WalletsLayout/WalletsLayoutContainer.test.js +84 -0
- package/lib/redux/actions/apiActions.js +77 -9
- package/lib/redux/actions/apiActions.test.js +233 -0
- package/lib/redux/actions/authActions.js +514 -198
- package/lib/redux/actions/authActions.test.js +627 -47
- package/lib/redux/actions/depositActions.js +1 -1
- package/lib/redux/actions/depositActions.test.js +100 -30
- package/lib/redux/actions/fusionAuthActions.test.js +265 -84
- package/lib/redux/actions/interestAccountActions.js +12 -3
- package/lib/redux/actions/interestAccountActions.test.js +73 -0
- package/lib/redux/actions/modalActions.js +1 -0
- package/lib/redux/actions/orderEntryActions.blockTrade.test.js +306 -0
- package/lib/redux/actions/orderEntryActions.js +74 -22
- package/lib/redux/actions/orderEntryActions.test.js +63 -11
- package/lib/redux/actions/orderHistoryActions.js +20 -8
- package/lib/redux/actions/orderHistoryActions.test.js +63 -0
- package/lib/redux/actions/userActions.js +379 -179
- package/lib/redux/actions/userActions.test.js +925 -234
- package/lib/redux/actions/withdrawActions.js +62 -29
- package/lib/redux/actions/withdrawActions.test.js +246 -73
- package/lib/redux/actions/withdrawActions.travelRule.test.js +17 -3
- package/lib/redux/margin/actions/marginActions.js +6 -3
- package/lib/redux/margin/actions/marginActions.test.js +166 -0
- package/lib/redux/middlewares/authMiddleware.js +5 -0
- package/lib/redux/middlewares/authMiddleware.test.js +88 -29
- package/lib/redux/reducers/authReducer.js +1 -0
- package/lib/redux/reducers/authReducer.test.js +38 -0
- package/lib/redux/reducers/userReducer.js +10 -0
- package/lib/redux/reducers/userReducer.test.js +29 -0
- package/lib/redux/selectors/orderEntrySelector.js +19 -8
- package/lib/redux/selectors/orderEntrySelector.test.js +209 -0
- package/lib/redux/selectors/orderTotalSelector.test.js +40 -1
- package/lib/redux/selectors/recentActivitySelector.js +8 -2
- package/lib/redux/selectors/recentActivitySelector.v2.test.js +33 -0
- package/lib/redux/selectors/userSelectors.js +6 -1
- package/lib/redux/selectors/userSelectors.test.js +28 -0
- package/lib/services/fms/fms.js +2 -0
- package/lib/services/fms/fms.test.js +35 -0
- package/package.json +4 -4
|
@@ -203,4 +203,170 @@ describe('marginActions', function () {
|
|
|
203
203
|
}, _callee5);
|
|
204
204
|
})));
|
|
205
205
|
});
|
|
206
|
+
describe('getMarginInstruments', function () {
|
|
207
|
+
it('should store the instrument configs the gateway returns', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
|
|
208
|
+
var configs;
|
|
209
|
+
return _regenerator().w(function (_context6) {
|
|
210
|
+
while (1) switch (_context6.n) {
|
|
211
|
+
case 0:
|
|
212
|
+
configs = [{
|
|
213
|
+
InstrumentId: 1,
|
|
214
|
+
InitialRequirement: 0.2
|
|
215
|
+
}];
|
|
216
|
+
_apex["default"].connection.setReturnValue({
|
|
217
|
+
o: JSON.stringify(configs)
|
|
218
|
+
});
|
|
219
|
+
_context6.n = 1;
|
|
220
|
+
return store.dispatch((0, _marginActions.getMarginInstruments)(1));
|
|
221
|
+
case 1:
|
|
222
|
+
expect(_apex["default"].connection.RPCPromise).toHaveBeenCalledWith('GetAllMarginInstrumentConfigs', {
|
|
223
|
+
OMSId: 1
|
|
224
|
+
});
|
|
225
|
+
expect(store.getActions()).toEqual([{
|
|
226
|
+
type: _actionTypes.REQUEST_MARGIN_INSTRUMENTS
|
|
227
|
+
}, {
|
|
228
|
+
type: _actionTypes.RECEIVE_MARGIN_INSTRUMENTS,
|
|
229
|
+
payload: configs
|
|
230
|
+
}]);
|
|
231
|
+
case 2:
|
|
232
|
+
return _context6.a(2);
|
|
233
|
+
}
|
|
234
|
+
}, _callee6);
|
|
235
|
+
})));
|
|
236
|
+
it('should store an empty list when the gateway answers with an error payload', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7() {
|
|
237
|
+
return _regenerator().w(function (_context7) {
|
|
238
|
+
while (1) switch (_context7.n) {
|
|
239
|
+
case 0:
|
|
240
|
+
_apex["default"].connection.setReturnValue({
|
|
241
|
+
o: JSON.stringify({
|
|
242
|
+
result: false,
|
|
243
|
+
errormsg: 'Operation Not Supported',
|
|
244
|
+
errorcode: 106,
|
|
245
|
+
detail: null
|
|
246
|
+
})
|
|
247
|
+
});
|
|
248
|
+
_context7.n = 1;
|
|
249
|
+
return store.dispatch((0, _marginActions.getMarginInstruments)(1));
|
|
250
|
+
case 1:
|
|
251
|
+
expect(store.getActions()).toEqual([{
|
|
252
|
+
type: _actionTypes.REQUEST_MARGIN_INSTRUMENTS
|
|
253
|
+
}, {
|
|
254
|
+
type: _actionTypes.RECEIVE_MARGIN_INSTRUMENTS,
|
|
255
|
+
payload: []
|
|
256
|
+
}]);
|
|
257
|
+
case 2:
|
|
258
|
+
return _context7.a(2);
|
|
259
|
+
}
|
|
260
|
+
}, _callee7);
|
|
261
|
+
})));
|
|
262
|
+
});
|
|
263
|
+
describe('getMarginProductsConfig', function () {
|
|
264
|
+
it('should store the product configs the gateway returns', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
|
|
265
|
+
var configs;
|
|
266
|
+
return _regenerator().w(function (_context8) {
|
|
267
|
+
while (1) switch (_context8.n) {
|
|
268
|
+
case 0:
|
|
269
|
+
configs = [{
|
|
270
|
+
ProductId: 1,
|
|
271
|
+
HourlyInterestRate: 0.0001
|
|
272
|
+
}];
|
|
273
|
+
_apex["default"].connection.setReturnValue({
|
|
274
|
+
o: JSON.stringify(configs)
|
|
275
|
+
});
|
|
276
|
+
_context8.n = 1;
|
|
277
|
+
return store.dispatch((0, _marginActions.getMarginProductsConfig)());
|
|
278
|
+
case 1:
|
|
279
|
+
expect(_apex["default"].connection.RPCPromise).toHaveBeenCalledWith('GetAllMarginProductConfigs', {
|
|
280
|
+
OMSId: 1
|
|
281
|
+
});
|
|
282
|
+
expect(store.getActions()).toEqual([{
|
|
283
|
+
type: _actionTypes.RECEIVE_MARGIN_PRODUCT_CONFIGS,
|
|
284
|
+
payload: configs
|
|
285
|
+
}]);
|
|
286
|
+
case 2:
|
|
287
|
+
return _context8.a(2);
|
|
288
|
+
}
|
|
289
|
+
}, _callee8);
|
|
290
|
+
})));
|
|
291
|
+
it('should store an empty list when the gateway answers with an error payload', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9() {
|
|
292
|
+
return _regenerator().w(function (_context9) {
|
|
293
|
+
while (1) switch (_context9.n) {
|
|
294
|
+
case 0:
|
|
295
|
+
_apex["default"].connection.setReturnValue({
|
|
296
|
+
o: JSON.stringify({
|
|
297
|
+
result: false,
|
|
298
|
+
errormsg: 'Operation Not Supported',
|
|
299
|
+
errorcode: 106,
|
|
300
|
+
detail: null
|
|
301
|
+
})
|
|
302
|
+
});
|
|
303
|
+
_context9.n = 1;
|
|
304
|
+
return store.dispatch((0, _marginActions.getMarginProductsConfig)());
|
|
305
|
+
case 1:
|
|
306
|
+
expect(store.getActions()).toEqual([{
|
|
307
|
+
type: _actionTypes.RECEIVE_MARGIN_PRODUCT_CONFIGS,
|
|
308
|
+
payload: []
|
|
309
|
+
}]);
|
|
310
|
+
case 2:
|
|
311
|
+
return _context9.a(2);
|
|
312
|
+
}
|
|
313
|
+
}, _callee9);
|
|
314
|
+
})));
|
|
315
|
+
});
|
|
316
|
+
describe('getAccountMarginBalances', function () {
|
|
317
|
+
it('should store the balances the gateway returns', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0() {
|
|
318
|
+
var balances, result;
|
|
319
|
+
return _regenerator().w(function (_context0) {
|
|
320
|
+
while (1) switch (_context0.n) {
|
|
321
|
+
case 0:
|
|
322
|
+
balances = [{
|
|
323
|
+
ProductId: 1,
|
|
324
|
+
Amount: 5
|
|
325
|
+
}];
|
|
326
|
+
_apex["default"].connection.setReturnValue({
|
|
327
|
+
o: JSON.stringify(balances)
|
|
328
|
+
});
|
|
329
|
+
_context0.n = 1;
|
|
330
|
+
return store.dispatch((0, _marginActions.getAccountMarginBalances)(2));
|
|
331
|
+
case 1:
|
|
332
|
+
result = _context0.v;
|
|
333
|
+
expect(store.getActions()).toEqual([{
|
|
334
|
+
type: _actionTypes.REQUEST_MARGIN_BALANCES
|
|
335
|
+
}, {
|
|
336
|
+
type: _actionTypes.RECEIVE_MARGIN_BALANCES,
|
|
337
|
+
payload: balances
|
|
338
|
+
}]);
|
|
339
|
+
expect(result).toBe(true);
|
|
340
|
+
case 2:
|
|
341
|
+
return _context0.a(2);
|
|
342
|
+
}
|
|
343
|
+
}, _callee0);
|
|
344
|
+
})));
|
|
345
|
+
it('should store an empty list when the gateway answers with an error payload', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
|
|
346
|
+
return _regenerator().w(function (_context1) {
|
|
347
|
+
while (1) switch (_context1.n) {
|
|
348
|
+
case 0:
|
|
349
|
+
_apex["default"].connection.setReturnValue({
|
|
350
|
+
o: JSON.stringify({
|
|
351
|
+
result: false,
|
|
352
|
+
errormsg: 'Operation Not Supported',
|
|
353
|
+
errorcode: 106,
|
|
354
|
+
detail: null
|
|
355
|
+
})
|
|
356
|
+
});
|
|
357
|
+
_context1.n = 1;
|
|
358
|
+
return store.dispatch((0, _marginActions.getAccountMarginBalances)(2));
|
|
359
|
+
case 1:
|
|
360
|
+
expect(store.getActions()).toEqual([{
|
|
361
|
+
type: _actionTypes.REQUEST_MARGIN_BALANCES
|
|
362
|
+
}, {
|
|
363
|
+
type: _actionTypes.RECEIVE_MARGIN_BALANCES,
|
|
364
|
+
payload: []
|
|
365
|
+
}]);
|
|
366
|
+
case 2:
|
|
367
|
+
return _context1.a(2);
|
|
368
|
+
}
|
|
369
|
+
}, _callee1);
|
|
370
|
+
})));
|
|
371
|
+
});
|
|
206
372
|
});
|
|
@@ -11,6 +11,7 @@ var _affiliateActions = require("../actions/affiliateActions");
|
|
|
11
11
|
var _reportActions = require("../actions/reportActions");
|
|
12
12
|
var _wsConnectionActions = require("../actions/wsConnectionActions");
|
|
13
13
|
var _authActions = require("../actions/authActions");
|
|
14
|
+
var _safeSessionStorage = require("../../helpers/safeSessionStorage");
|
|
14
15
|
var _appActions = require("../actions/appActions");
|
|
15
16
|
var _apiActions = require("../actions/apiActions");
|
|
16
17
|
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
@@ -102,6 +103,8 @@ var onLogin = function onLogin(dispatch, action) {
|
|
|
102
103
|
var onLogout = function onLogout(action) {
|
|
103
104
|
var skipReload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
104
105
|
localStorage.removeItem('token');
|
|
106
|
+
// the next sign-in in this tab is a new session, which is asked again
|
|
107
|
+
(0, _safeSessionStorage.removeSessionItem)(_authActions.PASSKEY_PROMPTED_KEY);
|
|
105
108
|
if (action.type === _authActions.FORCED_LOGOUT && !skipReload) {
|
|
106
109
|
window.location.reload();
|
|
107
110
|
}
|
|
@@ -127,6 +130,8 @@ var initDataAfterLogin = function initDataAfterLogin(userId) {
|
|
|
127
130
|
dispatch((0, _affiliateActions.getAffiliateCount)());
|
|
128
131
|
dispatch((0, _reportActions.getUserReports)(userId));
|
|
129
132
|
dispatch((0, _reportActions.getUserReportWriterResults)());
|
|
133
|
+
// every way in passes here (password, 2FA code or passkey, SSO, a reload's session token)
|
|
134
|
+
dispatch((0, _authActions.promptForRequiredPasskey)());
|
|
130
135
|
case 1:
|
|
131
136
|
return _context2.a(2);
|
|
132
137
|
}
|
|
@@ -8,6 +8,7 @@ var _userActions = require("../actions/userActions");
|
|
|
8
8
|
var _reportActions = require("../actions/reportActions");
|
|
9
9
|
var _apiKeyActions = require("../actions/apiKeyActions");
|
|
10
10
|
var auth = _interopRequireWildcard(require("../actions/authActions"));
|
|
11
|
+
var _passkeyApi = require("../../helpers/passkeyApi");
|
|
11
12
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
12
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
13
14
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -101,6 +102,15 @@ jest.mock('../actions/apiActions', function () {
|
|
|
101
102
|
})
|
|
102
103
|
};
|
|
103
104
|
});
|
|
105
|
+
jest.mock('../../helpers/passkeyApi', function () {
|
|
106
|
+
return {
|
|
107
|
+
PASSKEY_TFA_TYPE: 'WebAuthn',
|
|
108
|
+
answerWithPasskey: jest.fn(),
|
|
109
|
+
getPasskeyStatus: jest.fn(function () {
|
|
110
|
+
return Promise.resolve({});
|
|
111
|
+
})
|
|
112
|
+
};
|
|
113
|
+
});
|
|
104
114
|
describe('authMiddleware', function () {
|
|
105
115
|
var userId = 50;
|
|
106
116
|
var token = 123;
|
|
@@ -184,6 +194,41 @@ describe('authMiddleware', function () {
|
|
|
184
194
|
}
|
|
185
195
|
}, _callee3);
|
|
186
196
|
})));
|
|
197
|
+
it('asks a user who must have a passkey and has none to add one, whichever way they signed in', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
|
|
198
|
+
var signedIn;
|
|
199
|
+
return _regenerator().w(function (_context4) {
|
|
200
|
+
while (1) switch (_context4.n) {
|
|
201
|
+
case 0:
|
|
202
|
+
sessionStorage.clear();
|
|
203
|
+
_passkeyApi.getPasskeyStatus.mockResolvedValueOnce({
|
|
204
|
+
Enabled: true,
|
|
205
|
+
Passkeys: 0,
|
|
206
|
+
PasskeyRequired: true
|
|
207
|
+
});
|
|
208
|
+
signedIn = mockStore({
|
|
209
|
+
auth: {},
|
|
210
|
+
user: {
|
|
211
|
+
OMSId: 1
|
|
212
|
+
},
|
|
213
|
+
snackbar: {
|
|
214
|
+
snacks: []
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
_context4.n = 1;
|
|
218
|
+
return (0, _authMiddleware["default"])(signedIn)(next)(successAuthAction);
|
|
219
|
+
case 1:
|
|
220
|
+
_context4.n = 2;
|
|
221
|
+
return new Promise(function (resolve) {
|
|
222
|
+
return setTimeout(resolve, 0);
|
|
223
|
+
});
|
|
224
|
+
case 2:
|
|
225
|
+
expect(_passkeyApi.getPasskeyStatus).toHaveBeenCalled();
|
|
226
|
+
expect(JSON.stringify(signedIn.getActions())).toContain('passkeyRequiredSnack');
|
|
227
|
+
case 3:
|
|
228
|
+
return _context4.a(2);
|
|
229
|
+
}
|
|
230
|
+
}, _callee4);
|
|
231
|
+
})));
|
|
187
232
|
});
|
|
188
233
|
describe('fail auth', function () {
|
|
189
234
|
var failAuthAction = null;
|
|
@@ -195,23 +240,37 @@ describe('authMiddleware', function () {
|
|
|
195
240
|
}
|
|
196
241
|
};
|
|
197
242
|
});
|
|
198
|
-
it('should remove token from local storage', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
199
|
-
return _regenerator().w(function (
|
|
200
|
-
while (1) switch (
|
|
243
|
+
it('should remove token from local storage', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
|
|
244
|
+
return _regenerator().w(function (_context5) {
|
|
245
|
+
while (1) switch (_context5.n) {
|
|
201
246
|
case 0:
|
|
202
|
-
|
|
247
|
+
_context5.n = 1;
|
|
203
248
|
return (0, _authMiddleware["default"])(store)(next)(failAuthAction);
|
|
204
249
|
case 1:
|
|
205
250
|
expect(localStorage.removeItem).toHaveBeenCalledWith('token');
|
|
206
251
|
case 2:
|
|
207
|
-
return
|
|
252
|
+
return _context5.a(2);
|
|
208
253
|
}
|
|
209
|
-
},
|
|
254
|
+
}, _callee5);
|
|
255
|
+
})));
|
|
256
|
+
it('lets the next sign-in in this tab be asked for a required passkey again', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
|
|
257
|
+
return _regenerator().w(function (_context6) {
|
|
258
|
+
while (1) switch (_context6.n) {
|
|
259
|
+
case 0:
|
|
260
|
+
sessionStorage.setItem(auth.PASSKEY_PROMPTED_KEY, 'true');
|
|
261
|
+
_context6.n = 1;
|
|
262
|
+
return (0, _authMiddleware["default"])(store)(next)(failAuthAction);
|
|
263
|
+
case 1:
|
|
264
|
+
expect(sessionStorage.getItem(auth.PASSKEY_PROMPTED_KEY)).toBeNull();
|
|
265
|
+
case 2:
|
|
266
|
+
return _context6.a(2);
|
|
267
|
+
}
|
|
268
|
+
}, _callee6);
|
|
210
269
|
})));
|
|
211
|
-
it('should not reload the page for a self-initiated logout, even if the user was authenticated before', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
270
|
+
it('should not reload the page for a self-initiated logout, even if the user was authenticated before', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7() {
|
|
212
271
|
var reloadMock;
|
|
213
|
-
return _regenerator().w(function (
|
|
214
|
-
while (1) switch (
|
|
272
|
+
return _regenerator().w(function (_context7) {
|
|
273
|
+
while (1) switch (_context7.p = _context7.n) {
|
|
215
274
|
case 0:
|
|
216
275
|
jest.useFakeTimers();
|
|
217
276
|
reloadMock = jest.fn();
|
|
@@ -223,28 +282,28 @@ describe('authMiddleware', function () {
|
|
|
223
282
|
configurable: true
|
|
224
283
|
});
|
|
225
284
|
failAuthAction.payload.wasAuthenticatedBefore = true;
|
|
226
|
-
|
|
227
|
-
|
|
285
|
+
_context7.p = 1;
|
|
286
|
+
_context7.n = 2;
|
|
228
287
|
return (0, _authMiddleware["default"])(store)(next)(failAuthAction);
|
|
229
288
|
case 2:
|
|
230
289
|
expect(reloadMock).not.toHaveBeenCalled();
|
|
231
290
|
case 3:
|
|
232
|
-
|
|
291
|
+
_context7.p = 3;
|
|
233
292
|
// authMiddleware suppresses a FORCED_LOGOUT reload for 1s after a self-initiated
|
|
234
293
|
// logout; flush that debounce so it doesn't leak into other tests, even if the
|
|
235
294
|
// assertion above fails.
|
|
236
295
|
jest.advanceTimersByTime(1000);
|
|
237
296
|
jest.useRealTimers();
|
|
238
|
-
return
|
|
297
|
+
return _context7.f(3);
|
|
239
298
|
case 4:
|
|
240
|
-
return
|
|
299
|
+
return _context7.a(2);
|
|
241
300
|
}
|
|
242
|
-
},
|
|
301
|
+
}, _callee7, null, [[1,, 3, 4]]);
|
|
243
302
|
})));
|
|
244
|
-
it('should suppress a FORCED_LOGOUT reload within 1s of a self-initiated logout, then reload again once the window elapses', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
303
|
+
it('should suppress a FORCED_LOGOUT reload within 1s of a self-initiated logout, then reload again once the window elapses', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
|
|
245
304
|
var reloadMock, forcedLogoutAction;
|
|
246
|
-
return _regenerator().w(function (
|
|
247
|
-
while (1) switch (
|
|
305
|
+
return _regenerator().w(function (_context8) {
|
|
306
|
+
while (1) switch (_context8.n) {
|
|
248
307
|
case 0:
|
|
249
308
|
jest.useFakeTimers();
|
|
250
309
|
reloadMock = jest.fn();
|
|
@@ -259,23 +318,23 @@ describe('authMiddleware', function () {
|
|
|
259
318
|
type: auth.FORCED_LOGOUT,
|
|
260
319
|
payload: {}
|
|
261
320
|
};
|
|
262
|
-
|
|
321
|
+
_context8.n = 1;
|
|
263
322
|
return (0, _authMiddleware["default"])(store)(next)(failAuthAction);
|
|
264
323
|
case 1:
|
|
265
|
-
|
|
324
|
+
_context8.n = 2;
|
|
266
325
|
return (0, _authMiddleware["default"])(store)(next)(forcedLogoutAction);
|
|
267
326
|
case 2:
|
|
268
327
|
expect(reloadMock).not.toHaveBeenCalled();
|
|
269
328
|
jest.advanceTimersByTime(1000);
|
|
270
|
-
|
|
329
|
+
_context8.n = 3;
|
|
271
330
|
return (0, _authMiddleware["default"])(store)(next)(forcedLogoutAction);
|
|
272
331
|
case 3:
|
|
273
332
|
expect(reloadMock).toHaveBeenCalled();
|
|
274
333
|
jest.useRealTimers();
|
|
275
334
|
case 4:
|
|
276
|
-
return
|
|
335
|
+
return _context8.a(2);
|
|
277
336
|
}
|
|
278
|
-
},
|
|
337
|
+
}, _callee8);
|
|
279
338
|
})));
|
|
280
339
|
});
|
|
281
340
|
describe('forced logout', function () {
|
|
@@ -288,10 +347,10 @@ describe('authMiddleware', function () {
|
|
|
288
347
|
jest.resetModules();
|
|
289
348
|
isolatedAuthMiddleware = require('./authMiddleware')["default"];
|
|
290
349
|
});
|
|
291
|
-
it('should remove token from local storage and reload the page', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
350
|
+
it('should remove token from local storage and reload the page', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9() {
|
|
292
351
|
var reloadMock, forcedLogoutAction;
|
|
293
|
-
return _regenerator().w(function (
|
|
294
|
-
while (1) switch (
|
|
352
|
+
return _regenerator().w(function (_context9) {
|
|
353
|
+
while (1) switch (_context9.n) {
|
|
295
354
|
case 0:
|
|
296
355
|
reloadMock = jest.fn();
|
|
297
356
|
Object.defineProperty(window, 'location', {
|
|
@@ -305,15 +364,15 @@ describe('authMiddleware', function () {
|
|
|
305
364
|
type: auth.FORCED_LOGOUT,
|
|
306
365
|
payload: {}
|
|
307
366
|
};
|
|
308
|
-
|
|
367
|
+
_context9.n = 1;
|
|
309
368
|
return isolatedAuthMiddleware(store)(next)(forcedLogoutAction);
|
|
310
369
|
case 1:
|
|
311
370
|
expect(localStorage.removeItem).toHaveBeenCalledWith('token');
|
|
312
371
|
expect(reloadMock).toHaveBeenCalled();
|
|
313
372
|
case 2:
|
|
314
|
-
return
|
|
373
|
+
return _context9.a(2);
|
|
315
374
|
}
|
|
316
|
-
},
|
|
375
|
+
}, _callee9);
|
|
317
376
|
})));
|
|
318
377
|
});
|
|
319
378
|
});
|
|
@@ -33,6 +33,7 @@ function auth() {
|
|
|
33
33
|
case _authActions.AUTH_REDIRECT:
|
|
34
34
|
case _authActions.AUTH_2FA_REQUIRED:
|
|
35
35
|
case _authActions.ENABLE_2FA_REQUIRED:
|
|
36
|
+
case _authActions.AUTH_PASSKEY_ONLY:
|
|
36
37
|
return _objectSpread(_objectSpread({}, state), action.payload);
|
|
37
38
|
case _authActions.AUTH_SUCCESS:
|
|
38
39
|
{
|
|
@@ -134,4 +134,42 @@ describe("action ".concat(actions.AUTH_2FA_REQUIRED), function () {
|
|
|
134
134
|
});
|
|
135
135
|
expect(newState).toEqual(expectedState);
|
|
136
136
|
});
|
|
137
|
+
});
|
|
138
|
+
describe('passkeyOnly', function () {
|
|
139
|
+
var passkeyOnlySignIn = function passkeyOnlySignIn() {
|
|
140
|
+
return (0, _authReducer["default"])(undefined, actions.require2FA({
|
|
141
|
+
UserId: 1,
|
|
142
|
+
AuthType: 'Google',
|
|
143
|
+
PasskeyOnly: true
|
|
144
|
+
}));
|
|
145
|
+
};
|
|
146
|
+
it('is forgotten on logout, so the next user in the tab is not offered only a passkey', function () {
|
|
147
|
+
var signedIn = (0, _authReducer["default"])(passkeyOnlySignIn(), actions.authSuccess({
|
|
148
|
+
Authenticated: true,
|
|
149
|
+
UserId: 1,
|
|
150
|
+
SessionToken: 't'
|
|
151
|
+
}));
|
|
152
|
+
expect((0, _authReducer["default"])(signedIn, actions.setUserNotAuthenticated(true)).passkeyOnly).toBe(false);
|
|
153
|
+
});
|
|
154
|
+
it('is kept through the sign-in it was asked for', function () {
|
|
155
|
+
var signedIn = (0, _authReducer["default"])(passkeyOnlySignIn(), actions.authSuccess({
|
|
156
|
+
Authenticated: true,
|
|
157
|
+
UserId: 1,
|
|
158
|
+
SessionToken: 't'
|
|
159
|
+
}));
|
|
160
|
+
expect(signedIn.passkeyOnly).toBe(true);
|
|
161
|
+
});
|
|
162
|
+
it('is taken from a sign-in or session reply that carries it', function () {
|
|
163
|
+
var reply = {
|
|
164
|
+
Authenticated: true,
|
|
165
|
+
UserId: 1,
|
|
166
|
+
SessionToken: 't',
|
|
167
|
+
PasskeyOnly: true
|
|
168
|
+
};
|
|
169
|
+
expect((0, _authReducer["default"])(undefined, actions.authSuccess(reply)).passkeyOnly).toBe(true);
|
|
170
|
+
});
|
|
171
|
+
it("follows the gateway's passkey status, which a reloaded page reads again", function () {
|
|
172
|
+
expect((0, _authReducer["default"])(undefined, actions.setPasskeyOnly(true)).passkeyOnly).toBe(true);
|
|
173
|
+
expect((0, _authReducer["default"])(passkeyOnlySignIn(), actions.setPasskeyOnly(false)).passkeyOnly).toBe(false);
|
|
174
|
+
});
|
|
137
175
|
});
|
|
@@ -29,6 +29,7 @@ var getInitialState = function getInitialState() {
|
|
|
29
29
|
userInfo: {},
|
|
30
30
|
permissions: [],
|
|
31
31
|
accounts: [],
|
|
32
|
+
accountsLoaded: false,
|
|
32
33
|
userConfig: [],
|
|
33
34
|
selectedAccountId: parseInt(localStorage.getItem('selectedAccountId'), 10) || undefined,
|
|
34
35
|
kyc: {
|
|
@@ -74,6 +75,15 @@ function user() {
|
|
|
74
75
|
accounts: mergedAccounts
|
|
75
76
|
});
|
|
76
77
|
}
|
|
78
|
+
case _userActions.ACCOUNTS_LOADED:
|
|
79
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
80
|
+
accountsLoaded: true,
|
|
81
|
+
// USER_INFO_FETCHED selects the user's default AccountId, which can
|
|
82
|
+
// name an account the user is no longer linked to. With no accounts
|
|
83
|
+
// there is nothing to select, and account-scoped calls for that id are
|
|
84
|
+
// refused, so clear it.
|
|
85
|
+
selectedAccountId: state.accounts.length ? state.selectedAccountId : undefined
|
|
86
|
+
});
|
|
77
87
|
case _kycActions.UPDATE_ACCOUNT:
|
|
78
88
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
79
89
|
accounts: (0, _arrayHelper.updateAccountInArray)(state.accounts, payload)
|
|
@@ -13,6 +13,7 @@ describe('user reducer', function () {
|
|
|
13
13
|
userInfo: {},
|
|
14
14
|
permissions: [],
|
|
15
15
|
accounts: [],
|
|
16
|
+
accountsLoaded: false,
|
|
16
17
|
kyc: {
|
|
17
18
|
urlParams: null
|
|
18
19
|
},
|
|
@@ -23,6 +24,34 @@ describe('user reducer', function () {
|
|
|
23
24
|
};
|
|
24
25
|
expect((0, _userReducer["default"])(undefined, {})).toEqual(expectedState);
|
|
25
26
|
});
|
|
27
|
+
it("should handle ".concat(actions.ACCOUNTS_LOADED, " action"), function () {
|
|
28
|
+
var stateBefore = (0, _userReducer["default"])(undefined, {});
|
|
29
|
+
expect(stateBefore.accountsLoaded).toBe(false);
|
|
30
|
+
var stateAfter = (0, _userReducer["default"])(stateBefore, actions.accountsLoaded());
|
|
31
|
+
expect(stateAfter.accountsLoaded).toBe(true);
|
|
32
|
+
// Loaded with an empty accounts array is the accountless case, and must
|
|
33
|
+
// stay distinguishable from the not-yet-fetched case above.
|
|
34
|
+
expect(stateAfter.accounts).toEqual([]);
|
|
35
|
+
});
|
|
36
|
+
it("should clear selectedAccountId on ".concat(actions.ACCOUNTS_LOADED, " when the user has no accounts"), function () {
|
|
37
|
+
// The user's default AccountId still names an account they were unlinked from.
|
|
38
|
+
var stateBefore = (0, _userReducer["default"])(undefined, actions.userInfoFetched({
|
|
39
|
+
AccountId: 125
|
|
40
|
+
}));
|
|
41
|
+
expect(stateBefore.selectedAccountId).toBe(125);
|
|
42
|
+
var stateAfter = (0, _userReducer["default"])(stateBefore, actions.accountsLoaded());
|
|
43
|
+
expect(stateAfter.selectedAccountId).toBeUndefined();
|
|
44
|
+
});
|
|
45
|
+
it("should keep selectedAccountId on ".concat(actions.ACCOUNTS_LOADED, " when the user has accounts"), function () {
|
|
46
|
+
var state = (0, _userReducer["default"])(undefined, actions.userInfoFetched({
|
|
47
|
+
AccountId: 7
|
|
48
|
+
}));
|
|
49
|
+
state = (0, _userReducer["default"])(state, actions.receiveAccount([{
|
|
50
|
+
AccountId: 7
|
|
51
|
+
}]));
|
|
52
|
+
state = (0, _userReducer["default"])(state, actions.accountsLoaded());
|
|
53
|
+
expect(state.selectedAccountId).toBe(7);
|
|
54
|
+
});
|
|
26
55
|
it("should handle ".concat(actions.USER_INFO_FETCHED, " action"), function () {
|
|
27
56
|
var user = {
|
|
28
57
|
userID: 40
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.selectSpotMaxQuantity = exports.selectPayingBalance = exports.selectOrderTypes = exports.selectOrderSide = exports.selectOrderPrice = exports.selectOrderNet = exports.selectOrderMaxQuantity = exports.selectOrderFormValues = exports.selectOrderFee = exports.selectMarketPrice = exports.selectMarginMaxQuantity = exports.selectLevel1ForInstrument = exports.selectIsBuyForm = exports.selectFuturesOrderFormValues = exports.selectDefaultFormValues = exports.selectAdvancedOrderFormValues = exports.orderTotalSelector = exports.hasCreditTierSelector = exports.getOrderFormValuesSelector = void 0;
|
|
6
|
+
exports.selectTwapSchedule = exports.selectSpotMaxQuantity = exports.selectPayingBalance = exports.selectOrderTypes = exports.selectOrderSide = exports.selectOrderPrice = exports.selectOrderNet = exports.selectOrderMaxQuantity = exports.selectOrderFormValues = exports.selectOrderFee = exports.selectMarketPrice = exports.selectMarginMaxQuantity = exports.selectLevel1ForInstrument = exports.selectIsBuyForm = exports.selectFuturesOrderFormValues = exports.selectDefaultFormValues = exports.selectAdvancedOrderFormValues = exports.orderTotalSelector = exports.hasCreditTierSelector = exports.getOrderFormValuesSelector = void 0;
|
|
7
7
|
var _reselect = require("reselect");
|
|
8
8
|
var _bignumber = require("bignumber.js");
|
|
9
9
|
var _orderEntryFormConstants = require("../../constants/sendOrder/orderEntryFormConstants");
|
|
@@ -14,6 +14,8 @@ var _productsSelectors = require("./productsSelectors");
|
|
|
14
14
|
var _orderHelper = require("../../helpers/orderHelper");
|
|
15
15
|
var _config = _interopRequireDefault(require("../../config"));
|
|
16
16
|
var _placeOrderHelper = require("../../helpers/placeOrderHelper");
|
|
17
|
+
var _twapOrderHelper = require("../../helpers/twapOrderHelper");
|
|
18
|
+
var _decimalPlacesHelper = require("../../helpers/decimalPlaces/decimalPlacesHelper");
|
|
17
19
|
var _productPositionSelectors = require("./productPositionSelectors");
|
|
18
20
|
var _futuresSelectors = require("../futures/selectors/futuresSelectors");
|
|
19
21
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
@@ -89,6 +91,8 @@ var selectOrderPrice = exports.selectOrderPrice = (0, _reselect.createSelector)(
|
|
|
89
91
|
return values.stopPrice;
|
|
90
92
|
case _orderEntryFormConstants.orderTypes.stopLimit.displayName:
|
|
91
93
|
return values.limitPrice;
|
|
94
|
+
case _orderEntryFormConstants.orderTypes.twap.displayName:
|
|
95
|
+
return (0, _twapOrderHelper.hasLimitPrice)(values) ? values.limitPrice : marketPrice;
|
|
92
96
|
default:
|
|
93
97
|
return marketPrice;
|
|
94
98
|
}
|
|
@@ -108,11 +112,12 @@ var selectMarginMaxQuantity = exports.selectMarginMaxQuantity = (0, _reselect.cr
|
|
|
108
112
|
var selectOrderMaxQuantity = exports.selectOrderMaxQuantity = (0, _reselect.createSelector)([_selectors.isMarginActiveSelector, selectSpotMaxQuantity, selectMarginMaxQuantity], function (isMarginActive, spotMax, marginMax) {
|
|
109
113
|
return isMarginActive ? marginMax : spotMax;
|
|
110
114
|
});
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
115
|
+
|
|
116
|
+
// Peg prices come from the selected instrument: only the Advanced Orders form has an `instrument` field,
|
|
117
|
+
// and picking one there selects that instrument.
|
|
118
|
+
var orderTotalSelector = exports.orderTotalSelector = (0, _reselect.createSelector)([selectLevel1ForInstrument, function (state) {
|
|
114
119
|
return state.apexCore.level2;
|
|
115
|
-
}, selectOrderFormValues], function (
|
|
120
|
+
}, selectOrderFormValues], function (level1ForInstrument, level2, form) {
|
|
116
121
|
var orderType = form.orderType,
|
|
117
122
|
quantity = form.quantity,
|
|
118
123
|
value = form.value,
|
|
@@ -122,7 +127,8 @@ var orderTotalSelector = exports.orderTotalSelector = (0, _reselect.createSelect
|
|
|
122
127
|
limitPrice = form.limitPrice,
|
|
123
128
|
trailingAmount = form.trailingAmount,
|
|
124
129
|
limitOffset = form.limitOffset;
|
|
125
|
-
|
|
130
|
+
var isMarketFormTwap = (0, _twapOrderHelper.isTwapOrderType)(orderType) && !(0, _twapOrderHelper.hasLimitPrice)(form);
|
|
131
|
+
if (orderType === _orderEntryFormConstants.orderTypes.market.displayName || isMarketFormTwap) {
|
|
126
132
|
var _config$OrderCalcBuff = _config["default"].OrderCalcBuffer,
|
|
127
133
|
_config$OrderCalcBuff2 = _config$OrderCalcBuff === void 0 ? {} : _config$OrderCalcBuff,
|
|
128
134
|
priceBuffer = _config$OrderCalcBuff2.priceBuffer;
|
|
@@ -145,12 +151,12 @@ var orderTotalSelector = exports.orderTotalSelector = (0, _reselect.createSelect
|
|
|
145
151
|
return _price2.times(quantity).toNumber();
|
|
146
152
|
}
|
|
147
153
|
if (orderType === _orderEntryFormConstants.orderTypes.trailingStopMarket.displayName) {
|
|
148
|
-
var pegPrice = new _bignumber.BigNumber((0, _placeOrderHelper.getPegPriceByType)(
|
|
154
|
+
var pegPrice = new _bignumber.BigNumber((0, _placeOrderHelper.getPegPriceByType)(level1ForInstrument, form));
|
|
149
155
|
var _price3 = side === _orderEntryFormConstants.buyValue ? pegPrice.plus(trailingAmount) : pegPrice.minus(trailingAmount);
|
|
150
156
|
return _price3.times(quantity).toNumber();
|
|
151
157
|
}
|
|
152
158
|
if (orderType === _orderEntryFormConstants.orderTypes.trailingStopLimit.displayName) {
|
|
153
|
-
var _pegPrice = new _bignumber.BigNumber((0, _placeOrderHelper.getPegPriceByType)(
|
|
159
|
+
var _pegPrice = new _bignumber.BigNumber((0, _placeOrderHelper.getPegPriceByType)(level1ForInstrument, form));
|
|
154
160
|
var _price4 = side === _orderEntryFormConstants.buyValue ? _pegPrice.plus(trailingAmount).plus(limitOffset) : _pegPrice.minus(trailingAmount).minus(limitOffset);
|
|
155
161
|
return _price4.times(quantity).toNumber();
|
|
156
162
|
}
|
|
@@ -173,6 +179,11 @@ var selectOrderNet = exports.selectOrderNet = (0, _reselect.createSelector)([_in
|
|
|
173
179
|
var selectOrderFee = exports.selectOrderFee = (0, _reselect.createSelector)([selectOrderFormValues, _productPositionSelectors.productsSelector], function (formValues, products) {
|
|
174
180
|
return (0, _orderHelper.getOrderFee)(formValues, products);
|
|
175
181
|
});
|
|
182
|
+
|
|
183
|
+
/** The TWAP schedule (slices, slice size, interval) derived from the form; see twapOrderHelper. */
|
|
184
|
+
var selectTwapSchedule = exports.selectTwapSchedule = (0, _reselect.createSelector)([selectOrderFormValues, _instrumentPositionSelectors.selectedInstrumentSelector, selectMarketPrice], function (formValues, instrument, marketPrice) {
|
|
185
|
+
return (0, _twapOrderHelper.getTwapSchedule)(formValues, instrument, marketPrice, instrument ? (0, _decimalPlacesHelper.convertIncrementToIntDecimalPlaces)(instrument.QuantityIncrement) : 2, instrument ? (0, _decimalPlacesHelper.convertIncrementToIntDecimalPlaces)(instrument.PriceIncrement) : 2);
|
|
186
|
+
});
|
|
176
187
|
var hasCreditTierSelector = exports.hasCreditTierSelector = (0, _reselect.createSelector)(function (state) {
|
|
177
188
|
return state.user.accounts;
|
|
178
189
|
}, function (state) {
|