@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.
Files changed (132) hide show
  1. package/lib/apex.integration.test.js +435 -0
  2. package/lib/apex.js +37 -1
  3. package/lib/apex.test.js +138 -0
  4. package/lib/components/2FA/PasskeyOption.js +126 -0
  5. package/lib/components/2FA/TwoFactorAuthComponent.js +24 -5
  6. package/lib/components/2FA/TwoFactorAuthComponent.test.js +94 -0
  7. package/lib/components/2FA/TwoFactorAuthContainer.js +139 -27
  8. package/lib/components/2FA/TwoFactorAuthContainer.test.js +627 -0
  9. package/lib/components/AccountsDropdown/AccountsDropdownComponent.css +6 -0
  10. package/lib/components/AccountsDropdown/AccountsDropdownComponent.js +6 -2
  11. package/lib/components/AccountsDropdown/AccountsDropdownComponent.test.js +43 -0
  12. package/lib/components/AccountsDropdown/AccountsDropdownContainer.js +3 -1
  13. package/lib/components/BalancesList/BalancesListContainer.js +4 -1
  14. package/lib/components/ConfirmBlockTradeModal/ConfirmBlockTradeModalContainer.js +34 -6
  15. package/lib/components/ConfirmBlockTradeModal/ConfirmBlockTradeModalContainer.test.js +298 -0
  16. package/lib/components/ConfirmOrderModal/ConfirmOrderModalComponent.js +26 -4
  17. package/lib/components/ConfirmOrderModal/ConfirmOrderModalContainer.js +4 -1
  18. package/lib/components/DigitalAssets/digitalAssetsPriceLabel.test.js +238 -0
  19. package/lib/components/EnableTwoFactorAuth/Disable2FAForm.js +22 -7
  20. package/lib/components/EnableTwoFactorAuth/Disable2FAModal.js +15 -5
  21. package/lib/components/EnableTwoFactorAuth/Disable2FAModal.test.js +460 -0
  22. package/lib/components/EnableTwoFactorAuth/Disable2FAModalContainer.js +108 -16
  23. package/lib/components/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.js +7 -0
  24. package/lib/components/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.test.js +105 -0
  25. package/lib/components/EnableTwoFactorAuth/EnableTwoFactorAuthContainerFactory.js +15 -3
  26. package/lib/components/FusionAuth/UnlinkOAuthIdentityModal.css +13 -0
  27. package/lib/components/FusionAuth/UnlinkOAuthIdentityModal.js +246 -0
  28. package/lib/components/FusionAuth/UnlinkOAuthIdentityModal.test.js +521 -0
  29. package/lib/components/InstrumentPositions/InstrumentPositionsContainer.js +4 -1
  30. package/lib/components/Login/LoginFormComponent.js +1 -1
  31. package/lib/components/MarginBalances/MarginDepositWithdraw/MarginDepositModal/MarginDepositFormContainer.js +2 -1
  32. package/lib/components/NoAccountBanner/NoAccountBanner.css +9 -0
  33. package/lib/components/NoAccountBanner/NoAccountBanner.js +58 -0
  34. package/lib/components/NoAccountBanner/index.js +16 -0
  35. package/lib/components/NoAccountPlaceholder/NoAccountPlaceholder.css +31 -0
  36. package/lib/components/NoAccountPlaceholder/NoAccountPlaceholder.js +33 -0
  37. package/lib/components/NoAccountPlaceholder/index.js +9 -0
  38. package/lib/components/OrderEntryComponents/advancedForm/AdvancedOrderFormContainer.js +2 -0
  39. package/lib/components/OrderEntryComponents/common/FormAmountFields.js +5 -0
  40. package/lib/components/OrderEntryComponents/common/TwapScheduleFields.js +98 -0
  41. package/lib/components/OrderEntryComponents/defaultForm/OrderEntryAnchoring.js +86 -39
  42. package/lib/components/OrderEntryComponents/defaultForm/OrderEntryAnchoring.test.js +326 -0
  43. package/lib/components/OrderEntryComponents/defaultForm/OrderEntryContainer.js +10 -2
  44. package/lib/components/OrderHistoryComponents/DepositsStatus/DepositsStatusComponent.js +1 -1
  45. package/lib/components/OrderHistoryComponents/DepositsStatus/DepositsStatusComponent.test.js +99 -0
  46. package/lib/components/OrderHistoryComponents/InactiveOrders/InactiveOrdersComponent.js +1 -1
  47. package/lib/components/OrderHistoryComponents/OpenOrders/OpenOrdersComponent.js +1 -1
  48. package/lib/components/OrderHistoryComponents/WithdrawStatus/WithdrawStatusComponent.js +1 -1
  49. package/lib/components/OrderHistoryComponents/WithdrawStatus/WithdrawStatusComponent.test.js +113 -0
  50. package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/PasskeysSettingsCard.css +108 -0
  51. package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/PasskeysSettingsCard.test.js +983 -0
  52. package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/PasskeysSettingsCardComponent.js +500 -0
  53. package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/index.js +9 -0
  54. package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/SsoLinkRowComponent.css +4 -0
  55. package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/SsoLinkRowComponent.js +29 -17
  56. package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/SsoLinkRowComponent.test.js +135 -0
  57. package/lib/components/Settings/ProfileAndSecurity/TwoFactorAuthSettingsCard/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.js +12 -4
  58. package/lib/components/Settings/ProfileAndSecurity/TwoFactorAuthSettingsCard/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.test.js +268 -0
  59. package/lib/components/TwoFactorAuthForm/TwoFactorAuthForm.test.js +475 -0
  60. package/lib/components/TwoFactorAuthForm/TwoFactorAuthFormComponent.js +26 -5
  61. package/lib/components/TwoFactorAuthForm/TwoFactorAuthFormContainer.js +50 -32
  62. package/lib/components/common/APAutoTabInput/APAutoTabInput.js +5 -2
  63. package/lib/components/common/APSelect/APSelect.js +3 -1
  64. package/lib/components/common/ErrorBoundary/ErrorBoundary.css +35 -0
  65. package/lib/components/common/ErrorBoundary/ErrorBoundary.js +87 -0
  66. package/lib/config/CONFIG.md +4 -0
  67. package/lib/config/configDefault.json +2 -1
  68. package/lib/constants/sendOrder/orderEntryFormConstants.js +23 -4
  69. package/lib/constants/sendOrder/timeInForceConstants.js +3 -1
  70. package/lib/constants/sendOrder/twapRejectReasons.js +26 -0
  71. package/lib/helpers/errorTextFormatter.js +13 -4
  72. package/lib/helpers/errorTextFormatter.test.js +26 -0
  73. package/lib/helpers/orderHistoryHelper.js +13 -1
  74. package/lib/helpers/orderHistoryHelper.test.js +58 -13
  75. package/lib/helpers/passkeyApi.js +228 -0
  76. package/lib/helpers/passkeyApi.test.js +171 -0
  77. package/lib/helpers/placeOrderHelper.js +76 -61
  78. package/lib/helpers/placeOrderHelper.test.js +169 -10
  79. package/lib/helpers/recalculateOrderHelper.js +4 -1
  80. package/lib/helpers/recalculateOrderHelper.test.js +88 -2
  81. package/lib/helpers/twapOrderHelper.js +265 -0
  82. package/lib/helpers/twapOrderHelper.test.js +467 -0
  83. package/lib/helpers/twoFactorAuthCancellation.js +38 -0
  84. package/lib/helpers/webauthnHelper.js +300 -0
  85. package/lib/helpers/webauthnHelper.test.js +199 -0
  86. package/lib/hocs/forAccount.js +33 -0
  87. package/lib/hocs/forAccount.test.js +50 -0
  88. package/lib/hocs/forVerified.js +16 -2
  89. package/lib/hocs/withAuthentication.js +3 -1
  90. package/lib/hocs/withOneSubmission.js +168 -0
  91. package/lib/index.js +3 -2
  92. package/lib/layouts/HeaderLayout/HeaderLayout.js +2 -1
  93. package/lib/layouts/WalletsLayout/WalletsLayoutContainer.js +3 -1
  94. package/lib/layouts/WalletsLayout/WalletsLayoutContainer.test.js +84 -0
  95. package/lib/redux/actions/apiActions.js +77 -9
  96. package/lib/redux/actions/apiActions.test.js +233 -0
  97. package/lib/redux/actions/authActions.js +514 -198
  98. package/lib/redux/actions/authActions.test.js +627 -47
  99. package/lib/redux/actions/depositActions.js +1 -1
  100. package/lib/redux/actions/depositActions.test.js +100 -30
  101. package/lib/redux/actions/fusionAuthActions.test.js +265 -84
  102. package/lib/redux/actions/interestAccountActions.js +12 -3
  103. package/lib/redux/actions/interestAccountActions.test.js +73 -0
  104. package/lib/redux/actions/modalActions.js +1 -0
  105. package/lib/redux/actions/orderEntryActions.blockTrade.test.js +306 -0
  106. package/lib/redux/actions/orderEntryActions.js +74 -22
  107. package/lib/redux/actions/orderEntryActions.test.js +63 -11
  108. package/lib/redux/actions/orderHistoryActions.js +20 -8
  109. package/lib/redux/actions/orderHistoryActions.test.js +63 -0
  110. package/lib/redux/actions/userActions.js +379 -179
  111. package/lib/redux/actions/userActions.test.js +925 -234
  112. package/lib/redux/actions/withdrawActions.js +62 -29
  113. package/lib/redux/actions/withdrawActions.test.js +246 -73
  114. package/lib/redux/actions/withdrawActions.travelRule.test.js +17 -3
  115. package/lib/redux/margin/actions/marginActions.js +6 -3
  116. package/lib/redux/margin/actions/marginActions.test.js +166 -0
  117. package/lib/redux/middlewares/authMiddleware.js +5 -0
  118. package/lib/redux/middlewares/authMiddleware.test.js +88 -29
  119. package/lib/redux/reducers/authReducer.js +1 -0
  120. package/lib/redux/reducers/authReducer.test.js +38 -0
  121. package/lib/redux/reducers/userReducer.js +10 -0
  122. package/lib/redux/reducers/userReducer.test.js +29 -0
  123. package/lib/redux/selectors/orderEntrySelector.js +19 -8
  124. package/lib/redux/selectors/orderEntrySelector.test.js +209 -0
  125. package/lib/redux/selectors/orderTotalSelector.test.js +40 -1
  126. package/lib/redux/selectors/recentActivitySelector.js +8 -2
  127. package/lib/redux/selectors/recentActivitySelector.v2.test.js +33 -0
  128. package/lib/redux/selectors/userSelectors.js +6 -1
  129. package/lib/redux/selectors/userSelectors.test.js +28 -0
  130. package/lib/services/fms/fms.js +2 -0
  131. package/lib/services/fms/fms.test.js +35 -0
  132. package/package.json +4 -4
@@ -0,0 +1,209 @@
1
+ "use strict";
2
+
3
+ var _orderEntrySelector = require("./orderEntrySelector");
4
+ var _orderEntryFormConstants = require("../../constants/sendOrder/orderEntryFormConstants");
5
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
6
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
7
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
8
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ jest.mock('../../config', function () {
10
+ return {
11
+ Trading: {
12
+ SpotAllowedOrderTypes: [],
13
+ MarginAllowedOrderTypes: []
14
+ },
15
+ OrderCalcBuffer: {
16
+ priceBuffer: 0
17
+ }
18
+ };
19
+ });
20
+ var TWAP = _orderEntryFormConstants.orderTypes.twap.displayName;
21
+ var formName = 'advancedOrderEntry';
22
+ var instrument = {
23
+ InstrumentId: 1,
24
+ Symbol: 'BTCUSD',
25
+ Product1: 1,
26
+ Product2: 2,
27
+ Product1Symbol: 'BTC',
28
+ Product2Symbol: 'USD',
29
+ PriceIncrement: 0.01,
30
+ QuantityIncrement: 0.1,
31
+ MinimumQuantity: 0.1
32
+ };
33
+ var makeState = function makeState(values) {
34
+ return {
35
+ apexCore: {
36
+ instrument: {
37
+ instruments: [instrument],
38
+ selectedInstrumentId: 1
39
+ },
40
+ product: {
41
+ products: [{
42
+ ProductId: 1,
43
+ Product: 'BTC',
44
+ ProductFullName: 'Bitcoin',
45
+ DecimalPlaces: 8
46
+ }, {
47
+ ProductId: 2,
48
+ Product: 'USD',
49
+ ProductFullName: 'US Dollar',
50
+ DecimalPlaces: 2
51
+ }]
52
+ },
53
+ level1: {
54
+ 1: {
55
+ InstrumentId: 1,
56
+ BestBid: 99000,
57
+ BestOffer: 101000
58
+ }
59
+ },
60
+ level2: {
61
+ buy: [{
62
+ Price: 99000,
63
+ Quantity: 10
64
+ }],
65
+ sell: [{
66
+ Price: 101000,
67
+ Quantity: 10
68
+ }]
69
+ }
70
+ },
71
+ form: _defineProperty({}, formName, {
72
+ values: values
73
+ }),
74
+ user: {
75
+ accounts: [{
76
+ AccountId: 1,
77
+ AccountType: 'Standard'
78
+ }],
79
+ selectedAccountId: 1
80
+ },
81
+ futures: {
82
+ instruments: {
83
+ selectedInstrumentId: null
84
+ }
85
+ }
86
+ };
87
+ };
88
+ describe('orderEntrySelector TWAP', function () {
89
+ describe('selectTwapSchedule', function () {
90
+ it('derives the schedule the engine runs from the form and the selected instrument', function () {
91
+ // 1 BTC in 6 slices at a 0.1 increment rounds the slice up to 0.2, which covers 1 BTC in 5 slices.
92
+ var state = makeState({
93
+ orderType: TWAP,
94
+ side: _orderEntryFormConstants.sellValue,
95
+ quantity: '1',
96
+ slices: '6',
97
+ durationMinutes: '60',
98
+ limitPrice: ''
99
+ });
100
+ var schedule = (0, _orderEntrySelector.selectTwapSchedule)(state, {
101
+ formName: formName
102
+ });
103
+ expect(schedule.byValue).toBe(false);
104
+ expect(schedule.sliceSize.toNumber()).toBe(0.2);
105
+ expect(schedule.sliceDecimalPlaces).toBe(1);
106
+ expect(schedule.sliceSymbol).toBe('BTC');
107
+ expect(schedule.requestedSlices).toBe(6);
108
+ expect(schedule.slices).toBe(5);
109
+ expect(schedule.intervalSeconds).toBe(720);
110
+ expect(schedule.sliceValue.toNumber()).toBe(0.2 * 99000);
111
+ expect(schedule.belowMinimumQuantity).toBe(false);
112
+ });
113
+ it('sizes a market-form buy by value, with the slice at the price decimals', function () {
114
+ var state = makeState({
115
+ orderType: TWAP,
116
+ side: _orderEntryFormConstants.buyValue,
117
+ quantity: '',
118
+ value: '1000',
119
+ slices: '3',
120
+ durationMinutes: '30',
121
+ limitPrice: ''
122
+ });
123
+ var schedule = (0, _orderEntrySelector.selectTwapSchedule)(state, {
124
+ formName: formName
125
+ });
126
+ expect(schedule.byValue).toBe(true);
127
+ expect(schedule.sliceSize.toNumber()).toBe(333.34);
128
+ expect(schedule.sliceDecimalPlaces).toBe(2);
129
+ expect(schedule.sliceSymbol).toBe('USD');
130
+ expect(schedule.slices).toBe(3);
131
+ });
132
+ });
133
+ describe('selectOrderPrice', function () {
134
+ it('prices a market-form TWAP at the touch on its side', function () {
135
+ var sell = makeState({
136
+ orderType: TWAP,
137
+ side: _orderEntryFormConstants.sellValue,
138
+ limitPrice: ''
139
+ });
140
+ var buy = makeState({
141
+ orderType: TWAP,
142
+ side: _orderEntryFormConstants.buyValue,
143
+ limitPrice: ''
144
+ });
145
+ expect((0, _orderEntrySelector.selectOrderPrice)(sell, {
146
+ formName: formName
147
+ })).toBe(99000);
148
+ expect((0, _orderEntrySelector.selectOrderPrice)(buy, {
149
+ formName: formName
150
+ })).toBe(101000);
151
+ });
152
+ it('prices a limit-form TWAP at its limit price', function () {
153
+ var state = makeState({
154
+ orderType: TWAP,
155
+ side: _orderEntryFormConstants.sellValue,
156
+ limitPrice: '100000'
157
+ });
158
+ expect((0, _orderEntrySelector.selectOrderPrice)(state, {
159
+ formName: formName
160
+ })).toBe('100000');
161
+ });
162
+ });
163
+ describe('orderTotalSelector', function () {
164
+ it('totals a market-form TWAP like a market order of the same size', function () {
165
+ var twap = makeState({
166
+ orderType: TWAP,
167
+ side: _orderEntryFormConstants.sellValue,
168
+ quantity: '2',
169
+ limitPrice: ''
170
+ });
171
+ var market = makeState({
172
+ orderType: _orderEntryFormConstants.orderTypes.market.displayName,
173
+ side: _orderEntryFormConstants.sellValue,
174
+ quantity: '2'
175
+ });
176
+ expect((0, _orderEntrySelector.orderTotalSelector)(twap, {
177
+ formName: formName
178
+ })).toBe((0, _orderEntrySelector.orderTotalSelector)(market, {
179
+ formName: formName
180
+ }));
181
+ expect((0, _orderEntrySelector.orderTotalSelector)(twap, {
182
+ formName: formName
183
+ })).toBe(2 * 99000);
184
+ });
185
+ it('totals a value-sized market-form buy at its value', function () {
186
+ var state = makeState({
187
+ orderType: TWAP,
188
+ side: _orderEntryFormConstants.buyValue,
189
+ anchoredField: 'value',
190
+ value: '1000',
191
+ limitPrice: ''
192
+ });
193
+ expect((0, _orderEntrySelector.orderTotalSelector)(state, {
194
+ formName: formName
195
+ })).toBe('1000');
196
+ });
197
+ it('totals a limit-form TWAP at limit price times quantity', function () {
198
+ var state = makeState({
199
+ orderType: TWAP,
200
+ side: _orderEntryFormConstants.sellValue,
201
+ quantity: '2',
202
+ limitPrice: '100000'
203
+ });
204
+ expect((0, _orderEntrySelector.orderTotalSelector)(state, {
205
+ formName: formName
206
+ })).toBe(200000);
207
+ });
208
+ });
209
+ });
@@ -2,6 +2,7 @@
2
2
 
3
3
  var _orderEntrySelector = require("./orderEntrySelector");
4
4
  var _orderEntryFormConstants = require("../../constants/sendOrder/orderEntryFormConstants");
5
+ var _placeOrderHelper = require("../../helpers/placeOrderHelper");
5
6
  var _bignumber = require("bignumber.js");
6
7
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
7
8
  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; }
@@ -29,13 +30,51 @@ jest.mock('../../helpers/placeOrderHelper', function () {
29
30
  })
30
31
  };
31
32
  });
33
+ jest.mock('./instrumentPositionSelectors', function () {
34
+ return _objectSpread(_objectSpread({}, jest.requireActual('./instrumentPositionSelectors')), {}, {
35
+ selectedInstrumentSelector: function selectedInstrumentSelector() {
36
+ return {
37
+ InstrumentId: 1
38
+ };
39
+ }
40
+ });
41
+ });
32
42
  describe('orderTotalSelector', function () {
43
+ var selectedInstrumentLevel1 = {
44
+ BestOffer: 11,
45
+ BestBid: 9,
46
+ LastTradedPx: 10
47
+ };
33
48
  var state = {
34
49
  apexCore: {
35
- level1: [],
50
+ level1: {
51
+ 1: selectedInstrumentLevel1,
52
+ 2: {
53
+ BestOffer: 99,
54
+ BestBid: 98,
55
+ LastTradedPx: 98
56
+ }
57
+ },
36
58
  level2: []
37
59
  }
38
60
  };
61
+ it("reads the peg price from the selected instrument's level1, since the Order Entry form has no instrument field", function () {
62
+ var form = {
63
+ orderType: _orderEntryFormConstants.orderTypes.trailingStopMarket.displayName,
64
+ pegPriceType: '1',
65
+ trailingAmount: new _bignumber.BigNumber(2),
66
+ quantity: new _bignumber.BigNumber(2),
67
+ side: '0'
68
+ };
69
+ (0, _orderEntrySelector.orderTotalSelector)(_objectSpread(_objectSpread({}, state), {}, {
70
+ form: {
71
+ orderEntry: {
72
+ values: form
73
+ }
74
+ }
75
+ }), {});
76
+ expect(_placeOrderHelper.getPegPriceByType).toHaveBeenCalledWith(selectedInstrumentLevel1, form);
77
+ });
39
78
  it('should return correct totalAmount if orderType = market', function () {
40
79
  var form = {
41
80
  orderType: _orderEntryFormConstants.orderTypes.market.displayName
@@ -28,8 +28,14 @@ var newRecentActivitySelector = exports.newRecentActivitySelector = (0, _reselec
28
28
  var manifest = _ref.productManifest.manifest;
29
29
  return manifest;
30
30
  }], function (recentActivity, interestAccruals, products, manifest) {
31
+ // callAPI hands back a refused call's { result: false } payload as is, so
32
+ // either list can be an error object instead of an array.
33
+ var toList = function toList(value) {
34
+ return Array.isArray(value) ? value : [];
35
+ };
36
+
31
37
  // Transform recent activity transactions
32
- var transactions = recentActivity.map(function (el) {
38
+ var transactions = toList(recentActivity).map(function (el) {
33
39
  var product = products.find(function (i) {
34
40
  return i.ProductId === el.ProductId;
35
41
  }) || {};
@@ -50,7 +56,7 @@ var newRecentActivitySelector = exports.newRecentActivitySelector = (0, _reselec
50
56
  });
51
57
 
52
58
  // Transform interest accruals to match transaction format
53
- var interestAccrualsTransformed = (interestAccruals || []).map(function (el) {
59
+ var interestAccrualsTransformed = toList(interestAccruals).map(function (el) {
54
60
  var product = products.find(function (i) {
55
61
  return i.ProductId === el.BorrowedProductId;
56
62
  }) || {};
@@ -164,4 +164,37 @@ describe('newRecentActivitySelector - margin hardening features', function () {
164
164
  expect(result[1].TransactionType).toBe('LiquidationFee');
165
165
  expect(result[1].TimeStamp).toBe('2025-12-02T10:00:00.000Z');
166
166
  });
167
+ it('should return an empty list when the calls came back as error payloads', function () {
168
+ var refused = {
169
+ result: false,
170
+ errormsg: 'Not Authorized',
171
+ errorcode: 20,
172
+ detail: null
173
+ };
174
+ var testState = {
175
+ user: {
176
+ selectedAccountId: 125
177
+ },
178
+ apexCore: {
179
+ orderHistory: {
180
+ recentActivity: refused,
181
+ interestAccruals: refused
182
+ },
183
+ product: {
184
+ products: [{
185
+ ProductId: 1,
186
+ ProductSymbol: 'BTC',
187
+ Product: 'BTC'
188
+ }]
189
+ },
190
+ position: {
191
+ positions: {}
192
+ }
193
+ },
194
+ productManifest: {
195
+ manifest: {}
196
+ }
197
+ };
198
+ expect((0, _recentActivitySelector.newRecentActivitySelector)(testState)).toEqual([]);
199
+ });
167
200
  });
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.selectUserInfo = exports.selectUserConfig = exports.isSuperUser = exports.isStatusLevelIncreased = exports.isProfileSectionEditingDisabled = exports.isBrokerUser = exports.isBlockTradingEnabledForUser = void 0;
6
+ exports.selectUserInfo = exports.selectUserConfig = exports.isSuperUser = exports.isStatusLevelIncreased = exports.isProfileSectionEditingDisabled = exports.isBrokerUser = exports.isBlockTradingEnabledForUser = exports.hasNoAccountsSelector = void 0;
7
7
  var _reselect = require("reselect");
8
8
  var _get = _interopRequireDefault(require("lodash/get"));
9
9
  var _userPermissionsContants = require("../../constants/userPermissionsContants");
@@ -43,6 +43,11 @@ var isBrokerUser = exports.isBrokerUser = (0, _reselect.createSelector)(selectUs
43
43
  });
44
44
  });
45
45
  var isProfileSectionEditingDisabled = exports.isProfileSectionEditingDisabled = isStatusLevelIncreased;
46
+
47
+ // True once the account fetch has settled and found no accounts. False while it is still running.
48
+ var hasNoAccountsSelector = exports.hasNoAccountsSelector = (0, _reselect.createSelector)(getUserState, function (user) {
49
+ return user.accountsLoaded && !user.accounts.length;
50
+ });
46
51
  var isBlockTradingEnabledForUser = exports.isBlockTradingEnabledForUser = (0, _reselect.createSelector)(function (state) {
47
52
  return (0, _get["default"])(getUserState(state), 'permissions', emptyArray);
48
53
  }, function (permissions) {
@@ -53,4 +53,32 @@ describe('userSelectors', function () {
53
53
  };
54
54
  expect((0, _userSelectors.isStatusLevelIncreased)(state)).toBe(undefined);
55
55
  });
56
+ });
57
+ describe('hasNoAccountsSelector', function () {
58
+ it('is false while the accounts are still loading', function () {
59
+ expect((0, _userSelectors.hasNoAccountsSelector)({
60
+ user: {
61
+ accountsLoaded: false,
62
+ accounts: []
63
+ }
64
+ })).toBe(false);
65
+ });
66
+ it('is true once the accounts have loaded with none', function () {
67
+ expect((0, _userSelectors.hasNoAccountsSelector)({
68
+ user: {
69
+ accountsLoaded: true,
70
+ accounts: []
71
+ }
72
+ })).toBe(true);
73
+ });
74
+ it('is false for a user with an account', function () {
75
+ expect((0, _userSelectors.hasNoAccountsSelector)({
76
+ user: {
77
+ accountsLoaded: true,
78
+ accounts: [{
79
+ AccountId: 15
80
+ }]
81
+ }
82
+ })).toBe(false);
83
+ });
56
84
  });
@@ -7,6 +7,7 @@ exports.getFMS = getFMS;
7
7
  exports.getFMSGateway = getFMSGateway;
8
8
  var _alphapointApexApi = require("alphapoint-apex-api");
9
9
  var _config = _interopRequireDefault(require("../../config"));
10
+ var _apex = require("../../apex");
10
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
11
12
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
12
13
  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; }
@@ -81,5 +82,6 @@ function getFMS(sessionToken, gateway) {
81
82
  }
82
83
  }, options));
83
84
  ws.connection.standardCallback = function () {};
85
+ (0, _apex.routeErrorReplies)(ws.connection);
84
86
  return ws;
85
87
  }
@@ -57,4 +57,39 @@ describe('getFMSGateway', function () {
57
57
  return fms.getFMS('session-token-abc');
58
58
  }).toThrow(/FMS gateway is not provided/);
59
59
  });
60
+ });
61
+ describe('getFMS error-reply routing', function () {
62
+ beforeEach(function () {
63
+ jest.clearAllMocks();
64
+ jest.resetModules();
65
+ localStorageMock.getItem.mockReturnValue(null);
66
+ });
67
+ it('subscribes to the FMS socket so m:5 replies settle pending calls', function () {
68
+ var _require3 = require('alphapoint-apex-api'),
69
+ APEX = _require3.APEX;
70
+ var subscribe = jest.fn();
71
+ APEX.mockImplementationOnce(function APEXWithSocket() {
72
+ this.standardCallback = null;
73
+ this.callbacks = {};
74
+ this.ws = {
75
+ subscribe: subscribe
76
+ };
77
+ });
78
+ var _require4 = require('./fms'),
79
+ getFMS = _require4.getFMS;
80
+ var _getFMS = getFMS('token', 'wss://fms.example/WSFMSGateway'),
81
+ connection = _getFMS.connection;
82
+ var callback = jest.fn();
83
+ connection.callbacks[2] = callback;
84
+ var frame = {
85
+ m: 5,
86
+ i: 2,
87
+ n: 'GetFuturesPositions',
88
+ o: 'Endpoint Not Found'
89
+ };
90
+ subscribe.mock.calls[0][0](frame);
91
+ expect(subscribe).toHaveBeenCalledTimes(1);
92
+ expect(callback).toHaveBeenCalledWith(frame);
93
+ expect(connection.callbacks[2]).toBeUndefined();
94
+ });
60
95
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alphapoint/apex-web",
3
- "version": "5.5.6",
3
+ "version": "5.8.0",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -9,7 +9,7 @@
9
9
  "node": ">=18.0.0"
10
10
  },
11
11
  "dependencies": {
12
- "@alphapoint/apex-chart-react": "^5.5.6",
12
+ "@alphapoint/apex-chart-react": "^5.8.0",
13
13
  "@dnd-kit/core": "^6.1.0",
14
14
  "@dnd-kit/modifiers": "^7.0.0",
15
15
  "@dnd-kit/sortable": "^8.0.0",
@@ -71,7 +71,7 @@
71
71
  "@babel/runtime": "^7.23.4",
72
72
  "babel-jest": "^27.5.1",
73
73
  "cross-env": "^7.0.3",
74
- "eslint-config-apex": "^5.5.6",
74
+ "eslint-config-apex": "^5.8.0",
75
75
  "fs-extra": "^11.1.1",
76
76
  "identity-obj-proxy": "^3.0.0",
77
77
  "jest": "^27.5.1",
@@ -133,5 +133,5 @@
133
133
  "files": [
134
134
  "lib"
135
135
  ],
136
- "gitHead": "44bba0a197269322fa37fe520230e992371f01e8"
136
+ "gitHead": "766058d63ba1a63e754c0dda13e8097c2545d89d"
137
137
  }