-
Notifications
You must be signed in to change notification settings - Fork 1
/
QuickTrade.40a741ee8d94e9cce7d6.js
2754 lines (2361 loc) · 247 KB
/
QuickTrade.40a741ee8d94e9cce7d6.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(this["webpackJsonp"] = this["webpackJsonp"] || []).push([[7],{
/***/ 2723:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasLoaded", function() { return hasLoaded; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bindToCurrentAccount", function() { return bindToCurrentAccount; });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(395);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _ChainTypes__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1973);
/* harmony import */ var react_debounce_render__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2109);
/* harmony import */ var react_debounce_render__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react_debounce_render__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _BindToChainState__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1974);
/* harmony import */ var alt_react__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1854);
/* harmony import */ var _stores_AccountStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(544);
/* harmony import */ var _LoadingIndicator__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(1957);
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var hasLoaded = function hasLoaded(currentAccount) {
return !!currentAccount && !!currentAccount.get("id");
};
var bindToCurrentAccount = function bindToCurrentAccount(WrappedComponent) {
var _class, _temp;
// ...and returns another component...
var BindToCurrentAccount = (_temp = _class = function (_React$Component) {
_inherits(BindToCurrentAccount, _React$Component);
function BindToCurrentAccount(props) {
_classCallCheck(this, BindToCurrentAccount);
return _possibleConstructorReturn(this, (BindToCurrentAccount.__proto__ || Object.getPrototypeOf(BindToCurrentAccount)).call(this, props));
}
_createClass(BindToCurrentAccount, [{
key: "render",
value: function render() {
if (hasLoaded(this.props.currentAccount)) {
return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(WrappedComponent, this.props);
} else {
return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_LoadingIndicator__WEBPACK_IMPORTED_MODULE_6__["default"], null);
}
}
}]);
return BindToCurrentAccount;
}(react__WEBPACK_IMPORTED_MODULE_0___default.a.Component), _class.propTypes = {
currentAccount: _ChainTypes__WEBPACK_IMPORTED_MODULE_1__["default"].ChainAccount
}, _class.defaultProps = {
// set subscription
autosubscribe: true
}, _temp);
BindToCurrentAccount = Object(_BindToChainState__WEBPACK_IMPORTED_MODULE_3__["default"])(BindToCurrentAccount);
BindToCurrentAccount = react_debounce_render__WEBPACK_IMPORTED_MODULE_2___default()(BindToCurrentAccount, 100, {
leading: false
});
return Object(alt_react__WEBPACK_IMPORTED_MODULE_4__["connect"])(BindToCurrentAccount, {
listenTo: function listenTo() {
return [_stores_AccountStore__WEBPACK_IMPORTED_MODULE_5__["default"]];
},
getProps: function getProps() {
var currentAccount = _stores_AccountStore__WEBPACK_IMPORTED_MODULE_5__["default"].getState().currentAccount || _stores_AccountStore__WEBPACK_IMPORTED_MODULE_5__["default"].getState().passwordAccount || "please-login";
return {
currentAccount: new Map([["name", currentAccount]])
};
}
});
};
/***/ }),
/***/ 2740:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _isObject_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(623);
/* harmony import */ var _now_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2741);
/* harmony import */ var _toNumber_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2088);
/** Error message constants. */
var FUNC_ERROR_TEXT = 'Expected a function';
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeMax = Math.max,
nativeMin = Math.min;
/**
* Creates a debounced function that delays invoking `func` until after `wait`
* milliseconds have elapsed since the last time the debounced function was
* invoked. The debounced function comes with a `cancel` method to cancel
* delayed `func` invocations and a `flush` method to immediately invoke them.
* Provide `options` to indicate whether `func` should be invoked on the
* leading and/or trailing edge of the `wait` timeout. The `func` is invoked
* with the last arguments provided to the debounced function. Subsequent
* calls to the debounced function return the result of the last `func`
* invocation.
*
* **Note:** If `leading` and `trailing` options are `true`, `func` is
* invoked on the trailing edge of the timeout only if the debounced function
* is invoked more than once during the `wait` timeout.
*
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
* until to the next tick, similar to `setTimeout` with a timeout of `0`.
*
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
* for details over the differences between `_.debounce` and `_.throttle`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Function
* @param {Function} func The function to debounce.
* @param {number} [wait=0] The number of milliseconds to delay.
* @param {Object} [options={}] The options object.
* @param {boolean} [options.leading=false]
* Specify invoking on the leading edge of the timeout.
* @param {number} [options.maxWait]
* The maximum time `func` is allowed to be delayed before it's invoked.
* @param {boolean} [options.trailing=true]
* Specify invoking on the trailing edge of the timeout.
* @returns {Function} Returns the new debounced function.
* @example
*
* // Avoid costly calculations while the window size is in flux.
* jQuery(window).on('resize', _.debounce(calculateLayout, 150));
*
* // Invoke `sendMail` when clicked, debouncing subsequent calls.
* jQuery(element).on('click', _.debounce(sendMail, 300, {
* 'leading': true,
* 'trailing': false
* }));
*
* // Ensure `batchLog` is invoked once after 1 second of debounced calls.
* var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
* var source = new EventSource('/stream');
* jQuery(source).on('message', debounced);
*
* // Cancel the trailing debounced invocation.
* jQuery(window).on('popstate', debounced.cancel);
*/
function debounce(func, wait, options) {
var lastArgs,
lastThis,
maxWait,
result,
timerId,
lastCallTime,
lastInvokeTime = 0,
leading = false,
maxing = false,
trailing = true;
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
wait = Object(_toNumber_js__WEBPACK_IMPORTED_MODULE_2__["default"])(wait) || 0;
if (Object(_isObject_js__WEBPACK_IMPORTED_MODULE_0__["default"])(options)) {
leading = !!options.leading;
maxing = 'maxWait' in options;
maxWait = maxing ? nativeMax(Object(_toNumber_js__WEBPACK_IMPORTED_MODULE_2__["default"])(options.maxWait) || 0, wait) : maxWait;
trailing = 'trailing' in options ? !!options.trailing : trailing;
}
function invokeFunc(time) {
var args = lastArgs,
thisArg = lastThis;
lastArgs = lastThis = undefined;
lastInvokeTime = time;
result = func.apply(thisArg, args);
return result;
}
function leadingEdge(time) {
// Reset any `maxWait` timer.
lastInvokeTime = time;
// Start the timer for the trailing edge.
timerId = setTimeout(timerExpired, wait);
// Invoke the leading edge.
return leading ? invokeFunc(time) : result;
}
function remainingWait(time) {
var timeSinceLastCall = time - lastCallTime,
timeSinceLastInvoke = time - lastInvokeTime,
timeWaiting = wait - timeSinceLastCall;
return maxing
? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
: timeWaiting;
}
function shouldInvoke(time) {
var timeSinceLastCall = time - lastCallTime,
timeSinceLastInvoke = time - lastInvokeTime;
// Either this is the first call, activity has stopped and we're at the
// trailing edge, the system time has gone backwards and we're treating
// it as the trailing edge, or we've hit the `maxWait` limit.
return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
(timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
}
function timerExpired() {
var time = Object(_now_js__WEBPACK_IMPORTED_MODULE_1__["default"])();
if (shouldInvoke(time)) {
return trailingEdge(time);
}
// Restart the timer.
timerId = setTimeout(timerExpired, remainingWait(time));
}
function trailingEdge(time) {
timerId = undefined;
// Only invoke if we have `lastArgs` which means `func` has been
// debounced at least once.
if (trailing && lastArgs) {
return invokeFunc(time);
}
lastArgs = lastThis = undefined;
return result;
}
function cancel() {
if (timerId !== undefined) {
clearTimeout(timerId);
}
lastInvokeTime = 0;
lastArgs = lastCallTime = lastThis = timerId = undefined;
}
function flush() {
return timerId === undefined ? result : trailingEdge(Object(_now_js__WEBPACK_IMPORTED_MODULE_1__["default"])());
}
function debounced() {
var time = Object(_now_js__WEBPACK_IMPORTED_MODULE_1__["default"])(),
isInvoking = shouldInvoke(time);
lastArgs = arguments;
lastThis = this;
lastCallTime = time;
if (isInvoking) {
if (timerId === undefined) {
return leadingEdge(lastCallTime);
}
if (maxing) {
// Handle invocations in a tight loop.
timerId = setTimeout(timerExpired, wait);
return invokeFunc(lastCallTime);
}
}
if (timerId === undefined) {
timerId = setTimeout(timerExpired, wait);
}
return result;
}
debounced.cancel = cancel;
debounced.flush = flush;
return debounced;
}
/* harmony default export */ __webpack_exports__["default"] = (debounce);
/***/ }),
/***/ 2741:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _root_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(619);
/**
* Gets the timestamp of the number of milliseconds that have elapsed since
* the Unix epoch (1 January 1970 00:00:00 UTC).
*
* @static
* @memberOf _
* @since 2.4.0
* @category Date
* @returns {number} Returns the timestamp.
* @example
*
* _.defer(function(stamp) {
* console.log(_.now() - stamp);
* }, _.now());
* // => Logs the number of milliseconds it took for the deferred invocation.
*/
var now = function() {
return _root_js__WEBPACK_IMPORTED_MODULE_0__["default"].Date.now();
};
/* harmony default export */ __webpack_exports__["default"] = (now);
/***/ }),
/***/ 2813:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lookupAssets", function() { return lookupAssets; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "assetFilter", function() { return assetFilter; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fetchIssuerName", function() { return fetchIssuerName; });
/* harmony import */ var common_gatewayUtils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2106);
/* harmony import */ var bitsharesjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(410);
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
function lookupAssets(value) {
var gatewayAssets = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var getAssetList = arguments[2];
var setState = arguments[3];
if (!value && value !== "") return;
var quote = value.toUpperCase();
if (quote.startsWith("BIT") && quote.length >= 6) {
quote = value.substr(3, quote.length - 1);
}
getAssetList(quote, 10, gatewayAssets);
setState({ lookupQuote: quote });
}
function assetFilter(_ref, _ref2, setState, checkAndUpdateMarketList) {
var searchAssets = _ref.searchAssets,
marketPickerAsset = _ref.marketPickerAsset,
baseAsset = _ref.baseAsset,
quoteAsset = _ref.quoteAsset;
var inputValue = _ref2.inputValue,
lookupQuote = _ref2.lookupQuote;
setState({ activeSearch: true });
var assetCount = 0;
var allMarkets = [];
var baseSymbol = baseAsset.get("symbol");
var quoteSymbol = quoteAsset.get("symbol");
if (searchAssets.size && !!inputValue && inputValue.length > 2) {
searchAssets.filter(function (a) {
try {
if (a.options.description) {
var description = JSON.parse(a.options.description);
if ("visible" in description) {
if (!description.visible) return false;
}
}
} catch (e) {}
return a.symbol.indexOf(lookupQuote) !== -1;
}).forEach(function (asset) {
if (assetCount > 100) return;
assetCount++;
var issuerName = fetchIssuerName(asset.issuer);
var base = baseAsset.get("symbol");
var marketID = asset.symbol + "_" + base;
var isQuoteAsset = quoteSymbol == marketPickerAsset;
var includeAsset = isQuoteAsset && asset.symbol != baseSymbol || !isQuoteAsset && asset.symbol != quoteSymbol;
if (includeAsset) {
allMarkets.push([marketID, {
quote: asset.symbol,
base: base,
issuerId: asset.issuer,
issuer: issuerName
}]);
}
});
}
var marketsList = sortMarketsList(allMarkets, inputValue);
checkAndUpdateMarketList(marketsList);
}
function getMarketSortComponents(market) {
var weight = {};
var quote = market.quote;
if (quote.indexOf(".") !== -1) {
var _quote$split = quote.split("."),
_quote$split2 = _slicedToArray(_quote$split, 2),
gateway = _quote$split2[0],
asset = _quote$split2[1];
weight.gateway = gateway;
weight.asset = asset;
} else {
weight.asset = quote;
}
if (market.issuerId === "1.2.0") weight.isCommittee = true;
return weight;
}
function sortMarketsList(allMarkets, inputValue) {
if (inputValue.startsWith("BIT") && inputValue.length >= 6) {
inputValue = inputValue.substr(3, inputValue.length - 1);
}
return allMarkets.sort(function (_ref3, _ref4) {
var _ref6 = _slicedToArray(_ref3, 2),
marketA = _ref6[1];
var _ref5 = _slicedToArray(_ref4, 2),
marketB = _ref5[1];
var weightA = getMarketSortComponents(marketA);
var weightB = getMarketSortComponents(marketB);
if (weightA.asset !== weightB.asset) {
if (weightA.asset === inputValue) return -1;
if (weightB.asset === inputValue) return 1;
if (weightA.asset > weightB.asset) return -1;
if (weightA.asset < weightB.asset) return 1;
}
if (weightA.isCommittee ^ weightB.isCommittee) {
if (weightA.isCommittee) return -1;
if (weightB.isCommittee) return 1;
}
var aIsKnownGateway = Object(common_gatewayUtils__WEBPACK_IMPORTED_MODULE_0__["hasGatewayPrefix"])(marketA.quote);
var bIsKnownGateway = Object(common_gatewayUtils__WEBPACK_IMPORTED_MODULE_0__["hasGatewayPrefix"])(marketB.quote);
if (aIsKnownGateway && !bIsKnownGateway) return -1;
if (bIsKnownGateway && !aIsKnownGateway) return 1;
if (weightA.gateway > weightB.gateway) return 1;
if (weightA.gateway < weightB.gateway) return -1;
return 0;
});
}
function fetchIssuerName(issuerId) {
var issuer = bitsharesjs__WEBPACK_IMPORTED_MODULE_1__["ChainStore"].getObject(issuerId, false, false);
if (!issuer) {
return;
} else {
return issuer.get("name");
}
}
/***/ }),
/***/ 3306:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(395);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _Page404_Page404__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2623);
/* harmony import */ var _QuickTrade__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3307);
/* harmony import */ var _Utility_ChainTypes__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1973);
/* harmony import */ var _Utility_BindToChainState__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1974);
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var QuickTradeSubscriber = function (_Component) {
_inherits(QuickTradeSubscriber, _Component);
function QuickTradeSubscriber() {
_classCallCheck(this, QuickTradeSubscriber);
return _possibleConstructorReturn(this, (QuickTradeSubscriber.__proto__ || Object.getPrototypeOf(QuickTradeSubscriber)).apply(this, arguments));
}
_createClass(QuickTradeSubscriber, [{
key: "render",
value: function render() {
if (!!this.props.assetToReceive.get && !!this.props.assetToSell.get) {
return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_QuickTrade__WEBPACK_IMPORTED_MODULE_2__["default"], this.props);
} else {
return null;
}
}
}]);
return QuickTradeSubscriber;
}(react__WEBPACK_IMPORTED_MODULE_0__["Component"]);
QuickTradeSubscriber.propTypes = {
assetToSell: _Utility_ChainTypes__WEBPACK_IMPORTED_MODULE_3__["default"].ChainAsset,
assetToReceive: _Utility_ChainTypes__WEBPACK_IMPORTED_MODULE_3__["default"].ChainAsset
};
QuickTradeSubscriber.defaultProps = {
assetToSell: "CNY",
assetToReceive: "BTS"
};
var QuickTradeAssetResolver = Object(_Utility_BindToChainState__WEBPACK_IMPORTED_MODULE_4__["default"])(QuickTradeSubscriber, {
show_loader: true
});
var QuickTradeRouter = function (_Component2) {
_inherits(QuickTradeRouter, _Component2);
function QuickTradeRouter() {
_classCallCheck(this, QuickTradeRouter);
return _possibleConstructorReturn(this, (QuickTradeRouter.__proto__ || Object.getPrototypeOf(QuickTradeRouter)).apply(this, arguments));
}
_createClass(QuickTradeRouter, [{
key: "render",
value: function render() {
var symbols = !!this.props.match.params.marketID ? this.props.match.params.marketID.toUpperCase().split("_") : ["", ""];
if (symbols.length == 2 && !!symbols[0] && symbols[0] === symbols[1]) {
return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_Page404_Page404__WEBPACK_IMPORTED_MODULE_1__["default"], { subtitle: "market_not_found_subtitle" });
}
if (false) {}
return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(QuickTradeAssetResolver, _extends({}, this.props, {
assetToSell: symbols[0] || "",
assetToReceive: symbols.length == 2 ? symbols[1] : ""
}));
}
}]);
return QuickTradeRouter;
}(react__WEBPACK_IMPORTED_MODULE_0__["Component"]);
/* harmony default export */ __webpack_exports__["default"] = (QuickTradeRouter);
/***/ }),
/***/ 3307:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var lodash_es_debounce__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2740);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(395);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _Utility_BindToCurrentAccount__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2723);
/* harmony import */ var alt_react__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1854);
/* harmony import */ var _stores_AssetStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(2356);
/* harmony import */ var _stores_MarketsStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(2345);
/* harmony import */ var bitshares_ui_style_guide__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(728);
/* harmony import */ var bitshares_ui_style_guide__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(bitshares_ui_style_guide__WEBPACK_IMPORTED_MODULE_6__);
/* harmony import */ var components_QuickTrade_SellReceive__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(3308);
/* harmony import */ var actions_MarketsActions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(2346);
/* harmony import */ var _QuickTradeHelper__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(3311);
/* harmony import */ var bitsharesjs__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(410);
/* harmony import */ var actions_AssetActions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(2357);
/* harmony import */ var _Exchange_MarketPickerHelpers__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(2813);
/* harmony import */ var counterpart__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(578);
/* harmony import */ var counterpart__WEBPACK_IMPORTED_MODULE_13___default = /*#__PURE__*/__webpack_require__.n(counterpart__WEBPACK_IMPORTED_MODULE_13__);
/* harmony import */ var _Utility_LinkToAccountById__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(2418);
/* harmony import */ var common_MarketClasses__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(589);
/* harmony import */ var _Utility_FormattedPrice__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(2420);
/* harmony import */ var _Utility_AssetName__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(2100);
/* harmony import */ var react_translate_component__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(1860);
/* harmony import */ var react_translate_component__WEBPACK_IMPORTED_MODULE_18___default = /*#__PURE__*/__webpack_require__.n(react_translate_component__WEBPACK_IMPORTED_MODULE_18__);
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var QuickTrade = function (_Component) {
_inherits(QuickTrade, _Component);
function QuickTrade(props) {
_classCallCheck(this, QuickTrade);
var _this = _possibleConstructorReturn(this, (QuickTrade.__proto__ || Object.getPrototypeOf(QuickTrade)).call(this, props));
var accountAssets = Object(_QuickTradeHelper__WEBPACK_IMPORTED_MODULE_9__["getAssetsToSell"])(props.currentAccount);
_this.state = {
mounted: false,
sub: "",
sellAssetInput: "",
sellAsset: null,
sellAssets: accountAssets,
sellAmount: "",
sellImgName: "unknown",
receiveAssetInput: "",
receiveAsset: null,
receiveAssets: accountAssets,
receiveAmount: "",
receiveImgName: "unknown",
activeInput: "",
activeAmountInput: "",
lookupQuote: "",
orders: [],
orderView: "amount",
fees: null,
prices: null,
isSubscribedToMarket: true
};
_this.onSellAssetInputChange = _this.onSellAssetInputChange.bind(_this);
_this.onReceiveAssetInputChange = _this.onReceiveAssetInputChange.bind(_this);
_this.onSellAmountChange = _this.onSellAmountChange.bind(_this);
_this.onReceiveAmountChange = _this.onReceiveAmountChange.bind(_this);
_this.onSellImageError = _this.onSellImageError.bind(_this);
_this.onReceiveImageError = _this.onReceiveImageError.bind(_this);
_this.onReceiveAssetSearch = _this.onReceiveAssetSearch.bind(_this);
_this.onSwap = _this.onSwap.bind(_this);
_this.handleSubscriptionToggleChange = _this.handleSubscriptionToggleChange.bind(_this);
_this.hendleOrderView = _this.hendleOrderView.bind(_this);
_this.handleSell = _this.handleSell.bind(_this);
_this._subToMarket = _this._subToMarket.bind(_this);
_this._checkAndUpdateMarketList = _this._checkAndUpdateMarketList.bind(_this);
_this.getAssetList = Object(lodash_es_debounce__WEBPACK_IMPORTED_MODULE_0__["default"])(actions_AssetActions__WEBPACK_IMPORTED_MODULE_11__["default"].getAssetList.defer, 150);
return _this;
}
_createClass(QuickTrade, [{
key: "_routeTo",
value: function _routeTo(assetToSell, assetToReceive) {
var sellRoute = assetToSell;
var receiveRoute = assetToReceive;
if (!assetToSell) {
sellRoute = "";
}
if (!assetToReceive) {
receiveRoute = "";
}
var pathName = "/instant-trade/" + sellRoute + "_" + receiveRoute;
if (false) {}
if (this.props.location.pathname !== pathName) {
this.props.history.push(pathName);
}
}
}, {
key: "_areEqualAssets",
value: function _areEqualAssets(asset1, asset2) {
return this._isLoadedAsset(asset1) && this._isLoadedAsset(asset2) && asset1.get("id") === asset2.get("id");
}
}, {
key: "_isLoadedAsset",
value: function _isLoadedAsset(asset) {
return !!asset && !!asset.toJS;
}
}, {
key: "_areAssetsGiven",
value: function _areAssetsGiven() {
return this._isLoadedAsset(this.props.assetToSell) && this._isLoadedAsset(this.props.assetToReceive);
}
}, {
key: "_haveAssetsChanged",
value: function _haveAssetsChanged(prevProps) {
if (this._isLoadedAsset(this.props.assetToSell) !== this._isLoadedAsset(prevProps.assetToSell)) {
return true;
}
if (this._isLoadedAsset(this.props.assetToReceive) !== this._isLoadedAsset(prevProps.assetToReceive)) {
return true;
}
if (!this._areEqualAssets(this.props.assetToSell, prevProps.assetToSell) || !this._areEqualAssets(this.props.assetToReceive, prevProps.assetToReceive)) {
return true;
}
return false;
}
}, {
key: "_hasMarketChanged",
value: function _hasMarketChanged(prevProps) {
return JSON.stringify(prevProps.marketData) !== JSON.stringify(this.props.marketData);
}
}, {
key: "componentDidUpdate",
value: function componentDidUpdate(prevProps) {
var _this2 = this;
if (this._haveAssetsChanged(prevProps)) {
this._assetsHaveChanged();
} else {
if (this._hasMarketChanged(prevProps)) {
this._getOrders();
}
}
if (this.props.searchAssets !== prevProps.searchAssets) {
this.setState({ activeSearch: true });
var filteredAssets = this.props.searchAssets.toArray().filter(function (a) {
return a.symbol.indexOf(_this2.state.lookupQuote) !== -1;
});
this._checkAndUpdateMarketList(filteredAssets);
}
if (this.props.currentAccount !== prevProps.currentAccount) {
var assets = Object(_QuickTradeHelper__WEBPACK_IMPORTED_MODULE_9__["getAssetsToSell"])(this.props.currentAccount);
this.setState({
sellAssets: assets,
receiveAssets: assets
});
}
}
}, {
key: "componentDidMount",
value: function componentDidMount() {
this.setState({
mounted: true
});
if (this._areAssetsGiven()) {
this._assetsHaveChanged();
}
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
var sub = this.state.sub;
var _getAssetsDetails = this.getAssetsDetails(),
sellAssetId = _getAssetsDetails.sellAssetId,
receiveAssetId = _getAssetsDetails.receiveAssetId;
if (sub) {
actions_MarketsActions__WEBPACK_IMPORTED_MODULE_8__["default"].unSubscribeMarket(sellAssetId, receiveAssetId);
}
}
}, {
key: "_subToMarket",
value: function () {
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
var _this3 = this;
var _state, baseAsset, quoteAsset, sub, _getAssetsDetails2, baseAssetId, quoteAssetId, _props, bucketSize, currentGroupOrderLimit, _sub$split, _sub$split2, qa, ba;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_state = this.state, baseAsset = _state.receiveAsset, quoteAsset = _state.sellAsset, sub = _state.sub;
if (!(baseAsset && quoteAsset)) {
_context.next = 13;
break;
}
_getAssetsDetails2 = this.getAssetsDetails(), baseAssetId = _getAssetsDetails2.receiveAssetId, quoteAssetId = _getAssetsDetails2.sellAssetId;
_props = this.props, bucketSize = _props.bucketSize, currentGroupOrderLimit = _props.currentGroupOrderLimit;
if (!sub) {
_context.next = 10;
break;
}
_sub$split = sub.split("_"), _sub$split2 = _slicedToArray(_sub$split, 2), qa = _sub$split2[0], ba = _sub$split2[1];
if (!(qa === quoteAssetId && ba === baseAssetId)) {
_context.next = 8;
break;
}
return _context.abrupt("return");
case 8:
_context.next = 10;
return actions_MarketsActions__WEBPACK_IMPORTED_MODULE_8__["default"].unSubscribeMarket(qa, ba);
case 10:
_context.next = 12;
return actions_MarketsActions__WEBPACK_IMPORTED_MODULE_8__["default"].subscribeMarket(baseAsset, quoteAsset, 3600, 0);
case 12:
this.setState({
sub: quoteAssetId + "_" + baseAssetId
}, function () {
_this3.getAllPrices();
_this3.getAllFees();
});
case 13:
case "end":
return _context.stop();
}
}
}, _callee, this);
}));
function _subToMarket() {
return _ref.apply(this, arguments);
}
return _subToMarket;
}()
}, {
key: "getAllFees",
value: function () {
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
var currentAccount, _state2, sellAsset, receiveAsset, fees;
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
currentAccount = this.props.currentAccount;
_state2 = this.state, sellAsset = _state2.sellAsset, receiveAsset = _state2.receiveAsset;
if (!(sellAsset && receiveAsset)) {
_context2.next = 7;
break;
}
_context2.next = 5;
return Object(_QuickTradeHelper__WEBPACK_IMPORTED_MODULE_9__["getFees"])(receiveAsset, sellAsset, currentAccount);
case 5:
fees = _context2.sent;
this.setState({
fees: fees
});
case 7:
case "end":
return _context2.stop();
}
}
}, _callee2, this);
}));
function getAllFees() {
return _ref2.apply(this, arguments);
}
return getAllFees;
}()
}, {
key: "getAssetsDetails",
value: function getAssetsDetails() {
var _state3 = this.state,
sellAsset = _state3.sellAsset,
receiveAsset = _state3.receiveAsset;
return {
sellAssetId: sellAsset ? sellAsset.get("id") : null,
receiveAssetId: receiveAsset ? receiveAsset.get("id") : null,
sellAssetPrecision: sellAsset ? sellAsset.get("precision") : null,
receiveAssetPrecision: receiveAsset ? receiveAsset.get("precision") : null,
sellAssetSymbol: sellAsset ? sellAsset.get("symbol") : null,
receiveAssetSymbol: receiveAsset ? receiveAsset.get("symbol") : null
};
}
}, {
key: "getAllPrices",
value: function getAllPrices() {
var _props2 = this.props,
activeMarketHistory = _props2.activeMarketHistory,
feedPrice = _props2.feedPrice;
var prices = Object(_QuickTradeHelper__WEBPACK_IMPORTED_MODULE_9__["getPrices"])(activeMarketHistory, feedPrice);
this.setState({
prices: prices
});
}
}, {
key: "_getOrders",
value: function _getOrders() {
var _this4 = this;
if (!this.state.isSubscribedToMarket) {
console.log(this.props.marketData);
// if the user wants to inspect current orders, pause updating
return;
}
var combinedBids = this.props.marketData.combinedBids;
var _state4 = this.state,
sellAsset = _state4.sellAsset,
receiveAsset = _state4.receiveAsset,
sellAmount = _state4.sellAmount,
receiveAmount = _state4.receiveAmount,
activeInput = _state4.activeInput;
var _getAssetsDetails3 = this.getAssetsDetails(),
sellAssetPrecision = _getAssetsDetails3.sellAssetPrecision,
receiveAssetPrecision = _getAssetsDetails3.receiveAssetPrecision;
if (false) {}
if (combinedBids && combinedBids.length) {
if (sellAsset && receiveAsset) {
switch (activeInput) {
case "receiveAsset":
if (sellAmount) {
var orders = Object(_QuickTradeHelper__WEBPACK_IMPORTED_MODULE_9__["getOrders"])(sellAmount * Math.pow(10, sellAssetPrecision), combinedBids, "sell");
this.setState({
orders: orders,
ordersUpdated: new Date()
}, function () {
return _this4.updateReceiveAmount();
});
}
break;
case "sellAsset":
if (receiveAmount) {
var _orders = Object(_QuickTradeHelper__WEBPACK_IMPORTED_MODULE_9__["getOrders"])(receiveAmount * Math.pow(10, receiveAssetPrecision), combinedBids, "receive");
this.setState({
orders: _orders,
ordersUpdated: new Date()
}, function () {
return _this4.updateSellAmount();
});
}
break;
case "sell":
if (sellAmount) {
var _orders2 = Object(_QuickTradeHelper__WEBPACK_IMPORTED_MODULE_9__["getOrders"])(sellAmount * Math.pow(10, sellAssetPrecision), combinedBids, "sell");
this.setState({
orders: _orders2,
ordersUpdated: new Date()
}, function () {
return _this4.updateReceiveAmount();
});
} else {
this.setState({
orders: [],
receiveAmount: ""
});
}
break;
case "receive":
if (receiveAmount) {
var _orders3 = Object(_QuickTradeHelper__WEBPACK_IMPORTED_MODULE_9__["getOrders"])(receiveAmount * Math.pow(10, receiveAssetPrecision), combinedBids, "receive");
this.setState({
orders: _orders3,
ordersUpdated: new Date()
}, function () {