@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
@@ -112,7 +112,8 @@ var InnerInput = /*#__PURE__*/function (_React$Component) {
112
112
  info = _this$props2.info,
113
113
  meta = _this$props2.meta,
114
114
  label = _this$props2.label,
115
- customClass = _this$props2.customClass;
115
+ customClass = _this$props2.customClass,
116
+ disabled = _this$props2.disabled;
116
117
  var bemClasses = (0, _cssClassesHelper.getBEMClasses)(baseClass, customClass);
117
118
  var inputs = this.state.values.map(function (value, index) {
118
119
  return /*#__PURE__*/_react["default"].createElement("input", {
@@ -126,6 +127,7 @@ var InnerInput = /*#__PURE__*/function (_React$Component) {
126
127
  },
127
128
  value: _this3.state.values[index],
128
129
  autoFocus: !index,
130
+ disabled: disabled,
129
131
  onPaste: _this3.handlePaste
130
132
  });
131
133
  });
@@ -156,6 +158,7 @@ APAutoTabInput.propTypes = {
156
158
  type: _propTypes["default"].string,
157
159
  customClass: _propTypes["default"].string,
158
160
  numberOfInputs: _propTypes["default"].number.isRequired,
159
- maxLength: _propTypes["default"].number
161
+ maxLength: _propTypes["default"].number,
162
+ disabled: _propTypes["default"].bool
160
163
  };
161
164
  var _default = exports["default"] = APAutoTabInput;
@@ -48,7 +48,9 @@ var InnerSelect = exports.InnerSelect = function InnerSelect(props) {
48
48
  key: "".concat(idx, "-").concat(i.value),
49
49
  value: i.value,
50
50
  disabled: i.disabled,
51
- selected: i.selected
51
+ selected: i.selected,
52
+ title: i.title,
53
+ "data-test": i.dataTest
52
54
  }, i.label);
53
55
  })), /*#__PURE__*/_react["default"].createElement("small", {
54
56
  className: "form-text-muted ".concat(baseClasses('select-info'))
@@ -0,0 +1,35 @@
1
+ .error-boundary {
2
+ display: flex;
3
+ align-items: center;
4
+ justify-content: center;
5
+ min-height: 100vh;
6
+ padding: 24px;
7
+ background-color: var(--component__bg-color);
8
+ }
9
+
10
+ .error-boundary__container {
11
+ max-width: 48rem;
12
+ text-align: center;
13
+ }
14
+
15
+ .error-boundary__title {
16
+ margin-bottom: 1.6rem;
17
+ font-size: 2.4rem;
18
+ font-weight: 600;
19
+ }
20
+
21
+ .error-boundary__message {
22
+ margin-bottom: 2.4rem;
23
+ font-size: 1.6rem;
24
+ line-height: 1.5;
25
+ }
26
+
27
+ .error-boundary__button {
28
+ padding: 1rem 2.4rem;
29
+ font-size: 1.6rem;
30
+ border: none;
31
+ border-radius: 5px;
32
+ cursor: pointer;
33
+ background-color: var(--primary__bg-color);
34
+ color: var(--font__color-primary);
35
+ }
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _cssClassesHelper = require("../../../helpers/cssClassesHelper");
10
+ require("./ErrorBoundary.css");
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
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); }
13
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
14
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
15
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
16
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
17
+ function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
18
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
19
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
20
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
21
+ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
22
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
23
+ 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; }
24
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
25
+ 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); }
26
+ var baseClass = (0, _cssClassesHelper.getBEMClasses)('error-boundary');
27
+
28
+ /**
29
+ * Catches render-phase errors so a throw cannot unmount the whole tree into a
30
+ * blank page. Deliberately avoids i18n and redux so it stays useful even when
31
+ * those are the source of the failure.
32
+ */
33
+ var ErrorBoundary = /*#__PURE__*/function (_React$Component) {
34
+ function ErrorBoundary() {
35
+ var _this;
36
+ _classCallCheck(this, ErrorBoundary);
37
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
38
+ args[_key] = arguments[_key];
39
+ }
40
+ _this = _callSuper(this, ErrorBoundary, [].concat(args));
41
+ _defineProperty(_this, "state", {
42
+ hasError: false
43
+ });
44
+ _defineProperty(_this, "handleReload", function () {
45
+ window.location.reload();
46
+ });
47
+ return _this;
48
+ }
49
+ _inherits(ErrorBoundary, _React$Component);
50
+ return _createClass(ErrorBoundary, [{
51
+ key: "componentDidCatch",
52
+ value: function componentDidCatch(error, errorInfo) {
53
+ console.error('Unhandled render error', error, errorInfo);
54
+ }
55
+ }, {
56
+ key: "render",
57
+ value: function render() {
58
+ if (!this.state.hasError) {
59
+ return this.props.children;
60
+ }
61
+ return /*#__PURE__*/_react["default"].createElement("div", {
62
+ className: baseClass()
63
+ }, /*#__PURE__*/_react["default"].createElement("div", {
64
+ className: baseClass('container')
65
+ }, /*#__PURE__*/_react["default"].createElement("div", {
66
+ className: baseClass('title')
67
+ }, "Something went wrong"), /*#__PURE__*/_react["default"].createElement("div", {
68
+ className: baseClass('message')
69
+ }, "The page could not be displayed. Reloading may resolve it. If it persists, please contact support."), /*#__PURE__*/_react["default"].createElement("button", {
70
+ className: baseClass('button'),
71
+ onClick: this.handleReload,
72
+ type: "button"
73
+ }, "Reload")));
74
+ }
75
+ }], [{
76
+ key: "getDerivedStateFromError",
77
+ value: function getDerivedStateFromError() {
78
+ return {
79
+ hasError: true
80
+ };
81
+ }
82
+ }]);
83
+ }(_react["default"].Component);
84
+ ErrorBoundary.propTypes = {
85
+ children: _propTypes["default"].node
86
+ };
87
+ var _default = exports["default"] = ErrorBoundary;
@@ -16,6 +16,10 @@ Time display format based on the [date-fns format tokens](https://date-fns.org/v
16
16
 
17
17
  A combination of the above, e.g. `MM/DD/YYYY HH:mm`.
18
18
 
19
+ ## authTimeout: _integer_
20
+
21
+ Milliseconds to wait for WebAuthenticateUser when restoring a session from a stored token before the token is dropped and the page reloads. `0` (default) waits indefinitely.
22
+
19
23
  # KYC
20
24
 
21
25
  ## MinimumVerificationLevel: _integer_
@@ -23,7 +23,8 @@
23
23
  "Trailing Stop Market",
24
24
  "Trailing Stop Limit",
25
25
  "Report Block Trade",
26
- "Reserve Order"
26
+ "Reserve Order",
27
+ "TWAP"
27
28
  ],
28
29
  "MarginAllowedOrderTypes": [
29
30
  "Market Order",
@@ -3,8 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.submitButtonTextOptions = exports.sellValue = exports.orderTypes = exports.futuresOrderTypes = exports.futuresOrderFormTypes = exports.buyValue = exports.advancedOrderFormTypes = void 0;
6
+ exports.submitButtonTextOptions = exports.sellValue = exports.orderTypes = exports.futuresOrderTypes = exports.futuresOrderFormTypes = exports.defaultOrderFormTypes = exports.configurableOrderFormTypes = exports.buyValue = exports.advancedOrderFormTypes = void 0;
7
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); }
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; }
9
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
8
10
  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; }
9
11
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
10
12
  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); }
@@ -61,6 +63,14 @@ var orderTypes = exports.orderTypes = {
61
63
  orderType: '2',
62
64
  displayName: 'Reserve Order'
63
65
  },
66
+ // Time-weighted average price: a matching-engine order type (13) built like a reserve order. The
67
+ // form takes a duration and a number of slices; placeOrderHelper turns them into the GTD
68
+ // ExpireTime and the DisplayQuantity slice the engine releases on. See helpers/twapOrderHelper.js.
69
+ //t('TWAP')
70
+ twap: {
71
+ orderType: '13',
72
+ displayName: 'TWAP'
73
+ },
64
74
  //t('Spot')
65
75
  spot: {
66
76
  orderType: '2',
@@ -94,17 +104,26 @@ var futuresOrderTypes = exports.futuresOrderTypes = {
94
104
  displayName: 'Conditional'
95
105
  }
96
106
  };
97
- var advancedOrderFormTypes = exports.advancedOrderFormTypes = {
107
+
108
+ // The Order Entry panel always lists these: the form starts on Limit Order and the order-book
109
+ // handlers set Market or Limit Order, so they must never be filtered out.
110
+ var defaultOrderFormTypes = exports.defaultOrderFormTypes = {
98
111
  market: orderTypes.market,
99
112
  limit: orderTypes.limit,
100
113
  stopMarket: orderTypes.stopMarket,
101
- stopLimit: orderTypes.stopLimit,
114
+ stopLimit: orderTypes.stopLimit
115
+ };
116
+
117
+ // The Order Entry panel lists these only when Spot/MarginAllowedOrderTypes allow them.
118
+ var configurableOrderFormTypes = exports.configurableOrderFormTypes = {
102
119
  trailingStopMarket: orderTypes.trailingStopMarket,
103
120
  trailingStopLimit: orderTypes.trailingStopLimit,
104
121
  fillOrKill: orderTypes.fillOrKill,
105
122
  immediateOrCancel: orderTypes.immediateOrCancel,
106
- reserveOrder: orderTypes.reserveOrder
123
+ reserveOrder: orderTypes.reserveOrder,
124
+ twap: orderTypes.twap
107
125
  };
126
+ var advancedOrderFormTypes = exports.advancedOrderFormTypes = _objectSpread(_objectSpread({}, defaultOrderFormTypes), configurableOrderFormTypes);
108
127
  var futuresOrderFormTypes = exports.futuresOrderFormTypes = {
109
128
  market: futuresOrderTypes.market,
110
129
  limit: futuresOrderTypes.limit,
@@ -8,5 +8,7 @@ var timeInForceForOrderType = exports.timeInForceForOrderType = {
8
8
  'Reserve Order': 0,
9
9
  'Good till Cancel': 1,
10
10
  'Immediate or Cancel': 3,
11
- 'Fill Or Kill': 4
11
+ 'Fill Or Kill': 4,
12
+ // A TWAP is always Good till Date (6): its ExpireTime is the end of the slice schedule.
13
+ TWAP: 6
12
14
  };
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.twapRejectReasonText = void 0;
7
+ /**
8
+ * Reject reasons the gateway, OMS and matching engine return for a TWAP (apex
9
+ * OMSMessages/RejectHelper.cs 10534-10539), mapped to text the trader can act on. SendOrder returns
10
+ * them as `errormsg` with status Rejected. Anything not listed here falls through to the generic
11
+ * "Your order was rejected" snackbar.
12
+ */
13
+ var twapRejectReasonText = exports.twapRejectReasonText = {
14
+ // t('The TWAP duration must end in the future')
15
+ Twap_Invalid_Expiration: 'The TWAP duration must end in the future',
16
+ // t('The TWAP slice must be greater than zero and not more than the order amount')
17
+ Twap_Invalid_Slice_Quantity: 'The TWAP slice must be greater than zero and not more than the order amount',
18
+ // t("The TWAP slice is below the instrument's minimum quantity. Increase the amount or use fewer slices")
19
+ Twap_Slice_Below_Minimum: "The TWAP slice is below the instrument's minimum quantity. Increase the amount or use fewer slices",
20
+ // t('TWAP orders must be Good till Date')
21
+ Twap_Invalid_Time_In_Force: 'TWAP orders must be Good till Date',
22
+ // t('A TWAP buy needs a Limit Price or an Order Total')
23
+ Twap_Buy_Needs_Price_Or_Value: 'A TWAP buy needs a Limit Price or an Order Total',
24
+ // t('TWAP orders are not available for this account')
25
+ Twap_Not_Allowed_For_Account: 'TWAP orders are not available for this account'
26
+ };
@@ -5,11 +5,20 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.preprocessErrorTextForReduxForm = exports.formatErrorText = void 0;
7
7
  var formatErrorText = exports.formatErrorText = function formatErrorText(errorResponse) {
8
- var result = "".concat(errorResponse.errorcode, ": ").concat(errorResponse.errormsg);
9
- if (errorResponse.detail) {
10
- result = "".concat(result, ": ").concat(errorResponse.detail);
8
+ var _ref = errorResponse || {},
9
+ errorcode = _ref.errorcode,
10
+ errormsg = _ref.errormsg,
11
+ detail = _ref.detail;
12
+ var parts = [errorcode !== undefined && errorcode !== null ? String(errorcode) : '', typeof errormsg === 'string' ? errormsg.trim() : '', typeof detail === 'string' ? detail.trim() : ''].filter(Boolean);
13
+
14
+ // A reply with no code, message or detail (a 2FA gate refusal, a null reply) is still an error
15
+ // from the caller's point of view. The generic text is returned on its own so the snackbar can
16
+ // translate it as a whole key.
17
+ if (parts.length === 0) {
18
+ // t('The request was not successful.')
19
+ return 'The request was not successful.';
11
20
  }
12
- return result;
21
+ return parts.join(': ');
13
22
  };
14
23
 
15
24
  /**
@@ -11,4 +11,30 @@ describe('formatErrorText', function () {
11
11
  errorResponse.detail = 'Error details';
12
12
  expect((0, _errorTextFormatter.formatErrorText)(errorResponse)).toEqual('402: Test error: Error details');
13
13
  });
14
+ it('omits the code when the response has none', function () {
15
+ expect((0, _errorTextFormatter.formatErrorText)({
16
+ errormsg: 'not enabled'
17
+ })).toEqual('not enabled');
18
+ });
19
+ it('falls back to a generic message for an empty response', function () {
20
+ expect((0, _errorTextFormatter.formatErrorText)({})).toEqual('The request was not successful.');
21
+ expect((0, _errorTextFormatter.formatErrorText)(null)).toEqual('The request was not successful.');
22
+ });
23
+ it('keeps the code and detail when the message is empty', function () {
24
+ expect((0, _errorTextFormatter.formatErrorText)({
25
+ result: false,
26
+ errorcode: 101,
27
+ errormsg: '',
28
+ detail: 'Insufficient balance'
29
+ })).toEqual('101: Insufficient balance');
30
+ });
31
+ it('treats whitespace-only fields as empty', function () {
32
+ expect((0, _errorTextFormatter.formatErrorText)({
33
+ errormsg: ' \t\n '
34
+ })).toEqual('The request was not successful.');
35
+ expect((0, _errorTextFormatter.formatErrorText)({
36
+ errormsg: ' not enabled ',
37
+ detail: ' '
38
+ })).toEqual('not enabled');
39
+ });
14
40
  });
@@ -5,8 +5,20 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getOrderPriceToDisplay = exports.getFuturesOrderPriceToDisplay = void 0;
7
7
  var _numberFormatter = require("./numberFormatter");
8
+ /** A market-form TWAP (no limit price) is reported with a Price of 0: each slice takes the market. */
9
+ var isMarketTwap = function isMarketTwap(order) {
10
+ return order.OrderType === 'TWAP' && Number(order.Price) === 0;
11
+ };
12
+
13
+ /**
14
+ * The Price column of the order tables. `t` translates the "Market" placeholder a priceless order
15
+ * shows; the identity default keeps callers that only ever have a price unchanged.
16
+ */
8
17
  var getOrderPriceToDisplay = exports.getOrderPriceToDisplay = function getOrderPriceToDisplay(order, decimalPlaces) {
9
- return order.trailingPrice ? order.trailingPrice : order.Price ? (0, _numberFormatter.formatNumberToLocale)(order.Price, decimalPlaces || order.Price.symbol) : '';
18
+ var t = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function (s) {
19
+ return s;
20
+ };
21
+ return order.trailingPrice ? order.trailingPrice : isMarketTwap(order) ? t('Market') : order.Price ? (0, _numberFormatter.formatNumberToLocale)(order.Price, decimalPlaces || order.Price.symbol) : '';
10
22
  };
11
23
  var getFuturesOrderPriceToDisplay = exports.getFuturesOrderPriceToDisplay = function getFuturesOrderPriceToDisplay(order, decimalPlaces) {
12
24
  return order.trailingPrice ? order.trailingPrice : order.Price != null ? (0, _numberFormatter.formatNumberToLocale)(order.Price, decimalPlaces || order.Price.symbol) : '';
@@ -41,11 +41,56 @@ describe('orderHistoryHelper', function () {
41
41
  var result = getOrderPriceToDisplay(order, 2);
42
42
  expect(result).toBe('');
43
43
  });
44
+ it('shows a market-form TWAP (price 0) as Market, translated', function () {
45
+ var _require5 = require('./orderHistoryHelper'),
46
+ getOrderPriceToDisplay = _require5.getOrderPriceToDisplay;
47
+ var BigNumber = require('bignumber.js');
48
+ var t = function t(key) {
49
+ return "t:".concat(key);
50
+ };
51
+
52
+ // The open-orders selector wraps Price in a currency BigNumber, which is truthy even at 0.
53
+ var order = {
54
+ OrderType: 'TWAP',
55
+ Price: new BigNumber(0)
56
+ };
57
+ order.Price.symbol = 'USD';
58
+ expect(getOrderPriceToDisplay(order, 2, t)).toBe('t:Market');
59
+ expect(getOrderPriceToDisplay({
60
+ OrderType: 'TWAP',
61
+ Price: 0
62
+ }, 2, t)).toBe('t:Market');
63
+ expect(getOrderPriceToDisplay({
64
+ OrderType: 'TWAP',
65
+ Price: 0
66
+ }, 2)).toBe('Market');
67
+ });
68
+ it('shows a limit-form TWAP at its price', function () {
69
+ var _require6 = require('./orderHistoryHelper'),
70
+ getOrderPriceToDisplay = _require6.getOrderPriceToDisplay;
71
+ var BigNumber = require('bignumber.js');
72
+ var order = {
73
+ OrderType: 'TWAP',
74
+ Price: new BigNumber('100.1234')
75
+ };
76
+ order.Price.symbol = 'USD';
77
+ expect(getOrderPriceToDisplay(order, 2)).toBe('100.12');
78
+ });
79
+ it('keeps a zero price of another order type blank', function () {
80
+ var _require7 = require('./orderHistoryHelper'),
81
+ getOrderPriceToDisplay = _require7.getOrderPriceToDisplay;
82
+ expect(getOrderPriceToDisplay({
83
+ OrderType: 'Limit',
84
+ Price: 0
85
+ }, 2, function (key) {
86
+ return key;
87
+ })).toBe('');
88
+ });
44
89
  });
45
90
  describe('getFuturesOrderPriceToDisplay', function () {
46
91
  it('returns trailingPrice if such field exists in the order', function () {
47
- var _require5 = require('./orderHistoryHelper'),
48
- getFuturesOrderPriceToDisplay = _require5.getFuturesOrderPriceToDisplay;
92
+ var _require8 = require('./orderHistoryHelper'),
93
+ getFuturesOrderPriceToDisplay = _require8.getFuturesOrderPriceToDisplay;
49
94
  var BigNumber = require('bignumber.js');
50
95
  var order = {
51
96
  Price: new BigNumber('100'),
@@ -56,8 +101,8 @@ describe('orderHistoryHelper', function () {
56
101
  expect(result).toEqual('TRL');
57
102
  });
58
103
  it('returns formatted Price if there is no trailingPrice', function () {
59
- var _require6 = require('./orderHistoryHelper'),
60
- getFuturesOrderPriceToDisplay = _require6.getFuturesOrderPriceToDisplay;
104
+ var _require9 = require('./orderHistoryHelper'),
105
+ getFuturesOrderPriceToDisplay = _require9.getFuturesOrderPriceToDisplay;
61
106
  var BigNumber = require('bignumber.js');
62
107
  var order = {
63
108
  Price: new BigNumber('100.1234')
@@ -67,8 +112,8 @@ describe('orderHistoryHelper', function () {
67
112
  expect(result).toEqual('100.12');
68
113
  });
69
114
  it('returns formatted Price when Price is 0 (not null/undefined)', function () {
70
- var _require7 = require('./orderHistoryHelper'),
71
- getFuturesOrderPriceToDisplay = _require7.getFuturesOrderPriceToDisplay;
115
+ var _require0 = require('./orderHistoryHelper'),
116
+ getFuturesOrderPriceToDisplay = _require0.getFuturesOrderPriceToDisplay;
72
117
  var order = {
73
118
  Price: 0
74
119
  };
@@ -76,8 +121,8 @@ describe('orderHistoryHelper', function () {
76
121
  expect(result).toEqual('0.00');
77
122
  });
78
123
  it('returns empty string if Price is null', function () {
79
- var _require8 = require('./orderHistoryHelper'),
80
- getFuturesOrderPriceToDisplay = _require8.getFuturesOrderPriceToDisplay;
124
+ var _require1 = require('./orderHistoryHelper'),
125
+ getFuturesOrderPriceToDisplay = _require1.getFuturesOrderPriceToDisplay;
81
126
  var order = {
82
127
  Price: null
83
128
  };
@@ -85,8 +130,8 @@ describe('orderHistoryHelper', function () {
85
130
  expect(result).toBe('');
86
131
  });
87
132
  it('returns empty string if Price is undefined', function () {
88
- var _require9 = require('./orderHistoryHelper'),
89
- getFuturesOrderPriceToDisplay = _require9.getFuturesOrderPriceToDisplay;
133
+ var _require10 = require('./orderHistoryHelper'),
134
+ getFuturesOrderPriceToDisplay = _require10.getFuturesOrderPriceToDisplay;
90
135
  var order = {};
91
136
  var result = getFuturesOrderPriceToDisplay(order, 2);
92
137
  expect(result).toBe('');
@@ -94,9 +139,9 @@ describe('orderHistoryHelper', function () {
94
139
  });
95
140
  describe('getOrderPriceToDisplay vs getFuturesOrderPriceToDisplay', function () {
96
141
  it('handles Price: 0 differently between the two functions', function () {
97
- var _require0 = require('./orderHistoryHelper'),
98
- getOrderPriceToDisplay = _require0.getOrderPriceToDisplay,
99
- getFuturesOrderPriceToDisplay = _require0.getFuturesOrderPriceToDisplay;
142
+ var _require11 = require('./orderHistoryHelper'),
143
+ getOrderPriceToDisplay = _require11.getOrderPriceToDisplay,
144
+ getFuturesOrderPriceToDisplay = _require11.getFuturesOrderPriceToDisplay;
100
145
  var order = {
101
146
  Price: 0
102
147
  };