@depay/widgets 7.16.4 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/umd/index.js CHANGED
@@ -17,29 +17,24 @@
17
17
  reject(error);
18
18
  return;
19
19
  }
20
-
21
20
  if (info.done) {
22
21
  resolve(value);
23
22
  } else {
24
23
  Promise.resolve(value).then(_next, _throw);
25
24
  }
26
25
  }
27
-
28
26
  function _asyncToGenerator(fn) {
29
27
  return function () {
30
28
  var self = this,
31
- args = arguments;
29
+ args = arguments;
32
30
  return new Promise(function (resolve, reject) {
33
31
  var gen = fn.apply(self, args);
34
-
35
32
  function _next(value) {
36
33
  asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
37
34
  }
38
-
39
35
  function _throw(err) {
40
36
  asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
41
37
  }
42
-
43
38
  _next(undefined);
44
39
  });
45
40
  };
@@ -72,27 +67,22 @@
72
67
  return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
73
68
  }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
74
69
  }
75
-
76
70
  module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
77
71
  });
78
72
 
79
73
  var regeneratorRuntime$1 = createCommonjsModule(function (module) {
80
74
  var _typeof = _typeof_1["default"];
81
-
82
75
  function _regeneratorRuntime() {
83
- /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
84
-
85
76
  module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
86
77
  return exports;
87
78
  }, module.exports.__esModule = true, module.exports["default"] = module.exports;
88
79
  var exports = {},
89
- Op = Object.prototype,
90
- hasOwn = Op.hasOwnProperty,
91
- $Symbol = "function" == typeof Symbol ? Symbol : {},
92
- iteratorSymbol = $Symbol.iterator || "@@iterator",
93
- asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
94
- toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
95
-
80
+ Op = Object.prototype,
81
+ hasOwn = Op.hasOwnProperty,
82
+ $Symbol = "function" == typeof Symbol ? Symbol : {},
83
+ iteratorSymbol = $Symbol.iterator || "@@iterator",
84
+ asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
85
+ toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
96
86
  function define(obj, key, value) {
97
87
  return Object.defineProperty(obj, key, {
98
88
  value: value,
@@ -101,7 +91,6 @@
101
91
  writable: !0
102
92
  }), obj[key];
103
93
  }
104
-
105
94
  try {
106
95
  define({}, "");
107
96
  } catch (err) {
@@ -109,40 +98,33 @@
109
98
  return obj[key] = value;
110
99
  };
111
100
  }
112
-
113
101
  function wrap(innerFn, outerFn, self, tryLocsList) {
114
102
  var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
115
- generator = Object.create(protoGenerator.prototype),
116
- context = new Context(tryLocsList || []);
103
+ generator = Object.create(protoGenerator.prototype),
104
+ context = new Context(tryLocsList || []);
117
105
  return generator._invoke = function (innerFn, self, context) {
118
106
  var state = "suspendedStart";
119
107
  return function (method, arg) {
120
108
  if ("executing" === state) throw new Error("Generator is already running");
121
-
122
109
  if ("completed" === state) {
123
110
  if ("throw" === method) throw arg;
124
111
  return doneResult();
125
112
  }
126
-
127
113
  for (context.method = method, context.arg = arg;;) {
128
114
  var delegate = context.delegate;
129
-
130
115
  if (delegate) {
131
116
  var delegateResult = maybeInvokeDelegate(delegate, context);
132
-
133
117
  if (delegateResult) {
134
118
  if (delegateResult === ContinueSentinel) continue;
135
119
  return delegateResult;
136
120
  }
137
121
  }
138
-
139
122
  if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
140
123
  if ("suspendedStart" === state) throw state = "completed", context.arg;
141
124
  context.dispatchException(context.arg);
142
125
  } else "return" === context.method && context.abrupt("return", context.arg);
143
126
  state = "executing";
144
127
  var record = tryCatch(innerFn, self, context);
145
-
146
128
  if ("normal" === record.type) {
147
129
  if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
148
130
  return {
@@ -150,13 +132,11 @@
150
132
  done: context.done
151
133
  };
152
134
  }
153
-
154
135
  "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
155
136
  }
156
137
  };
157
138
  }(innerFn, self, context), generator;
158
139
  }
159
-
160
140
  function tryCatch(fn, obj, arg) {
161
141
  try {
162
142
  return {
@@ -170,25 +150,19 @@
170
150
  };
171
151
  }
172
152
  }
173
-
174
153
  exports.wrap = wrap;
175
154
  var ContinueSentinel = {};
176
-
177
155
  function Generator() {}
178
-
179
156
  function GeneratorFunction() {}
180
-
181
157
  function GeneratorFunctionPrototype() {}
182
-
183
158
  var IteratorPrototype = {};
184
159
  define(IteratorPrototype, iteratorSymbol, function () {
185
160
  return this;
186
161
  });
187
162
  var getProto = Object.getPrototypeOf,
188
- NativeIteratorPrototype = getProto && getProto(getProto(values([])));
163
+ NativeIteratorPrototype = getProto && getProto(getProto(values([])));
189
164
  NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
190
165
  var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
191
-
192
166
  function defineIteratorMethods(prototype) {
193
167
  ["next", "throw", "return"].forEach(function (method) {
194
168
  define(prototype, method, function (arg) {
@@ -196,14 +170,12 @@
196
170
  });
197
171
  });
198
172
  }
199
-
200
173
  function AsyncIterator(generator, PromiseImpl) {
201
174
  function invoke(method, arg, resolve, reject) {
202
175
  var record = tryCatch(generator[method], generator, arg);
203
-
204
176
  if ("throw" !== record.type) {
205
177
  var result = record.arg,
206
- value = result.value;
178
+ value = result.value;
207
179
  return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
208
180
  invoke("next", value, resolve, reject);
209
181
  }, function (err) {
@@ -214,91 +186,73 @@
214
186
  return invoke("throw", error, resolve, reject);
215
187
  });
216
188
  }
217
-
218
189
  reject(record.arg);
219
190
  }
220
-
221
191
  var previousPromise;
222
-
223
192
  this._invoke = function (method, arg) {
224
193
  function callInvokeWithMethodAndArg() {
225
194
  return new PromiseImpl(function (resolve, reject) {
226
195
  invoke(method, arg, resolve, reject);
227
196
  });
228
197
  }
229
-
230
198
  return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
231
199
  };
232
200
  }
233
-
234
201
  function maybeInvokeDelegate(delegate, context) {
235
202
  var method = delegate.iterator[context.method];
236
-
237
203
  if (undefined === method) {
238
204
  if (context.delegate = null, "throw" === context.method) {
239
205
  if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
240
206
  context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
241
207
  }
242
-
243
208
  return ContinueSentinel;
244
209
  }
245
-
246
210
  var record = tryCatch(method, delegate.iterator, context.arg);
247
211
  if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
248
212
  var info = record.arg;
249
213
  return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
250
214
  }
251
-
252
215
  function pushTryEntry(locs) {
253
216
  var entry = {
254
217
  tryLoc: locs[0]
255
218
  };
256
219
  1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
257
220
  }
258
-
259
221
  function resetTryEntry(entry) {
260
222
  var record = entry.completion || {};
261
223
  record.type = "normal", delete record.arg, entry.completion = record;
262
224
  }
263
-
264
225
  function Context(tryLocsList) {
265
226
  this.tryEntries = [{
266
227
  tryLoc: "root"
267
228
  }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
268
229
  }
269
-
270
230
  function values(iterable) {
271
231
  if (iterable) {
272
232
  var iteratorMethod = iterable[iteratorSymbol];
273
233
  if (iteratorMethod) return iteratorMethod.call(iterable);
274
234
  if ("function" == typeof iterable.next) return iterable;
275
-
276
235
  if (!isNaN(iterable.length)) {
277
236
  var i = -1,
278
- next = function next() {
279
- for (; ++i < iterable.length;) {
280
- if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
281
- }
282
-
283
- return next.value = undefined, next.done = !0, next;
284
- };
285
-
237
+ next = function next() {
238
+ for (; ++i < iterable.length;) {
239
+ if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
240
+ }
241
+ return next.value = undefined, next.done = !0, next;
242
+ };
286
243
  return next.next = next;
287
244
  }
288
245
  }
289
-
290
246
  return {
291
247
  next: doneResult
292
248
  };
293
249
  }
294
-
295
250
  function doneResult() {
296
251
  return {
297
252
  value: undefined,
298
253
  done: !0
299
254
  };
300
255
  }
301
-
302
256
  return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
303
257
  var ctor = "function" == typeof genFun && genFun.constructor;
304
258
  return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
@@ -322,17 +276,14 @@
322
276
  return "[object Generator]";
323
277
  }), exports.keys = function (object) {
324
278
  var keys = [];
325
-
326
279
  for (var key in object) {
327
280
  keys.push(key);
328
281
  }
329
-
330
282
  return keys.reverse(), function next() {
331
283
  for (; keys.length;) {
332
284
  var key = keys.pop();
333
285
  if (key in object) return next.value = key, next.done = !1, next;
334
286
  }
335
-
336
287
  return next.done = !0, next;
337
288
  };
338
289
  }, exports.values = values, Context.prototype = {
@@ -351,20 +302,16 @@
351
302
  dispatchException: function dispatchException(exception) {
352
303
  if (this.done) throw exception;
353
304
  var context = this;
354
-
355
305
  function handle(loc, caught) {
356
306
  return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
357
307
  }
358
-
359
308
  for (var i = this.tryEntries.length - 1; i >= 0; --i) {
360
309
  var entry = this.tryEntries[i],
361
- record = entry.completion;
310
+ record = entry.completion;
362
311
  if ("root" === entry.tryLoc) return handle("end");
363
-
364
312
  if (entry.tryLoc <= this.prev) {
365
313
  var hasCatch = hasOwn.call(entry, "catchLoc"),
366
- hasFinally = hasOwn.call(entry, "finallyLoc");
367
-
314
+ hasFinally = hasOwn.call(entry, "finallyLoc");
368
315
  if (hasCatch && hasFinally) {
369
316
  if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
370
317
  if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
@@ -380,13 +327,11 @@
380
327
  abrupt: function abrupt(type, arg) {
381
328
  for (var i = this.tryEntries.length - 1; i >= 0; --i) {
382
329
  var entry = this.tryEntries[i];
383
-
384
330
  if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
385
331
  var finallyEntry = entry;
386
332
  break;
387
333
  }
388
334
  }
389
-
390
335
  finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
391
336
  var record = finallyEntry ? finallyEntry.completion : {};
392
337
  return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
@@ -404,19 +349,15 @@
404
349
  "catch": function _catch(tryLoc) {
405
350
  for (var i = this.tryEntries.length - 1; i >= 0; --i) {
406
351
  var entry = this.tryEntries[i];
407
-
408
352
  if (entry.tryLoc === tryLoc) {
409
353
  var record = entry.completion;
410
-
411
354
  if ("throw" === record.type) {
412
355
  var thrown = record.arg;
413
356
  resetTryEntry(entry);
414
357
  }
415
-
416
358
  return thrown;
417
359
  }
418
360
  }
419
-
420
361
  throw new Error("illegal catch attempt");
421
362
  },
422
363
  delegateYield: function delegateYield(iterable, resultName, nextLoc) {
@@ -428,7 +369,6 @@
428
369
  }
429
370
  }, exports;
430
371
  }
431
-
432
372
  module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
433
373
  });
434
374
 
@@ -454,18 +394,14 @@
454
394
 
455
395
  function _iterableToArrayLimit(arr, i) {
456
396
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
457
-
458
397
  if (_i == null) return;
459
398
  var _arr = [];
460
399
  var _n = true;
461
400
  var _d = false;
462
-
463
401
  var _s, _e;
464
-
465
402
  try {
466
403
  for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
467
404
  _arr.push(_s.value);
468
-
469
405
  if (i && _arr.length === i) break;
470
406
  }
471
407
  } catch (err) {
@@ -478,17 +414,14 @@
478
414
  if (_d) throw _e;
479
415
  }
480
416
  }
481
-
482
417
  return _arr;
483
418
  }
484
419
 
485
420
  function _arrayLikeToArray(arr, len) {
486
421
  if (len == null || len > arr.length) len = arr.length;
487
-
488
422
  for (var i = 0, arr2 = new Array(len); i < len; i++) {
489
423
  arr2[i] = arr[i];
490
424
  }
491
-
492
425
  return arr2;
493
426
  }
494
427
 
@@ -515,32 +448,26 @@
515
448
 
516
449
  var ClosableProvider = (function (props) {
517
450
  var _useState = React.useState(true),
518
- _useState2 = _slicedToArray(_useState, 2),
519
- closable = _useState2[0],
520
- setClosable = _useState2[1];
521
-
451
+ _useState2 = _slicedToArray(_useState, 2),
452
+ closable = _useState2[0],
453
+ setClosable = _useState2[1];
522
454
  var _useState3 = React.useState(true),
523
- _useState4 = _slicedToArray(_useState3, 2),
524
- open = _useState4[0],
525
- setOpen = _useState4[1];
526
-
455
+ _useState4 = _slicedToArray(_useState3, 2),
456
+ open = _useState4[0],
457
+ setOpen = _useState4[1];
527
458
  var _useContext = React.useContext(UpdatableContext),
528
- setUpdatable = _useContext.setUpdatable;
529
-
459
+ setUpdatable = _useContext.setUpdatable;
530
460
  var close = function close() {
531
461
  if (props.closable === false) {
532
462
  return;
533
463
  }
534
-
535
464
  if (!closable) {
536
465
  return;
537
466
  }
538
-
539
467
  setUpdatable(false);
540
468
  setOpen(false);
541
469
  setTimeout(props.unmount, 300);
542
470
  };
543
-
544
471
  return /*#__PURE__*/React__default["default"].createElement(ClosableContext.Provider, {
545
472
  value: {
546
473
  closable: closable,
@@ -591,12 +518,10 @@
591
518
 
592
519
  var Dialog$1 = (function (props) {
593
520
  var _useContext = React.useContext(reactDialogStack.NavigateStackContext),
594
- navigate = _useContext.navigate;
595
-
521
+ navigate = _useContext.navigate;
596
522
  var _useContext2 = React.useContext(ClosableContext),
597
- close = _useContext2.close,
598
- closable = _useContext2.closable;
599
-
523
+ close = _useContext2.close,
524
+ closable = _useContext2.closable;
600
525
  return /*#__PURE__*/React__default["default"].createElement("div", {
601
526
  className: "Dialog"
602
527
  }, /*#__PURE__*/React__default["default"].createElement("div", {
@@ -624,13 +549,11 @@
624
549
 
625
550
  var ConnectingWalletDialog = (function (props) {
626
551
  var _useState = React.useState(false),
627
- _useState2 = _slicedToArray(_useState, 2),
628
- showConnectButton = _useState2[0],
629
- setShowConnectButton = _useState2[1];
630
-
552
+ _useState2 = _slicedToArray(_useState, 2),
553
+ showConnectButton = _useState2[0],
554
+ setShowConnectButton = _useState2[1];
631
555
  var _useContext = React.useContext(reactDialogStack.NavigateStackContext),
632
- navigate = _useContext.navigate;
633
-
556
+ navigate = _useContext.navigate;
634
557
  var wallet = props.wallet;
635
558
  wallet !== null && wallet !== void 0 && wallet.name ? wallet.name : 'wallet';
636
559
  var walletLogo = wallet !== null && wallet !== void 0 && wallet.logo ? wallet.logo : undefined;
@@ -642,7 +565,6 @@
642
565
  return clearTimeout(timeout);
643
566
  };
644
567
  }, []);
645
-
646
568
  if (props.pending) {
647
569
  return /*#__PURE__*/React__default["default"].createElement(Dialog$1, {
648
570
  stacked: true,
@@ -713,17 +635,15 @@
713
635
 
714
636
  var SelectWalletDialog = (function (props) {
715
637
  var _useState = React.useState(false),
716
- _useState2 = _slicedToArray(_useState, 2),
717
- showExplanation = _useState2[0],
718
- setShowExplanation = _useState2[1];
719
-
638
+ _useState2 = _slicedToArray(_useState, 2),
639
+ showExplanation = _useState2[0],
640
+ setShowExplanation = _useState2[1];
720
641
  var _useContext = React.useContext(reactDialogStack.NavigateStackContext),
721
- navigate = _useContext.navigate;
722
-
723
- var wallet = web3Wallets.getWallet();
642
+ navigate = _useContext.navigate;
643
+ var wallet = web3Wallets.getWallets()[0];
724
644
  React.useEffect(function () {
725
645
  _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
726
- var accounts;
646
+ var account;
727
647
  return regenerator.wrap(function _callee$(_context) {
728
648
  while (1) {
729
649
  switch (_context.prev = _context.next) {
@@ -732,18 +652,14 @@
732
652
  _context.next = 5;
733
653
  break;
734
654
  }
735
-
736
655
  _context.next = 3;
737
- return wallet.accounts();
738
-
656
+ return wallet.account();
739
657
  case 3:
740
- accounts = _context.sent;
741
-
742
- if (accounts == undefined || accounts.length == 0) {
658
+ account = _context.sent;
659
+ if (account == undefined) {
743
660
  navigate('ConnectingWallet');
744
661
  props.connect(wallet);
745
662
  }
746
-
747
663
  case 5:
748
664
  case "end":
749
665
  return _context.stop();
@@ -752,27 +668,21 @@
752
668
  }, _callee);
753
669
  }))();
754
670
  }, [wallet]);
755
-
756
671
  var connect = function connect(walletClass) {
757
672
  var wallet = new walletClass();
758
673
  props.setWallet(wallet);
759
674
  navigate('ConnectingWallet');
760
675
  props.connect(wallet);
761
676
  };
762
-
763
677
  var availableWallets = [web3Wallets.wallets.WalletConnect, web3Wallets.wallets.WalletLink];
764
-
765
678
  if (wallet) {
766
679
  availableWallets.unshift(wallet.constructor);
767
680
  }
768
-
769
681
  var walletCards = availableWallets.map(function (wallet, index) {
770
682
  var name = wallet.info.name;
771
-
772
683
  if (name == 'WalletConnect') {
773
684
  name = 'via WalletConnect';
774
685
  }
775
-
776
686
  return /*#__PURE__*/React__default["default"].createElement("div", {
777
687
  key: index,
778
688
  className: "PaddingBottomXS"
@@ -821,41 +731,34 @@
821
731
 
822
732
  var ConnectStack = (function (props) {
823
733
  var _useContext = React.useContext(ClosableContext),
824
- open = _useContext.open,
825
- close = _useContext.close;
826
-
734
+ open = _useContext.open,
735
+ close = _useContext.close;
827
736
  var _useState = React.useState(),
828
- _useState2 = _slicedToArray(_useState, 2),
829
- pending = _useState2[0],
830
- setPending = _useState2[1];
831
-
737
+ _useState2 = _slicedToArray(_useState, 2),
738
+ pending = _useState2[0],
739
+ setPending = _useState2[1];
832
740
  var _useState3 = React.useState(),
833
- _useState4 = _slicedToArray(_useState3, 2),
834
- wallet = _useState4[0],
835
- setWallet = _useState4[1];
836
-
741
+ _useState4 = _slicedToArray(_useState3, 2),
742
+ wallet = _useState4[0],
743
+ setWallet = _useState4[1];
837
744
  var connect = function connect(wallet) {
838
745
  wallet.connect().then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
839
- var accounts;
746
+ var account;
840
747
  return regenerator.wrap(function _callee$(_context) {
841
748
  while (1) {
842
749
  switch (_context.prev = _context.next) {
843
750
  case 0:
844
751
  _context.next = 2;
845
- return wallet.accounts();
846
-
752
+ return wallet.account();
847
753
  case 2:
848
- accounts = _context.sent;
849
-
850
- if (accounts instanceof Array && accounts.length > 0) {
754
+ account = _context.sent;
755
+ if (account) {
851
756
  if (props.autoClose) close();
852
757
  if (props.resolve) props.resolve({
853
758
  wallet: wallet,
854
- account: accounts[0],
855
- accounts: accounts
759
+ account: account
856
760
  });
857
761
  }
858
-
859
762
  case 4:
860
763
  case "end":
861
764
  return _context.stop();
@@ -864,7 +767,6 @@
864
767
  }, _callee);
865
768
  })))["catch"](function (error) {
866
769
  setPending(false);
867
-
868
770
  if ((error === null || error === void 0 ? void 0 : error.code) == 4001) {
869
771
  // User rejected the request.
870
772
  return;
@@ -877,17 +779,15 @@
877
779
  }
878
780
  });
879
781
  };
880
-
881
782
  React.useEffect(function () {
882
- var wallet = web3Wallets.getWallet();
883
-
783
+ var wallet = web3Wallets.getWallets()[0];
884
784
  if (wallet) {
885
785
  setWallet(wallet);
886
786
  }
887
787
  }, []);
888
788
  React.useEffect(function () {
889
789
  _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
890
- var accounts;
790
+ var account;
891
791
  return regenerator.wrap(function _callee2$(_context2) {
892
792
  while (1) {
893
793
  switch (_context2.prev = _context2.next) {
@@ -896,21 +796,16 @@
896
796
  _context2.next = 5;
897
797
  break;
898
798
  }
899
-
900
799
  _context2.next = 3;
901
- return wallet.accounts();
902
-
800
+ return wallet.account();
903
801
  case 3:
904
- accounts = _context2.sent;
905
-
906
- if (accounts instanceof Array && accounts.length > 0) {
802
+ account = _context2.sent;
803
+ if (account) {
907
804
  if (props.resolve) props.resolve({
908
805
  wallet: wallet,
909
- account: accounts[0],
910
- accounts: accounts
806
+ account: account
911
807
  });
912
808
  }
913
-
914
809
  case 5:
915
810
  case "end":
916
811
  return _context2.stop();
@@ -962,7 +857,6 @@
962
857
  Object.defineProperty(target, descriptor.key, descriptor);
963
858
  }
964
859
  }
965
-
966
860
  function _createClass(Constructor, protoProps, staticProps) {
967
861
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
968
862
  if (staticProps) _defineProperties(Constructor, staticProps);
@@ -984,7 +878,6 @@
984
878
  if (typeof superClass !== "function" && superClass !== null) {
985
879
  throw new TypeError("Super expression must either be null or a function");
986
880
  }
987
-
988
881
  subClass.prototype = Object.create(superClass && superClass.prototype, {
989
882
  constructor: {
990
883
  value: subClass,
@@ -1002,7 +895,6 @@
1002
895
  if (self === void 0) {
1003
896
  throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
1004
897
  }
1005
-
1006
898
  return self;
1007
899
  }
1008
900
 
@@ -1012,7 +904,6 @@
1012
904
  } else if (call !== void 0) {
1013
905
  throw new TypeError("Derived constructors may only return object or undefined");
1014
906
  }
1015
-
1016
907
  return _assertThisInitialized(self);
1017
908
  }
1018
909
 
@@ -1193,23 +1084,20 @@
1193
1084
  }
1194
1085
 
1195
1086
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
1196
-
1197
1087
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
1198
-
1199
1088
  var ErrorBoundary = /*#__PURE__*/function (_React$Component) {
1200
1089
  _inherits(ErrorBoundary, _React$Component);
1201
-
1202
1090
  var _super = _createSuper(ErrorBoundary);
1203
-
1204
1091
  function ErrorBoundary(props) {
1205
1092
  _classCallCheck(this, ErrorBoundary);
1206
-
1207
1093
  return _super.call(this, props);
1208
1094
  }
1209
-
1210
1095
  _createClass(ErrorBoundary, [{
1211
1096
  key: "componentDidCatch",
1212
1097
  value: function componentDidCatch(error, errorInfo) {
1098
+ if (error.error) {
1099
+ error = error.error;
1100
+ }
1213
1101
  this.props.setError(error);
1214
1102
  }
1215
1103
  }, {
@@ -1218,36 +1106,31 @@
1218
1106
  return this.props.children;
1219
1107
  }
1220
1108
  }]);
1221
-
1222
1109
  return ErrorBoundary;
1223
1110
  }(React__default["default"].Component);
1224
-
1225
1111
  var ErrorProvider = (function (props) {
1226
1112
  var _useState = React.useState(props.error),
1227
- _useState2 = _slicedToArray(_useState, 2),
1228
- error = _useState2[0],
1229
- setError = _useState2[1];
1230
-
1113
+ _useState2 = _slicedToArray(_useState, 2),
1114
+ error = _useState2[0],
1115
+ setError = _useState2[1];
1231
1116
  var _useState3 = React.useState(true),
1232
- _useState4 = _slicedToArray(_useState3, 2),
1233
- open = _useState4[0],
1234
- setOpen = _useState4[1];
1235
-
1117
+ _useState4 = _slicedToArray(_useState3, 2),
1118
+ open = _useState4[0],
1119
+ setOpen = _useState4[1];
1236
1120
  var setErrorFromChildren = function setErrorFromChildren(error) {
1121
+ if (error.error) {
1122
+ error = error.error;
1123
+ }
1237
1124
  setError(error);
1238
-
1239
1125
  if (props.errorCallback) {
1240
- props.errorCallback(error);
1126
+ props.errorCallback(error.message || error.toString());
1241
1127
  }
1242
1128
  };
1243
-
1244
1129
  var close = function close() {
1245
1130
  setOpen(false);
1246
1131
  setTimeout(props.unmount, 300);
1247
1132
  };
1248
-
1249
1133
  if (error) {
1250
- console.log(error);
1251
1134
  return /*#__PURE__*/React__default["default"].createElement(ReactDialog, {
1252
1135
  container: props.container,
1253
1136
  close: close,
@@ -1273,7 +1156,7 @@
1273
1156
  className: "PaddingLeftS PaddingRightS"
1274
1157
  }, /*#__PURE__*/React__default["default"].createElement("pre", {
1275
1158
  className: "ErrorSnippetText"
1276
- }, error.toString())), /*#__PURE__*/React__default["default"].createElement("div", {
1159
+ }, error.message || error.toString())), /*#__PURE__*/React__default["default"].createElement("div", {
1277
1160
  className: "PaddingTopS PaddingBottomS"
1278
1161
  }, /*#__PURE__*/React__default["default"].createElement("strong", {
1279
1162
  className: "FontSizeM PaddingTopS"
@@ -1407,7 +1290,6 @@
1407
1290
 
1408
1291
  var styleRenderer = (function (style) {
1409
1292
  var _style, _style2;
1410
-
1411
1293
  style = {
1412
1294
  colors: Object.assign({
1413
1295
  primary: '#ea357a',
@@ -1422,44 +1304,37 @@
1422
1304
 
1423
1305
  var mount = (function (_ref, content) {
1424
1306
  var style = _ref.style,
1425
- container = _ref.container,
1426
- document = _ref.document,
1427
- closed = _ref.closed;
1307
+ container = _ref.container,
1308
+ document = _ref.document,
1309
+ closed = _ref.closed;
1428
1310
  var insideStyle = styleRenderer(style);
1429
-
1430
1311
  if (style && style.css) {
1431
1312
  insideStyle = [insideStyle, style.css].join(' ');
1432
1313
  }
1433
-
1434
1314
  var unmountShadowDOM = function unmountShadowDOM() {
1435
1315
  // setTimeout to allow dialog to animate out first
1436
1316
  setTimeout(function () {
1437
1317
  unmount();
1438
-
1439
1318
  if (typeof closed == 'function') {
1440
1319
  closed();
1441
1320
  }
1442
1321
  }, 300);
1443
1322
  };
1444
-
1445
1323
  var outsideStyle;
1446
-
1447
1324
  if (container) {
1448
1325
  outsideStyle = "\n position: absolute;\n top: 0;\n left: 0;\n bottom: 0;\n right: 0;\n z-index: 99999;\n ";
1449
1326
  } else {
1450
1327
  outsideStyle = "\n position: fixed;\n top: 0;\n left: 0;\n bottom: 0;\n right: 0;\n z-index: 99999;\n ";
1451
1328
  }
1452
-
1453
1329
  var _ReactShadowDOM = reactShadowDom.ReactShadowDOM({
1454
- document: document,
1455
- element: container || document.body,
1456
- content: content(unmountShadowDOM),
1457
- outsideStyle: outsideStyle,
1458
- insideStyle: insideStyle,
1459
- insideClasses: container ? ['contained'] : []
1460
- }),
1461
- unmount = _ReactShadowDOM.unmount;
1462
-
1330
+ document: document,
1331
+ element: container || document.body,
1332
+ content: content(unmountShadowDOM),
1333
+ outsideStyle: outsideStyle,
1334
+ insideStyle: insideStyle,
1335
+ insideClasses: container ? ['contained'] : []
1336
+ }),
1337
+ unmount = _ReactShadowDOM.unmount;
1463
1338
  return unmount;
1464
1339
  });
1465
1340
 
@@ -1482,10 +1357,9 @@
1482
1357
 
1483
1358
  var UpdatableProvider = (function (props) {
1484
1359
  var _useState = React.useState(true),
1485
- _useState2 = _slicedToArray(_useState, 2),
1486
- updatable = _useState2[0],
1487
- setUpdatable = _useState2[1];
1488
-
1360
+ _useState2 = _slicedToArray(_useState, 2),
1361
+ updatable = _useState2[0],
1362
+ setUpdatable = _useState2[1];
1489
1363
  return /*#__PURE__*/React__default["default"].createElement(UpdatableContext.Provider, {
1490
1364
  value: {
1491
1365
  updatable: updatable,
@@ -1497,44 +1371,35 @@
1497
1371
  var Connect = function Connect(options) {
1498
1372
  requireReactVersion();
1499
1373
  var style, error, document;
1500
-
1501
1374
  if (_typeof(options) == 'object') {
1502
1375
  style = options.style;
1503
1376
  error = options.error;
1504
1377
  document = options.document;
1505
1378
  }
1506
-
1507
1379
  return new Promise( /*#__PURE__*/function () {
1508
1380
  var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(resolve, reject) {
1509
- var wallet, accounts;
1381
+ var wallet, account;
1510
1382
  return regenerator.wrap(function _callee$(_context) {
1511
1383
  while (1) {
1512
1384
  switch (_context.prev = _context.next) {
1513
1385
  case 0:
1514
- wallet = web3Wallets.getWallet();
1515
-
1386
+ wallet = web3Wallets.getWallets()[0];
1516
1387
  if (!wallet) {
1517
1388
  _context.next = 7;
1518
1389
  break;
1519
1390
  }
1520
-
1521
1391
  _context.next = 4;
1522
- return wallet.accounts();
1523
-
1392
+ return wallet.account();
1524
1393
  case 4:
1525
- accounts = _context.sent;
1526
-
1527
- if (!(accounts instanceof Array && accounts.length > 0)) {
1394
+ account = _context.sent;
1395
+ if (!account) {
1528
1396
  _context.next = 7;
1529
1397
  break;
1530
1398
  }
1531
-
1532
1399
  return _context.abrupt("return", resolve({
1533
1400
  wallet: wallet,
1534
- accounts: accounts,
1535
- account: accounts[0]
1401
+ account: account
1536
1402
  }));
1537
-
1538
1403
  case 7:
1539
1404
  mount({
1540
1405
  style: style,
@@ -1544,7 +1409,6 @@
1544
1409
  reject('USER_CLOSED_DIALOG');
1545
1410
  unmount();
1546
1411
  };
1547
-
1548
1412
  return function (container) {
1549
1413
  return /*#__PURE__*/React__default["default"].createElement(ErrorProvider, {
1550
1414
  errorCallback: error,
@@ -1561,7 +1425,6 @@
1561
1425
  }), /*#__PURE__*/React__default["default"].createElement(PoweredBy, null))));
1562
1426
  };
1563
1427
  });
1564
-
1565
1428
  case 8:
1566
1429
  case "end":
1567
1430
  return _context.stop();
@@ -1569,7 +1432,6 @@
1569
1432
  }
1570
1433
  }, _callee);
1571
1434
  }));
1572
-
1573
1435
  return function (_x, _x2) {
1574
1436
  return _ref.apply(this, arguments);
1575
1437
  };
@@ -1602,15 +1464,12 @@
1602
1464
  var sortedLowToHigh = _toConsumableArray(routes).sort(function (a, b) {
1603
1465
  var aAmountsAvailable = ethers.ethers.BigNumber.from(a.fromBalance).div(ethers.ethers.BigNumber.from(a.fromAmount));
1604
1466
  var bAmountsAvailable = ethers.ethers.BigNumber.from(b.fromBalance).div(ethers.ethers.BigNumber.from(b.fromAmount));
1605
-
1606
1467
  if (aAmountsAvailable.lt(bAmountsAvailable)) {
1607
1468
  return -1;
1608
1469
  }
1609
-
1610
1470
  if (bAmountsAvailable.lt(aAmountsAvailable)) {
1611
1471
  return 1;
1612
1472
  }
1613
-
1614
1473
  return 0; // equal
1615
1474
  });
1616
1475
 
@@ -1619,26 +1478,20 @@
1619
1478
 
1620
1479
  var round = (function (input) {
1621
1480
  var _digitsAfterDecimal;
1622
-
1623
1481
  var direction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'up';
1624
1482
  var inputAsFloat = parseFloat(input);
1625
1483
  var digitsAfterDecimal = inputAsFloat.toString().match(/\d+\.0*(\d{4})/);
1626
-
1627
1484
  if ((_digitsAfterDecimal = digitsAfterDecimal) !== null && _digitsAfterDecimal !== void 0 && _digitsAfterDecimal.length) {
1628
1485
  digitsAfterDecimal = digitsAfterDecimal[0];
1629
1486
  var focus = digitsAfterDecimal.match(/\d{4}$/)[0];
1630
-
1631
1487
  var _float;
1632
-
1633
1488
  var focusToFixed;
1634
-
1635
1489
  if (focus.match(/^0/)) {
1636
1490
  if (direction == 'up') {
1637
1491
  _float = parseFloat("".concat(focus[1], ".").concat(focus[2]).concat(focus[3]));
1638
1492
  } else {
1639
1493
  _float = parseFloat("".concat(focus[1], ".").concat(focus[2]).concat(focus[3]));
1640
1494
  }
1641
-
1642
1495
  focusToFixed = parseFloat(_float).toFixed(2);
1643
1496
  focusToFixed = "0".concat(focusToFixed).replace('.', '');
1644
1497
  } else {
@@ -1647,10 +1500,8 @@
1647
1500
  } else {
1648
1501
  _float = parseFloat("".concat(focus[0], ".").concat(focus[1]).concat(focus[2], "1"));
1649
1502
  }
1650
-
1651
1503
  focusToFixed = parseFloat(_float).toFixed(2).replace('.', '');
1652
1504
  }
1653
-
1654
1505
  if (focusToFixed == '0999' && parseInt(inputAsFloat.toFixed(0)) == 0) {
1655
1506
  focusToFixed = direction == 'up' ? '1000' : '0999';
1656
1507
  return parseFloat(digitsAfterDecimal.replace(/\d{4}$/, focusToFixed));
@@ -18873,42 +18724,32 @@
18873
18724
  return typeof configuration.amount != 'undefined' || typeof configuration.fromAmount != 'undefined';
18874
18725
  });
18875
18726
  };
18876
-
18877
18727
  var _useContext = React.useContext(ConfigurationContext),
18878
- configuredAmount = _useContext.amount;
18879
- _useContext.toAmount;
18880
- var recover = _useContext.recover;
18881
-
18728
+ configuredAmount = _useContext.amount;
18729
+ _useContext.toAmount;
18730
+ var recover = _useContext.recover;
18882
18731
  var _useState = React.useState(recover == undefined ? configurationsMissAmounts(props.accept) : false),
18883
- _useState2 = _slicedToArray(_useState, 2),
18884
- amountsMissing = _useState2[0],
18885
- setAmountsMissing = _useState2[1];
18886
-
18732
+ _useState2 = _slicedToArray(_useState, 2),
18733
+ amountsMissing = _useState2[0],
18734
+ setAmountsMissing = _useState2[1];
18887
18735
  var _useContext2 = React.useContext(WalletContext),
18888
- account = _useContext2.account;
18889
-
18736
+ account = _useContext2.account;
18890
18737
  var _useContext3 = React.useContext(ConversionRateContext),
18891
- conversionRate = _useContext3.conversionRate,
18892
- fixedCurrencyConversionRate = _useContext3.fixedCurrencyConversionRate;
18893
-
18738
+ conversionRate = _useContext3.conversionRate,
18739
+ fixedCurrencyConversionRate = _useContext3.fixedCurrencyConversionRate;
18894
18740
  var _useContext4 = React.useContext(ErrorContext),
18895
- setError = _useContext4.setError;
18896
-
18741
+ setError = _useContext4.setError;
18897
18742
  var _useState3 = React.useState(),
18898
- _useState4 = _slicedToArray(_useState3, 2),
18899
- acceptWithAmount = _useState4[0],
18900
- setAcceptWithAmount = _useState4[1];
18901
-
18743
+ _useState4 = _slicedToArray(_useState3, 2),
18744
+ acceptWithAmount = _useState4[0],
18745
+ setAcceptWithAmount = _useState4[1];
18902
18746
  var _useState5 = React.useState(_typeof(configuredAmount) == 'object' && configuredAmount.fix && configuredAmount.currency ? configuredAmount.fix : null),
18903
- _useState6 = _slicedToArray(_useState5, 1),
18904
- fixedAmount = _useState6[0];
18905
-
18747
+ _useState6 = _slicedToArray(_useState5, 1),
18748
+ fixedAmount = _useState6[0];
18906
18749
  var _useState7 = React.useState(_typeof(configuredAmount) == 'object' && configuredAmount.fix && configuredAmount.currency ? configuredAmount.currency : null),
18907
- _useState8 = _slicedToArray(_useState7, 1),
18908
- fixedCurrency = _useState8[0];
18909
-
18750
+ _useState8 = _slicedToArray(_useState7, 1),
18751
+ fixedCurrency = _useState8[0];
18910
18752
  var startAmount;
18911
-
18912
18753
  if (amountsMissing) {
18913
18754
  if (_typeof(configuredAmount) == "object" && configuredAmount.start && configuredAmount.start) {
18914
18755
  startAmount = configuredAmount.start;
@@ -18918,34 +18759,28 @@
18918
18759
  startAmount = 1;
18919
18760
  }
18920
18761
  }
18921
-
18922
18762
  var _useState9 = React.useState(startAmount),
18923
- _useState10 = _slicedToArray(_useState9, 2),
18924
- amount = _useState10[0],
18925
- setAmount = _useState10[1];
18926
-
18763
+ _useState10 = _slicedToArray(_useState9, 2),
18764
+ amount = _useState10[0],
18765
+ setAmount = _useState10[1];
18927
18766
  var _useState11 = React.useState(),
18928
- _useState12 = _slicedToArray(_useState11, 2),
18929
- maxRoute = _useState12[0],
18930
- setMaxRoute = _useState12[1];
18931
-
18767
+ _useState12 = _slicedToArray(_useState11, 2),
18768
+ maxRoute = _useState12[0],
18769
+ setMaxRoute = _useState12[1];
18932
18770
  var _useState13 = React.useState(),
18933
- _useState14 = _slicedToArray(_useState13, 2),
18934
- maxAmount = _useState14[0],
18935
- setMaxAmount = _useState14[1];
18936
-
18771
+ _useState14 = _slicedToArray(_useState13, 2),
18772
+ maxAmount = _useState14[0],
18773
+ setMaxAmount = _useState14[1];
18937
18774
  React.useEffect(function () {
18938
18775
  if (recover) {
18939
18776
  return;
18940
18777
  }
18941
-
18942
18778
  setAmountsMissing(configurationsMissAmounts(props.accept));
18943
18779
  }, [props.accept, recover]);
18944
-
18945
18780
  var getAmounts = function getAmounts(_ref) {
18946
18781
  var amount = _ref.amount,
18947
- conversionRate = _ref.conversionRate,
18948
- fixedCurrencyConversionRate = _ref.fixedCurrencyConversionRate;
18782
+ conversionRate = _ref.conversionRate,
18783
+ fixedCurrencyConversionRate = _ref.fixedCurrencyConversionRate;
18949
18784
  return new Promise(function (resolve, reject) {
18950
18785
  if (configuredAmount && configuredAmount.token) {
18951
18786
  resolve(props.accept.map(function () {
@@ -18998,12 +18833,11 @@
18998
18833
  }
18999
18834
  });
19000
18835
  };
19001
-
19002
18836
  var updateAmounts = React.useCallback(lodash.debounce(function (_ref2) {
19003
18837
  var account = _ref2.account,
19004
- amount = _ref2.amount,
19005
- conversionRate = _ref2.conversionRate,
19006
- fixedCurrencyConversionRate = _ref2.fixedCurrencyConversionRate;
18838
+ amount = _ref2.amount,
18839
+ conversionRate = _ref2.conversionRate,
18840
+ fixedCurrencyConversionRate = _ref2.fixedCurrencyConversionRate;
19007
18841
  getAmounts({
19008
18842
  amount: amount,
19009
18843
  conversionRate: conversionRate,
@@ -19013,7 +18847,6 @@
19013
18847
  if (amounts[index] == undefined) {
19014
18848
  return;
19015
18849
  }
19016
-
19017
18850
  return {
19018
18851
  blockchain: configuration.blockchain,
19019
18852
  amount: round(amounts[index]),
@@ -19029,7 +18862,6 @@
19029
18862
  if (recover) {
19030
18863
  return;
19031
18864
  }
19032
-
19033
18865
  if (amountsMissing && account && conversionRate && (fixedAmount ? fixedCurrencyConversionRate : true)) {
19034
18866
  updateAmounts({
19035
18867
  account: account,
@@ -19059,7 +18891,6 @@
19059
18891
  }).then(setMaxAmount);
19060
18892
  return;
19061
18893
  }
19062
-
19063
18894
  web3Tokens.Token.readable({
19064
18895
  amount: routes[0].amountOut,
19065
18896
  blockchain: maxRoute.blockchain,
@@ -19072,7 +18903,6 @@
19072
18903
  })["catch"](setError);
19073
18904
  } else if (maxRoute.fromToken.address == web3Constants.CONSTANTS[maxRoute.blockchain].USD) {
19074
18905
  var _maxAmount = parseFloat(new decimal_js.Decimal(readableMaxAmount).mul(conversionRate).toString());
19075
-
19076
18906
  setMaxAmount(_maxAmount > 10 ? Math.round(_maxAmount - 1) : _maxAmount - 1);
19077
18907
  } else {
19078
18908
  web3Exchanges.route({
@@ -19086,7 +18916,6 @@
19086
18916
  if (routes[0] == undefined) {
19087
18917
  return;
19088
18918
  }
19089
-
19090
18919
  web3Tokens.Token.readable({
19091
18920
  amount: routes[0].amountOut,
19092
18921
  blockchain: maxRoute.blockchain,
@@ -19137,22 +18966,18 @@
19137
18966
 
19138
18967
  var ConversionRateProvider = (function (props) {
19139
18968
  var _useContext = React.useContext(ErrorContext);
19140
- _useContext.setError;
19141
-
18969
+ _useContext.setError;
19142
18970
  var _useContext2 = React.useContext(ConfigurationContext),
19143
- amount = _useContext2.amount,
19144
- currency = _useContext2.currency;
19145
-
18971
+ amount = _useContext2.amount,
18972
+ currency = _useContext2.currency;
19146
18973
  var _useState = React.useState(),
19147
- _useState2 = _slicedToArray(_useState, 2),
19148
- conversionRate = _useState2[0],
19149
- setConversionRate = _useState2[1];
19150
-
18974
+ _useState2 = _slicedToArray(_useState, 2),
18975
+ conversionRate = _useState2[0],
18976
+ setConversionRate = _useState2[1];
19151
18977
  var _useState3 = React.useState(),
19152
- _useState4 = _slicedToArray(_useState3, 2),
19153
- fixedCurrencyConversionRate = _useState4[0],
19154
- setFixedCurrencyConversionRate = _useState4[1];
19155
-
18978
+ _useState4 = _slicedToArray(_useState3, 2),
18979
+ fixedCurrencyConversionRate = _useState4[0],
18980
+ setFixedCurrencyConversionRate = _useState4[1];
19156
18981
  React.useEffect(function () {
19157
18982
  if (_typeof(amount) == 'object' && amount.currency) {
19158
18983
  localCurrency.Currency.fromUSD({
@@ -19162,7 +18987,6 @@
19162
18987
  return setFixedCurrencyConversionRate(conversion.amount);
19163
18988
  });
19164
18989
  }
19165
-
19166
18990
  localCurrency.Currency.fromUSD({
19167
18991
  amount: 1,
19168
18992
  code: currency
@@ -19186,8 +19010,7 @@
19186
19010
 
19187
19011
  var NoPaymentMethodFoundDialog = (function () {
19188
19012
  var _useContext = React.useContext(ClosableContext),
19189
- close = _useContext.close;
19190
-
19013
+ close = _useContext.close;
19191
19014
  return /*#__PURE__*/React__default["default"].createElement(Dialog$1, {
19192
19015
  header: /*#__PURE__*/React__default["default"].createElement("div", {
19193
19016
  className: "PaddingTopS PaddingLeftM PaddingRightM"
@@ -19225,87 +19048,68 @@
19225
19048
 
19226
19049
  var PaymentProvider = (function (props) {
19227
19050
  var _useContext = React.useContext(ErrorContext),
19228
- setError = _useContext.setError;
19229
-
19051
+ setError = _useContext.setError;
19230
19052
  var _useContext2 = React.useContext(ConfigurationContext),
19231
- _sent = _useContext2.sent,
19232
- confirmed = _useContext2.confirmed,
19233
- failed = _useContext2.failed,
19234
- recover = _useContext2.recover,
19235
- before = _useContext2.before;
19236
-
19053
+ _sent = _useContext2.sent,
19054
+ succeeded = _useContext2.succeeded,
19055
+ failed = _useContext2.failed,
19056
+ recover = _useContext2.recover,
19057
+ before = _useContext2.before;
19237
19058
  var _useContext3 = React.useContext(PaymentRoutingContext),
19238
- selectedRoute = _useContext3.selectedRoute;
19239
- _useContext3.getPaymentRoutes;
19240
-
19059
+ selectedRoute = _useContext3.selectedRoute;
19060
+ _useContext3.getPaymentRoutes;
19241
19061
  var _useContext4 = React.useContext(ClosableContext),
19242
- open = _useContext4.open,
19243
- close = _useContext4.close,
19244
- setClosable = _useContext4.setClosable;
19245
-
19062
+ open = _useContext4.open,
19063
+ close = _useContext4.close,
19064
+ setClosable = _useContext4.setClosable;
19246
19065
  var _useContext5 = React.useContext(PaymentRoutingContext),
19247
- allRoutes = _useContext5.allRoutes;
19248
-
19066
+ allRoutes = _useContext5.allRoutes;
19249
19067
  var _useContext6 = React.useContext(UpdatableContext),
19250
- setUpdatable = _useContext6.setUpdatable;
19251
-
19068
+ setUpdatable = _useContext6.setUpdatable;
19252
19069
  var _useContext7 = React.useContext(NavigateContext),
19253
- navigate = _useContext7.navigate,
19254
- set = _useContext7.set;
19255
-
19070
+ navigate = _useContext7.navigate,
19071
+ set = _useContext7.set;
19256
19072
  var _useContext8 = React.useContext(WalletContext),
19257
- wallet = _useContext8.wallet;
19258
-
19073
+ wallet = _useContext8.wallet;
19259
19074
  var _useContext9 = React.useContext(PaymentTrackingContext),
19260
- release = _useContext9.release,
19261
- tracking = _useContext9.tracking,
19262
- initializePaymentTracking = _useContext9.initializeTracking;
19263
-
19075
+ release = _useContext9.release,
19076
+ tracking = _useContext9.tracking,
19077
+ initializePaymentTracking = _useContext9.initializeTracking;
19264
19078
  var _useContext10 = React.useContext(TransactionTrackingContext),
19265
- foundTransaction = _useContext10.foundTransaction,
19266
- initializeTransactionTracking = _useContext10.initializeTracking;
19267
-
19079
+ foundTransaction = _useContext10.foundTransaction,
19080
+ initializeTransactionTracking = _useContext10.initializeTracking;
19268
19081
  var _useState = React.useState(),
19269
- _useState2 = _slicedToArray(_useState, 2),
19270
- payment = _useState2[0],
19271
- setPayment = _useState2[1];
19272
-
19082
+ _useState2 = _slicedToArray(_useState, 2),
19083
+ payment = _useState2[0],
19084
+ setPayment = _useState2[1];
19273
19085
  var _useState3 = React.useState(),
19274
- _useState4 = _slicedToArray(_useState3, 2),
19275
- transaction = _useState4[0],
19276
- setTransaction = _useState4[1];
19277
-
19086
+ _useState4 = _slicedToArray(_useState3, 2),
19087
+ transaction = _useState4[0],
19088
+ setTransaction = _useState4[1];
19278
19089
  var _useState5 = React.useState(),
19279
- _useState6 = _slicedToArray(_useState5, 2),
19280
- approvalTransaction = _useState6[0],
19281
- setApprovalTransaction = _useState6[1];
19282
-
19090
+ _useState6 = _slicedToArray(_useState5, 2),
19091
+ approvalTransaction = _useState6[0],
19092
+ setApprovalTransaction = _useState6[1];
19283
19093
  var _useState7 = React.useState('initialized'),
19284
- _useState8 = _slicedToArray(_useState7, 2),
19285
- paymentState = _useState8[0],
19286
- setPaymentState = _useState8[1];
19287
-
19288
- var paymentConfirmed = function paymentConfirmed(transaction) {
19094
+ _useState8 = _slicedToArray(_useState7, 2),
19095
+ paymentState = _useState8[0],
19096
+ setPaymentState = _useState8[1];
19097
+ var paymentSucceeded = function paymentSucceeded(transaction) {
19289
19098
  if (tracking != true) {
19290
19099
  setClosable(true);
19291
19100
  }
19292
-
19293
- setPaymentState('confirmed');
19294
-
19295
- if (confirmed) {
19296
- confirmed(transaction);
19101
+ setPaymentState('success');
19102
+ if (succeeded) {
19103
+ succeeded(transaction);
19297
19104
  }
19298
19105
  };
19299
-
19300
19106
  var paymentFailed = function paymentFailed(transaction, error) {
19301
19107
  if (failed) {
19302
19108
  failed(transaction, error);
19303
19109
  }
19304
-
19305
19110
  setClosable(true);
19306
- set(['PaymentError']);
19111
+ set(['PaymentFailed']);
19307
19112
  };
19308
-
19309
19113
  var pay = /*#__PURE__*/function () {
19310
19114
  var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
19311
19115
  var stop, currentBlock;
@@ -19317,20 +19121,15 @@
19317
19121
  _context.next = 6;
19318
19122
  break;
19319
19123
  }
19320
-
19321
19124
  _context.next = 3;
19322
19125
  return before(payment.route.transaction);
19323
-
19324
19126
  case 3:
19325
19127
  stop = _context.sent;
19326
-
19327
19128
  if (!(stop === false)) {
19328
19129
  _context.next = 6;
19329
19130
  break;
19330
19131
  }
19331
-
19332
19132
  return _context.abrupt("return");
19333
-
19334
19133
  case 6:
19335
19134
  setClosable(false);
19336
19135
  setPaymentState('paying');
@@ -19340,33 +19139,29 @@
19340
19139
  blockchain: payment.route.transaction.blockchain,
19341
19140
  method: 'latestBlockNumber'
19342
19141
  });
19343
-
19344
19142
  case 11:
19345
19143
  currentBlock = _context.sent;
19346
19144
  wallet.sendTransaction(Object.assign({}, payment.route.transaction, {
19347
19145
  sent: function sent(transaction) {
19348
19146
  initializeTransactionTracking(transaction, currentBlock);
19349
-
19350
19147
  if (_sent) {
19351
19148
  _sent(transaction);
19352
19149
  }
19353
19150
  },
19354
- confirmed: paymentConfirmed,
19151
+ succeeded: paymentSucceeded,
19355
19152
  failed: paymentFailed
19356
19153
  })).then(function (sentTransaction) {
19357
- initializePaymentTracking(sentTransaction, currentBlock, payment.route);
19358
19154
  setTransaction(sentTransaction);
19155
+ initializePaymentTracking(sentTransaction, currentBlock, payment.route);
19359
19156
  })["catch"](function (error) {
19360
19157
  console.log('error', error);
19361
19158
  setPaymentState('initialized');
19362
19159
  setClosable(true);
19363
19160
  setUpdatable(true);
19364
-
19365
19161
  if ((error === null || error === void 0 ? void 0 : error.code) == 'WRONG_NETWORK') {
19366
19162
  navigate('WrongNetwork');
19367
19163
  }
19368
19164
  });
19369
-
19370
19165
  case 13:
19371
19166
  case "end":
19372
19167
  return _context.stop();
@@ -19374,17 +19169,15 @@
19374
19169
  }
19375
19170
  }, _callee);
19376
19171
  }));
19377
-
19378
19172
  return function pay() {
19379
19173
  return _ref.apply(this, arguments);
19380
19174
  };
19381
19175
  }();
19382
-
19383
19176
  var approve = function approve() {
19384
19177
  setClosable(false);
19385
19178
  setPaymentState('approving');
19386
19179
  wallet.sendTransaction(Object.assign({}, payment.route.approvalTransaction, {
19387
- confirmed: function confirmed() {
19180
+ succeeded: function succeeded() {
19388
19181
  payment.route.approvalRequired = false;
19389
19182
  setPayment(payment);
19390
19183
  setClosable(true);
@@ -19398,10 +19191,9 @@
19398
19191
  setClosable(true);
19399
19192
  });
19400
19193
  };
19401
-
19402
19194
  React.useEffect(function () {
19403
19195
  if (release) {
19404
- setPaymentState('confirmed');
19196
+ setPaymentState('success');
19405
19197
  }
19406
19198
  }, [release]);
19407
19199
  React.useEffect(function () {
@@ -19424,9 +19216,8 @@
19424
19216
  });
19425
19217
  Promise.all([paymentToken.name(), paymentToken.symbol()]).then(function (_ref2) {
19426
19218
  var _ref3 = _slicedToArray(_ref2, 2),
19427
- name = _ref3[0],
19428
- symbol = _ref3[1];
19429
-
19219
+ name = _ref3[0],
19220
+ symbol = _ref3[1];
19430
19221
  setPayment({
19431
19222
  blockchain: recover.blockchain,
19432
19223
  token: recover.token,
@@ -19440,7 +19231,6 @@
19440
19231
  React.useEffect(function () {
19441
19232
  if (foundTransaction && foundTransaction.id && foundTransaction.status) {
19442
19233
  var newTransaction;
19443
-
19444
19234
  if (foundTransaction.id.toLowerCase() != transaction.id.toLowerCase()) {
19445
19235
  newTransaction = Object.assign({}, transaction, {
19446
19236
  id: foundTransaction.id,
@@ -19450,9 +19240,8 @@
19450
19240
  });
19451
19241
  setTransaction(newTransaction);
19452
19242
  }
19453
-
19454
19243
  if (foundTransaction.status == 'success') {
19455
- paymentConfirmed(newTransaction || transaction);
19244
+ paymentSucceeded(newTransaction || transaction);
19456
19245
  } else if (foundTransaction.status == 'failed') {
19457
19246
  paymentFailed(newTransaction || transaction);
19458
19247
  }
@@ -19463,10 +19252,9 @@
19463
19252
  var fromToken = selectedRoute.fromToken;
19464
19253
  Promise.all([fromToken.name(), fromToken.symbol(), fromToken.readable(selectedRoute.fromAmount)]).then(function (_ref4) {
19465
19254
  var _ref5 = _slicedToArray(_ref4, 3),
19466
- name = _ref5[0],
19467
- symbol = _ref5[1],
19468
- amount = _ref5[2];
19469
-
19255
+ name = _ref5[0],
19256
+ symbol = _ref5[1],
19257
+ amount = _ref5[2];
19470
19258
  setPayment({
19471
19259
  blockchain: selectedRoute.blockchain,
19472
19260
  route: selectedRoute,
@@ -19487,7 +19275,6 @@
19487
19275
  setUpdatable(true);
19488
19276
  }
19489
19277
  }, [allRoutes]);
19490
-
19491
19278
  if (allRoutes instanceof Array && allRoutes.length == 0) {
19492
19279
  return /*#__PURE__*/React__default["default"].createElement(reactDialogStack.ReactDialogStack, {
19493
19280
  open: open,
@@ -19524,14 +19311,11 @@
19524
19311
  } else {
19525
19312
  obj[key] = value;
19526
19313
  }
19527
-
19528
19314
  return obj;
19529
19315
  }
19530
19316
 
19531
19317
  function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
19532
-
19533
19318
  function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
19534
-
19535
19319
  var prepareAcceptedPayments = function prepareAcceptedPayments(accept) {
19536
19320
  var toAddress = _typeof(accept.receiver) == 'object' ? accept.receiver.address : accept.receiver;
19537
19321
  var toContract = _typeof(accept.receiver) == 'object' ? accept.receiver : undefined;
@@ -19540,7 +19324,6 @@
19540
19324
  toContract: toContract
19541
19325
  });
19542
19326
  };
19543
-
19544
19327
  var mergeFromAccounts = function mergeFromAccounts(accept, account) {
19545
19328
  var from = {};
19546
19329
  accept.forEach(function (accept) {
@@ -19548,14 +19331,13 @@
19548
19331
  });
19549
19332
  return from;
19550
19333
  };
19551
-
19552
19334
  var routePayments = (function (_ref) {
19553
19335
  var accept = _ref.accept,
19554
- account = _ref.account,
19555
- whitelist = _ref.whitelist,
19556
- blacklist = _ref.blacklist,
19557
- event = _ref.event,
19558
- fee = _ref.fee;
19336
+ account = _ref.account,
19337
+ whitelist = _ref.whitelist,
19338
+ blacklist = _ref.blacklist,
19339
+ event = _ref.event,
19340
+ fee = _ref.fee;
19559
19341
  return web3Payments.route({
19560
19342
  accept: accept.map(prepareAcceptedPayments),
19561
19343
  from: mergeFromAccounts(accept, account),
@@ -19567,421 +19349,100 @@
19567
19349
  });
19568
19350
 
19569
19351
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
19570
-
19571
19352
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
19572
19353
  var PaymentRoutingProvider = (function (props) {
19573
19354
  var _useState = React.useState(),
19574
- _useState2 = _slicedToArray(_useState, 2),
19575
- allRoutes = _useState2[0],
19576
- setAllRoutes = _useState2[1];
19577
-
19355
+ _useState2 = _slicedToArray(_useState, 2),
19356
+ allRoutes = _useState2[0],
19357
+ setAllRoutes = _useState2[1];
19578
19358
  var _useState3 = React.useState(),
19579
- _useState4 = _slicedToArray(_useState3, 2),
19580
- updatedRouteWithNewPrice = _useState4[0],
19581
- setUpdatedRouteWithNewPrice = _useState4[1];
19582
-
19359
+ _useState4 = _slicedToArray(_useState3, 2),
19360
+ updatedRouteWithNewPrice = _useState4[0],
19361
+ setUpdatedRouteWithNewPrice = _useState4[1];
19583
19362
  var _useState5 = React.useState(),
19584
- _useState6 = _slicedToArray(_useState5, 2),
19585
- selectedRoute = _useState6[0],
19586
- setSelectedRoute = _useState6[1];
19587
-
19363
+ _useState6 = _slicedToArray(_useState5, 2),
19364
+ selectedRoute = _useState6[0],
19365
+ setSelectedRoute = _useState6[1];
19588
19366
  var _useState7 = React.useState(false),
19589
- _useState8 = _slicedToArray(_useState7, 2),
19590
- slowRouting = _useState8[0],
19591
- setSlowRouting = _useState8[1];
19592
-
19367
+ _useState8 = _slicedToArray(_useState7, 2),
19368
+ slowRouting = _useState8[0],
19369
+ setSlowRouting = _useState8[1];
19593
19370
  var _useState9 = React.useState(0),
19594
- _useState10 = _slicedToArray(_useState9, 2),
19595
- reloadCount = _useState10[0],
19596
- setReloadCount = _useState10[1];
19597
-
19371
+ _useState10 = _slicedToArray(_useState9, 2),
19372
+ reloadCount = _useState10[0],
19373
+ setReloadCount = _useState10[1];
19598
19374
  var _useContext = React.useContext(WalletContext),
19599
- account = _useContext.account;
19600
-
19375
+ account = _useContext.account;
19601
19376
  var _useContext2 = React.useContext(UpdatableContext),
19602
- updatable = _useContext2.updatable;
19603
-
19377
+ updatable = _useContext2.updatable;
19604
19378
  var _useContext3 = React.useContext(ConfigurationContext),
19605
- recover = _useContext3.recover;
19606
-
19607
- var calculateAmountInWithSlippage = /*#__PURE__*/function () {
19608
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(route) {
19609
- var currentBlock, blocks, i, exchangeRoute, lastAmountsIn, defaultSlippage, defaultSlippageNewAmountBN, defaultReadableAmount, defaultSlippageRoundedAmountBN, newAmountBN, readableAmount, roundedAmountBN, difference1, difference2, slippage, _difference, _difference2, _slippage, highestAmountBN;
19610
-
19379
+ recover = _useContext3.recover;
19380
+ var onRoutesUpdate = /*#__PURE__*/function () {
19381
+ var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(routes) {
19611
19382
  return regenerator.wrap(function _callee2$(_context2) {
19612
19383
  while (1) {
19613
19384
  switch (_context2.prev = _context2.next) {
19614
- case 0:
19615
- if (!route.directTransfer) {
19616
- _context2.next = 2;
19617
- break;
19618
- }
19619
-
19620
- return _context2.abrupt("return");
19621
-
19622
- case 2:
19623
- _context2.next = 4;
19624
- return web3Client.request({
19625
- blockchain: route.blockchain,
19626
- method: 'latestBlockNumber'
19627
- });
19628
-
19629
- case 4:
19630
- currentBlock = _context2.sent;
19631
- blocks = [];
19632
-
19633
- for (i = 0; i <= 2; i++) {
19634
- blocks.push(currentBlock - i);
19635
- }
19636
-
19637
- exchangeRoute = route.exchangeRoutes[0];
19638
-
19639
- if (!(typeof exchangeRoute == 'undefined' || typeof exchangeRoute.exchange == 'undefined')) {
19640
- _context2.next = 10;
19641
- break;
19642
- }
19643
-
19644
- return _context2.abrupt("return");
19645
-
19646
- case 10:
19647
- _context2.next = 12;
19648
- return Promise.all(blocks.map( /*#__PURE__*/function () {
19649
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(block) {
19650
- var amountIn;
19651
- return regenerator.wrap(function _callee$(_context) {
19652
- while (1) {
19653
- switch (_context.prev = _context.next) {
19654
- case 0:
19655
- _context.next = 2;
19656
- return exchangeRoute.exchange.getAmountIn({
19657
- path: exchangeRoute.path,
19658
- amountOut: exchangeRoute.amountOutMin,
19659
- block: block
19660
- });
19661
-
19662
- case 2:
19663
- amountIn = _context.sent;
19664
- return _context.abrupt("return", amountIn);
19665
-
19666
- case 4:
19667
- case "end":
19668
- return _context.stop();
19669
- }
19670
- }
19671
- }, _callee);
19672
- }));
19673
-
19674
- return function (_x2) {
19675
- return _ref2.apply(this, arguments);
19676
- };
19677
- }()));
19678
-
19679
- case 12:
19680
- lastAmountsIn = _context2.sent;
19681
-
19682
- if (!(!lastAmountsIn[0] || !lastAmountsIn[1] || !lastAmountsIn[2])) {
19683
- _context2.next = 15;
19684
- break;
19685
- }
19686
-
19687
- return _context2.abrupt("return");
19688
-
19689
- case 15:
19690
- defaultSlippage = '0.5'; // %
19691
-
19692
- if (ethers.ethers.BigNumber.from(route.fromAmount).mul(10000).div(ethers.ethers.BigNumber.from(route.toAmount).add(ethers.ethers.BigNumber.from(route.feeAmount || '0'))).sub(10000).toString() <= 100) {
19693
- // stable coin swap
19694
- defaultSlippage = '0.1'; // %
19695
- }
19696
-
19697
- defaultSlippageNewAmountBN = lastAmountsIn[2].add(lastAmountsIn[2].mul(parseFloat(defaultSlippage) * 100).div(10000));
19698
- _context2.next = 20;
19699
- return route.fromToken.readable(defaultSlippageNewAmountBN);
19700
-
19701
- case 20:
19702
- defaultReadableAmount = _context2.sent;
19703
- _context2.next = 23;
19704
- return route.fromToken.BigNumber(round(defaultReadableAmount));
19705
-
19706
- case 23:
19707
- defaultSlippageRoundedAmountBN = _context2.sent;
19708
-
19709
- if (!(lastAmountsIn[0].gt(lastAmountsIn[1]) && lastAmountsIn[1].gt(lastAmountsIn[2]))) {
19710
- _context2.next = 41;
19711
- break;
19712
- }
19713
-
19714
- // EXTREME DIRETIONAL SLIPPAGE
19715
- difference1 = lastAmountsIn[0].sub(lastAmountsIn[1]);
19716
- difference2 = lastAmountsIn[1].sub(lastAmountsIn[2]);
19717
-
19718
- if (difference1.lt(difference2)) {
19719
- slippage = difference2.add(difference2.sub(difference1));
19720
- } else {
19721
- slippage = difference1.add(difference1.sub(difference2));
19722
- }
19723
-
19724
- newAmountBN = lastAmountsIn[0].add(slippage);
19725
- _context2.next = 31;
19726
- return route.fromToken.readable(newAmountBN);
19727
-
19728
- case 31:
19729
- readableAmount = _context2.sent;
19730
- _context2.next = 34;
19731
- return route.fromToken.BigNumber(round(readableAmount));
19732
-
19733
- case 34:
19734
- roundedAmountBN = _context2.sent;
19735
-
19736
- if (!roundedAmountBN.gt(defaultSlippageRoundedAmountBN)) {
19737
- _context2.next = 39;
19738
- break;
19739
- }
19740
-
19741
- if (!(route.fromAmount == roundedAmountBN.toString())) {
19742
- _context2.next = 38;
19743
- break;
19744
- }
19745
-
19746
- return _context2.abrupt("return");
19747
-
19748
- case 38:
19749
- return _context2.abrupt("return", roundedAmountBN);
19750
-
19751
- case 39:
19752
- _context2.next = 57;
19753
- break;
19754
-
19755
- case 41:
19756
- if (lastAmountsIn[0].eq(lastAmountsIn[1]) && lastAmountsIn[1].eq(lastAmountsIn[2])) {
19757
- _context2.next = 57;
19758
- break;
19759
- }
19760
-
19761
- // BASE NOISE SLIPPAGE
19762
- _difference = lastAmountsIn[0].sub(lastAmountsIn[1]).abs();
19763
- _difference2 = lastAmountsIn[1].sub(lastAmountsIn[2]).abs();
19764
-
19765
- if (_difference.lt(_difference2)) {
19766
- _slippage = _difference;
19767
- } else {
19768
- _slippage = _difference2;
19769
- }
19770
-
19771
- if (lastAmountsIn[0].gt(lastAmountsIn[1]) && lastAmountsIn[0].gt(lastAmountsIn[2])) {
19772
- highestAmountBN = lastAmountsIn[0];
19773
- } else if (lastAmountsIn[1].gt(lastAmountsIn[2]) && lastAmountsIn[1].gt(lastAmountsIn[0])) {
19774
- highestAmountBN = lastAmountsIn[1];
19775
- } else {
19776
- highestAmountBN = lastAmountsIn[2];
19777
- }
19778
-
19779
- newAmountBN = highestAmountBN.add(_slippage);
19780
- _context2.next = 49;
19781
- return route.fromToken.readable(newAmountBN);
19782
-
19783
- case 49:
19784
- readableAmount = _context2.sent;
19785
- _context2.next = 52;
19786
- return route.fromToken.BigNumber(round(readableAmount));
19787
-
19788
- case 52:
19789
- roundedAmountBN = _context2.sent;
19790
-
19791
- if (!roundedAmountBN.gt(defaultSlippageRoundedAmountBN)) {
19792
- _context2.next = 57;
19793
- break;
19794
- }
19795
-
19796
- if (!(route.fromAmount == roundedAmountBN.toString())) {
19797
- _context2.next = 56;
19798
- break;
19799
- }
19800
-
19801
- return _context2.abrupt("return");
19802
-
19803
- case 56:
19804
- return _context2.abrupt("return", roundedAmountBN);
19805
-
19806
- case 57:
19807
- if (!(route.fromAmount == defaultSlippageRoundedAmountBN.toString())) {
19808
- _context2.next = 59;
19809
- break;
19810
- }
19811
-
19812
- return _context2.abrupt("return");
19813
-
19814
- case 59:
19815
- return _context2.abrupt("return", defaultSlippageRoundedAmountBN);
19816
-
19817
- case 60:
19818
- case "end":
19819
- return _context2.stop();
19820
- }
19821
- }
19822
- }, _callee2);
19823
- }));
19824
-
19825
- return function calculateAmountInWithSlippage(_x) {
19826
- return _ref.apply(this, arguments);
19827
- };
19828
- }();
19829
-
19830
- var onRoutesUpdate = /*#__PURE__*/function () {
19831
- var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(routes) {
19832
- return regenerator.wrap(function _callee5$(_context5) {
19833
- while (1) {
19834
- switch (_context5.prev = _context5.next) {
19835
19385
  case 0:
19836
19386
  if (routes.length == 0) {
19837
19387
  setAllRoutes([]);
19838
-
19839
19388
  if (props.setMaxRoute) {
19840
19389
  props.setMaxRoute(null);
19841
19390
  }
19842
19391
  } else {
19843
19392
  roundAmounts(routes).then( /*#__PURE__*/function () {
19844
- var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(roundedRoutes) {
19845
- var selectRoute, amountInWithSlippage, newSelectRoute, _amountInWithSlippage;
19846
-
19847
- return regenerator.wrap(function _callee4$(_context4) {
19393
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(roundedRoutes) {
19394
+ var selectRoute, newSelectRoute;
19395
+ return regenerator.wrap(function _callee$(_context) {
19848
19396
  while (1) {
19849
- switch (_context4.prev = _context4.next) {
19397
+ switch (_context.prev = _context.next) {
19850
19398
  case 0:
19851
- if (!(typeof selectedRoute == 'undefined')) {
19852
- _context4.next = 11;
19853
- break;
19399
+ if (typeof selectedRoute == 'undefined') {
19400
+ selectRoute = roundedRoutes[0];
19401
+ setSelectedRoute(selectRoute);
19402
+ } else {
19403
+ newSelectRoute = roundedRoutes[roundedRoutes.findIndex(function (route) {
19404
+ return route.fromToken.address == selectedRoute.fromToken.address && route.blockchain == selectedRoute.blockchain;
19405
+ })];
19406
+ if (newSelectRoute) {
19407
+ if (selectedRoute.fromAmount != newSelectRoute.fromAmount) {
19408
+ setUpdatedRouteWithNewPrice(newSelectRoute);
19409
+ }
19410
+ }
19854
19411
  }
19855
-
19856
- selectRoute = roundedRoutes[0];
19857
- _context4.next = 4;
19858
- return calculateAmountInWithSlippage(selectRoute);
19859
-
19860
- case 4:
19861
- amountInWithSlippage = _context4.sent;
19862
-
19863
- if (!amountInWithSlippage) {
19864
- _context4.next = 8;
19865
- break;
19866
- }
19867
-
19868
- _context4.next = 8;
19869
- return roundAmount(selectRoute, amountInWithSlippage);
19870
-
19871
- case 8:
19872
- setSelectedRoute(selectRoute);
19873
- _context4.next = 20;
19874
- break;
19875
-
19876
- case 11:
19877
- newSelectRoute = roundedRoutes[roundedRoutes.findIndex(function (route) {
19878
- return route.fromToken.address == selectedRoute.fromToken.address && route.blockchain == selectedRoute.blockchain;
19879
- })];
19880
-
19881
- if (!newSelectRoute) {
19882
- _context4.next = 20;
19883
- break;
19884
- }
19885
-
19886
- _context4.next = 15;
19887
- return calculateAmountInWithSlippage(newSelectRoute);
19888
-
19889
- case 15:
19890
- _amountInWithSlippage = _context4.sent;
19891
-
19892
- if (!_amountInWithSlippage) {
19893
- _context4.next = 19;
19894
- break;
19895
- }
19896
-
19897
- _context4.next = 19;
19898
- return roundAmount(newSelectRoute, _amountInWithSlippage);
19899
-
19900
- case 19:
19901
- if (_amountInWithSlippage == undefined || selectedRoute.fromAmount != _amountInWithSlippage.toString()) {
19902
- setUpdatedRouteWithNewPrice(newSelectRoute);
19903
- }
19904
-
19905
- case 20:
19906
- _context4.next = 22;
19907
- return Promise.all(roundedRoutes.map( /*#__PURE__*/function () {
19908
- var _ref5 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(route, index) {
19909
- var amountInWithSlippage;
19910
- return regenerator.wrap(function _callee3$(_context3) {
19911
- while (1) {
19912
- switch (_context3.prev = _context3.next) {
19913
- case 0:
19914
- _context3.next = 2;
19915
- return calculateAmountInWithSlippage(route);
19916
-
19917
- case 2:
19918
- amountInWithSlippage = _context3.sent;
19919
-
19920
- if (!amountInWithSlippage) {
19921
- _context3.next = 6;
19922
- break;
19923
- }
19924
-
19925
- _context3.next = 6;
19926
- return roundAmount(route, amountInWithSlippage);
19927
-
19928
- case 6:
19929
- return _context3.abrupt("return", route);
19930
-
19931
- case 7:
19932
- case "end":
19933
- return _context3.stop();
19934
- }
19935
- }
19936
- }, _callee3);
19937
- }));
19938
-
19939
- return function (_x5, _x6) {
19940
- return _ref5.apply(this, arguments);
19941
- };
19942
- }())).then(setAllRoutes);
19943
-
19944
- case 22:
19412
+ setAllRoutes(roundedRoutes);
19945
19413
  if (props.setMaxRoute) {
19946
19414
  props.setMaxRoute(findMaxRoute(roundedRoutes));
19947
19415
  }
19948
-
19949
- case 23:
19416
+ case 3:
19950
19417
  case "end":
19951
- return _context4.stop();
19418
+ return _context.stop();
19952
19419
  }
19953
19420
  }
19954
- }, _callee4);
19421
+ }, _callee);
19955
19422
  }));
19956
-
19957
- return function (_x4) {
19958
- return _ref4.apply(this, arguments);
19423
+ return function (_x2) {
19424
+ return _ref2.apply(this, arguments);
19959
19425
  };
19960
19426
  }());
19961
19427
  }
19962
-
19963
19428
  case 1:
19964
19429
  case "end":
19965
- return _context5.stop();
19430
+ return _context2.stop();
19966
19431
  }
19967
19432
  }
19968
- }, _callee5);
19433
+ }, _callee2);
19969
19434
  }));
19970
-
19971
- return function onRoutesUpdate(_x3) {
19972
- return _ref3.apply(this, arguments);
19435
+ return function onRoutesUpdate(_x) {
19436
+ return _ref.apply(this, arguments);
19973
19437
  };
19974
19438
  }();
19975
-
19976
- var getPaymentRoutes = function getPaymentRoutes(_ref6) {
19977
- _ref6.allRoutes;
19978
- _ref6.selectedRoute;
19979
- var updatable = _ref6.updatable;
19980
-
19439
+ var getPaymentRoutes = function getPaymentRoutes(_ref3) {
19440
+ _ref3.allRoutes;
19441
+ _ref3.selectedRoute;
19442
+ var updatable = _ref3.updatable;
19981
19443
  if (updatable == false || !props.accept || !account) {
19982
19444
  return;
19983
19445
  }
19984
-
19985
19446
  var slowRoutingTimeout = setTimeout(function () {
19986
19447
  setSlowRouting(true);
19987
19448
  }, 4000);
@@ -19992,145 +19453,86 @@
19992
19453
  onRoutesUpdate(routes);
19993
19454
  });
19994
19455
  };
19995
-
19996
19456
  var updateRouteAmount = function updateRouteAmount(route, amountBN) {
19997
19457
  route.fromAmount = amountBN.toString();
19998
19458
  route.transaction.params.amounts[0] = amountBN.toString();
19999
-
20000
19459
  if (route.transaction.value && route.transaction.value.toString() != '0') {
20001
19460
  route.transaction.value = amountBN.toString();
20002
19461
  }
20003
19462
  };
20004
-
20005
19463
  var roundAmount = /*#__PURE__*/function () {
20006
- var _ref7 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(route, amountBN) {
19464
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(route, amountBN) {
20007
19465
  var readableAmount, roundedAmountBN;
20008
- return regenerator.wrap(function _callee6$(_context6) {
19466
+ return regenerator.wrap(function _callee3$(_context3) {
20009
19467
  while (1) {
20010
- switch (_context6.prev = _context6.next) {
19468
+ switch (_context3.prev = _context3.next) {
20011
19469
  case 0:
20012
19470
  if (!route.directTransfer) {
20013
- _context6.next = 2;
19471
+ _context3.next = 2;
20014
19472
  break;
20015
19473
  }
20016
-
20017
- return _context6.abrupt("return", route);
20018
-
19474
+ return _context3.abrupt("return", route);
20019
19475
  case 2:
20020
- _context6.next = 4;
19476
+ _context3.next = 4;
20021
19477
  return route.fromToken.readable(amountBN || route.transaction.params.amounts[0]);
20022
-
20023
19478
  case 4:
20024
- readableAmount = _context6.sent;
20025
- _context6.next = 7;
19479
+ readableAmount = _context3.sent;
19480
+ _context3.next = 7;
20026
19481
  return route.fromToken.BigNumber(round(readableAmount));
20027
-
20028
19482
  case 7:
20029
- roundedAmountBN = _context6.sent;
19483
+ roundedAmountBN = _context3.sent;
20030
19484
  updateRouteAmount(route, roundedAmountBN);
20031
- return _context6.abrupt("return", route);
20032
-
19485
+ return _context3.abrupt("return", route);
20033
19486
  case 10:
20034
19487
  case "end":
20035
- return _context6.stop();
19488
+ return _context3.stop();
20036
19489
  }
20037
19490
  }
20038
- }, _callee6);
19491
+ }, _callee3);
20039
19492
  }));
20040
-
20041
- return function roundAmount(_x7, _x8) {
20042
- return _ref7.apply(this, arguments);
19493
+ return function roundAmount(_x3, _x4) {
19494
+ return _ref4.apply(this, arguments);
20043
19495
  };
20044
19496
  }();
20045
-
20046
19497
  var roundAmounts = /*#__PURE__*/function () {
20047
- var _ref8 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7(routes) {
20048
- return regenerator.wrap(function _callee7$(_context7) {
19498
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(routes) {
19499
+ return regenerator.wrap(function _callee4$(_context4) {
20049
19500
  while (1) {
20050
- switch (_context7.prev = _context7.next) {
19501
+ switch (_context4.prev = _context4.next) {
20051
19502
  case 0:
20052
- return _context7.abrupt("return", Promise.all(routes.map(function (route) {
19503
+ return _context4.abrupt("return", Promise.all(routes.map(function (route) {
20053
19504
  return roundAmount(route);
20054
19505
  })));
20055
-
20056
19506
  case 1:
20057
19507
  case "end":
20058
- return _context7.stop();
19508
+ return _context4.stop();
20059
19509
  }
20060
19510
  }
20061
- }, _callee7);
19511
+ }, _callee4);
20062
19512
  }));
20063
-
20064
- return function roundAmounts(_x9) {
20065
- return _ref8.apply(this, arguments);
19513
+ return function roundAmounts(_x5) {
19514
+ return _ref5.apply(this, arguments);
20066
19515
  };
20067
19516
  }();
20068
-
20069
19517
  var updateRouteWithNewPrice = /*#__PURE__*/function () {
20070
- var _ref9 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8() {
20071
- return regenerator.wrap(function _callee8$(_context8) {
19518
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5() {
19519
+ return regenerator.wrap(function _callee5$(_context5) {
20072
19520
  while (1) {
20073
- switch (_context8.prev = _context8.next) {
19521
+ switch (_context5.prev = _context5.next) {
20074
19522
  case 0:
20075
19523
  setSelectedRoute(_objectSpread({}, updatedRouteWithNewPrice));
20076
19524
  setUpdatedRouteWithNewPrice(null);
20077
-
20078
19525
  case 2:
20079
19526
  case "end":
20080
- return _context8.stop();
19527
+ return _context5.stop();
20081
19528
  }
20082
19529
  }
20083
- }, _callee8);
19530
+ }, _callee5);
20084
19531
  }));
20085
-
20086
19532
  return function updateRouteWithNewPrice() {
20087
- return _ref9.apply(this, arguments);
19533
+ return _ref6.apply(this, arguments);
20088
19534
  };
20089
19535
  }();
20090
-
20091
- React.useEffect(function () {
20092
- function updateRouteWithAmountInWithSlippage() {
20093
- return _updateRouteWithAmountInWithSlippage.apply(this, arguments);
20094
- }
20095
-
20096
- function _updateRouteWithAmountInWithSlippage() {
20097
- _updateRouteWithAmountInWithSlippage = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9() {
20098
- var amountInWithSlippage;
20099
- return regenerator.wrap(function _callee9$(_context9) {
20100
- while (1) {
20101
- switch (_context9.prev = _context9.next) {
20102
- case 0:
20103
- _context9.next = 2;
20104
- return calculateAmountInWithSlippage(selectedRoute);
20105
-
20106
- case 2:
20107
- amountInWithSlippage = _context9.sent;
20108
-
20109
- if (!amountInWithSlippage) {
20110
- _context9.next = 7;
20111
- break;
20112
- }
20113
-
20114
- _context9.next = 6;
20115
- return roundAmount(selectedRoute, amountInWithSlippage);
20116
-
20117
- case 6:
20118
- setUpdatedRouteWithNewPrice(selectedRoute);
20119
-
20120
- case 7:
20121
- case "end":
20122
- return _context9.stop();
20123
- }
20124
- }
20125
- }, _callee9);
20126
- }));
20127
- return _updateRouteWithAmountInWithSlippage.apply(this, arguments);
20128
- }
20129
-
20130
- if (selectedRoute) {
20131
- updateRouteWithAmountInWithSlippage();
20132
- }
20133
- }, [selectedRoute]);
20134
19536
  React.useEffect(function () {
20135
19537
  var timeout = setTimeout(function () {
20136
19538
  setReloadCount(reloadCount + 1);
@@ -20167,55 +19569,42 @@
20167
19569
 
20168
19570
  var PaymentValueProvider = (function (props) {
20169
19571
  var _useContext = React.useContext(ErrorContext),
20170
- setError = _useContext.setError;
20171
-
19572
+ setError = _useContext.setError;
20172
19573
  var _useContext2 = React.useContext(WalletContext),
20173
- account = _useContext2.account;
20174
-
19574
+ account = _useContext2.account;
20175
19575
  var _useContext3 = React.useContext(UpdatableContext),
20176
- updatable = _useContext3.updatable;
20177
-
19576
+ updatable = _useContext3.updatable;
20178
19577
  var _useContext4 = React.useContext(ConfigurationContext),
20179
- configuredAmount = _useContext4.amount,
20180
- currencyCode = _useContext4.currencyCode;
20181
-
19578
+ configuredAmount = _useContext4.amount,
19579
+ currencyCode = _useContext4.currencyCode;
20182
19580
  var _useContext5 = React.useContext(ChangableAmountContext),
20183
- amount = _useContext5.amount;
20184
-
19581
+ amount = _useContext5.amount;
20185
19582
  var _useContext6 = React.useContext(PaymentContext),
20186
- payment = _useContext6.payment;
20187
-
19583
+ payment = _useContext6.payment;
20188
19584
  var _useState = React.useState(),
20189
- _useState2 = _slicedToArray(_useState, 2),
20190
- paymentValue = _useState2[0],
20191
- setPaymentValue = _useState2[1];
20192
-
19585
+ _useState2 = _slicedToArray(_useState, 2),
19586
+ paymentValue = _useState2[0],
19587
+ setPaymentValue = _useState2[1];
20193
19588
  var _useState3 = React.useState(),
20194
- _useState4 = _slicedToArray(_useState3, 2),
20195
- displayedPaymentValue = _useState4[0],
20196
- setDisplayedPaymentValue = _useState4[1];
20197
-
19589
+ _useState4 = _slicedToArray(_useState3, 2),
19590
+ displayedPaymentValue = _useState4[0],
19591
+ setDisplayedPaymentValue = _useState4[1];
20198
19592
  var _useState5 = React.useState(),
20199
- _useState6 = _slicedToArray(_useState5, 2),
20200
- paymentValueLoss = _useState6[0],
20201
- setPaymentValueLoss = _useState6[1];
20202
-
19593
+ _useState6 = _slicedToArray(_useState5, 2),
19594
+ paymentValueLoss = _useState6[0],
19595
+ setPaymentValueLoss = _useState6[1];
20203
19596
  var _useContext7 = React.useContext(ConfigurationContext),
20204
- currency = _useContext7.currency;
20205
-
19597
+ currency = _useContext7.currency;
20206
19598
  var _useState7 = React.useState(0),
20207
- _useState8 = _slicedToArray(_useState7, 2),
20208
- reloadCount = _useState8[0],
20209
- setReloadCount = _useState8[1];
20210
-
19599
+ _useState8 = _slicedToArray(_useState7, 2),
19600
+ reloadCount = _useState8[0],
19601
+ setReloadCount = _useState8[1];
20211
19602
  var updatePaymentValue = function updatePaymentValue(_ref) {
20212
19603
  var updatable = _ref.updatable,
20213
- payment = _ref.payment;
20214
-
19604
+ payment = _ref.payment;
20215
19605
  if (updatable == false || (payment === null || payment === void 0 ? void 0 : payment.route) == undefined) {
20216
19606
  return;
20217
19607
  }
20218
-
20219
19608
  Promise.all([web3Exchanges.route({
20220
19609
  blockchain: payment.route.blockchain,
20221
19610
  tokenIn: payment.route.fromToken.address,
@@ -20235,27 +19624,22 @@
20235
19624
  address: web3Constants.CONSTANTS[payment.route.blockchain].USD
20236
19625
  }).decimals()]).then(function (_ref2) {
20237
19626
  var _ref3 = _slicedToArray(_ref2, 3),
20238
- fromTokenUSDExchangeRoutes = _ref3[0],
20239
- reverseRoutes = _ref3[1],
20240
- USDDecimals = _ref3[2];
20241
-
19627
+ fromTokenUSDExchangeRoutes = _ref3[0],
19628
+ reverseRoutes = _ref3[1],
19629
+ USDDecimals = _ref3[2];
20242
19630
  var fromTokenUSDRoute = fromTokenUSDExchangeRoutes[0];
20243
19631
  var reverseRoute = reverseRoutes[0];
20244
-
20245
19632
  if (reverseRoute) {
20246
19633
  var reverseAmountOutBN = ethers.ethers.BigNumber.from(reverseRoute.amountOut);
20247
19634
  var paymentAmountInBN = ethers.ethers.BigNumber.from(payment.route.fromAmount);
20248
19635
  var divPercent = 100 - reverseAmountOutBN.mul(ethers.ethers.BigNumber.from('100')).div(paymentAmountInBN).abs().toString();
20249
-
20250
19636
  if (divPercent >= 10) {
20251
19637
  setPaymentValueLoss(divPercent);
20252
19638
  } else {
20253
19639
  setPaymentValueLoss(null);
20254
19640
  }
20255
19641
  }
20256
-
20257
19642
  var fromTokenUSDAmount;
20258
-
20259
19643
  if (payment.route.fromToken.address.toLowerCase() == web3Constants.CONSTANTS[payment.route.blockchain].USD.toLowerCase()) {
20260
19644
  fromTokenUSDAmount = payment.route.fromAmount.toString();
20261
19645
  } else if (fromTokenUSDRoute == undefined) {
@@ -20264,7 +19648,6 @@
20264
19648
  } else {
20265
19649
  fromTokenUSDAmount = fromTokenUSDRoute.amountOut.toString();
20266
19650
  }
20267
-
20268
19651
  var fromTokenUSDValue = ethers.ethers.utils.formatUnits(fromTokenUSDAmount, USDDecimals);
20269
19652
  localCurrency.Currency.fromUSD({
20270
19653
  amount: fromTokenUSDValue,
@@ -20272,7 +19655,6 @@
20272
19655
  }).then(setPaymentValue);
20273
19656
  })["catch"](setError);
20274
19657
  };
20275
-
20276
19658
  React.useEffect(function () {
20277
19659
  if (paymentValue && amount && configuredAmount && configuredAmount.currency && configuredAmount.fix) {
20278
19660
  setDisplayedPaymentValue(paymentValue.toString());
@@ -20317,14 +19699,12 @@
20317
19699
 
20318
19700
  var DonationRoutingProvider = (function (props) {
20319
19701
  var _useContext = React.useContext(ChangableAmountContext),
20320
- acceptWithAmount = _useContext.acceptWithAmount,
20321
- setMaxRoute = _useContext.setMaxRoute;
20322
-
19702
+ acceptWithAmount = _useContext.acceptWithAmount,
19703
+ setMaxRoute = _useContext.setMaxRoute;
20323
19704
  var _useContext2 = React.useContext(ConfigurationContext),
20324
- blacklist = _useContext2.blacklist,
20325
- whitelist = _useContext2.whitelist,
20326
- fee = _useContext2.fee;
20327
-
19705
+ blacklist = _useContext2.blacklist,
19706
+ whitelist = _useContext2.whitelist,
19707
+ fee = _useContext2.fee;
20328
19708
  return /*#__PURE__*/React__default["default"].createElement(DonationRoutingContext.Provider, {
20329
19709
  value: {}
20330
19710
  }, /*#__PURE__*/React__default["default"].createElement(PaymentRoutingProvider, {
@@ -20341,9 +19721,7 @@
20341
19721
 
20342
19722
  var format = (function (input) {
20343
19723
  var _float = round(input);
20344
-
20345
19724
  var floatToString = _float.toString();
20346
-
20347
19725
  if (new RegExp(/\./).test(floatToString)) {
20348
19726
  var exploded = floatToString.split('.');
20349
19727
  return new Intl.NumberFormat().format(parseInt(exploded[0])) + '.' + exploded[1];
@@ -20354,81 +19732,61 @@
20354
19732
 
20355
19733
  var ChangeAmountDialog = (function (props) {
20356
19734
  var _useContext = React.useContext(reactDialogStack.NavigateStackContext),
20357
- navigate = _useContext.navigate;
20358
-
19735
+ navigate = _useContext.navigate;
20359
19736
  var _useContext2 = React.useContext(ErrorContext);
20360
- _useContext2.setError;
20361
-
19737
+ _useContext2.setError;
20362
19738
  var _useContext3 = React.useContext(WalletContext);
20363
- _useContext3.account;
20364
-
19739
+ _useContext3.account;
20365
19740
  var _useContext4 = React.useContext(ChangableAmountContext),
20366
- amount = _useContext4.amount,
20367
- setAmount = _useContext4.setAmount,
20368
- maxAmount = _useContext4.maxAmount;
20369
-
19741
+ amount = _useContext4.amount,
19742
+ setAmount = _useContext4.setAmount,
19743
+ maxAmount = _useContext4.maxAmount;
20370
19744
  var _useContext5 = React.useContext(PaymentValueContext);
20371
- _useContext5.displayedPaymentValue;
20372
-
19745
+ _useContext5.displayedPaymentValue;
20373
19746
  var _useState = React.useState(amount),
20374
- _useState2 = _slicedToArray(_useState, 2),
20375
- inputAmount = _useState2[0],
20376
- setInputAmount = _useState2[1];
20377
-
19747
+ _useState2 = _slicedToArray(_useState, 2),
19748
+ inputAmount = _useState2[0],
19749
+ setInputAmount = _useState2[1];
20378
19750
  var _useContext6 = React.useContext(ConfigurationContext),
20379
- currencyCode = _useContext6.currencyCode,
20380
- amountConfiguration = _useContext6.amount;
20381
-
19751
+ currencyCode = _useContext6.currencyCode,
19752
+ amountConfiguration = _useContext6.amount;
20382
19753
  var _useContext7 = React.useContext(PaymentRoutingContext);
20383
- _useContext7.allRoutes;
20384
- var setSelectedRoute = _useContext7.setSelectedRoute;
20385
-
19754
+ _useContext7.allRoutes;
19755
+ var setSelectedRoute = _useContext7.setSelectedRoute;
20386
19756
  var min = _typeof(amountConfiguration) == "object" && amountConfiguration.min ? amountConfiguration.min : 1;
20387
19757
  var step = _typeof(amountConfiguration) == "object" && amountConfiguration.step ? amountConfiguration.step : 1;
20388
19758
  var displayedCurrencyCode = amountConfiguration != undefined && amountConfiguration.token ? null : currencyCode;
20389
-
20390
19759
  var changeAmountAndGoBack = function changeAmountAndGoBack() {
20391
19760
  var newAmount = toValidValue(parseFloat(inputAmount));
20392
-
20393
19761
  if (newAmount != amount) {
20394
19762
  setSelectedRoute(undefined);
20395
19763
  setAmount(newAmount);
20396
19764
  }
20397
-
20398
19765
  navigate('back');
20399
19766
  };
20400
-
20401
19767
  var changeAmount = function changeAmount(value) {
20402
19768
  if (Number.isNaN(value)) {
20403
19769
  return;
20404
19770
  }
20405
-
20406
19771
  setInputAmount(value);
20407
19772
  };
20408
-
20409
19773
  var toValidStep = function toValidStep(value) {
20410
19774
  if (step) {
20411
19775
  value = parseFloat(new decimal_js.Decimal(Math.floor(new decimal_js.Decimal(value).div(step))).mul(step).toString());
20412
19776
  }
20413
-
20414
19777
  return value;
20415
19778
  };
20416
-
20417
19779
  var toValidValue = function toValidValue(value) {
20418
19780
  value = toValidStep(value);
20419
-
20420
19781
  if (maxAmount) {
20421
19782
  value = Math.max(min, Math.min(value, maxAmount));
20422
19783
  }
20423
-
20424
19784
  value = toValidStep(value);
20425
19785
  return value;
20426
19786
  };
20427
-
20428
19787
  var setValidValue = function setValidValue(value) {
20429
19788
  setInputAmount(toValidValue(value));
20430
19789
  };
20431
-
20432
19790
  return /*#__PURE__*/React__default["default"].createElement(Dialog$1, {
20433
19791
  stacked: true,
20434
19792
  header: /*#__PURE__*/React__default["default"].createElement("div", {
@@ -20483,8 +19841,7 @@
20483
19841
 
20484
19842
  var ChangePaymentSkeleton = (function (props) {
20485
19843
  var _useContext = React.useContext(PaymentValueContext),
20486
- paymentValue = _useContext.paymentValue;
20487
-
19844
+ paymentValue = _useContext.paymentValue;
20488
19845
  return /*#__PURE__*/React__default["default"].createElement(Dialog$1, {
20489
19846
  stacked: true,
20490
19847
  header: /*#__PURE__*/React__default["default"].createElement("div", {
@@ -20516,34 +19873,27 @@
20516
19873
 
20517
19874
  var ChangePaymentDialog = (function (props) {
20518
19875
  var _useContext = React.useContext(ErrorContext),
20519
- setError = _useContext.setError;
20520
-
19876
+ setError = _useContext.setError;
20521
19877
  var _useContext2 = React.useContext(PaymentRoutingContext),
20522
- allRoutes = _useContext2.allRoutes,
20523
- setSelectedRoute = _useContext2.setSelectedRoute;
20524
-
19878
+ allRoutes = _useContext2.allRoutes,
19879
+ setSelectedRoute = _useContext2.setSelectedRoute;
20525
19880
  var _useContext3 = React.useContext(PaymentValueContext);
20526
- _useContext3.paymentValue;
20527
- var displayedPaymentValue = _useContext3.displayedPaymentValue;
20528
-
19881
+ _useContext3.paymentValue;
19882
+ var displayedPaymentValue = _useContext3.displayedPaymentValue;
20529
19883
  var _useContext4 = React.useContext(reactDialogStack.NavigateStackContext),
20530
- navigate = _useContext4.navigate;
20531
-
19884
+ navigate = _useContext4.navigate;
20532
19885
  var _useState = React.useState([]),
20533
- _useState2 = _slicedToArray(_useState, 2),
20534
- allPaymentRoutesWithData = _useState2[0],
20535
- setAllPaymentRoutesWithData = _useState2[1];
20536
-
19886
+ _useState2 = _slicedToArray(_useState, 2),
19887
+ allPaymentRoutesWithData = _useState2[0],
19888
+ setAllPaymentRoutesWithData = _useState2[1];
20537
19889
  var _useState3 = React.useState([]),
20538
- _useState4 = _slicedToArray(_useState3, 2),
20539
- cards = _useState4[0],
20540
- setCards = _useState4[1];
20541
-
19890
+ _useState4 = _slicedToArray(_useState3, 2),
19891
+ cards = _useState4[0],
19892
+ setCards = _useState4[1];
20542
19893
  React.useEffect(function () {
20543
19894
  if (allRoutes == undefined) {
20544
19895
  return;
20545
19896
  }
20546
-
20547
19897
  Promise.all(allRoutes.map(function (route) {
20548
19898
  route.exchangeRoutes[0];
20549
19899
  route.fromToken;
@@ -20598,11 +19948,9 @@
20598
19948
  }, /*#__PURE__*/React__default["default"].createElement("small", null, format(round(parseFloat(payment.route.fromBalance.toString()) / Math.pow(10, payment.decimals), 'down')))))));
20599
19949
  }));
20600
19950
  }, [allPaymentRoutesWithData]);
20601
-
20602
19951
  if (allPaymentRoutesWithData.length == 0 || cards.length == 0) {
20603
19952
  return /*#__PURE__*/React__default["default"].createElement(ChangePaymentSkeleton, null);
20604
19953
  }
20605
-
20606
19954
  return /*#__PURE__*/React__default["default"].createElement(Dialog$1, {
20607
19955
  stacked: true,
20608
19956
  header: /*#__PURE__*/React__default["default"].createElement("div", {
@@ -20623,8 +19971,7 @@
20623
19971
 
20624
19972
  var DonationOverviewSkeleton = (function (props) {
20625
19973
  var _useContext = React.useContext(ConfigurationContext),
20626
- title = _useContext.title;
20627
-
19974
+ title = _useContext.title;
20628
19975
  return /*#__PURE__*/React__default["default"].createElement(Dialog$1, {
20629
19976
  header: /*#__PURE__*/React__default["default"].createElement("div", {
20630
19977
  className: "PaddingTopS PaddingLeftM PaddingRightM TextLeft"
@@ -20722,42 +20069,34 @@
20722
20069
 
20723
20070
  var Footer = (function () {
20724
20071
  var _useContext = React.useContext(ChangableAmountContext);
20725
- _useContext.amount;
20726
- _useContext.amountsMissing;
20727
-
20072
+ _useContext.amount;
20073
+ _useContext.amountsMissing;
20728
20074
  var _useContext2 = React.useContext(PaymentTrackingContext),
20729
- tracking = _useContext2.tracking,
20730
- release = _useContext2.release,
20731
- forwardTo = _useContext2.forwardTo;
20732
-
20075
+ tracking = _useContext2.tracking,
20076
+ release = _useContext2.release,
20077
+ forwardTo = _useContext2.forwardTo;
20733
20078
  var _useContext3 = React.useContext(PaymentContext),
20734
- payment = _useContext3.payment,
20735
- paymentState = _useContext3.paymentState,
20736
- pay = _useContext3.pay,
20737
- transaction = _useContext3.transaction,
20738
- approve = _useContext3.approve,
20739
- approvalTransaction = _useContext3.approvalTransaction;
20740
-
20079
+ payment = _useContext3.payment,
20080
+ paymentState = _useContext3.paymentState,
20081
+ pay = _useContext3.pay,
20082
+ transaction = _useContext3.transaction,
20083
+ approve = _useContext3.approve,
20084
+ approvalTransaction = _useContext3.approvalTransaction;
20741
20085
  var _useContext4 = React.useContext(PaymentValueContext);
20742
- _useContext4.paymentValue;
20743
- var displayedPaymentValue = _useContext4.displayedPaymentValue,
20744
- paymentValueLoss = _useContext4.paymentValueLoss;
20745
-
20086
+ _useContext4.paymentValue;
20087
+ var displayedPaymentValue = _useContext4.displayedPaymentValue,
20088
+ paymentValueLoss = _useContext4.paymentValueLoss;
20746
20089
  var _useContext5 = React.useContext(PaymentRoutingContext),
20747
- updatedRouteWithNewPrice = _useContext5.updatedRouteWithNewPrice,
20748
- updateRouteWithNewPrice = _useContext5.updateRouteWithNewPrice;
20749
-
20090
+ updatedRouteWithNewPrice = _useContext5.updatedRouteWithNewPrice,
20091
+ updateRouteWithNewPrice = _useContext5.updateRouteWithNewPrice;
20750
20092
  var _useContext6 = React.useContext(reactDialogStack.NavigateStackContext);
20751
- _useContext6.navigate;
20752
-
20093
+ _useContext6.navigate;
20753
20094
  var _useContext7 = React.useContext(ClosableContext),
20754
- close = _useContext7.close;
20755
-
20095
+ close = _useContext7.close;
20756
20096
  var trackingInfo = function trackingInfo() {
20757
20097
  if (tracking != true) {
20758
20098
  return null;
20759
20099
  }
20760
-
20761
20100
  if (release) {
20762
20101
  return /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement("div", {
20763
20102
  className: "Card transparent small disabled"
@@ -20792,7 +20131,6 @@
20792
20131
  }, "Validating payment")))));
20793
20132
  }
20794
20133
  };
20795
-
20796
20134
  var additionalPaymentInformation = function additionalPaymentInformation() {
20797
20135
  if (paymentState == 'paying' && transaction == undefined) {
20798
20136
  return /*#__PURE__*/React__default["default"].createElement("div", {
@@ -20812,7 +20150,7 @@
20812
20150
  }, /*#__PURE__*/React__default["default"].createElement("div", {
20813
20151
  className: "Opacity05"
20814
20152
  }, "Confirm transaction in your wallet")))));
20815
- } else if (paymentState == 'confirmed') {
20153
+ } else if (paymentState == 'success') {
20816
20154
  return /*#__PURE__*/React__default["default"].createElement("div", {
20817
20155
  className: "PaddingBottomS"
20818
20156
  }, /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement("a", {
@@ -20836,7 +20174,6 @@
20836
20174
  }, "Payment confirmed"))))), trackingInfo());
20837
20175
  }
20838
20176
  };
20839
-
20840
20177
  var approvalButton = function approvalButton() {
20841
20178
  if (payment.route == undefined || !payment.route.approvalRequired || payment.route.directTransfer) {
20842
20179
  return null;
@@ -20860,7 +20197,6 @@
20860
20197
  }, /*#__PURE__*/React__default["default"].createElement(LoadingText, null, "Approving")));
20861
20198
  }
20862
20199
  };
20863
-
20864
20200
  var mainAction = function mainAction() {
20865
20201
  if (updatedRouteWithNewPrice) {
20866
20202
  return /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement("div", {
@@ -20889,7 +20225,6 @@
20889
20225
  if (payment.route.approvalRequired && !payment.route.directTransfer) {
20890
20226
  return;
20891
20227
  }
20892
-
20893
20228
  pay();
20894
20229
  }
20895
20230
  }, "Pay ", displayedPaymentValue);
@@ -20901,7 +20236,7 @@
20901
20236
  target: "_blank",
20902
20237
  rel: "noopener noreferrer"
20903
20238
  }, /*#__PURE__*/React__default["default"].createElement(LoadingText, null, "Paying"));
20904
- } else if (paymentState == 'confirmed') {
20239
+ } else if (paymentState == 'success') {
20905
20240
  if (tracking == true) {
20906
20241
  if (release) {
20907
20242
  if (forwardTo) {
@@ -20930,32 +20265,25 @@
20930
20265
  }
20931
20266
  }
20932
20267
  };
20933
-
20934
20268
  return /*#__PURE__*/React__default["default"].createElement("div", null, approvalButton(), additionalPaymentInformation(), mainAction());
20935
20269
  });
20936
20270
 
20937
20271
  var DonationOverviewDialog = (function (props) {
20938
20272
  var _useContext = React.useContext(ConfigurationContext);
20939
- _useContext.currencyCode;
20940
- var title = _useContext.title;
20941
-
20273
+ _useContext.currencyCode;
20274
+ var title = _useContext.title;
20942
20275
  var _useContext2 = React.useContext(ChangableAmountContext);
20943
- _useContext2.amount;
20944
-
20276
+ _useContext2.amount;
20945
20277
  var _useContext3 = React.useContext(PaymentContext),
20946
- payment = _useContext3.payment,
20947
- paymentState = _useContext3.paymentState;
20948
-
20278
+ payment = _useContext3.payment,
20279
+ paymentState = _useContext3.paymentState;
20949
20280
  var _useContext4 = React.useContext(PaymentValueContext),
20950
- displayedPaymentValue = _useContext4.displayedPaymentValue;
20951
-
20281
+ displayedPaymentValue = _useContext4.displayedPaymentValue;
20952
20282
  var _useContext5 = React.useContext(reactDialogStack.NavigateStackContext),
20953
- navigate = _useContext5.navigate;
20954
-
20283
+ navigate = _useContext5.navigate;
20955
20284
  if (payment == undefined) {
20956
20285
  return /*#__PURE__*/React__default["default"].createElement(DonationOverviewSkeleton, null);
20957
20286
  }
20958
-
20959
20287
  var blockchain = web3Blockchains.Blockchain.findByName(payment.blockchain);
20960
20288
  return /*#__PURE__*/React__default["default"].createElement(Dialog$1, {
20961
20289
  header: /*#__PURE__*/React__default["default"].createElement("div", {
@@ -20972,7 +20300,6 @@
20972
20300
  if (paymentState != 'initialized') {
20973
20301
  return;
20974
20302
  }
20975
-
20976
20303
  navigate('ChangeAmount');
20977
20304
  }
20978
20305
  }, /*#__PURE__*/React__default["default"].createElement("div", {
@@ -20994,7 +20321,6 @@
20994
20321
  if (paymentState != 'initialized') {
20995
20322
  return;
20996
20323
  }
20997
-
20998
20324
  navigate('ChangePayment');
20999
20325
  }
21000
20326
  }, /*#__PURE__*/React__default["default"].createElement("div", {
@@ -21031,13 +20357,11 @@
21031
20357
  });
21032
20358
  });
21033
20359
 
21034
- var PaymentErrorDialog = (function () {
20360
+ var PaymentFailedDialog = (function () {
21035
20361
  var _useContext = React.useContext(ClosableContext),
21036
- close = _useContext.close;
21037
-
20362
+ close = _useContext.close;
21038
20363
  var _useContext2 = React.useContext(PaymentContext),
21039
- transaction = _useContext2.transaction;
21040
-
20364
+ transaction = _useContext2.transaction;
21041
20365
  return /*#__PURE__*/React__default["default"].createElement(Dialog$1, {
21042
20366
  stacked: false,
21043
20367
  header: /*#__PURE__*/React__default["default"].createElement("div", {
@@ -21080,11 +20404,9 @@
21080
20404
 
21081
20405
  var WrongNetworkDialog = (function (props) {
21082
20406
  var _useContext = React.useContext(PaymentContext),
21083
- payment = _useContext.payment;
21084
-
20407
+ payment = _useContext.payment;
21085
20408
  var _useContext2 = React.useContext(reactDialogStack.NavigateStackContext),
21086
- navigate = _useContext2.navigate;
21087
-
20409
+ navigate = _useContext2.navigate;
21088
20410
  var blockchain = web3Blockchains.Blockchain.findByName(payment.route.blockchain);
21089
20411
  return /*#__PURE__*/React__default["default"].createElement(Dialog$1, {
21090
20412
  stacked: true,
@@ -21120,12 +20442,10 @@
21120
20442
 
21121
20443
  var DonationStack = (function (props) {
21122
20444
  var _useContext = React.useContext(ClosableContext),
21123
- open = _useContext.open,
21124
- close = _useContext.close;
21125
-
20445
+ open = _useContext.open,
20446
+ close = _useContext.close;
21126
20447
  var _useContext2 = React.useContext(NavigateContext),
21127
- setNavigator = _useContext2.setNavigator;
21128
-
20448
+ setNavigator = _useContext2.setNavigator;
21129
20449
  return /*#__PURE__*/React__default["default"].createElement(reactDialogStack.ReactDialogStack, {
21130
20450
  setNavigator: setNavigator,
21131
20451
  open: open,
@@ -21137,7 +20457,7 @@
21137
20457
  DonationOverview: /*#__PURE__*/React__default["default"].createElement(DonationOverviewDialog, null),
21138
20458
  ChangeAmount: /*#__PURE__*/React__default["default"].createElement(ChangeAmountDialog, null),
21139
20459
  ChangePayment: /*#__PURE__*/React__default["default"].createElement(ChangePaymentDialog, null),
21140
- PaymentError: /*#__PURE__*/React__default["default"].createElement(PaymentErrorDialog, null),
20460
+ PaymentFailed: /*#__PURE__*/React__default["default"].createElement(PaymentFailedDialog, null),
21141
20461
  WrongNetwork: /*#__PURE__*/React__default["default"].createElement(WrongNetworkDialog, null)
21142
20462
  }
21143
20463
  });
@@ -21145,23 +20465,19 @@
21145
20465
 
21146
20466
  var NavigateProvider = (function (props) {
21147
20467
  var navigator;
21148
-
21149
20468
  var setNavigator = function setNavigator(_navigator) {
21150
20469
  navigator = _navigator;
21151
20470
  };
21152
-
21153
20471
  var navigate = function navigate(dialog) {
21154
20472
  if (navigator) {
21155
20473
  navigator.navigate(dialog);
21156
20474
  }
21157
20475
  };
21158
-
21159
20476
  var set = function set(dialogs) {
21160
20477
  if (navigator) {
21161
20478
  navigator.set(dialogs);
21162
20479
  }
21163
20480
  };
21164
-
21165
20481
  return /*#__PURE__*/React__default["default"].createElement(NavigateContext.Provider, {
21166
20482
  value: {
21167
20483
  navigate: navigate,
@@ -21173,58 +20489,46 @@
21173
20489
 
21174
20490
  var PaymentTrackingProvider = (function (props) {
21175
20491
  var _useContext = React.useContext(ErrorContext);
21176
- _useContext.errorCallback;
21177
-
20492
+ _useContext.errorCallback;
21178
20493
  var _useContext2 = React.useContext(ConfigurationContext),
21179
- track = _useContext2.track,
21180
- validated = _useContext2.validated,
21181
- integration = _useContext2.integration,
21182
- link = _useContext2.link,
21183
- type = _useContext2.type;
21184
-
20494
+ track = _useContext2.track,
20495
+ validated = _useContext2.validated,
20496
+ integration = _useContext2.integration,
20497
+ link = _useContext2.link,
20498
+ type = _useContext2.type;
21185
20499
  var _useState = React.useState(),
21186
- _useState2 = _slicedToArray(_useState, 2),
21187
- transaction = _useState2[0],
21188
- setTransaction = _useState2[1];
21189
-
20500
+ _useState2 = _slicedToArray(_useState, 2),
20501
+ transaction = _useState2[0],
20502
+ setTransaction = _useState2[1];
21190
20503
  var _useState3 = React.useState(),
21191
- _useState4 = _slicedToArray(_useState3, 2),
21192
- afterBlock = _useState4[0],
21193
- setAfterBlock = _useState4[1];
21194
-
20504
+ _useState4 = _slicedToArray(_useState3, 2),
20505
+ afterBlock = _useState4[0],
20506
+ setAfterBlock = _useState4[1];
21195
20507
  var _useState5 = React.useState(),
21196
- _useState6 = _slicedToArray(_useState5, 2),
21197
- paymentRoute = _useState6[0],
21198
- setPaymentRoute = _useState6[1];
21199
-
20508
+ _useState6 = _slicedToArray(_useState5, 2),
20509
+ paymentRoute = _useState6[0],
20510
+ setPaymentRoute = _useState6[1];
21200
20511
  var _useState7 = React.useState(!!(track && (track.endpoint || typeof track.method == 'function') && track.async != true)),
21201
- _useState8 = _slicedToArray(_useState7, 1),
21202
- tracking = _useState8[0];
21203
-
20512
+ _useState8 = _slicedToArray(_useState7, 1),
20513
+ tracking = _useState8[0];
21204
20514
  var _useState9 = React.useState(!!(track && track.poll && (track.poll.endpoint || typeof track.poll.method == 'function') && track.async != true)),
21205
- _useState10 = _slicedToArray(_useState9, 1),
21206
- polling = _useState10[0];
21207
-
20515
+ _useState10 = _slicedToArray(_useState9, 1),
20516
+ polling = _useState10[0];
21208
20517
  var _useState11 = React.useState(false),
21209
- _useState12 = _slicedToArray(_useState11, 2),
21210
- release = _useState12[0],
21211
- setRelease = _useState12[1];
21212
-
20518
+ _useState12 = _slicedToArray(_useState11, 2),
20519
+ release = _useState12[0],
20520
+ setRelease = _useState12[1];
21213
20521
  var _useState13 = React.useState(),
21214
- _useState14 = _slicedToArray(_useState13, 2),
21215
- forwardTo = _useState14[0],
21216
- setForwardTo = _useState14[1];
21217
-
20522
+ _useState14 = _slicedToArray(_useState13, 2),
20523
+ forwardTo = _useState14[0],
20524
+ setForwardTo = _useState14[1];
21218
20525
  var _useContext3 = React.useContext(ClosableContext),
21219
- setClosable = _useContext3.setClosable;
21220
-
20526
+ setClosable = _useContext3.setClosable;
21221
20527
  var _useContext4 = React.useContext(NavigateContext),
21222
- navigate = _useContext4.navigate,
21223
- set = _useContext4.set;
21224
-
20528
+ navigate = _useContext4.navigate;
20529
+ _useContext4.set;
21225
20530
  var openSocket = function openSocket(transaction) {
21226
20531
  var socket = new WebSocket('wss://integrate.depay.com/cable');
21227
-
21228
20532
  socket.onopen = function (event) {
21229
20533
  var msg = {
21230
20534
  command: 'subscribe',
@@ -21237,31 +20541,20 @@
21237
20541
  };
21238
20542
  socket.send(JSON.stringify(msg));
21239
20543
  };
21240
-
21241
20544
  socket.onclose = function (event) {};
21242
-
21243
20545
  socket.onmessage = function (event) {
21244
20546
  var item = JSON.parse(event.data);
21245
-
21246
20547
  if (item.type === "ping" || !item.message) {
21247
20548
  return;
21248
20549
  }
21249
-
21250
- if (item.message.status == 'failed') {
21251
- setClosable(true);
21252
- set(['PaymentError']);
21253
- }
21254
-
21255
20550
  if (validated) {
21256
20551
  validated(item.message.status == 'success');
21257
20552
  }
21258
-
21259
20553
  if (item.message.release) {
21260
20554
  setRelease(true);
21261
20555
  setClosable(!item.message.forward_to);
21262
20556
  setForwardTo(item.message.forward_to);
21263
20557
  socket.close();
21264
-
21265
20558
  if (!!item.message.forward_to) {
21266
20559
  setTimeout(function () {
21267
20560
  props.document.location.href = item.message.forward_to;
@@ -21269,31 +20562,23 @@
21269
20562
  }
21270
20563
  }
21271
20564
  };
21272
-
21273
20565
  socket.onerror = function (error) {
21274
20566
  console.log('WebSocket Error: ' + error);
21275
20567
  };
21276
20568
  };
21277
-
21278
20569
  var retryStartTracking = function retryStartTracking(transaction, afterBlock, paymentRoute, attempt) {
21279
20570
  attempt = parseInt(attempt || 1, 10);
21280
- console.log('attempt', attempt);
21281
- console.log('track.attempts', track === null || track === void 0 ? void 0 : track.attempts);
21282
-
21283
20571
  if (attempt < ((track === null || track === void 0 ? void 0 : track.attempts) || 40)) {
21284
20572
  setTimeout(function () {
21285
20573
  startTracking(transaction, afterBlock, paymentRoute, attempt + 1);
21286
20574
  }, 3000);
21287
20575
  } else {
21288
- console.log('navigate TrackingFailed');
21289
20576
  navigate('TrackingFailed');
21290
20577
  }
21291
20578
  };
21292
-
21293
20579
  var continueTryTracking = function continueTryTracking() {
21294
20580
  retryStartTracking(transaction, afterBlock, paymentRoute, 1);
21295
20581
  };
21296
-
21297
20582
  var callTracking = function callTracking(payment) {
21298
20583
  if (track.endpoint) {
21299
20584
  return fetch(track.endpoint, {
@@ -21309,10 +20594,8 @@
21309
20594
  throw 'No tracking defined!';
21310
20595
  }
21311
20596
  };
21312
-
21313
20597
  var startTracking = function startTracking(transaction, afterBlock, paymentRoute, attempt) {
21314
20598
  var _paymentRoute$feeAmou;
21315
-
21316
20599
  callTracking({
21317
20600
  blockchain: transaction.blockchain,
21318
20601
  transaction: transaction.id.toLowerCase(),
@@ -21335,12 +20618,10 @@
21335
20618
  retryStartTracking(transaction, afterBlock, paymentRoute, attempt);
21336
20619
  });
21337
20620
  };
21338
-
21339
20621
  var pollStatus = function pollStatus(polling, transaction, afterBlock, paymentRoute, pollingInterval) {
21340
20622
  if (!polling || transaction == undefined || afterBlock == undefined || paymentRoute == undefined) {
21341
20623
  return;
21342
20624
  }
21343
-
21344
20625
  var payment = {
21345
20626
  blockchain: transaction.blockchain,
21346
20627
  transaction: transaction.id.toLowerCase(),
@@ -21349,7 +20630,6 @@
21349
20630
  after_block: afterBlock,
21350
20631
  to_token: paymentRoute.toToken.address
21351
20632
  };
21352
-
21353
20633
  var handleResponse = function handleResponse(response) {
21354
20634
  if (response.status == 200 || response.status == 201) {
21355
20635
  response.json().then(function (data) {
@@ -21368,7 +20648,6 @@
21368
20648
  setRelease(true);
21369
20649
  }
21370
20650
  };
21371
-
21372
20651
  if (track.poll.endpoint) {
21373
20652
  fetch(track.poll.endpoint, {
21374
20653
  method: 'POST',
@@ -21381,16 +20660,13 @@
21381
20660
  track.poll.method(payment).then(handleResponse);
21382
20661
  }
21383
20662
  };
21384
-
21385
20663
  React.useEffect(function () {
21386
20664
  if (!polling) {
21387
20665
  return;
21388
20666
  }
21389
-
21390
20667
  if (!tracking) {
21391
20668
  return;
21392
20669
  }
21393
-
21394
20670
  var pollingInterval = setInterval(function () {
21395
20671
  return pollStatus(polling, transaction, afterBlock, paymentRoute, pollingInterval);
21396
20672
  }, 5000);
@@ -21398,7 +20674,6 @@
21398
20674
  clearInterval(pollingInterval);
21399
20675
  };
21400
20676
  }, [polling, transaction, afterBlock, paymentRoute]);
21401
-
21402
20677
  var storePayment = function storePayment(transaction, afterBlock, paymentRoute, attempt) {
21403
20678
  fetch('https://public.depay.com/payments', {
21404
20679
  headers: {
@@ -21439,24 +20714,19 @@
21439
20714
  }, 3000);
21440
20715
  });
21441
20716
  };
21442
-
21443
20717
  var initializeTracking = function initializeTracking(transaction, afterBlock, paymentRoute) {
21444
20718
  storePayment(transaction, afterBlock, paymentRoute);
21445
-
21446
20719
  if (tracking || track && track.async == true) {
21447
20720
  startTracking(transaction, afterBlock, paymentRoute);
21448
20721
  }
21449
-
21450
20722
  if (tracking == false) {
21451
20723
  return;
21452
20724
  }
21453
-
21454
20725
  setTransaction(transaction);
21455
20726
  setAfterBlock(afterBlock);
21456
20727
  setPaymentRoute(paymentRoute);
21457
20728
  openSocket(transaction);
21458
20729
  };
21459
-
21460
20730
  return /*#__PURE__*/React__default["default"].createElement(PaymentTrackingContext.Provider, {
21461
20731
  value: {
21462
20732
  tracking: tracking,
@@ -21470,26 +20740,21 @@
21470
20740
 
21471
20741
  var TransactionTrackingProvider = (function (props) {
21472
20742
  var _useState = React.useState(),
21473
- _useState2 = _slicedToArray(_useState, 2),
21474
- givenTransaction = _useState2[0],
21475
- setGivenTransaction = _useState2[1];
21476
-
20743
+ _useState2 = _slicedToArray(_useState, 2),
20744
+ givenTransaction = _useState2[0],
20745
+ setGivenTransaction = _useState2[1];
21477
20746
  var _useState3 = React.useState(),
21478
- _useState4 = _slicedToArray(_useState3, 2),
21479
- foundTransaction = _useState4[0],
21480
- setFoundTransaction = _useState4[1];
21481
-
20747
+ _useState4 = _slicedToArray(_useState3, 2),
20748
+ foundTransaction = _useState4[0],
20749
+ setFoundTransaction = _useState4[1];
21482
20750
  var _useState5 = React.useState(false),
21483
- _useState6 = _slicedToArray(_useState5, 2),
21484
- polling = _useState6[0],
21485
- setPolling = _useState6[1];
21486
-
20751
+ _useState6 = _slicedToArray(_useState5, 2),
20752
+ polling = _useState6[0],
20753
+ setPolling = _useState6[1];
21487
20754
  var _useContext = React.useContext(ErrorContext);
21488
- _useContext.errorCallback;
21489
-
20755
+ _useContext.errorCallback;
21490
20756
  var _useContext2 = React.useContext(ConfigurationContext),
21491
- recover = _useContext2.recover;
21492
-
20757
+ recover = _useContext2.recover;
21493
20758
  React.useEffect(function () {
21494
20759
  if (polling) {
21495
20760
  var poll = function poll() {
@@ -21507,7 +20772,6 @@
21507
20772
  }
21508
20773
  });
21509
20774
  };
21510
-
21511
20775
  var pollingInterval = setInterval(poll, 5000);
21512
20776
  poll();
21513
20777
  return function () {
@@ -21515,13 +20779,11 @@
21515
20779
  };
21516
20780
  }
21517
20781
  }, [polling]);
21518
-
21519
20782
  var createTracking = function createTracking(transaction, afterBlock, attempt) {
21520
20783
  if (attempt > 3) {
21521
20784
  console.log('TRANSACTION TRACKING FAILED AFTER 3 ATTEMPTS!');
21522
20785
  return;
21523
20786
  }
21524
-
21525
20787
  fetch('https://public.depay.com/transactions', {
21526
20788
  method: 'POST',
21527
20789
  headers: {
@@ -21550,10 +20812,8 @@
21550
20812
  }, 3000);
21551
20813
  });
21552
20814
  };
21553
-
21554
20815
  var openSocket = function openSocket(transaction) {
21555
20816
  var socket = new WebSocket('wss://integrate.depay.com/cable');
21556
-
21557
20817
  socket.onopen = function (event) {
21558
20818
  var msg = {
21559
20819
  command: 'subscribe',
@@ -21566,37 +20826,28 @@
21566
20826
  };
21567
20827
  socket.send(JSON.stringify(msg));
21568
20828
  };
21569
-
21570
20829
  socket.onclose = function (event) {};
21571
-
21572
20830
  socket.onmessage = function (event) {
21573
20831
  var item = JSON.parse(event.data);
21574
-
21575
20832
  if (item.type === "ping") {
21576
20833
  return;
21577
20834
  }
21578
-
21579
20835
  if (item.message && item.message.status && item.message.status != 'pending') {
21580
20836
  setFoundTransaction(item.message);
21581
20837
  }
21582
20838
  };
21583
-
21584
20839
  socket.onerror = function (error) {
21585
20840
  console.log('WebSocket Error: ' + error);
21586
20841
  };
21587
20842
  };
21588
-
21589
20843
  var initializeTracking = function initializeTracking(transaction, afterBlock) {
21590
20844
  setGivenTransaction(transaction);
21591
-
21592
20845
  if (recover == undefined) {
21593
20846
  createTracking(transaction, afterBlock, 1);
21594
20847
  }
21595
-
21596
20848
  openSocket(transaction);
21597
20849
  setPolling(true);
21598
20850
  };
21599
-
21600
20851
  React.useEffect(function () {
21601
20852
  if (recover) {
21602
20853
  initializeTracking({
@@ -21617,38 +20868,31 @@
21617
20868
 
21618
20869
  var WalletProvider = (function (props) {
21619
20870
  var _useContext = React.useContext(ConfigurationContext),
21620
- recover = _useContext.recover;
21621
-
20871
+ recover = _useContext.recover;
21622
20872
  var _useContext2 = React.useContext(ErrorContext);
21623
- _useContext2.setError;
21624
-
20873
+ _useContext2.setError;
21625
20874
  var _useState = React.useState(),
21626
- _useState2 = _slicedToArray(_useState, 2),
21627
- wallet = _useState2[0],
21628
- setWallet = _useState2[1];
21629
-
20875
+ _useState2 = _slicedToArray(_useState, 2),
20876
+ wallet = _useState2[0],
20877
+ setWallet = _useState2[1];
21630
20878
  var _useState3 = React.useState(),
21631
- _useState4 = _slicedToArray(_useState3, 2),
21632
- account = _useState4[0],
21633
- setAccount = _useState4[1];
21634
-
20879
+ _useState4 = _slicedToArray(_useState3, 2),
20880
+ account = _useState4[0],
20881
+ setAccount = _useState4[1];
21635
20882
  var _useState5 = React.useState(),
21636
- _useState6 = _slicedToArray(_useState5, 2),
21637
- walletState = _useState6[0],
21638
- setWalletState = _useState6[1];
21639
-
20883
+ _useState6 = _slicedToArray(_useState5, 2),
20884
+ walletState = _useState6[0],
20885
+ setWalletState = _useState6[1];
21640
20886
  var connected = function connected(_ref) {
21641
20887
  var account = _ref.account,
21642
- wallet = _ref.wallet;
20888
+ wallet = _ref.wallet;
21643
20889
  setAccount(account);
21644
20890
  setWallet(wallet);
21645
20891
  setWalletState('connected');
21646
-
21647
20892
  if (props.connected) {
21648
20893
  props.connected(account);
21649
20894
  }
21650
20895
  };
21651
-
21652
20896
  if (walletState == 'connected' || recover != undefined) {
21653
20897
  return /*#__PURE__*/React__default["default"].createElement(WalletContext.Provider, {
21654
20898
  value: {
@@ -21674,33 +20918,26 @@
21674
20918
  switch (_context.prev = _context.next) {
21675
20919
  case 0:
21676
20920
  accept = _ref.accept;
21677
-
21678
20921
  if (!(!(accept instanceof Array) || accept.length == 0)) {
21679
20922
  _context.next = 3;
21680
20923
  break;
21681
20924
  }
21682
-
21683
20925
  throw 'You need to set the tokens you accept as donation!';
21684
-
21685
20926
  case 3:
21686
20927
  accept.forEach(function (configuration) {
21687
20928
  if (typeof configuration.blockchain === 'undefined') {
21688
20929
  throw 'You need to set the blockchain you want to receive the donation on!';
21689
20930
  }
21690
-
21691
20931
  if (!['ethereum', 'bsc', 'polygon'].includes(configuration.blockchain)) {
21692
20932
  throw 'You need to set a supported blockchain!';
21693
20933
  }
21694
-
21695
20934
  if (typeof configuration.token === 'undefined') {
21696
20935
  throw 'You need to set the token you want to receive as donation!';
21697
20936
  }
21698
-
21699
20937
  if (typeof configuration.receiver === 'undefined') {
21700
20938
  throw 'You need to set the receiver address that you want to receive the donation!';
21701
20939
  }
21702
20940
  });
21703
-
21704
20941
  case 4:
21705
20942
  case "end":
21706
20943
  return _context.stop();
@@ -21708,27 +20945,24 @@
21708
20945
  }
21709
20946
  }, _callee);
21710
20947
  }));
21711
-
21712
20948
  return function preflight(_x) {
21713
20949
  return _ref2.apply(this, arguments);
21714
20950
  };
21715
20951
  }();
21716
-
21717
20952
  var Donation = /*#__PURE__*/function () {
21718
20953
  var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(_ref3) {
21719
- var amount, accept, event, sent, confirmed, validated, failed, error, critical, style, whitelist, blacklist, providers, currency, connected, closed, track, fee, closable, integration, link, container, title, document, unmount;
20954
+ var amount, accept, event, sent, succeeded, validated, failed, error, critical, style, whitelist, blacklist, providers, currency, connected, closed, track, fee, closable, integration, link, container, title, document, unmount;
21720
20955
  return regenerator.wrap(function _callee2$(_context2) {
21721
20956
  while (1) {
21722
20957
  switch (_context2.prev = _context2.next) {
21723
20958
  case 0:
21724
- amount = _ref3.amount, accept = _ref3.accept, event = _ref3.event, sent = _ref3.sent, confirmed = _ref3.confirmed, validated = _ref3.validated, failed = _ref3.failed, error = _ref3.error, critical = _ref3.critical, style = _ref3.style, whitelist = _ref3.whitelist, blacklist = _ref3.blacklist, providers = _ref3.providers, currency = _ref3.currency, connected = _ref3.connected, closed = _ref3.closed, track = _ref3.track, fee = _ref3.fee, closable = _ref3.closable, integration = _ref3.integration, link = _ref3.link, container = _ref3.container, title = _ref3.title, document = _ref3.document;
20959
+ amount = _ref3.amount, accept = _ref3.accept, event = _ref3.event, sent = _ref3.sent, succeeded = _ref3.succeeded, validated = _ref3.validated, failed = _ref3.failed, error = _ref3.error, critical = _ref3.critical, style = _ref3.style, whitelist = _ref3.whitelist, blacklist = _ref3.blacklist, providers = _ref3.providers, currency = _ref3.currency, connected = _ref3.connected, closed = _ref3.closed, track = _ref3.track, fee = _ref3.fee, closable = _ref3.closable, integration = _ref3.integration, link = _ref3.link, container = _ref3.container, title = _ref3.title, document = _ref3.document;
21725
20960
  requireReactVersion();
21726
20961
  _context2.prev = 2;
21727
20962
  _context2.next = 5;
21728
20963
  return preflight$2({
21729
20964
  accept: accept
21730
20965
  });
21731
-
21732
20966
  case 5:
21733
20967
  unmount = mount({
21734
20968
  style: style,
@@ -21751,7 +20985,7 @@
21751
20985
  track: track,
21752
20986
  fee: fee,
21753
20987
  sent: sent,
21754
- confirmed: confirmed,
20988
+ succeeded: succeeded,
21755
20989
  validated: validated,
21756
20990
  failed: failed,
21757
20991
  blacklist: blacklist,
@@ -21784,16 +21018,13 @@
21784
21018
  return _context2.abrupt("return", {
21785
21019
  unmount: unmount
21786
21020
  });
21787
-
21788
21021
  case 9:
21789
21022
  _context2.prev = 9;
21790
21023
  _context2.t0 = _context2["catch"](2);
21791
21024
  console.log('critical error', _context2.t0);
21792
-
21793
21025
  if (critical != undefined) {
21794
21026
  critical(_context2.t0);
21795
21027
  }
21796
-
21797
21028
  case 13:
21798
21029
  case "end":
21799
21030
  return _context2.stop();
@@ -21801,7 +21032,6 @@
21801
21032
  }
21802
21033
  }, _callee2, null, [[2, 9]]);
21803
21034
  }));
21804
-
21805
21035
  return function Donation(_x2) {
21806
21036
  return _ref4.apply(this, arguments);
21807
21037
  };
@@ -21809,23 +21039,19 @@
21809
21039
 
21810
21040
  var SignLoginDialog = (function (props) {
21811
21041
  var _useContext = React.useContext(ErrorContext),
21812
- setError = _useContext.setError;
21813
-
21042
+ setError = _useContext.setError;
21814
21043
  var _useContext2 = React.useContext(ConfigurationContext),
21815
- message = _useContext2.message,
21816
- endpoint = _useContext2.endpoint;
21817
-
21044
+ message = _useContext2.message,
21045
+ endpoint = _useContext2.endpoint;
21818
21046
  var _useContext3 = React.useContext(ConfigurationContext),
21819
- recover = _useContext3.recover;
21820
-
21821
- var wallet = web3Wallets.getWallet();
21047
+ recover = _useContext3.recover;
21048
+ var wallet = web3Wallets.getWallets()[0];
21822
21049
  wallet !== null && wallet !== void 0 && wallet.name ? wallet.name : 'wallet';
21823
21050
  var walletLogo = wallet !== null && wallet !== void 0 && wallet.logo ? wallet.logo : undefined;
21824
-
21825
21051
  if (typeof recover != 'function') {
21826
21052
  recover = function recover(_ref) {
21827
21053
  var message = _ref.message,
21828
- signature = _ref.signature;
21054
+ signature = _ref.signature;
21829
21055
  return new Promise(function (resolve, reject) {
21830
21056
  fetch(endpoint, {
21831
21057
  method: 'POST',
@@ -21850,7 +21076,6 @@
21850
21076
  });
21851
21077
  };
21852
21078
  }
21853
-
21854
21079
  var login = function login() {
21855
21080
  wallet.sign(message).then(function (signature) {
21856
21081
  recover({
@@ -21863,7 +21088,6 @@
21863
21088
  }
21864
21089
  });
21865
21090
  };
21866
-
21867
21091
  return /*#__PURE__*/React__default["default"].createElement(Dialog$1, {
21868
21092
  body: /*#__PURE__*/React__default["default"].createElement("div", {
21869
21093
  className: "TextCenter"
@@ -21890,14 +21114,12 @@
21890
21114
 
21891
21115
  var LoginStack = (function (props) {
21892
21116
  var _useContext = React.useContext(ClosableContext),
21893
- open = _useContext.open,
21894
- close = _useContext.close;
21895
-
21117
+ open = _useContext.open,
21118
+ close = _useContext.close;
21896
21119
  var _useState = React.useState(true),
21897
- _useState2 = _slicedToArray(_useState, 2);
21898
- _useState2[0];
21899
- _useState2[1];
21900
-
21120
+ _useState2 = _slicedToArray(_useState, 2);
21121
+ _useState2[0];
21122
+ _useState2[1];
21901
21123
  return /*#__PURE__*/React__default["default"].createElement(reactDialogStack.ReactDialogStack, {
21902
21124
  open: open,
21903
21125
  close: close,
@@ -21916,7 +21138,6 @@
21916
21138
  var Login = function Login(options) {
21917
21139
  requireReactVersion();
21918
21140
  var style, error, document, message, endpoint, recover;
21919
-
21920
21141
  if (_typeof(options) == 'object') {
21921
21142
  style = options.style;
21922
21143
  error = options.error;
@@ -21925,7 +21146,6 @@
21925
21146
  endpoint = options.endpoint;
21926
21147
  recover = options.recover;
21927
21148
  }
21928
-
21929
21149
  return new Promise( /*#__PURE__*/function () {
21930
21150
  var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(_resolve, reject) {
21931
21151
  return regenerator.wrap(function _callee$(_context) {
@@ -21941,7 +21161,6 @@
21941
21161
  reject('USER_CLOSED_DIALOG');
21942
21162
  unmount();
21943
21163
  };
21944
-
21945
21164
  return function (container) {
21946
21165
  return /*#__PURE__*/React__default["default"].createElement(ErrorProvider, {
21947
21166
  errorCallback: error,
@@ -21960,14 +21179,12 @@
21960
21179
  container: container,
21961
21180
  resolve: function resolve(account) {
21962
21181
  unmount();
21963
-
21964
21182
  _resolve(account);
21965
21183
  }
21966
21184
  }), /*#__PURE__*/React__default["default"].createElement(PoweredBy, null)))));
21967
21185
  };
21968
21186
  });
21969
21187
  })["catch"](reject);
21970
-
21971
21188
  case 1:
21972
21189
  case "end":
21973
21190
  return _context.stop();
@@ -21975,7 +21192,6 @@
21975
21192
  }
21976
21193
  }, _callee);
21977
21194
  }));
21978
-
21979
21195
  return function (_x, _x2) {
21980
21196
  return _ref.apply(this, arguments);
21981
21197
  };
@@ -21986,15 +21202,13 @@
21986
21202
 
21987
21203
  var PaymentAmountRoutingProvider = (function (props) {
21988
21204
  var _useContext = React.useContext(ChangableAmountContext),
21989
- amountsMissing = _useContext.amountsMissing,
21990
- acceptWithAmount = _useContext.acceptWithAmount,
21991
- setMaxRoute = _useContext.setMaxRoute;
21992
-
21205
+ amountsMissing = _useContext.amountsMissing,
21206
+ acceptWithAmount = _useContext.acceptWithAmount,
21207
+ setMaxRoute = _useContext.setMaxRoute;
21993
21208
  var _useState = React.useState(),
21994
- _useState2 = _slicedToArray(_useState, 2),
21995
- accept = _useState2[0],
21996
- setAccept = _useState2[1];
21997
-
21209
+ _useState2 = _slicedToArray(_useState, 2),
21210
+ accept = _useState2[0],
21211
+ setAccept = _useState2[1];
21998
21212
  React.useEffect(function () {
21999
21213
  if (amountsMissing) {
22000
21214
  if (acceptWithAmount) {
@@ -22018,13 +21232,11 @@
22018
21232
 
22019
21233
  var PaymentOverviewSkeleton = (function (props) {
22020
21234
  var _useContext = React.useContext(ChangableAmountContext),
22021
- amountsMissing = _useContext.amountsMissing,
22022
- fixedAmount = _useContext.fixedAmount;
22023
-
21235
+ amountsMissing = _useContext.amountsMissing,
21236
+ fixedAmount = _useContext.fixedAmount;
22024
21237
  var _useContext2 = React.useContext(PaymentRoutingContext),
22025
- slowRouting = _useContext2.slowRouting,
22026
- selectedRoute = _useContext2.selectedRoute;
22027
-
21238
+ slowRouting = _useContext2.slowRouting,
21239
+ selectedRoute = _useContext2.selectedRoute;
22028
21240
  return /*#__PURE__*/React__default["default"].createElement(Dialog$1, {
22029
21241
  header: /*#__PURE__*/React__default["default"].createElement("div", {
22030
21242
  className: "PaddingTopS PaddingLeftM PaddingRightM TextLeft"
@@ -22058,29 +21270,23 @@
22058
21270
 
22059
21271
  var PaymentOverviewDialog = (function (props) {
22060
21272
  var _useContext = React.useContext(ConfigurationContext),
22061
- currencyCode = _useContext.currencyCode,
22062
- recover = _useContext.recover;
22063
-
21273
+ currencyCode = _useContext.currencyCode,
21274
+ recover = _useContext.recover;
22064
21275
  var _useContext2 = React.useContext(PaymentContext),
22065
- payment = _useContext2.payment,
22066
- paymentState = _useContext2.paymentState;
22067
-
21276
+ payment = _useContext2.payment,
21277
+ paymentState = _useContext2.paymentState;
22068
21278
  var _useContext3 = React.useContext(ChangableAmountContext),
22069
- amount = _useContext3.amount,
22070
- amountsMissing = _useContext3.amountsMissing,
22071
- fixedAmount = _useContext3.fixedAmount,
22072
- fixedCurrency = _useContext3.fixedCurrency;
22073
-
21279
+ amount = _useContext3.amount,
21280
+ amountsMissing = _useContext3.amountsMissing,
21281
+ fixedAmount = _useContext3.fixedAmount,
21282
+ fixedCurrency = _useContext3.fixedCurrency;
22074
21283
  var _useContext4 = React.useContext(PaymentValueContext),
22075
- paymentValue = _useContext4.paymentValue;
22076
-
21284
+ paymentValue = _useContext4.paymentValue;
22077
21285
  var _useContext5 = React.useContext(reactDialogStack.NavigateStackContext),
22078
- navigate = _useContext5.navigate;
22079
-
21286
+ navigate = _useContext5.navigate;
22080
21287
  if (payment == undefined || recover == undefined && paymentValue == undefined) {
22081
21288
  return /*#__PURE__*/React__default["default"].createElement(PaymentOverviewSkeleton, null);
22082
21289
  }
22083
-
22084
21290
  var blockchain = web3Blockchains.Blockchain.findByName(payment.blockchain);
22085
21291
  return /*#__PURE__*/React__default["default"].createElement(Dialog$1, {
22086
21292
  header: /*#__PURE__*/React__default["default"].createElement("div", {
@@ -22097,7 +21303,6 @@
22097
21303
  if (paymentState != 'initialized') {
22098
21304
  return;
22099
21305
  }
22100
-
22101
21306
  navigate('ChangeAmount');
22102
21307
  }
22103
21308
  }, /*#__PURE__*/React__default["default"].createElement("div", {
@@ -22122,7 +21327,6 @@
22122
21327
  if (paymentState != 'initialized') {
22123
21328
  return;
22124
21329
  }
22125
-
22126
21330
  navigate('ChangePayment');
22127
21331
  }
22128
21332
  }, /*#__PURE__*/React__default["default"].createElement("div", {
@@ -22161,19 +21365,15 @@
22161
21365
 
22162
21366
  var TrackingFailedDialog = (function () {
22163
21367
  var _useContext = React.useContext(PaymentTrackingContext),
22164
- continueTryTracking = _useContext.continueTryTracking;
22165
-
21368
+ continueTryTracking = _useContext.continueTryTracking;
22166
21369
  var _useContext2 = React.useContext(PaymentContext),
22167
- transaction = _useContext2.transaction;
22168
-
21370
+ transaction = _useContext2.transaction;
22169
21371
  var _useContext3 = React.useContext(reactDialogStack.NavigateStackContext),
22170
- navigate = _useContext3.navigate;
22171
-
21372
+ navigate = _useContext3.navigate;
22172
21373
  var tryAgain = function tryAgain() {
22173
21374
  continueTryTracking();
22174
21375
  navigate('back');
22175
21376
  };
22176
-
22177
21377
  return /*#__PURE__*/React__default["default"].createElement(Dialog$1, {
22178
21378
  stacked: false,
22179
21379
  header: /*#__PURE__*/React__default["default"].createElement("div", {
@@ -22209,12 +21409,10 @@
22209
21409
 
22210
21410
  var PaymentStack = (function (props) {
22211
21411
  var _useContext = React.useContext(ClosableContext),
22212
- open = _useContext.open,
22213
- close = _useContext.close;
22214
-
21412
+ open = _useContext.open,
21413
+ close = _useContext.close;
22215
21414
  var _useContext2 = React.useContext(NavigateContext),
22216
- setNavigator = _useContext2.setNavigator;
22217
-
21415
+ setNavigator = _useContext2.setNavigator;
22218
21416
  return /*#__PURE__*/React__default["default"].createElement(reactDialogStack.ReactDialogStack, {
22219
21417
  setNavigator: setNavigator,
22220
21418
  open: open,
@@ -22226,7 +21424,7 @@
22226
21424
  PaymentOverview: /*#__PURE__*/React__default["default"].createElement(PaymentOverviewDialog, null),
22227
21425
  ChangeAmount: /*#__PURE__*/React__default["default"].createElement(ChangeAmountDialog, null),
22228
21426
  ChangePayment: /*#__PURE__*/React__default["default"].createElement(ChangePaymentDialog, null),
22229
- PaymentError: /*#__PURE__*/React__default["default"].createElement(PaymentErrorDialog, null),
21427
+ PaymentFailed: /*#__PURE__*/React__default["default"].createElement(PaymentFailedDialog, null),
22230
21428
  WrongNetwork: /*#__PURE__*/React__default["default"].createElement(WrongNetworkDialog, null),
22231
21429
  TrackingFailed: /*#__PURE__*/React__default["default"].createElement(TrackingFailedDialog, null)
22232
21430
  }
@@ -22241,37 +21439,29 @@
22241
21439
  switch (_context.prev = _context.next) {
22242
21440
  case 0:
22243
21441
  accept = _ref.accept, recover = _ref.recover;
22244
-
22245
21442
  if (!recover) {
22246
21443
  _context.next = 3;
22247
21444
  break;
22248
21445
  }
22249
-
22250
21446
  return _context.abrupt("return");
22251
-
22252
21447
  case 3:
22253
21448
  accept.forEach(function (configuration) {
22254
21449
  if (typeof configuration.blockchain === 'undefined') {
22255
21450
  throw 'You need to set the blockchain your want to receive the payment on!';
22256
21451
  }
22257
-
22258
21452
  if (!['ethereum', 'bsc', 'polygon'].includes(configuration.blockchain)) {
22259
21453
  throw 'You need to set a supported blockchain!';
22260
21454
  }
22261
-
22262
21455
  if (typeof configuration.token === 'undefined' && typeof configuration.fromToken === 'undefined' && typeof configuration.fromAmount === 'undefined' && typeof configuration.toToken === 'undefined') {
22263
21456
  throw 'You need to set the token you want to receive as payment!';
22264
21457
  }
22265
-
22266
21458
  if (typeof configuration.token === 'undefined' && typeof configuration.fromToken !== 'undefined' && typeof configuration.fromAmount === 'undefined' && typeof configuration.toToken === 'undefined') {
22267
21459
  throw 'You need to set the fromToken, fromAmount and toToken!';
22268
21460
  }
22269
-
22270
21461
  if (typeof configuration.receiver === 'undefined') {
22271
21462
  throw 'You need to set the receiver address that you want to receive the payment!';
22272
21463
  }
22273
21464
  });
22274
-
22275
21465
  case 4:
22276
21466
  case "end":
22277
21467
  return _context.stop();
@@ -22279,20 +21469,18 @@
22279
21469
  }
22280
21470
  }, _callee);
22281
21471
  }));
22282
-
22283
21472
  return function preflight(_x) {
22284
21473
  return _ref2.apply(this, arguments);
22285
21474
  };
22286
21475
  }();
22287
-
22288
21476
  var Payment = /*#__PURE__*/function () {
22289
21477
  var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(_ref3) {
22290
- var accept, amount, event, sent, confirmed, validated, failed, error, critical, style, whitelist, blacklist, providers, currency, connected, closed, track, fee, recover, closable, integration, link, container, before, document, unmount;
21478
+ var accept, amount, event, sent, succeeded, validated, failed, error, critical, style, whitelist, blacklist, providers, currency, connected, closed, track, fee, recover, closable, integration, link, container, before, document, unmount;
22291
21479
  return regenerator.wrap(function _callee2$(_context2) {
22292
21480
  while (1) {
22293
21481
  switch (_context2.prev = _context2.next) {
22294
21482
  case 0:
22295
- accept = _ref3.accept, amount = _ref3.amount, event = _ref3.event, sent = _ref3.sent, confirmed = _ref3.confirmed, validated = _ref3.validated, failed = _ref3.failed, error = _ref3.error, critical = _ref3.critical, style = _ref3.style, whitelist = _ref3.whitelist, blacklist = _ref3.blacklist, providers = _ref3.providers, currency = _ref3.currency, connected = _ref3.connected, closed = _ref3.closed, track = _ref3.track, fee = _ref3.fee, recover = _ref3.recover, closable = _ref3.closable, integration = _ref3.integration, link = _ref3.link, container = _ref3.container, before = _ref3.before, document = _ref3.document;
21483
+ accept = _ref3.accept, amount = _ref3.amount, event = _ref3.event, sent = _ref3.sent, succeeded = _ref3.succeeded, validated = _ref3.validated, failed = _ref3.failed, error = _ref3.error, critical = _ref3.critical, style = _ref3.style, whitelist = _ref3.whitelist, blacklist = _ref3.blacklist, providers = _ref3.providers, currency = _ref3.currency, connected = _ref3.connected, closed = _ref3.closed, track = _ref3.track, fee = _ref3.fee, recover = _ref3.recover, closable = _ref3.closable, integration = _ref3.integration, link = _ref3.link, container = _ref3.container, before = _ref3.before, document = _ref3.document;
22296
21484
  requireReactVersion();
22297
21485
  _context2.prev = 2;
22298
21486
  _context2.next = 5;
@@ -22300,7 +21488,6 @@
22300
21488
  accept: accept,
22301
21489
  recover: recover
22302
21490
  });
22303
-
22304
21491
  case 5:
22305
21492
  unmount = mount({
22306
21493
  style: style,
@@ -22322,7 +21509,7 @@
22322
21509
  currency: currency,
22323
21510
  event: event,
22324
21511
  sent: sent,
22325
- confirmed: confirmed,
21512
+ succeeded: succeeded,
22326
21513
  validated: validated,
22327
21514
  failed: failed,
22328
21515
  whitelist: whitelist,
@@ -22364,16 +21551,13 @@
22364
21551
  return _context2.abrupt("return", {
22365
21552
  unmount: unmount
22366
21553
  });
22367
-
22368
21554
  case 9:
22369
21555
  _context2.prev = 9;
22370
21556
  _context2.t0 = _context2["catch"](2);
22371
21557
  console.log('critical error', _context2.t0);
22372
-
22373
21558
  if (critical != undefined) {
22374
21559
  critical(_context2.t0);
22375
21560
  }
22376
-
22377
21561
  case 13:
22378
21562
  case "end":
22379
21563
  return _context2.stop();
@@ -22381,19 +21565,17 @@
22381
21565
  }
22382
21566
  }, _callee2, null, [[2, 9]]);
22383
21567
  }));
22384
-
22385
21568
  return function Payment(_x2) {
22386
21569
  return _ref4.apply(this, arguments);
22387
21570
  };
22388
21571
  }();
22389
-
22390
21572
  Payment.preload = function (_ref5) {
22391
21573
  var account = _ref5.account,
22392
- accept = _ref5.accept,
22393
- whitelist = _ref5.whitelist,
22394
- blacklist = _ref5.blacklist,
22395
- event = _ref5.event,
22396
- fee = _ref5.fee;
21574
+ accept = _ref5.accept,
21575
+ whitelist = _ref5.whitelist,
21576
+ blacklist = _ref5.blacklist,
21577
+ event = _ref5.event,
21578
+ fee = _ref5.fee;
22397
21579
  routePayments({
22398
21580
  account: account,
22399
21581
  accept: accept,
@@ -22410,25 +21592,21 @@
22410
21592
 
22411
21593
  var ToTokenProvider = (function (props) {
22412
21594
  var _useContext = React.useContext(PaymentContext),
22413
- payment = _useContext.payment;
22414
-
21595
+ payment = _useContext.payment;
22415
21596
  var _useState = React.useState(),
22416
- _useState2 = _slicedToArray(_useState, 2),
22417
- toToken = _useState2[0],
22418
- setToToken = _useState2[1];
22419
-
21597
+ _useState2 = _slicedToArray(_useState, 2),
21598
+ toToken = _useState2[0],
21599
+ setToToken = _useState2[1];
22420
21600
  var _useState3 = React.useState(),
22421
- _useState4 = _slicedToArray(_useState3, 2),
22422
- toTokenReadableAmount = _useState4[0],
22423
- setToTokenReadableAmount = _useState4[1];
22424
-
21601
+ _useState4 = _slicedToArray(_useState3, 2),
21602
+ toTokenReadableAmount = _useState4[0],
21603
+ setToTokenReadableAmount = _useState4[1];
22425
21604
  React.useEffect(function () {
22426
21605
  if (payment) {
22427
21606
  Promise.all([payment.route.toToken.symbol(), payment.route.toToken.readable(payment.route.toAmount)]).then(function (_ref) {
22428
21607
  var _ref2 = _slicedToArray(_ref, 2),
22429
- symbol = _ref2[0],
22430
- readableAmount = _ref2[1];
22431
-
21608
+ symbol = _ref2[0],
21609
+ readableAmount = _ref2[1];
22432
21610
  setToToken({
22433
21611
  address: payment.route.toToken.address,
22434
21612
  symbol: symbol
@@ -22447,29 +21625,23 @@
22447
21625
 
22448
21626
  var SaleRoutingProvider = (function (props) {
22449
21627
  var _useContext = React.useContext(ChangableAmountContext),
22450
- acceptWithAmount = _useContext.acceptWithAmount,
22451
- setMaxRoute = _useContext.setMaxRoute;
22452
-
21628
+ acceptWithAmount = _useContext.acceptWithAmount,
21629
+ setMaxRoute = _useContext.setMaxRoute;
22453
21630
  var _useContext2 = React.useContext(ConfigurationContext),
22454
- sell = _useContext2.sell;
22455
-
21631
+ sell = _useContext2.sell;
22456
21632
  var _useContext3 = React.useContext(ConfigurationContext),
22457
- blacklist = _useContext3.blacklist;
22458
-
21633
+ blacklist = _useContext3.blacklist;
22459
21634
  if (blacklist == undefined) {
22460
21635
  blacklist = {};
22461
21636
  }
22462
-
22463
21637
  for (var blockchain in sell) {
22464
21638
  var token = sell[blockchain];
22465
-
22466
21639
  if (blacklist[blockchain] instanceof Array) {
22467
21640
  blacklist[blockchain].push(token);
22468
21641
  } else {
22469
21642
  blacklist[blockchain] = [token];
22470
21643
  }
22471
21644
  }
22472
-
22473
21645
  return /*#__PURE__*/React__default["default"].createElement(SaleRoutingContext.Provider, {
22474
21646
  value: {}
22475
21647
  }, /*#__PURE__*/React__default["default"].createElement(PaymentRoutingProvider, {
@@ -22517,31 +21689,24 @@
22517
21689
 
22518
21690
  var SaleOverviewDialog = (function (props) {
22519
21691
  var _useContext = React.useContext(ChangableAmountContext);
22520
- _useContext.amount;
22521
-
21692
+ _useContext.amount;
22522
21693
  var _useContext2 = React.useContext(ConfigurationContext),
22523
- tokenImage = _useContext2.tokenImage,
22524
- amountConfiguration = _useContext2.amount;
22525
-
21694
+ tokenImage = _useContext2.tokenImage,
21695
+ amountConfiguration = _useContext2.amount;
22526
21696
  var _useContext3 = React.useContext(PaymentValueContext),
22527
- paymentValue = _useContext3.paymentValue;
22528
-
21697
+ paymentValue = _useContext3.paymentValue;
22529
21698
  var _useContext4 = React.useContext(PaymentContext),
22530
- payment = _useContext4.payment,
22531
- paymentState = _useContext4.paymentState;
22532
-
21699
+ payment = _useContext4.payment,
21700
+ paymentState = _useContext4.paymentState;
22533
21701
  var _useContext5 = React.useContext(reactDialogStack.NavigateStackContext),
22534
- navigate = _useContext5.navigate;
22535
-
21702
+ navigate = _useContext5.navigate;
22536
21703
  var _useContext6 = React.useContext(ToTokenContext),
22537
- toToken = _useContext6.toToken,
22538
- toTokenReadableAmount = _useContext6.toTokenReadableAmount;
22539
-
21704
+ toToken = _useContext6.toToken,
21705
+ toTokenReadableAmount = _useContext6.toTokenReadableAmount;
22540
21706
  var _useState = React.useState(),
22541
- _useState2 = _slicedToArray(_useState, 2),
22542
- salePerTokenValue = _useState2[0],
22543
- setSalePerTokenValue = _useState2[1];
22544
-
21707
+ _useState2 = _slicedToArray(_useState, 2),
21708
+ salePerTokenValue = _useState2[0],
21709
+ setSalePerTokenValue = _useState2[1];
22545
21710
  React.useEffect(function () {
22546
21711
  if (paymentValue && (amountConfiguration == undefined || amountConfiguration.token != true) && toTokenReadableAmount) {
22547
21712
  var UsdAmountPerToken = paymentValue.amount / parseFloat(toTokenReadableAmount);
@@ -22553,19 +21718,15 @@
22553
21718
  amount: 0,
22554
21719
  code: paymentValue.code
22555
21720
  }).toString();
22556
-
22557
21721
  if (readableLocalizedAmountPerToken != zero) {
22558
21722
  setSalePerTokenValue(readableLocalizedAmountPerToken);
22559
21723
  }
22560
21724
  }
22561
21725
  }, [paymentValue, toTokenReadableAmount]);
22562
-
22563
21726
  if (toToken == undefined || toTokenReadableAmount == undefined || payment == undefined || paymentValue == undefined) {
22564
21727
  return /*#__PURE__*/React__default["default"].createElement(SaleOverviewSkeleton, null);
22565
21728
  }
22566
-
22567
21729
  var tokenImageElement;
22568
-
22569
21730
  if (tokenImage) {
22570
21731
  tokenImageElement = /*#__PURE__*/React__default["default"].createElement("img", {
22571
21732
  src: tokenImage
@@ -22576,7 +21737,6 @@
22576
21737
  address: toToken.address
22577
21738
  });
22578
21739
  }
22579
-
22580
21740
  var blockchain = web3Blockchains.Blockchain.findByName(payment.blockchain);
22581
21741
  return /*#__PURE__*/React__default["default"].createElement(Dialog$1, {
22582
21742
  header: /*#__PURE__*/React__default["default"].createElement("div", {
@@ -22593,7 +21753,6 @@
22593
21753
  if (paymentState != 'initialized') {
22594
21754
  return;
22595
21755
  }
22596
-
22597
21756
  navigate('ChangeAmount');
22598
21757
  }
22599
21758
  }, /*#__PURE__*/React__default["default"].createElement("div", {
@@ -22629,7 +21788,6 @@
22629
21788
  if (paymentState != 'initialized') {
22630
21789
  return;
22631
21790
  }
22632
-
22633
21791
  navigate('ChangePayment');
22634
21792
  }
22635
21793
  }, /*#__PURE__*/React__default["default"].createElement("div", {
@@ -22663,12 +21821,10 @@
22663
21821
 
22664
21822
  var SaleStack = (function (props) {
22665
21823
  var _useContext = React.useContext(ClosableContext),
22666
- open = _useContext.open,
22667
- close = _useContext.close;
22668
-
21824
+ open = _useContext.open,
21825
+ close = _useContext.close;
22669
21826
  var _useContext2 = React.useContext(NavigateContext),
22670
- setNavigator = _useContext2.setNavigator;
22671
-
21827
+ setNavigator = _useContext2.setNavigator;
22672
21828
  return /*#__PURE__*/React__default["default"].createElement(reactDialogStack.ReactDialogStack, {
22673
21829
  setNavigator: setNavigator,
22674
21830
  open: open,
@@ -22681,7 +21837,7 @@
22681
21837
  ChangeAmount: /*#__PURE__*/React__default["default"].createElement(ChangeAmountDialog, null),
22682
21838
  ChangePayment: /*#__PURE__*/React__default["default"].createElement(ChangePaymentDialog, null),
22683
21839
  NoPaymentMethodFound: /*#__PURE__*/React__default["default"].createElement(NoPaymentMethodFoundDialog, null),
22684
- PaymentError: /*#__PURE__*/React__default["default"].createElement(PaymentErrorDialog, null),
21840
+ PaymentFailed: /*#__PURE__*/React__default["default"].createElement(PaymentFailedDialog, null),
22685
21841
  WrongNetwork: /*#__PURE__*/React__default["default"].createElement(WrongNetworkDialog, null)
22686
21842
  }
22687
21843
  });
@@ -22695,30 +21851,23 @@
22695
21851
  switch (_context.prev = _context.next) {
22696
21852
  case 0:
22697
21853
  sell = _ref.sell;
22698
-
22699
21854
  if (!(_typeof(sell) != 'object')) {
22700
21855
  _context.next = 3;
22701
21856
  break;
22702
21857
  }
22703
-
22704
21858
  throw 'You need to configure at least 1 "blockchain": "token"';
22705
-
22706
21859
  case 3:
22707
21860
  if (!(Object.keys(sell).length == 0)) {
22708
21861
  _context.next = 5;
22709
21862
  break;
22710
21863
  }
22711
-
22712
21864
  throw 'You need to configure at least 1 "blockchain": "token"';
22713
-
22714
21865
  case 5:
22715
21866
  if (!(Object.values(sell).length == 0)) {
22716
21867
  _context.next = 7;
22717
21868
  break;
22718
21869
  }
22719
-
22720
21870
  throw 'You need to configure at least 1 "blockchain": "token"';
22721
-
22722
21871
  case 7:
22723
21872
  case "end":
22724
21873
  return _context.stop();
@@ -22726,27 +21875,24 @@
22726
21875
  }
22727
21876
  }, _callee);
22728
21877
  }));
22729
-
22730
21878
  return function preflight(_x) {
22731
21879
  return _ref2.apply(this, arguments);
22732
21880
  };
22733
21881
  }();
22734
-
22735
21882
  var Sale = /*#__PURE__*/function () {
22736
21883
  var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(_ref3) {
22737
- var amount, sell, sent, confirmed, failed, error, critical, style, blacklist, providers, currency, connected, closed, tokenImage, closable, integration, document, accept, unmount;
21884
+ var amount, sell, sent, succeeded, failed, error, critical, style, blacklist, providers, currency, connected, closed, tokenImage, closable, integration, document, accept, unmount;
22738
21885
  return regenerator.wrap(function _callee2$(_context2) {
22739
21886
  while (1) {
22740
21887
  switch (_context2.prev = _context2.next) {
22741
21888
  case 0:
22742
- amount = _ref3.amount, sell = _ref3.sell, sent = _ref3.sent, confirmed = _ref3.confirmed, failed = _ref3.failed, error = _ref3.error, critical = _ref3.critical, style = _ref3.style, blacklist = _ref3.blacklist, providers = _ref3.providers, currency = _ref3.currency, connected = _ref3.connected, closed = _ref3.closed, tokenImage = _ref3.tokenImage, closable = _ref3.closable, integration = _ref3.integration, document = _ref3.document;
21889
+ amount = _ref3.amount, sell = _ref3.sell, sent = _ref3.sent, succeeded = _ref3.succeeded, failed = _ref3.failed, error = _ref3.error, critical = _ref3.critical, style = _ref3.style, blacklist = _ref3.blacklist, providers = _ref3.providers, currency = _ref3.currency, connected = _ref3.connected, closed = _ref3.closed, tokenImage = _ref3.tokenImage, closable = _ref3.closable, integration = _ref3.integration, document = _ref3.document;
22743
21890
  requireReactVersion();
22744
21891
  _context2.prev = 2;
22745
21892
  _context2.next = 5;
22746
21893
  return preflight({
22747
21894
  sell: sell
22748
21895
  });
22749
-
22750
21896
  case 5:
22751
21897
  accept = Object.keys(sell).map(function (key) {
22752
21898
  return {
@@ -22772,7 +21918,7 @@
22772
21918
  sell: sell,
22773
21919
  currency: currency,
22774
21920
  sent: sent,
22775
- confirmed: confirmed,
21921
+ succeeded: succeeded,
22776
21922
  failed: failed,
22777
21923
  blacklist: blacklist,
22778
21924
  providers: providers,
@@ -22801,16 +21947,13 @@
22801
21947
  return _context2.abrupt("return", {
22802
21948
  unmount: unmount
22803
21949
  });
22804
-
22805
21950
  case 10:
22806
21951
  _context2.prev = 10;
22807
21952
  _context2.t0 = _context2["catch"](2);
22808
21953
  console.log('critical error', _context2.t0);
22809
-
22810
21954
  if (critical != undefined) {
22811
21955
  critical(_context2.t0);
22812
21956
  }
22813
-
22814
21957
  case 14:
22815
21958
  case "end":
22816
21959
  return _context2.stop();
@@ -22818,7 +21961,6 @@
22818
21961
  }
22819
21962
  }, _callee2, null, [[2, 10]]);
22820
21963
  }));
22821
-
22822
21964
  return function Sale(_x2) {
22823
21965
  return _ref4.apply(this, arguments);
22824
21966
  };
@@ -22828,10 +21970,9 @@
22828
21970
 
22829
21971
  var SelectionProvider = (function (props) {
22830
21972
  var _useState = React.useState({}),
22831
- _useState2 = _slicedToArray(_useState, 2),
22832
- selection = _useState2[0],
22833
- setSelection = _useState2[1];
22834
-
21973
+ _useState2 = _slicedToArray(_useState, 2),
21974
+ selection = _useState2[0],
21975
+ setSelection = _useState2[1];
22835
21976
  return /*#__PURE__*/React__default["default"].createElement(SelectionContext.Provider, {
22836
21977
  value: {
22837
21978
  selection: selection,
@@ -22865,25 +22006,20 @@
22865
22006
 
22866
22007
  var ConfirmTokenSelectionDialog = (function (props) {
22867
22008
  var _useContext = React.useContext(SelectionContext),
22868
- selection = _useContext.selection;
22869
-
22009
+ selection = _useContext.selection;
22870
22010
  var _useContext2 = React.useContext(ClosableContext),
22871
- setOpen = _useContext2.setOpen;
22872
-
22011
+ setOpen = _useContext2.setOpen;
22873
22012
  var token = selection.token;
22874
22013
  var address = token.address || token.external_id;
22875
22014
  var logo = token.logo || token.image;
22876
22015
  var blockchain = web3Blockchains.Blockchain.findByName(token.blockchain);
22877
22016
  var age = token.first_transfer ? msToTime(new Date() - new Date(token.first_transfer)) : undefined;
22878
-
22879
22017
  if (age) {
22880
22018
  age = [age.year && age.year >= 1 ? age.year >= 2 ? "".concat(age.year, " years") : "1 year" : undefined, age.month && age.month >= 1 ? age.month >= 2 ? "".concat(age.month, " months") : "1 month" : undefined, age.day && age.day >= 1 && age.month <= 1 && age.year < 1 ? age.day >= 2 ? "".concat(age.day, " days !!!") : "1 day !!!" : undefined].filter(function (n) {
22881
22019
  return n;
22882
22020
  }).join(' ');
22883
22021
  }
22884
-
22885
22022
  var holders = token.unique_senders ? token.unique_senders : undefined;
22886
-
22887
22023
  if (holders) {
22888
22024
  if (holders > 1000000) {
22889
22025
  holders = "Millions";
@@ -22897,7 +22033,6 @@
22897
22033
  holders = "Only a Few!!!";
22898
22034
  }
22899
22035
  }
22900
-
22901
22036
  var onClickConfirm = function onClickConfirm() {
22902
22037
  setOpen(false);
22903
22038
  props.resolve({
@@ -22910,7 +22045,6 @@
22910
22045
  });
22911
22046
  setTimeout(props.unmount, 300);
22912
22047
  };
22913
-
22914
22048
  return /*#__PURE__*/React__default["default"].createElement(Dialog$1, {
22915
22049
  header: /*#__PURE__*/React__default["default"].createElement("div", {
22916
22050
  className: "PaddingTopS PaddingLeftM PaddingRightM TextLeft"
@@ -22968,26 +22102,21 @@
22968
22102
 
22969
22103
  var SelectBlockchainDialog = (function (props) {
22970
22104
  var _useContext = React.useContext(SelectionContext),
22971
- setSelection = _useContext.setSelection;
22972
-
22105
+ setSelection = _useContext.setSelection;
22973
22106
  var _useContext2 = React.useContext(reactDialogStack.NavigateStackContext),
22974
- navigate = _useContext2.navigate;
22975
-
22107
+ navigate = _useContext2.navigate;
22976
22108
  var stacked = Object.keys(props.selection).length > 1;
22977
22109
  var blockchains = [web3Blockchains.Blockchain.findByName('ethereum'), web3Blockchains.Blockchain.findByName('bsc'), web3Blockchains.Blockchain.findByName('polygon')];
22978
-
22979
22110
  var selectBlockchain = function selectBlockchain(blockchain) {
22980
22111
  setSelection(Object.assign(props.selection, {
22981
22112
  blockchain: blockchain
22982
22113
  }));
22983
-
22984
22114
  if (stacked) {
22985
22115
  navigate('back');
22986
22116
  } else {
22987
22117
  props.resolve(blockchain);
22988
22118
  }
22989
22119
  };
22990
-
22991
22120
  var elements = blockchains.map(function (blockchain, index) {
22992
22121
  return /*#__PURE__*/React__default["default"].createElement("div", {
22993
22122
  key: index,
@@ -23025,42 +22154,33 @@
23025
22154
 
23026
22155
  var SelectTokenDialog = (function (props) {
23027
22156
  var _useContext = React.useContext(reactDialogStack.NavigateStackContext),
23028
- navigate = _useContext.navigate;
23029
-
22157
+ navigate = _useContext.navigate;
23030
22158
  var _useContext2 = React.useContext(ClosableContext),
23031
- setOpen = _useContext2.setOpen;
23032
-
22159
+ setOpen = _useContext2.setOpen;
23033
22160
  var _useContext3 = React.useContext(SelectionContext),
23034
- setSelection = _useContext3.setSelection;
23035
-
22161
+ setSelection = _useContext3.setSelection;
23036
22162
  var _useState = React.useState(''),
23037
- _useState2 = _slicedToArray(_useState, 2),
23038
- searchTerm = _useState2[0],
23039
- setSearchTerm = _useState2[1];
23040
-
22163
+ _useState2 = _slicedToArray(_useState, 2),
22164
+ searchTerm = _useState2[0],
22165
+ setSearchTerm = _useState2[1];
23041
22166
  var _useState3 = React.useState(),
23042
- _useState4 = _slicedToArray(_useState3, 2),
23043
- blockchain = _useState4[0],
23044
- setBlockchain = _useState4[1];
23045
-
22167
+ _useState4 = _slicedToArray(_useState3, 2),
22168
+ blockchain = _useState4[0],
22169
+ setBlockchain = _useState4[1];
23046
22170
  var _useState5 = React.useState(false),
23047
- _useState6 = _slicedToArray(_useState5, 2),
23048
- showAddToken = _useState6[0],
23049
- setShowAddToken = _useState6[1];
23050
-
22171
+ _useState6 = _slicedToArray(_useState5, 2),
22172
+ showAddToken = _useState6[0],
22173
+ setShowAddToken = _useState6[1];
23051
22174
  var _useState7 = React.useState([]),
23052
- _useState8 = _slicedToArray(_useState7, 2),
23053
- tokens = _useState8[0],
23054
- setTokens = _useState8[1];
23055
-
22175
+ _useState8 = _slicedToArray(_useState7, 2),
22176
+ tokens = _useState8[0],
22177
+ setTokens = _useState8[1];
23056
22178
  var _useState9 = React.useState(),
23057
- _useState10 = _slicedToArray(_useState9, 2);
23058
- _useState10[0];
23059
- _useState10[1];
23060
-
22179
+ _useState10 = _slicedToArray(_useState9, 2);
22180
+ _useState10[0];
22181
+ _useState10[1];
23061
22182
  var searchElement = React.useRef();
23062
- var wallet = web3Wallets.getWallet();
23063
-
22183
+ var wallet = web3Wallets.getWallets()[0];
23064
22184
  var startWithBlockchain = function startWithBlockchain(name) {
23065
22185
  var blockchain = web3Blockchains.Blockchain.findByName(name);
23066
22186
  setBlockchain(blockchain);
@@ -23070,12 +22190,10 @@
23070
22190
  }));
23071
22191
  setTokens(blockchain.tokens);
23072
22192
  };
23073
-
23074
22193
  React.useEffect(function () {
23075
22194
  if (wallet) {
23076
22195
  wallet.connectedTo().then(function (name) {
23077
22196
  var blockchain = web3Blockchains.Blockchain.findByName(name);
23078
-
23079
22197
  if (name && name.length && blockchain && blockchain.tokens && blockchain.tokens.length) {
23080
22198
  startWithBlockchain(name);
23081
22199
  } else {
@@ -23090,27 +22208,22 @@
23090
22208
  if (props.selection.blockchain) {
23091
22209
  setBlockchain(props.selection.blockchain);
23092
22210
  setTokens(props.selection.blockchain.tokens);
23093
-
23094
22211
  if (searchElement.current) {
23095
22212
  searchElement.current.value = '';
23096
22213
  searchElement.current.focus();
23097
22214
  }
23098
22215
  }
23099
22216
  }, [props.selection, props.selection.blockchain]);
23100
-
23101
22217
  var onClickChangeBlockchain = function onClickChangeBlockchain() {
23102
22218
  navigate('SelectBlockchain');
23103
22219
  };
23104
-
23105
22220
  var onClickAddToken = function onClickAddToken() {
23106
22221
  setShowAddToken(true);
23107
-
23108
22222
  if (searchElement.current) {
23109
22223
  searchElement.current.value = '';
23110
22224
  searchElement.current.focus();
23111
22225
  }
23112
22226
  };
23113
-
23114
22227
  var searchTokens = React.useCallback(lodash.debounce(function (term, blockchainName) {
23115
22228
  fetch("https://public.depay.com/tokens/search?blockchain=".concat(blockchainName, "&term=").concat(term)).then(function (response) {
23116
22229
  if (response.status == 200) {
@@ -23126,32 +22239,26 @@
23126
22239
  return reject;
23127
22240
  });
23128
22241
  }, 300), []);
23129
-
23130
22242
  var onChangeSearch = function onChangeSearch(event) {
23131
22243
  var term = event.target.value;
23132
22244
  setSearchTerm(term);
23133
-
23134
22245
  if (term.match(/^0x/)) {
23135
22246
  setTokens([]);
23136
22247
  var token;
23137
-
23138
22248
  try {
23139
22249
  token = new web3Tokens.Token({
23140
22250
  blockchain: blockchain.name,
23141
22251
  address: term
23142
22252
  });
23143
22253
  } catch (_unused) {}
23144
-
23145
22254
  if (token == undefined) {
23146
22255
  return;
23147
22256
  }
23148
-
23149
22257
  Promise.all([token.name(), token.symbol(), token.decimals()]).then(function (_ref) {
23150
22258
  var _ref2 = _slicedToArray(_ref, 3),
23151
- name = _ref2[0],
23152
- symbol = _ref2[1],
23153
- decimals = _ref2[2];
23154
-
22259
+ name = _ref2[0],
22260
+ symbol = _ref2[1],
22261
+ decimals = _ref2[2];
23155
22262
  setTokens([{
23156
22263
  name: name,
23157
22264
  symbol: symbol,
@@ -23167,7 +22274,6 @@
23167
22274
  setTokens(blockchain.tokens);
23168
22275
  }
23169
22276
  };
23170
-
23171
22277
  var select = function select(token) {
23172
22278
  if (blockchain.tokens.find(function (majorToken) {
23173
22279
  return majorToken.address.toLowerCase() == (token.address || token.external_id).toLowerCase();
@@ -23189,7 +22295,6 @@
23189
22295
  navigate('ConfirmTokenSelection');
23190
22296
  }
23191
22297
  };
23192
-
23193
22298
  var elements = tokens.map(function (token, index) {
23194
22299
  return /*#__PURE__*/React__default["default"].createElement("div", {
23195
22300
  key: "".concat(index, "-").concat(token.address),
@@ -23220,11 +22325,9 @@
23220
22325
  className: "CardText"
23221
22326
  }, token.name))));
23222
22327
  });
23223
-
23224
22328
  if (blockchain == undefined) {
23225
22329
  return null;
23226
22330
  }
23227
-
23228
22331
  return /*#__PURE__*/React__default["default"].createElement(Dialog$1, {
23229
22332
  header: /*#__PURE__*/React__default["default"].createElement("div", {
23230
22333
  className: "PaddingTopS PaddingLeftM PaddingRightM TextLeft"
@@ -23277,22 +22380,17 @@
23277
22380
 
23278
22381
  var SelectStack = (function (props) {
23279
22382
  var _useContext = React.useContext(ConfigurationContext),
23280
- what = _useContext.what;
23281
-
22383
+ what = _useContext.what;
23282
22384
  var _useContext2 = React.useContext(ClosableContext),
23283
- open = _useContext2.open,
23284
- close = _useContext2.close;
23285
-
22385
+ open = _useContext2.open,
22386
+ close = _useContext2.close;
23286
22387
  var _useContext3 = React.useContext(SelectionContext),
23287
- selection = _useContext3.selection;
23288
-
22388
+ selection = _useContext3.selection;
23289
22389
  var start;
23290
-
23291
22390
  switch (what) {
23292
22391
  default:
23293
22392
  start = 'SelectToken';
23294
22393
  }
23295
-
23296
22394
  return /*#__PURE__*/React__default["default"].createElement(reactDialogStack.ReactDialogStack, {
23297
22395
  open: open,
23298
22396
  close: close,
@@ -23321,22 +22419,18 @@
23321
22419
  var Select = function Select(options) {
23322
22420
  requireReactVersion();
23323
22421
  var style, error, document, what;
23324
-
23325
22422
  if (_typeof(options) == 'object') {
23326
22423
  style = options.style;
23327
22424
  error = options.error;
23328
22425
  document = options.document;
23329
22426
  what = options.what;
23330
22427
  }
23331
-
23332
22428
  var startupError;
23333
-
23334
22429
  if (what == undefined) {
23335
22430
  startupError = '"what" needs to be configured!';
23336
22431
  } else if (['token'].indexOf(what) < 0) {
23337
22432
  startupError = "Unknown \"what\" configured: ".concat(what, "!");
23338
22433
  }
23339
-
23340
22434
  return new Promise( /*#__PURE__*/function () {
23341
22435
  var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(resolve, reject) {
23342
22436
  return regenerator.wrap(function _callee$(_context) {
@@ -23351,7 +22445,6 @@
23351
22445
  reject('USER_CLOSED_DIALOG');
23352
22446
  unmount();
23353
22447
  };
23354
-
23355
22448
  return function (container) {
23356
22449
  return /*#__PURE__*/React__default["default"].createElement(ErrorProvider, {
23357
22450
  error: startupError,
@@ -23372,7 +22465,6 @@
23372
22465
  })), /*#__PURE__*/React__default["default"].createElement(PoweredBy, null)))));
23373
22466
  };
23374
22467
  });
23375
-
23376
22468
  case 1:
23377
22469
  case "end":
23378
22470
  return _context.stop();
@@ -23380,7 +22472,6 @@
23380
22472
  }
23381
22473
  }, _callee);
23382
22474
  }));
23383
-
23384
22475
  return function (_x, _x2) {
23385
22476
  return _ref.apply(this, arguments);
23386
22477
  };
@@ -23393,8 +22484,7 @@
23393
22484
  Login: Login,
23394
22485
  Payment: Payment,
23395
22486
  Sale: Sale,
23396
- Select: Select,
23397
- provider: web3Client.provider
22487
+ Select: Select
23398
22488
  };
23399
22489
 
23400
22490
  return DePayWidgets;