@depay/widgets 7.16.5 → 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/README.md +14 -14
- package/dist/esm/index.bundle.js +22 -18
- package/dist/esm/index.js +528 -1439
- package/dist/umd/index.bundle.js +22 -18
- package/dist/umd/index.js +526 -1437
- package/package.json +19 -18
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useState, useContext, useEffect, useCallback, useRef } from 'react';
|
|
2
2
|
import { NavigateStackContext, ReactDialogStack } from '@depay/react-dialog-stack';
|
|
3
|
-
import {
|
|
3
|
+
import { getWallets, wallets } from '@depay/web3-wallets';
|
|
4
4
|
import ReactDOM from 'react-dom';
|
|
5
5
|
import { ReactShadowDOM } from '@depay/react-shadow-dom';
|
|
6
6
|
import { ethers } from 'ethers';
|
|
@@ -9,7 +9,7 @@ import { Decimal } from 'decimal.js';
|
|
|
9
9
|
import { route } from '@depay/web3-exchanges';
|
|
10
10
|
import { Token } from '@depay/web3-tokens';
|
|
11
11
|
import { Currency } from '@depay/local-currency';
|
|
12
|
-
import { setProviderEndpoints, request
|
|
12
|
+
import { setProviderEndpoints, request } from '@depay/web3-client';
|
|
13
13
|
import { Blockchain } from '@depay/web3-blockchains';
|
|
14
14
|
import { route as route$1 } from '@depay/web3-payments';
|
|
15
15
|
import { TokenImage } from '@depay/react-token-image';
|
|
@@ -22,29 +22,24 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
|
22
22
|
reject(error);
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
|
-
|
|
26
25
|
if (info.done) {
|
|
27
26
|
resolve(value);
|
|
28
27
|
} else {
|
|
29
28
|
Promise.resolve(value).then(_next, _throw);
|
|
30
29
|
}
|
|
31
30
|
}
|
|
32
|
-
|
|
33
31
|
function _asyncToGenerator(fn) {
|
|
34
32
|
return function () {
|
|
35
33
|
var self = this,
|
|
36
|
-
|
|
34
|
+
args = arguments;
|
|
37
35
|
return new Promise(function (resolve, reject) {
|
|
38
36
|
var gen = fn.apply(self, args);
|
|
39
|
-
|
|
40
37
|
function _next(value) {
|
|
41
38
|
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
42
39
|
}
|
|
43
|
-
|
|
44
40
|
function _throw(err) {
|
|
45
41
|
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
46
42
|
}
|
|
47
|
-
|
|
48
43
|
_next(undefined);
|
|
49
44
|
});
|
|
50
45
|
};
|
|
@@ -77,27 +72,22 @@ function _typeof(obj) {
|
|
|
77
72
|
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
78
73
|
}, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
|
|
79
74
|
}
|
|
80
|
-
|
|
81
75
|
module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
82
76
|
});
|
|
83
77
|
|
|
84
78
|
var regeneratorRuntime$1 = createCommonjsModule(function (module) {
|
|
85
79
|
var _typeof = _typeof_1["default"];
|
|
86
|
-
|
|
87
80
|
function _regeneratorRuntime() {
|
|
88
|
-
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
89
|
-
|
|
90
81
|
module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
|
|
91
82
|
return exports;
|
|
92
83
|
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
93
84
|
var exports = {},
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
85
|
+
Op = Object.prototype,
|
|
86
|
+
hasOwn = Op.hasOwnProperty,
|
|
87
|
+
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
88
|
+
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
89
|
+
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
90
|
+
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
101
91
|
function define(obj, key, value) {
|
|
102
92
|
return Object.defineProperty(obj, key, {
|
|
103
93
|
value: value,
|
|
@@ -106,7 +96,6 @@ function _regeneratorRuntime() {
|
|
|
106
96
|
writable: !0
|
|
107
97
|
}), obj[key];
|
|
108
98
|
}
|
|
109
|
-
|
|
110
99
|
try {
|
|
111
100
|
define({}, "");
|
|
112
101
|
} catch (err) {
|
|
@@ -114,40 +103,33 @@ function _regeneratorRuntime() {
|
|
|
114
103
|
return obj[key] = value;
|
|
115
104
|
};
|
|
116
105
|
}
|
|
117
|
-
|
|
118
106
|
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
119
107
|
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
120
|
-
|
|
121
|
-
|
|
108
|
+
generator = Object.create(protoGenerator.prototype),
|
|
109
|
+
context = new Context(tryLocsList || []);
|
|
122
110
|
return generator._invoke = function (innerFn, self, context) {
|
|
123
111
|
var state = "suspendedStart";
|
|
124
112
|
return function (method, arg) {
|
|
125
113
|
if ("executing" === state) throw new Error("Generator is already running");
|
|
126
|
-
|
|
127
114
|
if ("completed" === state) {
|
|
128
115
|
if ("throw" === method) throw arg;
|
|
129
116
|
return doneResult();
|
|
130
117
|
}
|
|
131
|
-
|
|
132
118
|
for (context.method = method, context.arg = arg;;) {
|
|
133
119
|
var delegate = context.delegate;
|
|
134
|
-
|
|
135
120
|
if (delegate) {
|
|
136
121
|
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
137
|
-
|
|
138
122
|
if (delegateResult) {
|
|
139
123
|
if (delegateResult === ContinueSentinel) continue;
|
|
140
124
|
return delegateResult;
|
|
141
125
|
}
|
|
142
126
|
}
|
|
143
|
-
|
|
144
127
|
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
145
128
|
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
146
129
|
context.dispatchException(context.arg);
|
|
147
130
|
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
148
131
|
state = "executing";
|
|
149
132
|
var record = tryCatch(innerFn, self, context);
|
|
150
|
-
|
|
151
133
|
if ("normal" === record.type) {
|
|
152
134
|
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
153
135
|
return {
|
|
@@ -155,13 +137,11 @@ function _regeneratorRuntime() {
|
|
|
155
137
|
done: context.done
|
|
156
138
|
};
|
|
157
139
|
}
|
|
158
|
-
|
|
159
140
|
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
160
141
|
}
|
|
161
142
|
};
|
|
162
143
|
}(innerFn, self, context), generator;
|
|
163
144
|
}
|
|
164
|
-
|
|
165
145
|
function tryCatch(fn, obj, arg) {
|
|
166
146
|
try {
|
|
167
147
|
return {
|
|
@@ -175,25 +155,19 @@ function _regeneratorRuntime() {
|
|
|
175
155
|
};
|
|
176
156
|
}
|
|
177
157
|
}
|
|
178
|
-
|
|
179
158
|
exports.wrap = wrap;
|
|
180
159
|
var ContinueSentinel = {};
|
|
181
|
-
|
|
182
160
|
function Generator() {}
|
|
183
|
-
|
|
184
161
|
function GeneratorFunction() {}
|
|
185
|
-
|
|
186
162
|
function GeneratorFunctionPrototype() {}
|
|
187
|
-
|
|
188
163
|
var IteratorPrototype = {};
|
|
189
164
|
define(IteratorPrototype, iteratorSymbol, function () {
|
|
190
165
|
return this;
|
|
191
166
|
});
|
|
192
167
|
var getProto = Object.getPrototypeOf,
|
|
193
|
-
|
|
168
|
+
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
194
169
|
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
195
170
|
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
196
|
-
|
|
197
171
|
function defineIteratorMethods(prototype) {
|
|
198
172
|
["next", "throw", "return"].forEach(function (method) {
|
|
199
173
|
define(prototype, method, function (arg) {
|
|
@@ -201,14 +175,12 @@ function _regeneratorRuntime() {
|
|
|
201
175
|
});
|
|
202
176
|
});
|
|
203
177
|
}
|
|
204
|
-
|
|
205
178
|
function AsyncIterator(generator, PromiseImpl) {
|
|
206
179
|
function invoke(method, arg, resolve, reject) {
|
|
207
180
|
var record = tryCatch(generator[method], generator, arg);
|
|
208
|
-
|
|
209
181
|
if ("throw" !== record.type) {
|
|
210
182
|
var result = record.arg,
|
|
211
|
-
|
|
183
|
+
value = result.value;
|
|
212
184
|
return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
213
185
|
invoke("next", value, resolve, reject);
|
|
214
186
|
}, function (err) {
|
|
@@ -219,91 +191,73 @@ function _regeneratorRuntime() {
|
|
|
219
191
|
return invoke("throw", error, resolve, reject);
|
|
220
192
|
});
|
|
221
193
|
}
|
|
222
|
-
|
|
223
194
|
reject(record.arg);
|
|
224
195
|
}
|
|
225
|
-
|
|
226
196
|
var previousPromise;
|
|
227
|
-
|
|
228
197
|
this._invoke = function (method, arg) {
|
|
229
198
|
function callInvokeWithMethodAndArg() {
|
|
230
199
|
return new PromiseImpl(function (resolve, reject) {
|
|
231
200
|
invoke(method, arg, resolve, reject);
|
|
232
201
|
});
|
|
233
202
|
}
|
|
234
|
-
|
|
235
203
|
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
236
204
|
};
|
|
237
205
|
}
|
|
238
|
-
|
|
239
206
|
function maybeInvokeDelegate(delegate, context) {
|
|
240
207
|
var method = delegate.iterator[context.method];
|
|
241
|
-
|
|
242
208
|
if (undefined === method) {
|
|
243
209
|
if (context.delegate = null, "throw" === context.method) {
|
|
244
210
|
if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
|
245
211
|
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
246
212
|
}
|
|
247
|
-
|
|
248
213
|
return ContinueSentinel;
|
|
249
214
|
}
|
|
250
|
-
|
|
251
215
|
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
252
216
|
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
253
217
|
var info = record.arg;
|
|
254
218
|
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);
|
|
255
219
|
}
|
|
256
|
-
|
|
257
220
|
function pushTryEntry(locs) {
|
|
258
221
|
var entry = {
|
|
259
222
|
tryLoc: locs[0]
|
|
260
223
|
};
|
|
261
224
|
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
262
225
|
}
|
|
263
|
-
|
|
264
226
|
function resetTryEntry(entry) {
|
|
265
227
|
var record = entry.completion || {};
|
|
266
228
|
record.type = "normal", delete record.arg, entry.completion = record;
|
|
267
229
|
}
|
|
268
|
-
|
|
269
230
|
function Context(tryLocsList) {
|
|
270
231
|
this.tryEntries = [{
|
|
271
232
|
tryLoc: "root"
|
|
272
233
|
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
273
234
|
}
|
|
274
|
-
|
|
275
235
|
function values(iterable) {
|
|
276
236
|
if (iterable) {
|
|
277
237
|
var iteratorMethod = iterable[iteratorSymbol];
|
|
278
238
|
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
279
239
|
if ("function" == typeof iterable.next) return iterable;
|
|
280
|
-
|
|
281
240
|
if (!isNaN(iterable.length)) {
|
|
282
241
|
var i = -1,
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
};
|
|
290
|
-
|
|
242
|
+
next = function next() {
|
|
243
|
+
for (; ++i < iterable.length;) {
|
|
244
|
+
if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
245
|
+
}
|
|
246
|
+
return next.value = undefined, next.done = !0, next;
|
|
247
|
+
};
|
|
291
248
|
return next.next = next;
|
|
292
249
|
}
|
|
293
250
|
}
|
|
294
|
-
|
|
295
251
|
return {
|
|
296
252
|
next: doneResult
|
|
297
253
|
};
|
|
298
254
|
}
|
|
299
|
-
|
|
300
255
|
function doneResult() {
|
|
301
256
|
return {
|
|
302
257
|
value: undefined,
|
|
303
258
|
done: !0
|
|
304
259
|
};
|
|
305
260
|
}
|
|
306
|
-
|
|
307
261
|
return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
308
262
|
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
309
263
|
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
@@ -327,17 +281,14 @@ function _regeneratorRuntime() {
|
|
|
327
281
|
return "[object Generator]";
|
|
328
282
|
}), exports.keys = function (object) {
|
|
329
283
|
var keys = [];
|
|
330
|
-
|
|
331
284
|
for (var key in object) {
|
|
332
285
|
keys.push(key);
|
|
333
286
|
}
|
|
334
|
-
|
|
335
287
|
return keys.reverse(), function next() {
|
|
336
288
|
for (; keys.length;) {
|
|
337
289
|
var key = keys.pop();
|
|
338
290
|
if (key in object) return next.value = key, next.done = !1, next;
|
|
339
291
|
}
|
|
340
|
-
|
|
341
292
|
return next.done = !0, next;
|
|
342
293
|
};
|
|
343
294
|
}, exports.values = values, Context.prototype = {
|
|
@@ -356,20 +307,16 @@ function _regeneratorRuntime() {
|
|
|
356
307
|
dispatchException: function dispatchException(exception) {
|
|
357
308
|
if (this.done) throw exception;
|
|
358
309
|
var context = this;
|
|
359
|
-
|
|
360
310
|
function handle(loc, caught) {
|
|
361
311
|
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
362
312
|
}
|
|
363
|
-
|
|
364
313
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
365
314
|
var entry = this.tryEntries[i],
|
|
366
|
-
|
|
315
|
+
record = entry.completion;
|
|
367
316
|
if ("root" === entry.tryLoc) return handle("end");
|
|
368
|
-
|
|
369
317
|
if (entry.tryLoc <= this.prev) {
|
|
370
318
|
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
371
|
-
|
|
372
|
-
|
|
319
|
+
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
373
320
|
if (hasCatch && hasFinally) {
|
|
374
321
|
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
375
322
|
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
@@ -385,13 +332,11 @@ function _regeneratorRuntime() {
|
|
|
385
332
|
abrupt: function abrupt(type, arg) {
|
|
386
333
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
387
334
|
var entry = this.tryEntries[i];
|
|
388
|
-
|
|
389
335
|
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
390
336
|
var finallyEntry = entry;
|
|
391
337
|
break;
|
|
392
338
|
}
|
|
393
339
|
}
|
|
394
|
-
|
|
395
340
|
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
|
396
341
|
var record = finallyEntry ? finallyEntry.completion : {};
|
|
397
342
|
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
@@ -409,19 +354,15 @@ function _regeneratorRuntime() {
|
|
|
409
354
|
"catch": function _catch(tryLoc) {
|
|
410
355
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
411
356
|
var entry = this.tryEntries[i];
|
|
412
|
-
|
|
413
357
|
if (entry.tryLoc === tryLoc) {
|
|
414
358
|
var record = entry.completion;
|
|
415
|
-
|
|
416
359
|
if ("throw" === record.type) {
|
|
417
360
|
var thrown = record.arg;
|
|
418
361
|
resetTryEntry(entry);
|
|
419
362
|
}
|
|
420
|
-
|
|
421
363
|
return thrown;
|
|
422
364
|
}
|
|
423
365
|
}
|
|
424
|
-
|
|
425
366
|
throw new Error("illegal catch attempt");
|
|
426
367
|
},
|
|
427
368
|
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
|
@@ -433,7 +374,6 @@ function _regeneratorRuntime() {
|
|
|
433
374
|
}
|
|
434
375
|
}, exports;
|
|
435
376
|
}
|
|
436
|
-
|
|
437
377
|
module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
438
378
|
});
|
|
439
379
|
|
|
@@ -459,18 +399,14 @@ function _arrayWithHoles(arr) {
|
|
|
459
399
|
|
|
460
400
|
function _iterableToArrayLimit(arr, i) {
|
|
461
401
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
462
|
-
|
|
463
402
|
if (_i == null) return;
|
|
464
403
|
var _arr = [];
|
|
465
404
|
var _n = true;
|
|
466
405
|
var _d = false;
|
|
467
|
-
|
|
468
406
|
var _s, _e;
|
|
469
|
-
|
|
470
407
|
try {
|
|
471
408
|
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
472
409
|
_arr.push(_s.value);
|
|
473
|
-
|
|
474
410
|
if (i && _arr.length === i) break;
|
|
475
411
|
}
|
|
476
412
|
} catch (err) {
|
|
@@ -483,17 +419,14 @@ function _iterableToArrayLimit(arr, i) {
|
|
|
483
419
|
if (_d) throw _e;
|
|
484
420
|
}
|
|
485
421
|
}
|
|
486
|
-
|
|
487
422
|
return _arr;
|
|
488
423
|
}
|
|
489
424
|
|
|
490
425
|
function _arrayLikeToArray(arr, len) {
|
|
491
426
|
if (len == null || len > arr.length) len = arr.length;
|
|
492
|
-
|
|
493
427
|
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
494
428
|
arr2[i] = arr[i];
|
|
495
429
|
}
|
|
496
|
-
|
|
497
430
|
return arr2;
|
|
498
431
|
}
|
|
499
432
|
|
|
@@ -520,32 +453,26 @@ var UpdatableContext = /*#__PURE__*/React.createContext();
|
|
|
520
453
|
|
|
521
454
|
var ClosableProvider = (function (props) {
|
|
522
455
|
var _useState = useState(true),
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
456
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
457
|
+
closable = _useState2[0],
|
|
458
|
+
setClosable = _useState2[1];
|
|
527
459
|
var _useState3 = useState(true),
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
460
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
461
|
+
open = _useState4[0],
|
|
462
|
+
setOpen = _useState4[1];
|
|
532
463
|
var _useContext = useContext(UpdatableContext),
|
|
533
|
-
|
|
534
|
-
|
|
464
|
+
setUpdatable = _useContext.setUpdatable;
|
|
535
465
|
var close = function close() {
|
|
536
466
|
if (props.closable === false) {
|
|
537
467
|
return;
|
|
538
468
|
}
|
|
539
|
-
|
|
540
469
|
if (!closable) {
|
|
541
470
|
return;
|
|
542
471
|
}
|
|
543
|
-
|
|
544
472
|
setUpdatable(false);
|
|
545
473
|
setOpen(false);
|
|
546
474
|
setTimeout(props.unmount, 300);
|
|
547
475
|
};
|
|
548
|
-
|
|
549
476
|
return /*#__PURE__*/React.createElement(ClosableContext.Provider, {
|
|
550
477
|
value: {
|
|
551
478
|
closable: closable,
|
|
@@ -596,12 +523,10 @@ var CloseIcon = (function () {
|
|
|
596
523
|
|
|
597
524
|
var Dialog$1 = (function (props) {
|
|
598
525
|
var _useContext = useContext(NavigateStackContext),
|
|
599
|
-
|
|
600
|
-
|
|
526
|
+
navigate = _useContext.navigate;
|
|
601
527
|
var _useContext2 = useContext(ClosableContext),
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
528
|
+
close = _useContext2.close,
|
|
529
|
+
closable = _useContext2.closable;
|
|
605
530
|
return /*#__PURE__*/React.createElement("div", {
|
|
606
531
|
className: "Dialog"
|
|
607
532
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -629,13 +554,11 @@ var Dialog$1 = (function (props) {
|
|
|
629
554
|
|
|
630
555
|
var ConnectingWalletDialog = (function (props) {
|
|
631
556
|
var _useState = useState(false),
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
557
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
558
|
+
showConnectButton = _useState2[0],
|
|
559
|
+
setShowConnectButton = _useState2[1];
|
|
636
560
|
var _useContext = useContext(NavigateStackContext),
|
|
637
|
-
|
|
638
|
-
|
|
561
|
+
navigate = _useContext.navigate;
|
|
639
562
|
var wallet = props.wallet;
|
|
640
563
|
wallet !== null && wallet !== void 0 && wallet.name ? wallet.name : 'wallet';
|
|
641
564
|
var walletLogo = wallet !== null && wallet !== void 0 && wallet.logo ? wallet.logo : undefined;
|
|
@@ -647,7 +570,6 @@ var ConnectingWalletDialog = (function (props) {
|
|
|
647
570
|
return clearTimeout(timeout);
|
|
648
571
|
};
|
|
649
572
|
}, []);
|
|
650
|
-
|
|
651
573
|
if (props.pending) {
|
|
652
574
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
653
575
|
stacked: true,
|
|
@@ -718,17 +640,15 @@ var ChevronRight = (function () {
|
|
|
718
640
|
|
|
719
641
|
var SelectWalletDialog = (function (props) {
|
|
720
642
|
var _useState = useState(false),
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
643
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
644
|
+
showExplanation = _useState2[0],
|
|
645
|
+
setShowExplanation = _useState2[1];
|
|
725
646
|
var _useContext = useContext(NavigateStackContext),
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
var wallet = getWallet();
|
|
647
|
+
navigate = _useContext.navigate;
|
|
648
|
+
var wallet = getWallets()[0];
|
|
729
649
|
useEffect(function () {
|
|
730
650
|
_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
|
|
731
|
-
var
|
|
651
|
+
var account;
|
|
732
652
|
return regenerator.wrap(function _callee$(_context) {
|
|
733
653
|
while (1) {
|
|
734
654
|
switch (_context.prev = _context.next) {
|
|
@@ -737,18 +657,14 @@ var SelectWalletDialog = (function (props) {
|
|
|
737
657
|
_context.next = 5;
|
|
738
658
|
break;
|
|
739
659
|
}
|
|
740
|
-
|
|
741
660
|
_context.next = 3;
|
|
742
|
-
return wallet.
|
|
743
|
-
|
|
661
|
+
return wallet.account();
|
|
744
662
|
case 3:
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
if (accounts == undefined || accounts.length == 0) {
|
|
663
|
+
account = _context.sent;
|
|
664
|
+
if (account == undefined) {
|
|
748
665
|
navigate('ConnectingWallet');
|
|
749
666
|
props.connect(wallet);
|
|
750
667
|
}
|
|
751
|
-
|
|
752
668
|
case 5:
|
|
753
669
|
case "end":
|
|
754
670
|
return _context.stop();
|
|
@@ -757,27 +673,21 @@ var SelectWalletDialog = (function (props) {
|
|
|
757
673
|
}, _callee);
|
|
758
674
|
}))();
|
|
759
675
|
}, [wallet]);
|
|
760
|
-
|
|
761
676
|
var connect = function connect(walletClass) {
|
|
762
677
|
var wallet = new walletClass();
|
|
763
678
|
props.setWallet(wallet);
|
|
764
679
|
navigate('ConnectingWallet');
|
|
765
680
|
props.connect(wallet);
|
|
766
681
|
};
|
|
767
|
-
|
|
768
682
|
var availableWallets = [wallets.WalletConnect, wallets.WalletLink];
|
|
769
|
-
|
|
770
683
|
if (wallet) {
|
|
771
684
|
availableWallets.unshift(wallet.constructor);
|
|
772
685
|
}
|
|
773
|
-
|
|
774
686
|
var walletCards = availableWallets.map(function (wallet, index) {
|
|
775
687
|
var name = wallet.info.name;
|
|
776
|
-
|
|
777
688
|
if (name == 'WalletConnect') {
|
|
778
689
|
name = 'via WalletConnect';
|
|
779
690
|
}
|
|
780
|
-
|
|
781
691
|
return /*#__PURE__*/React.createElement("div", {
|
|
782
692
|
key: index,
|
|
783
693
|
className: "PaddingBottomXS"
|
|
@@ -826,41 +736,34 @@ var SelectWalletDialog = (function (props) {
|
|
|
826
736
|
|
|
827
737
|
var ConnectStack = (function (props) {
|
|
828
738
|
var _useContext = useContext(ClosableContext),
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
739
|
+
open = _useContext.open,
|
|
740
|
+
close = _useContext.close;
|
|
832
741
|
var _useState = useState(),
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
742
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
743
|
+
pending = _useState2[0],
|
|
744
|
+
setPending = _useState2[1];
|
|
837
745
|
var _useState3 = useState(),
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
746
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
747
|
+
wallet = _useState4[0],
|
|
748
|
+
setWallet = _useState4[1];
|
|
842
749
|
var connect = function connect(wallet) {
|
|
843
750
|
wallet.connect().then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
|
|
844
|
-
var
|
|
751
|
+
var account;
|
|
845
752
|
return regenerator.wrap(function _callee$(_context) {
|
|
846
753
|
while (1) {
|
|
847
754
|
switch (_context.prev = _context.next) {
|
|
848
755
|
case 0:
|
|
849
756
|
_context.next = 2;
|
|
850
|
-
return wallet.
|
|
851
|
-
|
|
757
|
+
return wallet.account();
|
|
852
758
|
case 2:
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
if (accounts instanceof Array && accounts.length > 0) {
|
|
759
|
+
account = _context.sent;
|
|
760
|
+
if (account) {
|
|
856
761
|
if (props.autoClose) close();
|
|
857
762
|
if (props.resolve) props.resolve({
|
|
858
763
|
wallet: wallet,
|
|
859
|
-
account:
|
|
860
|
-
accounts: accounts
|
|
764
|
+
account: account
|
|
861
765
|
});
|
|
862
766
|
}
|
|
863
|
-
|
|
864
767
|
case 4:
|
|
865
768
|
case "end":
|
|
866
769
|
return _context.stop();
|
|
@@ -869,7 +772,6 @@ var ConnectStack = (function (props) {
|
|
|
869
772
|
}, _callee);
|
|
870
773
|
})))["catch"](function (error) {
|
|
871
774
|
setPending(false);
|
|
872
|
-
|
|
873
775
|
if ((error === null || error === void 0 ? void 0 : error.code) == 4001) {
|
|
874
776
|
// User rejected the request.
|
|
875
777
|
return;
|
|
@@ -882,17 +784,15 @@ var ConnectStack = (function (props) {
|
|
|
882
784
|
}
|
|
883
785
|
});
|
|
884
786
|
};
|
|
885
|
-
|
|
886
787
|
useEffect(function () {
|
|
887
|
-
var wallet =
|
|
888
|
-
|
|
788
|
+
var wallet = getWallets()[0];
|
|
889
789
|
if (wallet) {
|
|
890
790
|
setWallet(wallet);
|
|
891
791
|
}
|
|
892
792
|
}, []);
|
|
893
793
|
useEffect(function () {
|
|
894
794
|
_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
|
|
895
|
-
var
|
|
795
|
+
var account;
|
|
896
796
|
return regenerator.wrap(function _callee2$(_context2) {
|
|
897
797
|
while (1) {
|
|
898
798
|
switch (_context2.prev = _context2.next) {
|
|
@@ -901,21 +801,16 @@ var ConnectStack = (function (props) {
|
|
|
901
801
|
_context2.next = 5;
|
|
902
802
|
break;
|
|
903
803
|
}
|
|
904
|
-
|
|
905
804
|
_context2.next = 3;
|
|
906
|
-
return wallet.
|
|
907
|
-
|
|
805
|
+
return wallet.account();
|
|
908
806
|
case 3:
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
if (accounts instanceof Array && accounts.length > 0) {
|
|
807
|
+
account = _context2.sent;
|
|
808
|
+
if (account) {
|
|
912
809
|
if (props.resolve) props.resolve({
|
|
913
810
|
wallet: wallet,
|
|
914
|
-
account:
|
|
915
|
-
accounts: accounts
|
|
811
|
+
account: account
|
|
916
812
|
});
|
|
917
813
|
}
|
|
918
|
-
|
|
919
814
|
case 5:
|
|
920
815
|
case "end":
|
|
921
816
|
return _context2.stop();
|
|
@@ -967,7 +862,6 @@ function _defineProperties(target, props) {
|
|
|
967
862
|
Object.defineProperty(target, descriptor.key, descriptor);
|
|
968
863
|
}
|
|
969
864
|
}
|
|
970
|
-
|
|
971
865
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
972
866
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
973
867
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
@@ -989,7 +883,6 @@ function _inherits(subClass, superClass) {
|
|
|
989
883
|
if (typeof superClass !== "function" && superClass !== null) {
|
|
990
884
|
throw new TypeError("Super expression must either be null or a function");
|
|
991
885
|
}
|
|
992
|
-
|
|
993
886
|
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
994
887
|
constructor: {
|
|
995
888
|
value: subClass,
|
|
@@ -1007,7 +900,6 @@ function _assertThisInitialized(self) {
|
|
|
1007
900
|
if (self === void 0) {
|
|
1008
901
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
1009
902
|
}
|
|
1010
|
-
|
|
1011
903
|
return self;
|
|
1012
904
|
}
|
|
1013
905
|
|
|
@@ -1017,7 +909,6 @@ function _possibleConstructorReturn(self, call) {
|
|
|
1017
909
|
} else if (call !== void 0) {
|
|
1018
910
|
throw new TypeError("Derived constructors may only return object or undefined");
|
|
1019
911
|
}
|
|
1020
|
-
|
|
1021
912
|
return _assertThisInitialized(self);
|
|
1022
913
|
}
|
|
1023
914
|
|
|
@@ -1198,23 +1089,20 @@ class ReactDialog extends React.Component {
|
|
|
1198
1089
|
}
|
|
1199
1090
|
|
|
1200
1091
|
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); }; }
|
|
1201
|
-
|
|
1202
1092
|
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; } }
|
|
1203
|
-
|
|
1204
1093
|
var ErrorBoundary = /*#__PURE__*/function (_React$Component) {
|
|
1205
1094
|
_inherits(ErrorBoundary, _React$Component);
|
|
1206
|
-
|
|
1207
1095
|
var _super = _createSuper(ErrorBoundary);
|
|
1208
|
-
|
|
1209
1096
|
function ErrorBoundary(props) {
|
|
1210
1097
|
_classCallCheck(this, ErrorBoundary);
|
|
1211
|
-
|
|
1212
1098
|
return _super.call(this, props);
|
|
1213
1099
|
}
|
|
1214
|
-
|
|
1215
1100
|
_createClass(ErrorBoundary, [{
|
|
1216
1101
|
key: "componentDidCatch",
|
|
1217
1102
|
value: function componentDidCatch(error, errorInfo) {
|
|
1103
|
+
if (error.error) {
|
|
1104
|
+
error = error.error;
|
|
1105
|
+
}
|
|
1218
1106
|
this.props.setError(error);
|
|
1219
1107
|
}
|
|
1220
1108
|
}, {
|
|
@@ -1223,36 +1111,31 @@ var ErrorBoundary = /*#__PURE__*/function (_React$Component) {
|
|
|
1223
1111
|
return this.props.children;
|
|
1224
1112
|
}
|
|
1225
1113
|
}]);
|
|
1226
|
-
|
|
1227
1114
|
return ErrorBoundary;
|
|
1228
1115
|
}(React.Component);
|
|
1229
|
-
|
|
1230
1116
|
var ErrorProvider = (function (props) {
|
|
1231
1117
|
var _useState = useState(props.error),
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1118
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1119
|
+
error = _useState2[0],
|
|
1120
|
+
setError = _useState2[1];
|
|
1236
1121
|
var _useState3 = useState(true),
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1122
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
1123
|
+
open = _useState4[0],
|
|
1124
|
+
setOpen = _useState4[1];
|
|
1241
1125
|
var setErrorFromChildren = function setErrorFromChildren(error) {
|
|
1126
|
+
if (error.error) {
|
|
1127
|
+
error = error.error;
|
|
1128
|
+
}
|
|
1242
1129
|
setError(error);
|
|
1243
|
-
|
|
1244
1130
|
if (props.errorCallback) {
|
|
1245
|
-
props.errorCallback(error);
|
|
1131
|
+
props.errorCallback(error.message || error.toString());
|
|
1246
1132
|
}
|
|
1247
1133
|
};
|
|
1248
|
-
|
|
1249
1134
|
var close = function close() {
|
|
1250
1135
|
setOpen(false);
|
|
1251
1136
|
setTimeout(props.unmount, 300);
|
|
1252
1137
|
};
|
|
1253
|
-
|
|
1254
1138
|
if (error) {
|
|
1255
|
-
console.log(error);
|
|
1256
1139
|
return /*#__PURE__*/React.createElement(ReactDialog, {
|
|
1257
1140
|
container: props.container,
|
|
1258
1141
|
close: close,
|
|
@@ -1278,7 +1161,7 @@ var ErrorProvider = (function (props) {
|
|
|
1278
1161
|
className: "PaddingLeftS PaddingRightS"
|
|
1279
1162
|
}, /*#__PURE__*/React.createElement("pre", {
|
|
1280
1163
|
className: "ErrorSnippetText"
|
|
1281
|
-
}, error.toString())), /*#__PURE__*/React.createElement("div", {
|
|
1164
|
+
}, error.message || error.toString())), /*#__PURE__*/React.createElement("div", {
|
|
1282
1165
|
className: "PaddingTopS PaddingBottomS"
|
|
1283
1166
|
}, /*#__PURE__*/React.createElement("strong", {
|
|
1284
1167
|
className: "FontSizeM PaddingTopS"
|
|
@@ -1412,7 +1295,6 @@ var TooltipStyle = (function (style) {
|
|
|
1412
1295
|
|
|
1413
1296
|
var styleRenderer = (function (style) {
|
|
1414
1297
|
var _style, _style2;
|
|
1415
|
-
|
|
1416
1298
|
style = {
|
|
1417
1299
|
colors: Object.assign({
|
|
1418
1300
|
primary: '#ea357a',
|
|
@@ -1427,44 +1309,37 @@ var styleRenderer = (function (style) {
|
|
|
1427
1309
|
|
|
1428
1310
|
var mount = (function (_ref, content) {
|
|
1429
1311
|
var style = _ref.style,
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1312
|
+
container = _ref.container,
|
|
1313
|
+
document = _ref.document,
|
|
1314
|
+
closed = _ref.closed;
|
|
1433
1315
|
var insideStyle = styleRenderer(style);
|
|
1434
|
-
|
|
1435
1316
|
if (style && style.css) {
|
|
1436
1317
|
insideStyle = [insideStyle, style.css].join(' ');
|
|
1437
1318
|
}
|
|
1438
|
-
|
|
1439
1319
|
var unmountShadowDOM = function unmountShadowDOM() {
|
|
1440
1320
|
// setTimeout to allow dialog to animate out first
|
|
1441
1321
|
setTimeout(function () {
|
|
1442
1322
|
unmount();
|
|
1443
|
-
|
|
1444
1323
|
if (typeof closed == 'function') {
|
|
1445
1324
|
closed();
|
|
1446
1325
|
}
|
|
1447
1326
|
}, 300);
|
|
1448
1327
|
};
|
|
1449
|
-
|
|
1450
1328
|
var outsideStyle;
|
|
1451
|
-
|
|
1452
1329
|
if (container) {
|
|
1453
1330
|
outsideStyle = "\n position: absolute;\n top: 0;\n left: 0;\n bottom: 0;\n right: 0;\n z-index: 99999;\n ";
|
|
1454
1331
|
} else {
|
|
1455
1332
|
outsideStyle = "\n position: fixed;\n top: 0;\n left: 0;\n bottom: 0;\n right: 0;\n z-index: 99999;\n ";
|
|
1456
1333
|
}
|
|
1457
|
-
|
|
1458
1334
|
var _ReactShadowDOM = ReactShadowDOM({
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1335
|
+
document: document,
|
|
1336
|
+
element: container || document.body,
|
|
1337
|
+
content: content(unmountShadowDOM),
|
|
1338
|
+
outsideStyle: outsideStyle,
|
|
1339
|
+
insideStyle: insideStyle,
|
|
1340
|
+
insideClasses: container ? ['contained'] : []
|
|
1341
|
+
}),
|
|
1342
|
+
unmount = _ReactShadowDOM.unmount;
|
|
1468
1343
|
return unmount;
|
|
1469
1344
|
});
|
|
1470
1345
|
|
|
@@ -1487,10 +1362,9 @@ var requireReactVersion = (function () {
|
|
|
1487
1362
|
|
|
1488
1363
|
var UpdatableProvider = (function (props) {
|
|
1489
1364
|
var _useState = useState(true),
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1365
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1366
|
+
updatable = _useState2[0],
|
|
1367
|
+
setUpdatable = _useState2[1];
|
|
1494
1368
|
return /*#__PURE__*/React.createElement(UpdatableContext.Provider, {
|
|
1495
1369
|
value: {
|
|
1496
1370
|
updatable: updatable,
|
|
@@ -1502,44 +1376,35 @@ var UpdatableProvider = (function (props) {
|
|
|
1502
1376
|
var Connect = function Connect(options) {
|
|
1503
1377
|
requireReactVersion();
|
|
1504
1378
|
var style, error, document;
|
|
1505
|
-
|
|
1506
1379
|
if (_typeof(options) == 'object') {
|
|
1507
1380
|
style = options.style;
|
|
1508
1381
|
error = options.error;
|
|
1509
1382
|
document = options.document;
|
|
1510
1383
|
}
|
|
1511
|
-
|
|
1512
1384
|
return new Promise( /*#__PURE__*/function () {
|
|
1513
1385
|
var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(resolve, reject) {
|
|
1514
|
-
var wallet,
|
|
1386
|
+
var wallet, account;
|
|
1515
1387
|
return regenerator.wrap(function _callee$(_context) {
|
|
1516
1388
|
while (1) {
|
|
1517
1389
|
switch (_context.prev = _context.next) {
|
|
1518
1390
|
case 0:
|
|
1519
|
-
wallet =
|
|
1520
|
-
|
|
1391
|
+
wallet = getWallets()[0];
|
|
1521
1392
|
if (!wallet) {
|
|
1522
1393
|
_context.next = 7;
|
|
1523
1394
|
break;
|
|
1524
1395
|
}
|
|
1525
|
-
|
|
1526
1396
|
_context.next = 4;
|
|
1527
|
-
return wallet.
|
|
1528
|
-
|
|
1397
|
+
return wallet.account();
|
|
1529
1398
|
case 4:
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
if (!(accounts instanceof Array && accounts.length > 0)) {
|
|
1399
|
+
account = _context.sent;
|
|
1400
|
+
if (!account) {
|
|
1533
1401
|
_context.next = 7;
|
|
1534
1402
|
break;
|
|
1535
1403
|
}
|
|
1536
|
-
|
|
1537
1404
|
return _context.abrupt("return", resolve({
|
|
1538
1405
|
wallet: wallet,
|
|
1539
|
-
|
|
1540
|
-
account: accounts[0]
|
|
1406
|
+
account: account
|
|
1541
1407
|
}));
|
|
1542
|
-
|
|
1543
1408
|
case 7:
|
|
1544
1409
|
mount({
|
|
1545
1410
|
style: style,
|
|
@@ -1549,7 +1414,6 @@ var Connect = function Connect(options) {
|
|
|
1549
1414
|
reject('USER_CLOSED_DIALOG');
|
|
1550
1415
|
unmount();
|
|
1551
1416
|
};
|
|
1552
|
-
|
|
1553
1417
|
return function (container) {
|
|
1554
1418
|
return /*#__PURE__*/React.createElement(ErrorProvider, {
|
|
1555
1419
|
errorCallback: error,
|
|
@@ -1566,7 +1430,6 @@ var Connect = function Connect(options) {
|
|
|
1566
1430
|
}), /*#__PURE__*/React.createElement(PoweredBy, null))));
|
|
1567
1431
|
};
|
|
1568
1432
|
});
|
|
1569
|
-
|
|
1570
1433
|
case 8:
|
|
1571
1434
|
case "end":
|
|
1572
1435
|
return _context.stop();
|
|
@@ -1574,7 +1437,6 @@ var Connect = function Connect(options) {
|
|
|
1574
1437
|
}
|
|
1575
1438
|
}, _callee);
|
|
1576
1439
|
}));
|
|
1577
|
-
|
|
1578
1440
|
return function (_x, _x2) {
|
|
1579
1441
|
return _ref.apply(this, arguments);
|
|
1580
1442
|
};
|
|
@@ -1607,15 +1469,12 @@ var findMaxRoute = (function (routes) {
|
|
|
1607
1469
|
var sortedLowToHigh = _toConsumableArray(routes).sort(function (a, b) {
|
|
1608
1470
|
var aAmountsAvailable = ethers.BigNumber.from(a.fromBalance).div(ethers.BigNumber.from(a.fromAmount));
|
|
1609
1471
|
var bAmountsAvailable = ethers.BigNumber.from(b.fromBalance).div(ethers.BigNumber.from(b.fromAmount));
|
|
1610
|
-
|
|
1611
1472
|
if (aAmountsAvailable.lt(bAmountsAvailable)) {
|
|
1612
1473
|
return -1;
|
|
1613
1474
|
}
|
|
1614
|
-
|
|
1615
1475
|
if (bAmountsAvailable.lt(aAmountsAvailable)) {
|
|
1616
1476
|
return 1;
|
|
1617
1477
|
}
|
|
1618
|
-
|
|
1619
1478
|
return 0; // equal
|
|
1620
1479
|
});
|
|
1621
1480
|
|
|
@@ -1624,26 +1483,20 @@ var findMaxRoute = (function (routes) {
|
|
|
1624
1483
|
|
|
1625
1484
|
var round = (function (input) {
|
|
1626
1485
|
var _digitsAfterDecimal;
|
|
1627
|
-
|
|
1628
1486
|
var direction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'up';
|
|
1629
1487
|
var inputAsFloat = parseFloat(input);
|
|
1630
1488
|
var digitsAfterDecimal = inputAsFloat.toString().match(/\d+\.0*(\d{4})/);
|
|
1631
|
-
|
|
1632
1489
|
if ((_digitsAfterDecimal = digitsAfterDecimal) !== null && _digitsAfterDecimal !== void 0 && _digitsAfterDecimal.length) {
|
|
1633
1490
|
digitsAfterDecimal = digitsAfterDecimal[0];
|
|
1634
1491
|
var focus = digitsAfterDecimal.match(/\d{4}$/)[0];
|
|
1635
|
-
|
|
1636
1492
|
var _float;
|
|
1637
|
-
|
|
1638
1493
|
var focusToFixed;
|
|
1639
|
-
|
|
1640
1494
|
if (focus.match(/^0/)) {
|
|
1641
1495
|
if (direction == 'up') {
|
|
1642
1496
|
_float = parseFloat("".concat(focus[1], ".").concat(focus[2]).concat(focus[3]));
|
|
1643
1497
|
} else {
|
|
1644
1498
|
_float = parseFloat("".concat(focus[1], ".").concat(focus[2]).concat(focus[3]));
|
|
1645
1499
|
}
|
|
1646
|
-
|
|
1647
1500
|
focusToFixed = parseFloat(_float).toFixed(2);
|
|
1648
1501
|
focusToFixed = "0".concat(focusToFixed).replace('.', '');
|
|
1649
1502
|
} else {
|
|
@@ -1652,10 +1505,8 @@ var round = (function (input) {
|
|
|
1652
1505
|
} else {
|
|
1653
1506
|
_float = parseFloat("".concat(focus[0], ".").concat(focus[1]).concat(focus[2], "1"));
|
|
1654
1507
|
}
|
|
1655
|
-
|
|
1656
1508
|
focusToFixed = parseFloat(_float).toFixed(2).replace('.', '');
|
|
1657
1509
|
}
|
|
1658
|
-
|
|
1659
1510
|
if (focusToFixed == '0999' && parseInt(inputAsFloat.toFixed(0)) == 0) {
|
|
1660
1511
|
focusToFixed = direction == 'up' ? '1000' : '0999';
|
|
1661
1512
|
return parseFloat(digitsAfterDecimal.replace(/\d{4}$/, focusToFixed));
|
|
@@ -18878,42 +18729,32 @@ var ChangableAmountProvider = (function (props) {
|
|
|
18878
18729
|
return typeof configuration.amount != 'undefined' || typeof configuration.fromAmount != 'undefined';
|
|
18879
18730
|
});
|
|
18880
18731
|
};
|
|
18881
|
-
|
|
18882
18732
|
var _useContext = useContext(ConfigurationContext),
|
|
18883
|
-
|
|
18884
|
-
|
|
18885
|
-
|
|
18886
|
-
|
|
18733
|
+
configuredAmount = _useContext.amount;
|
|
18734
|
+
_useContext.toAmount;
|
|
18735
|
+
var recover = _useContext.recover;
|
|
18887
18736
|
var _useState = useState(recover == undefined ? configurationsMissAmounts(props.accept) : false),
|
|
18888
|
-
|
|
18889
|
-
|
|
18890
|
-
|
|
18891
|
-
|
|
18737
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
18738
|
+
amountsMissing = _useState2[0],
|
|
18739
|
+
setAmountsMissing = _useState2[1];
|
|
18892
18740
|
var _useContext2 = useContext(WalletContext),
|
|
18893
|
-
|
|
18894
|
-
|
|
18741
|
+
account = _useContext2.account;
|
|
18895
18742
|
var _useContext3 = useContext(ConversionRateContext),
|
|
18896
|
-
|
|
18897
|
-
|
|
18898
|
-
|
|
18743
|
+
conversionRate = _useContext3.conversionRate,
|
|
18744
|
+
fixedCurrencyConversionRate = _useContext3.fixedCurrencyConversionRate;
|
|
18899
18745
|
var _useContext4 = useContext(ErrorContext),
|
|
18900
|
-
|
|
18901
|
-
|
|
18746
|
+
setError = _useContext4.setError;
|
|
18902
18747
|
var _useState3 = useState(),
|
|
18903
|
-
|
|
18904
|
-
|
|
18905
|
-
|
|
18906
|
-
|
|
18748
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
18749
|
+
acceptWithAmount = _useState4[0],
|
|
18750
|
+
setAcceptWithAmount = _useState4[1];
|
|
18907
18751
|
var _useState5 = useState(_typeof(configuredAmount) == 'object' && configuredAmount.fix && configuredAmount.currency ? configuredAmount.fix : null),
|
|
18908
|
-
|
|
18909
|
-
|
|
18910
|
-
|
|
18752
|
+
_useState6 = _slicedToArray(_useState5, 1),
|
|
18753
|
+
fixedAmount = _useState6[0];
|
|
18911
18754
|
var _useState7 = useState(_typeof(configuredAmount) == 'object' && configuredAmount.fix && configuredAmount.currency ? configuredAmount.currency : null),
|
|
18912
|
-
|
|
18913
|
-
|
|
18914
|
-
|
|
18755
|
+
_useState8 = _slicedToArray(_useState7, 1),
|
|
18756
|
+
fixedCurrency = _useState8[0];
|
|
18915
18757
|
var startAmount;
|
|
18916
|
-
|
|
18917
18758
|
if (amountsMissing) {
|
|
18918
18759
|
if (_typeof(configuredAmount) == "object" && configuredAmount.start && configuredAmount.start) {
|
|
18919
18760
|
startAmount = configuredAmount.start;
|
|
@@ -18923,34 +18764,28 @@ var ChangableAmountProvider = (function (props) {
|
|
|
18923
18764
|
startAmount = 1;
|
|
18924
18765
|
}
|
|
18925
18766
|
}
|
|
18926
|
-
|
|
18927
18767
|
var _useState9 = useState(startAmount),
|
|
18928
|
-
|
|
18929
|
-
|
|
18930
|
-
|
|
18931
|
-
|
|
18768
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
18769
|
+
amount = _useState10[0],
|
|
18770
|
+
setAmount = _useState10[1];
|
|
18932
18771
|
var _useState11 = useState(),
|
|
18933
|
-
|
|
18934
|
-
|
|
18935
|
-
|
|
18936
|
-
|
|
18772
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
18773
|
+
maxRoute = _useState12[0],
|
|
18774
|
+
setMaxRoute = _useState12[1];
|
|
18937
18775
|
var _useState13 = useState(),
|
|
18938
|
-
|
|
18939
|
-
|
|
18940
|
-
|
|
18941
|
-
|
|
18776
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
18777
|
+
maxAmount = _useState14[0],
|
|
18778
|
+
setMaxAmount = _useState14[1];
|
|
18942
18779
|
useEffect(function () {
|
|
18943
18780
|
if (recover) {
|
|
18944
18781
|
return;
|
|
18945
18782
|
}
|
|
18946
|
-
|
|
18947
18783
|
setAmountsMissing(configurationsMissAmounts(props.accept));
|
|
18948
18784
|
}, [props.accept, recover]);
|
|
18949
|
-
|
|
18950
18785
|
var getAmounts = function getAmounts(_ref) {
|
|
18951
18786
|
var amount = _ref.amount,
|
|
18952
|
-
|
|
18953
|
-
|
|
18787
|
+
conversionRate = _ref.conversionRate,
|
|
18788
|
+
fixedCurrencyConversionRate = _ref.fixedCurrencyConversionRate;
|
|
18954
18789
|
return new Promise(function (resolve, reject) {
|
|
18955
18790
|
if (configuredAmount && configuredAmount.token) {
|
|
18956
18791
|
resolve(props.accept.map(function () {
|
|
@@ -19003,12 +18838,11 @@ var ChangableAmountProvider = (function (props) {
|
|
|
19003
18838
|
}
|
|
19004
18839
|
});
|
|
19005
18840
|
};
|
|
19006
|
-
|
|
19007
18841
|
var updateAmounts = useCallback(lodash.debounce(function (_ref2) {
|
|
19008
18842
|
var account = _ref2.account,
|
|
19009
|
-
|
|
19010
|
-
|
|
19011
|
-
|
|
18843
|
+
amount = _ref2.amount,
|
|
18844
|
+
conversionRate = _ref2.conversionRate,
|
|
18845
|
+
fixedCurrencyConversionRate = _ref2.fixedCurrencyConversionRate;
|
|
19012
18846
|
getAmounts({
|
|
19013
18847
|
amount: amount,
|
|
19014
18848
|
conversionRate: conversionRate,
|
|
@@ -19018,7 +18852,6 @@ var ChangableAmountProvider = (function (props) {
|
|
|
19018
18852
|
if (amounts[index] == undefined) {
|
|
19019
18853
|
return;
|
|
19020
18854
|
}
|
|
19021
|
-
|
|
19022
18855
|
return {
|
|
19023
18856
|
blockchain: configuration.blockchain,
|
|
19024
18857
|
amount: round(amounts[index]),
|
|
@@ -19034,7 +18867,6 @@ var ChangableAmountProvider = (function (props) {
|
|
|
19034
18867
|
if (recover) {
|
|
19035
18868
|
return;
|
|
19036
18869
|
}
|
|
19037
|
-
|
|
19038
18870
|
if (amountsMissing && account && conversionRate && (fixedAmount ? fixedCurrencyConversionRate : true)) {
|
|
19039
18871
|
updateAmounts({
|
|
19040
18872
|
account: account,
|
|
@@ -19064,7 +18896,6 @@ var ChangableAmountProvider = (function (props) {
|
|
|
19064
18896
|
}).then(setMaxAmount);
|
|
19065
18897
|
return;
|
|
19066
18898
|
}
|
|
19067
|
-
|
|
19068
18899
|
Token.readable({
|
|
19069
18900
|
amount: routes[0].amountOut,
|
|
19070
18901
|
blockchain: maxRoute.blockchain,
|
|
@@ -19077,7 +18908,6 @@ var ChangableAmountProvider = (function (props) {
|
|
|
19077
18908
|
})["catch"](setError);
|
|
19078
18909
|
} else if (maxRoute.fromToken.address == CONSTANTS[maxRoute.blockchain].USD) {
|
|
19079
18910
|
var _maxAmount = parseFloat(new Decimal(readableMaxAmount).mul(conversionRate).toString());
|
|
19080
|
-
|
|
19081
18911
|
setMaxAmount(_maxAmount > 10 ? Math.round(_maxAmount - 1) : _maxAmount - 1);
|
|
19082
18912
|
} else {
|
|
19083
18913
|
route({
|
|
@@ -19091,7 +18921,6 @@ var ChangableAmountProvider = (function (props) {
|
|
|
19091
18921
|
if (routes[0] == undefined) {
|
|
19092
18922
|
return;
|
|
19093
18923
|
}
|
|
19094
|
-
|
|
19095
18924
|
Token.readable({
|
|
19096
18925
|
amount: routes[0].amountOut,
|
|
19097
18926
|
blockchain: maxRoute.blockchain,
|
|
@@ -19142,22 +18971,18 @@ var ConfigurationProvider = (function (props) {
|
|
|
19142
18971
|
|
|
19143
18972
|
var ConversionRateProvider = (function (props) {
|
|
19144
18973
|
var _useContext = useContext(ErrorContext);
|
|
19145
|
-
|
|
19146
|
-
|
|
18974
|
+
_useContext.setError;
|
|
19147
18975
|
var _useContext2 = useContext(ConfigurationContext),
|
|
19148
|
-
|
|
19149
|
-
|
|
19150
|
-
|
|
18976
|
+
amount = _useContext2.amount,
|
|
18977
|
+
currency = _useContext2.currency;
|
|
19151
18978
|
var _useState = useState(),
|
|
19152
|
-
|
|
19153
|
-
|
|
19154
|
-
|
|
19155
|
-
|
|
18979
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
18980
|
+
conversionRate = _useState2[0],
|
|
18981
|
+
setConversionRate = _useState2[1];
|
|
19156
18982
|
var _useState3 = useState(),
|
|
19157
|
-
|
|
19158
|
-
|
|
19159
|
-
|
|
19160
|
-
|
|
18983
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
18984
|
+
fixedCurrencyConversionRate = _useState4[0],
|
|
18985
|
+
setFixedCurrencyConversionRate = _useState4[1];
|
|
19161
18986
|
useEffect(function () {
|
|
19162
18987
|
if (_typeof(amount) == 'object' && amount.currency) {
|
|
19163
18988
|
Currency.fromUSD({
|
|
@@ -19167,7 +18992,6 @@ var ConversionRateProvider = (function (props) {
|
|
|
19167
18992
|
return setFixedCurrencyConversionRate(conversion.amount);
|
|
19168
18993
|
});
|
|
19169
18994
|
}
|
|
19170
|
-
|
|
19171
18995
|
Currency.fromUSD({
|
|
19172
18996
|
amount: 1,
|
|
19173
18997
|
code: currency
|
|
@@ -19191,8 +19015,7 @@ var QuestionsGraphic = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAHQCA
|
|
|
19191
19015
|
|
|
19192
19016
|
var NoPaymentMethodFoundDialog = (function () {
|
|
19193
19017
|
var _useContext = useContext(ClosableContext),
|
|
19194
|
-
|
|
19195
|
-
|
|
19018
|
+
close = _useContext.close;
|
|
19196
19019
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
19197
19020
|
header: /*#__PURE__*/React.createElement("div", {
|
|
19198
19021
|
className: "PaddingTopS PaddingLeftM PaddingRightM"
|
|
@@ -19230,87 +19053,68 @@ var TransactionTrackingContext = /*#__PURE__*/React.createContext();
|
|
|
19230
19053
|
|
|
19231
19054
|
var PaymentProvider = (function (props) {
|
|
19232
19055
|
var _useContext = useContext(ErrorContext),
|
|
19233
|
-
|
|
19234
|
-
|
|
19056
|
+
setError = _useContext.setError;
|
|
19235
19057
|
var _useContext2 = useContext(ConfigurationContext),
|
|
19236
|
-
|
|
19237
|
-
|
|
19238
|
-
|
|
19239
|
-
|
|
19240
|
-
|
|
19241
|
-
|
|
19058
|
+
_sent = _useContext2.sent,
|
|
19059
|
+
succeeded = _useContext2.succeeded,
|
|
19060
|
+
failed = _useContext2.failed,
|
|
19061
|
+
recover = _useContext2.recover,
|
|
19062
|
+
before = _useContext2.before;
|
|
19242
19063
|
var _useContext3 = useContext(PaymentRoutingContext),
|
|
19243
|
-
|
|
19244
|
-
|
|
19245
|
-
|
|
19064
|
+
selectedRoute = _useContext3.selectedRoute;
|
|
19065
|
+
_useContext3.getPaymentRoutes;
|
|
19246
19066
|
var _useContext4 = useContext(ClosableContext),
|
|
19247
|
-
|
|
19248
|
-
|
|
19249
|
-
|
|
19250
|
-
|
|
19067
|
+
open = _useContext4.open,
|
|
19068
|
+
close = _useContext4.close,
|
|
19069
|
+
setClosable = _useContext4.setClosable;
|
|
19251
19070
|
var _useContext5 = useContext(PaymentRoutingContext),
|
|
19252
|
-
|
|
19253
|
-
|
|
19071
|
+
allRoutes = _useContext5.allRoutes;
|
|
19254
19072
|
var _useContext6 = useContext(UpdatableContext),
|
|
19255
|
-
|
|
19256
|
-
|
|
19073
|
+
setUpdatable = _useContext6.setUpdatable;
|
|
19257
19074
|
var _useContext7 = useContext(NavigateContext),
|
|
19258
|
-
|
|
19259
|
-
|
|
19260
|
-
|
|
19075
|
+
navigate = _useContext7.navigate,
|
|
19076
|
+
set = _useContext7.set;
|
|
19261
19077
|
var _useContext8 = useContext(WalletContext),
|
|
19262
|
-
|
|
19263
|
-
|
|
19078
|
+
wallet = _useContext8.wallet;
|
|
19264
19079
|
var _useContext9 = useContext(PaymentTrackingContext),
|
|
19265
|
-
|
|
19266
|
-
|
|
19267
|
-
|
|
19268
|
-
|
|
19080
|
+
release = _useContext9.release,
|
|
19081
|
+
tracking = _useContext9.tracking,
|
|
19082
|
+
initializePaymentTracking = _useContext9.initializeTracking;
|
|
19269
19083
|
var _useContext10 = useContext(TransactionTrackingContext),
|
|
19270
|
-
|
|
19271
|
-
|
|
19272
|
-
|
|
19084
|
+
foundTransaction = _useContext10.foundTransaction,
|
|
19085
|
+
initializeTransactionTracking = _useContext10.initializeTracking;
|
|
19273
19086
|
var _useState = useState(),
|
|
19274
|
-
|
|
19275
|
-
|
|
19276
|
-
|
|
19277
|
-
|
|
19087
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
19088
|
+
payment = _useState2[0],
|
|
19089
|
+
setPayment = _useState2[1];
|
|
19278
19090
|
var _useState3 = useState(),
|
|
19279
|
-
|
|
19280
|
-
|
|
19281
|
-
|
|
19282
|
-
|
|
19091
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
19092
|
+
transaction = _useState4[0],
|
|
19093
|
+
setTransaction = _useState4[1];
|
|
19283
19094
|
var _useState5 = useState(),
|
|
19284
|
-
|
|
19285
|
-
|
|
19286
|
-
|
|
19287
|
-
|
|
19095
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
19096
|
+
approvalTransaction = _useState6[0],
|
|
19097
|
+
setApprovalTransaction = _useState6[1];
|
|
19288
19098
|
var _useState7 = useState('initialized'),
|
|
19289
|
-
|
|
19290
|
-
|
|
19291
|
-
|
|
19292
|
-
|
|
19293
|
-
var paymentConfirmed = function paymentConfirmed(transaction) {
|
|
19099
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
19100
|
+
paymentState = _useState8[0],
|
|
19101
|
+
setPaymentState = _useState8[1];
|
|
19102
|
+
var paymentSucceeded = function paymentSucceeded(transaction) {
|
|
19294
19103
|
if (tracking != true) {
|
|
19295
19104
|
setClosable(true);
|
|
19296
19105
|
}
|
|
19297
|
-
|
|
19298
|
-
|
|
19299
|
-
|
|
19300
|
-
if (confirmed) {
|
|
19301
|
-
confirmed(transaction);
|
|
19106
|
+
setPaymentState('success');
|
|
19107
|
+
if (succeeded) {
|
|
19108
|
+
succeeded(transaction);
|
|
19302
19109
|
}
|
|
19303
19110
|
};
|
|
19304
|
-
|
|
19305
19111
|
var paymentFailed = function paymentFailed(transaction, error) {
|
|
19306
19112
|
if (failed) {
|
|
19307
19113
|
failed(transaction, error);
|
|
19308
19114
|
}
|
|
19309
|
-
|
|
19310
19115
|
setClosable(true);
|
|
19311
|
-
set(['
|
|
19116
|
+
set(['PaymentFailed']);
|
|
19312
19117
|
};
|
|
19313
|
-
|
|
19314
19118
|
var pay = /*#__PURE__*/function () {
|
|
19315
19119
|
var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
|
|
19316
19120
|
var stop, currentBlock;
|
|
@@ -19322,20 +19126,15 @@ var PaymentProvider = (function (props) {
|
|
|
19322
19126
|
_context.next = 6;
|
|
19323
19127
|
break;
|
|
19324
19128
|
}
|
|
19325
|
-
|
|
19326
19129
|
_context.next = 3;
|
|
19327
19130
|
return before(payment.route.transaction);
|
|
19328
|
-
|
|
19329
19131
|
case 3:
|
|
19330
19132
|
stop = _context.sent;
|
|
19331
|
-
|
|
19332
19133
|
if (!(stop === false)) {
|
|
19333
19134
|
_context.next = 6;
|
|
19334
19135
|
break;
|
|
19335
19136
|
}
|
|
19336
|
-
|
|
19337
19137
|
return _context.abrupt("return");
|
|
19338
|
-
|
|
19339
19138
|
case 6:
|
|
19340
19139
|
setClosable(false);
|
|
19341
19140
|
setPaymentState('paying');
|
|
@@ -19345,33 +19144,29 @@ var PaymentProvider = (function (props) {
|
|
|
19345
19144
|
blockchain: payment.route.transaction.blockchain,
|
|
19346
19145
|
method: 'latestBlockNumber'
|
|
19347
19146
|
});
|
|
19348
|
-
|
|
19349
19147
|
case 11:
|
|
19350
19148
|
currentBlock = _context.sent;
|
|
19351
19149
|
wallet.sendTransaction(Object.assign({}, payment.route.transaction, {
|
|
19352
19150
|
sent: function sent(transaction) {
|
|
19353
19151
|
initializeTransactionTracking(transaction, currentBlock);
|
|
19354
|
-
|
|
19355
19152
|
if (_sent) {
|
|
19356
19153
|
_sent(transaction);
|
|
19357
19154
|
}
|
|
19358
19155
|
},
|
|
19359
|
-
|
|
19156
|
+
succeeded: paymentSucceeded,
|
|
19360
19157
|
failed: paymentFailed
|
|
19361
19158
|
})).then(function (sentTransaction) {
|
|
19362
|
-
initializePaymentTracking(sentTransaction, currentBlock, payment.route);
|
|
19363
19159
|
setTransaction(sentTransaction);
|
|
19160
|
+
initializePaymentTracking(sentTransaction, currentBlock, payment.route);
|
|
19364
19161
|
})["catch"](function (error) {
|
|
19365
19162
|
console.log('error', error);
|
|
19366
19163
|
setPaymentState('initialized');
|
|
19367
19164
|
setClosable(true);
|
|
19368
19165
|
setUpdatable(true);
|
|
19369
|
-
|
|
19370
19166
|
if ((error === null || error === void 0 ? void 0 : error.code) == 'WRONG_NETWORK') {
|
|
19371
19167
|
navigate('WrongNetwork');
|
|
19372
19168
|
}
|
|
19373
19169
|
});
|
|
19374
|
-
|
|
19375
19170
|
case 13:
|
|
19376
19171
|
case "end":
|
|
19377
19172
|
return _context.stop();
|
|
@@ -19379,17 +19174,15 @@ var PaymentProvider = (function (props) {
|
|
|
19379
19174
|
}
|
|
19380
19175
|
}, _callee);
|
|
19381
19176
|
}));
|
|
19382
|
-
|
|
19383
19177
|
return function pay() {
|
|
19384
19178
|
return _ref.apply(this, arguments);
|
|
19385
19179
|
};
|
|
19386
19180
|
}();
|
|
19387
|
-
|
|
19388
19181
|
var approve = function approve() {
|
|
19389
19182
|
setClosable(false);
|
|
19390
19183
|
setPaymentState('approving');
|
|
19391
19184
|
wallet.sendTransaction(Object.assign({}, payment.route.approvalTransaction, {
|
|
19392
|
-
|
|
19185
|
+
succeeded: function succeeded() {
|
|
19393
19186
|
payment.route.approvalRequired = false;
|
|
19394
19187
|
setPayment(payment);
|
|
19395
19188
|
setClosable(true);
|
|
@@ -19403,10 +19196,9 @@ var PaymentProvider = (function (props) {
|
|
|
19403
19196
|
setClosable(true);
|
|
19404
19197
|
});
|
|
19405
19198
|
};
|
|
19406
|
-
|
|
19407
19199
|
useEffect(function () {
|
|
19408
19200
|
if (release) {
|
|
19409
|
-
setPaymentState('
|
|
19201
|
+
setPaymentState('success');
|
|
19410
19202
|
}
|
|
19411
19203
|
}, [release]);
|
|
19412
19204
|
useEffect(function () {
|
|
@@ -19429,9 +19221,8 @@ var PaymentProvider = (function (props) {
|
|
|
19429
19221
|
});
|
|
19430
19222
|
Promise.all([paymentToken.name(), paymentToken.symbol()]).then(function (_ref2) {
|
|
19431
19223
|
var _ref3 = _slicedToArray(_ref2, 2),
|
|
19432
|
-
|
|
19433
|
-
|
|
19434
|
-
|
|
19224
|
+
name = _ref3[0],
|
|
19225
|
+
symbol = _ref3[1];
|
|
19435
19226
|
setPayment({
|
|
19436
19227
|
blockchain: recover.blockchain,
|
|
19437
19228
|
token: recover.token,
|
|
@@ -19445,7 +19236,6 @@ var PaymentProvider = (function (props) {
|
|
|
19445
19236
|
useEffect(function () {
|
|
19446
19237
|
if (foundTransaction && foundTransaction.id && foundTransaction.status) {
|
|
19447
19238
|
var newTransaction;
|
|
19448
|
-
|
|
19449
19239
|
if (foundTransaction.id.toLowerCase() != transaction.id.toLowerCase()) {
|
|
19450
19240
|
newTransaction = Object.assign({}, transaction, {
|
|
19451
19241
|
id: foundTransaction.id,
|
|
@@ -19455,9 +19245,8 @@ var PaymentProvider = (function (props) {
|
|
|
19455
19245
|
});
|
|
19456
19246
|
setTransaction(newTransaction);
|
|
19457
19247
|
}
|
|
19458
|
-
|
|
19459
19248
|
if (foundTransaction.status == 'success') {
|
|
19460
|
-
|
|
19249
|
+
paymentSucceeded(newTransaction || transaction);
|
|
19461
19250
|
} else if (foundTransaction.status == 'failed') {
|
|
19462
19251
|
paymentFailed(newTransaction || transaction);
|
|
19463
19252
|
}
|
|
@@ -19468,10 +19257,9 @@ var PaymentProvider = (function (props) {
|
|
|
19468
19257
|
var fromToken = selectedRoute.fromToken;
|
|
19469
19258
|
Promise.all([fromToken.name(), fromToken.symbol(), fromToken.readable(selectedRoute.fromAmount)]).then(function (_ref4) {
|
|
19470
19259
|
var _ref5 = _slicedToArray(_ref4, 3),
|
|
19471
|
-
|
|
19472
|
-
|
|
19473
|
-
|
|
19474
|
-
|
|
19260
|
+
name = _ref5[0],
|
|
19261
|
+
symbol = _ref5[1],
|
|
19262
|
+
amount = _ref5[2];
|
|
19475
19263
|
setPayment({
|
|
19476
19264
|
blockchain: selectedRoute.blockchain,
|
|
19477
19265
|
route: selectedRoute,
|
|
@@ -19492,7 +19280,6 @@ var PaymentProvider = (function (props) {
|
|
|
19492
19280
|
setUpdatable(true);
|
|
19493
19281
|
}
|
|
19494
19282
|
}, [allRoutes]);
|
|
19495
|
-
|
|
19496
19283
|
if (allRoutes instanceof Array && allRoutes.length == 0) {
|
|
19497
19284
|
return /*#__PURE__*/React.createElement(ReactDialogStack, {
|
|
19498
19285
|
open: open,
|
|
@@ -19529,14 +19316,11 @@ function _defineProperty(obj, key, value) {
|
|
|
19529
19316
|
} else {
|
|
19530
19317
|
obj[key] = value;
|
|
19531
19318
|
}
|
|
19532
|
-
|
|
19533
19319
|
return obj;
|
|
19534
19320
|
}
|
|
19535
19321
|
|
|
19536
19322
|
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; }
|
|
19537
|
-
|
|
19538
19323
|
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; }
|
|
19539
|
-
|
|
19540
19324
|
var prepareAcceptedPayments = function prepareAcceptedPayments(accept) {
|
|
19541
19325
|
var toAddress = _typeof(accept.receiver) == 'object' ? accept.receiver.address : accept.receiver;
|
|
19542
19326
|
var toContract = _typeof(accept.receiver) == 'object' ? accept.receiver : undefined;
|
|
@@ -19545,7 +19329,6 @@ var prepareAcceptedPayments = function prepareAcceptedPayments(accept) {
|
|
|
19545
19329
|
toContract: toContract
|
|
19546
19330
|
});
|
|
19547
19331
|
};
|
|
19548
|
-
|
|
19549
19332
|
var mergeFromAccounts = function mergeFromAccounts(accept, account) {
|
|
19550
19333
|
var from = {};
|
|
19551
19334
|
accept.forEach(function (accept) {
|
|
@@ -19553,14 +19336,13 @@ var mergeFromAccounts = function mergeFromAccounts(accept, account) {
|
|
|
19553
19336
|
});
|
|
19554
19337
|
return from;
|
|
19555
19338
|
};
|
|
19556
|
-
|
|
19557
19339
|
var routePayments = (function (_ref) {
|
|
19558
19340
|
var accept = _ref.accept,
|
|
19559
|
-
|
|
19560
|
-
|
|
19561
|
-
|
|
19562
|
-
|
|
19563
|
-
|
|
19341
|
+
account = _ref.account,
|
|
19342
|
+
whitelist = _ref.whitelist,
|
|
19343
|
+
blacklist = _ref.blacklist,
|
|
19344
|
+
event = _ref.event,
|
|
19345
|
+
fee = _ref.fee;
|
|
19564
19346
|
return route$1({
|
|
19565
19347
|
accept: accept.map(prepareAcceptedPayments),
|
|
19566
19348
|
from: mergeFromAccounts(accept, account),
|
|
@@ -19572,421 +19354,100 @@ var routePayments = (function (_ref) {
|
|
|
19572
19354
|
});
|
|
19573
19355
|
|
|
19574
19356
|
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; }
|
|
19575
|
-
|
|
19576
19357
|
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; }
|
|
19577
19358
|
var PaymentRoutingProvider = (function (props) {
|
|
19578
19359
|
var _useState = useState(),
|
|
19579
|
-
|
|
19580
|
-
|
|
19581
|
-
|
|
19582
|
-
|
|
19360
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
19361
|
+
allRoutes = _useState2[0],
|
|
19362
|
+
setAllRoutes = _useState2[1];
|
|
19583
19363
|
var _useState3 = useState(),
|
|
19584
|
-
|
|
19585
|
-
|
|
19586
|
-
|
|
19587
|
-
|
|
19364
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
19365
|
+
updatedRouteWithNewPrice = _useState4[0],
|
|
19366
|
+
setUpdatedRouteWithNewPrice = _useState4[1];
|
|
19588
19367
|
var _useState5 = useState(),
|
|
19589
|
-
|
|
19590
|
-
|
|
19591
|
-
|
|
19592
|
-
|
|
19368
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
19369
|
+
selectedRoute = _useState6[0],
|
|
19370
|
+
setSelectedRoute = _useState6[1];
|
|
19593
19371
|
var _useState7 = useState(false),
|
|
19594
|
-
|
|
19595
|
-
|
|
19596
|
-
|
|
19597
|
-
|
|
19372
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
19373
|
+
slowRouting = _useState8[0],
|
|
19374
|
+
setSlowRouting = _useState8[1];
|
|
19598
19375
|
var _useState9 = useState(0),
|
|
19599
|
-
|
|
19600
|
-
|
|
19601
|
-
|
|
19602
|
-
|
|
19376
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
19377
|
+
reloadCount = _useState10[0],
|
|
19378
|
+
setReloadCount = _useState10[1];
|
|
19603
19379
|
var _useContext = useContext(WalletContext),
|
|
19604
|
-
|
|
19605
|
-
|
|
19380
|
+
account = _useContext.account;
|
|
19606
19381
|
var _useContext2 = useContext(UpdatableContext),
|
|
19607
|
-
|
|
19608
|
-
|
|
19382
|
+
updatable = _useContext2.updatable;
|
|
19609
19383
|
var _useContext3 = useContext(ConfigurationContext),
|
|
19610
|
-
|
|
19611
|
-
|
|
19612
|
-
|
|
19613
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(route) {
|
|
19614
|
-
var currentBlock, blocks, i, exchangeRoute, lastAmountsIn, defaultSlippage, defaultSlippageNewAmountBN, defaultReadableAmount, defaultSlippageRoundedAmountBN, newAmountBN, readableAmount, roundedAmountBN, difference1, difference2, slippage, _difference, _difference2, _slippage, highestAmountBN;
|
|
19615
|
-
|
|
19384
|
+
recover = _useContext3.recover;
|
|
19385
|
+
var onRoutesUpdate = /*#__PURE__*/function () {
|
|
19386
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(routes) {
|
|
19616
19387
|
return regenerator.wrap(function _callee2$(_context2) {
|
|
19617
19388
|
while (1) {
|
|
19618
19389
|
switch (_context2.prev = _context2.next) {
|
|
19619
|
-
case 0:
|
|
19620
|
-
if (!route.directTransfer) {
|
|
19621
|
-
_context2.next = 2;
|
|
19622
|
-
break;
|
|
19623
|
-
}
|
|
19624
|
-
|
|
19625
|
-
return _context2.abrupt("return");
|
|
19626
|
-
|
|
19627
|
-
case 2:
|
|
19628
|
-
_context2.next = 4;
|
|
19629
|
-
return request({
|
|
19630
|
-
blockchain: route.blockchain,
|
|
19631
|
-
method: 'latestBlockNumber'
|
|
19632
|
-
});
|
|
19633
|
-
|
|
19634
|
-
case 4:
|
|
19635
|
-
currentBlock = _context2.sent;
|
|
19636
|
-
blocks = [];
|
|
19637
|
-
|
|
19638
|
-
for (i = 0; i <= 2; i++) {
|
|
19639
|
-
blocks.push(currentBlock - i);
|
|
19640
|
-
}
|
|
19641
|
-
|
|
19642
|
-
exchangeRoute = route.exchangeRoutes[0];
|
|
19643
|
-
|
|
19644
|
-
if (!(typeof exchangeRoute == 'undefined' || typeof exchangeRoute.exchange == 'undefined')) {
|
|
19645
|
-
_context2.next = 10;
|
|
19646
|
-
break;
|
|
19647
|
-
}
|
|
19648
|
-
|
|
19649
|
-
return _context2.abrupt("return");
|
|
19650
|
-
|
|
19651
|
-
case 10:
|
|
19652
|
-
_context2.next = 12;
|
|
19653
|
-
return Promise.all(blocks.map( /*#__PURE__*/function () {
|
|
19654
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(block) {
|
|
19655
|
-
var amountIn;
|
|
19656
|
-
return regenerator.wrap(function _callee$(_context) {
|
|
19657
|
-
while (1) {
|
|
19658
|
-
switch (_context.prev = _context.next) {
|
|
19659
|
-
case 0:
|
|
19660
|
-
_context.next = 2;
|
|
19661
|
-
return exchangeRoute.exchange.getAmountIn({
|
|
19662
|
-
path: exchangeRoute.path,
|
|
19663
|
-
amountOut: exchangeRoute.amountOutMin,
|
|
19664
|
-
block: block
|
|
19665
|
-
});
|
|
19666
|
-
|
|
19667
|
-
case 2:
|
|
19668
|
-
amountIn = _context.sent;
|
|
19669
|
-
return _context.abrupt("return", amountIn);
|
|
19670
|
-
|
|
19671
|
-
case 4:
|
|
19672
|
-
case "end":
|
|
19673
|
-
return _context.stop();
|
|
19674
|
-
}
|
|
19675
|
-
}
|
|
19676
|
-
}, _callee);
|
|
19677
|
-
}));
|
|
19678
|
-
|
|
19679
|
-
return function (_x2) {
|
|
19680
|
-
return _ref2.apply(this, arguments);
|
|
19681
|
-
};
|
|
19682
|
-
}()));
|
|
19683
|
-
|
|
19684
|
-
case 12:
|
|
19685
|
-
lastAmountsIn = _context2.sent;
|
|
19686
|
-
|
|
19687
|
-
if (!(!lastAmountsIn[0] || !lastAmountsIn[1] || !lastAmountsIn[2])) {
|
|
19688
|
-
_context2.next = 15;
|
|
19689
|
-
break;
|
|
19690
|
-
}
|
|
19691
|
-
|
|
19692
|
-
return _context2.abrupt("return");
|
|
19693
|
-
|
|
19694
|
-
case 15:
|
|
19695
|
-
defaultSlippage = '0.5'; // %
|
|
19696
|
-
|
|
19697
|
-
if (ethers.BigNumber.from(route.fromAmount).mul(10000).div(ethers.BigNumber.from(route.toAmount).add(ethers.BigNumber.from(route.feeAmount || '0'))).sub(10000).toString() <= 100) {
|
|
19698
|
-
// stable coin swap
|
|
19699
|
-
defaultSlippage = '0.1'; // %
|
|
19700
|
-
}
|
|
19701
|
-
|
|
19702
|
-
defaultSlippageNewAmountBN = lastAmountsIn[2].add(lastAmountsIn[2].mul(parseFloat(defaultSlippage) * 100).div(10000));
|
|
19703
|
-
_context2.next = 20;
|
|
19704
|
-
return route.fromToken.readable(defaultSlippageNewAmountBN);
|
|
19705
|
-
|
|
19706
|
-
case 20:
|
|
19707
|
-
defaultReadableAmount = _context2.sent;
|
|
19708
|
-
_context2.next = 23;
|
|
19709
|
-
return route.fromToken.BigNumber(round(defaultReadableAmount));
|
|
19710
|
-
|
|
19711
|
-
case 23:
|
|
19712
|
-
defaultSlippageRoundedAmountBN = _context2.sent;
|
|
19713
|
-
|
|
19714
|
-
if (!(lastAmountsIn[0].gt(lastAmountsIn[1]) && lastAmountsIn[1].gt(lastAmountsIn[2]))) {
|
|
19715
|
-
_context2.next = 41;
|
|
19716
|
-
break;
|
|
19717
|
-
}
|
|
19718
|
-
|
|
19719
|
-
// EXTREME DIRETIONAL SLIPPAGE
|
|
19720
|
-
difference1 = lastAmountsIn[0].sub(lastAmountsIn[1]);
|
|
19721
|
-
difference2 = lastAmountsIn[1].sub(lastAmountsIn[2]);
|
|
19722
|
-
|
|
19723
|
-
if (difference1.lt(difference2)) {
|
|
19724
|
-
slippage = difference2.add(difference2.sub(difference1));
|
|
19725
|
-
} else {
|
|
19726
|
-
slippage = difference1.add(difference1.sub(difference2));
|
|
19727
|
-
}
|
|
19728
|
-
|
|
19729
|
-
newAmountBN = lastAmountsIn[0].add(slippage);
|
|
19730
|
-
_context2.next = 31;
|
|
19731
|
-
return route.fromToken.readable(newAmountBN);
|
|
19732
|
-
|
|
19733
|
-
case 31:
|
|
19734
|
-
readableAmount = _context2.sent;
|
|
19735
|
-
_context2.next = 34;
|
|
19736
|
-
return route.fromToken.BigNumber(round(readableAmount));
|
|
19737
|
-
|
|
19738
|
-
case 34:
|
|
19739
|
-
roundedAmountBN = _context2.sent;
|
|
19740
|
-
|
|
19741
|
-
if (!roundedAmountBN.gt(defaultSlippageRoundedAmountBN)) {
|
|
19742
|
-
_context2.next = 39;
|
|
19743
|
-
break;
|
|
19744
|
-
}
|
|
19745
|
-
|
|
19746
|
-
if (!(route.fromAmount == roundedAmountBN.toString())) {
|
|
19747
|
-
_context2.next = 38;
|
|
19748
|
-
break;
|
|
19749
|
-
}
|
|
19750
|
-
|
|
19751
|
-
return _context2.abrupt("return");
|
|
19752
|
-
|
|
19753
|
-
case 38:
|
|
19754
|
-
return _context2.abrupt("return", roundedAmountBN);
|
|
19755
|
-
|
|
19756
|
-
case 39:
|
|
19757
|
-
_context2.next = 57;
|
|
19758
|
-
break;
|
|
19759
|
-
|
|
19760
|
-
case 41:
|
|
19761
|
-
if (lastAmountsIn[0].eq(lastAmountsIn[1]) && lastAmountsIn[1].eq(lastAmountsIn[2])) {
|
|
19762
|
-
_context2.next = 57;
|
|
19763
|
-
break;
|
|
19764
|
-
}
|
|
19765
|
-
|
|
19766
|
-
// BASE NOISE SLIPPAGE
|
|
19767
|
-
_difference = lastAmountsIn[0].sub(lastAmountsIn[1]).abs();
|
|
19768
|
-
_difference2 = lastAmountsIn[1].sub(lastAmountsIn[2]).abs();
|
|
19769
|
-
|
|
19770
|
-
if (_difference.lt(_difference2)) {
|
|
19771
|
-
_slippage = _difference;
|
|
19772
|
-
} else {
|
|
19773
|
-
_slippage = _difference2;
|
|
19774
|
-
}
|
|
19775
|
-
|
|
19776
|
-
if (lastAmountsIn[0].gt(lastAmountsIn[1]) && lastAmountsIn[0].gt(lastAmountsIn[2])) {
|
|
19777
|
-
highestAmountBN = lastAmountsIn[0];
|
|
19778
|
-
} else if (lastAmountsIn[1].gt(lastAmountsIn[2]) && lastAmountsIn[1].gt(lastAmountsIn[0])) {
|
|
19779
|
-
highestAmountBN = lastAmountsIn[1];
|
|
19780
|
-
} else {
|
|
19781
|
-
highestAmountBN = lastAmountsIn[2];
|
|
19782
|
-
}
|
|
19783
|
-
|
|
19784
|
-
newAmountBN = highestAmountBN.add(_slippage);
|
|
19785
|
-
_context2.next = 49;
|
|
19786
|
-
return route.fromToken.readable(newAmountBN);
|
|
19787
|
-
|
|
19788
|
-
case 49:
|
|
19789
|
-
readableAmount = _context2.sent;
|
|
19790
|
-
_context2.next = 52;
|
|
19791
|
-
return route.fromToken.BigNumber(round(readableAmount));
|
|
19792
|
-
|
|
19793
|
-
case 52:
|
|
19794
|
-
roundedAmountBN = _context2.sent;
|
|
19795
|
-
|
|
19796
|
-
if (!roundedAmountBN.gt(defaultSlippageRoundedAmountBN)) {
|
|
19797
|
-
_context2.next = 57;
|
|
19798
|
-
break;
|
|
19799
|
-
}
|
|
19800
|
-
|
|
19801
|
-
if (!(route.fromAmount == roundedAmountBN.toString())) {
|
|
19802
|
-
_context2.next = 56;
|
|
19803
|
-
break;
|
|
19804
|
-
}
|
|
19805
|
-
|
|
19806
|
-
return _context2.abrupt("return");
|
|
19807
|
-
|
|
19808
|
-
case 56:
|
|
19809
|
-
return _context2.abrupt("return", roundedAmountBN);
|
|
19810
|
-
|
|
19811
|
-
case 57:
|
|
19812
|
-
if (!(route.fromAmount == defaultSlippageRoundedAmountBN.toString())) {
|
|
19813
|
-
_context2.next = 59;
|
|
19814
|
-
break;
|
|
19815
|
-
}
|
|
19816
|
-
|
|
19817
|
-
return _context2.abrupt("return");
|
|
19818
|
-
|
|
19819
|
-
case 59:
|
|
19820
|
-
return _context2.abrupt("return", defaultSlippageRoundedAmountBN);
|
|
19821
|
-
|
|
19822
|
-
case 60:
|
|
19823
|
-
case "end":
|
|
19824
|
-
return _context2.stop();
|
|
19825
|
-
}
|
|
19826
|
-
}
|
|
19827
|
-
}, _callee2);
|
|
19828
|
-
}));
|
|
19829
|
-
|
|
19830
|
-
return function calculateAmountInWithSlippage(_x) {
|
|
19831
|
-
return _ref.apply(this, arguments);
|
|
19832
|
-
};
|
|
19833
|
-
}();
|
|
19834
|
-
|
|
19835
|
-
var onRoutesUpdate = /*#__PURE__*/function () {
|
|
19836
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(routes) {
|
|
19837
|
-
return regenerator.wrap(function _callee5$(_context5) {
|
|
19838
|
-
while (1) {
|
|
19839
|
-
switch (_context5.prev = _context5.next) {
|
|
19840
19390
|
case 0:
|
|
19841
19391
|
if (routes.length == 0) {
|
|
19842
19392
|
setAllRoutes([]);
|
|
19843
|
-
|
|
19844
19393
|
if (props.setMaxRoute) {
|
|
19845
19394
|
props.setMaxRoute(null);
|
|
19846
19395
|
}
|
|
19847
19396
|
} else {
|
|
19848
19397
|
roundAmounts(routes).then( /*#__PURE__*/function () {
|
|
19849
|
-
var
|
|
19850
|
-
var selectRoute,
|
|
19851
|
-
|
|
19852
|
-
return regenerator.wrap(function _callee4$(_context4) {
|
|
19398
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(roundedRoutes) {
|
|
19399
|
+
var selectRoute, newSelectRoute;
|
|
19400
|
+
return regenerator.wrap(function _callee$(_context) {
|
|
19853
19401
|
while (1) {
|
|
19854
|
-
switch (
|
|
19402
|
+
switch (_context.prev = _context.next) {
|
|
19855
19403
|
case 0:
|
|
19856
|
-
if (
|
|
19857
|
-
|
|
19858
|
-
|
|
19404
|
+
if (typeof selectedRoute == 'undefined') {
|
|
19405
|
+
selectRoute = roundedRoutes[0];
|
|
19406
|
+
setSelectedRoute(selectRoute);
|
|
19407
|
+
} else {
|
|
19408
|
+
newSelectRoute = roundedRoutes[roundedRoutes.findIndex(function (route) {
|
|
19409
|
+
return route.fromToken.address == selectedRoute.fromToken.address && route.blockchain == selectedRoute.blockchain;
|
|
19410
|
+
})];
|
|
19411
|
+
if (newSelectRoute) {
|
|
19412
|
+
if (selectedRoute.fromAmount != newSelectRoute.fromAmount) {
|
|
19413
|
+
setUpdatedRouteWithNewPrice(newSelectRoute);
|
|
19414
|
+
}
|
|
19415
|
+
}
|
|
19859
19416
|
}
|
|
19860
|
-
|
|
19861
|
-
selectRoute = roundedRoutes[0];
|
|
19862
|
-
_context4.next = 4;
|
|
19863
|
-
return calculateAmountInWithSlippage(selectRoute);
|
|
19864
|
-
|
|
19865
|
-
case 4:
|
|
19866
|
-
amountInWithSlippage = _context4.sent;
|
|
19867
|
-
|
|
19868
|
-
if (!amountInWithSlippage) {
|
|
19869
|
-
_context4.next = 8;
|
|
19870
|
-
break;
|
|
19871
|
-
}
|
|
19872
|
-
|
|
19873
|
-
_context4.next = 8;
|
|
19874
|
-
return roundAmount(selectRoute, amountInWithSlippage);
|
|
19875
|
-
|
|
19876
|
-
case 8:
|
|
19877
|
-
setSelectedRoute(selectRoute);
|
|
19878
|
-
_context4.next = 20;
|
|
19879
|
-
break;
|
|
19880
|
-
|
|
19881
|
-
case 11:
|
|
19882
|
-
newSelectRoute = roundedRoutes[roundedRoutes.findIndex(function (route) {
|
|
19883
|
-
return route.fromToken.address == selectedRoute.fromToken.address && route.blockchain == selectedRoute.blockchain;
|
|
19884
|
-
})];
|
|
19885
|
-
|
|
19886
|
-
if (!newSelectRoute) {
|
|
19887
|
-
_context4.next = 20;
|
|
19888
|
-
break;
|
|
19889
|
-
}
|
|
19890
|
-
|
|
19891
|
-
_context4.next = 15;
|
|
19892
|
-
return calculateAmountInWithSlippage(newSelectRoute);
|
|
19893
|
-
|
|
19894
|
-
case 15:
|
|
19895
|
-
_amountInWithSlippage = _context4.sent;
|
|
19896
|
-
|
|
19897
|
-
if (!_amountInWithSlippage) {
|
|
19898
|
-
_context4.next = 19;
|
|
19899
|
-
break;
|
|
19900
|
-
}
|
|
19901
|
-
|
|
19902
|
-
_context4.next = 19;
|
|
19903
|
-
return roundAmount(newSelectRoute, _amountInWithSlippage);
|
|
19904
|
-
|
|
19905
|
-
case 19:
|
|
19906
|
-
if (selectedRoute.fromAmount != newSelectRoute.fromAmount) {
|
|
19907
|
-
setUpdatedRouteWithNewPrice(newSelectRoute);
|
|
19908
|
-
}
|
|
19909
|
-
|
|
19910
|
-
case 20:
|
|
19911
|
-
_context4.next = 22;
|
|
19912
|
-
return Promise.all(roundedRoutes.map( /*#__PURE__*/function () {
|
|
19913
|
-
var _ref5 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(route, index) {
|
|
19914
|
-
var amountInWithSlippage;
|
|
19915
|
-
return regenerator.wrap(function _callee3$(_context3) {
|
|
19916
|
-
while (1) {
|
|
19917
|
-
switch (_context3.prev = _context3.next) {
|
|
19918
|
-
case 0:
|
|
19919
|
-
_context3.next = 2;
|
|
19920
|
-
return calculateAmountInWithSlippage(route);
|
|
19921
|
-
|
|
19922
|
-
case 2:
|
|
19923
|
-
amountInWithSlippage = _context3.sent;
|
|
19924
|
-
|
|
19925
|
-
if (!amountInWithSlippage) {
|
|
19926
|
-
_context3.next = 6;
|
|
19927
|
-
break;
|
|
19928
|
-
}
|
|
19929
|
-
|
|
19930
|
-
_context3.next = 6;
|
|
19931
|
-
return roundAmount(route, amountInWithSlippage);
|
|
19932
|
-
|
|
19933
|
-
case 6:
|
|
19934
|
-
return _context3.abrupt("return", route);
|
|
19935
|
-
|
|
19936
|
-
case 7:
|
|
19937
|
-
case "end":
|
|
19938
|
-
return _context3.stop();
|
|
19939
|
-
}
|
|
19940
|
-
}
|
|
19941
|
-
}, _callee3);
|
|
19942
|
-
}));
|
|
19943
|
-
|
|
19944
|
-
return function (_x5, _x6) {
|
|
19945
|
-
return _ref5.apply(this, arguments);
|
|
19946
|
-
};
|
|
19947
|
-
}())).then(setAllRoutes);
|
|
19948
|
-
|
|
19949
|
-
case 22:
|
|
19417
|
+
setAllRoutes(roundedRoutes);
|
|
19950
19418
|
if (props.setMaxRoute) {
|
|
19951
19419
|
props.setMaxRoute(findMaxRoute(roundedRoutes));
|
|
19952
19420
|
}
|
|
19953
|
-
|
|
19954
|
-
case 23:
|
|
19421
|
+
case 3:
|
|
19955
19422
|
case "end":
|
|
19956
|
-
return
|
|
19423
|
+
return _context.stop();
|
|
19957
19424
|
}
|
|
19958
19425
|
}
|
|
19959
|
-
},
|
|
19426
|
+
}, _callee);
|
|
19960
19427
|
}));
|
|
19961
|
-
|
|
19962
|
-
|
|
19963
|
-
return _ref4.apply(this, arguments);
|
|
19428
|
+
return function (_x2) {
|
|
19429
|
+
return _ref2.apply(this, arguments);
|
|
19964
19430
|
};
|
|
19965
19431
|
}());
|
|
19966
19432
|
}
|
|
19967
|
-
|
|
19968
19433
|
case 1:
|
|
19969
19434
|
case "end":
|
|
19970
|
-
return
|
|
19435
|
+
return _context2.stop();
|
|
19971
19436
|
}
|
|
19972
19437
|
}
|
|
19973
|
-
},
|
|
19438
|
+
}, _callee2);
|
|
19974
19439
|
}));
|
|
19975
|
-
|
|
19976
|
-
|
|
19977
|
-
return _ref3.apply(this, arguments);
|
|
19440
|
+
return function onRoutesUpdate(_x) {
|
|
19441
|
+
return _ref.apply(this, arguments);
|
|
19978
19442
|
};
|
|
19979
19443
|
}();
|
|
19980
|
-
|
|
19981
|
-
|
|
19982
|
-
|
|
19983
|
-
|
|
19984
|
-
var updatable = _ref6.updatable;
|
|
19985
|
-
|
|
19444
|
+
var getPaymentRoutes = function getPaymentRoutes(_ref3) {
|
|
19445
|
+
_ref3.allRoutes;
|
|
19446
|
+
_ref3.selectedRoute;
|
|
19447
|
+
var updatable = _ref3.updatable;
|
|
19986
19448
|
if (updatable == false || !props.accept || !account) {
|
|
19987
19449
|
return;
|
|
19988
19450
|
}
|
|
19989
|
-
|
|
19990
19451
|
var slowRoutingTimeout = setTimeout(function () {
|
|
19991
19452
|
setSlowRouting(true);
|
|
19992
19453
|
}, 4000);
|
|
@@ -19997,146 +19458,86 @@ var PaymentRoutingProvider = (function (props) {
|
|
|
19997
19458
|
onRoutesUpdate(routes);
|
|
19998
19459
|
});
|
|
19999
19460
|
};
|
|
20000
|
-
|
|
20001
19461
|
var updateRouteAmount = function updateRouteAmount(route, amountBN) {
|
|
20002
19462
|
route.fromAmount = amountBN.toString();
|
|
20003
19463
|
route.transaction.params.amounts[0] = amountBN.toString();
|
|
20004
|
-
|
|
20005
19464
|
if (route.transaction.value && route.transaction.value.toString() != '0') {
|
|
20006
19465
|
route.transaction.value = amountBN.toString();
|
|
20007
19466
|
}
|
|
20008
19467
|
};
|
|
20009
|
-
|
|
20010
19468
|
var roundAmount = /*#__PURE__*/function () {
|
|
20011
|
-
var
|
|
19469
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(route, amountBN) {
|
|
20012
19470
|
var readableAmount, roundedAmountBN;
|
|
20013
|
-
return regenerator.wrap(function
|
|
19471
|
+
return regenerator.wrap(function _callee3$(_context3) {
|
|
20014
19472
|
while (1) {
|
|
20015
|
-
switch (
|
|
19473
|
+
switch (_context3.prev = _context3.next) {
|
|
20016
19474
|
case 0:
|
|
20017
19475
|
if (!route.directTransfer) {
|
|
20018
|
-
|
|
19476
|
+
_context3.next = 2;
|
|
20019
19477
|
break;
|
|
20020
19478
|
}
|
|
20021
|
-
|
|
20022
|
-
return _context6.abrupt("return", route);
|
|
20023
|
-
|
|
19479
|
+
return _context3.abrupt("return", route);
|
|
20024
19480
|
case 2:
|
|
20025
|
-
|
|
19481
|
+
_context3.next = 4;
|
|
20026
19482
|
return route.fromToken.readable(amountBN || route.transaction.params.amounts[0]);
|
|
20027
|
-
|
|
20028
19483
|
case 4:
|
|
20029
|
-
readableAmount =
|
|
20030
|
-
|
|
19484
|
+
readableAmount = _context3.sent;
|
|
19485
|
+
_context3.next = 7;
|
|
20031
19486
|
return route.fromToken.BigNumber(round(readableAmount));
|
|
20032
|
-
|
|
20033
19487
|
case 7:
|
|
20034
|
-
roundedAmountBN =
|
|
19488
|
+
roundedAmountBN = _context3.sent;
|
|
20035
19489
|
updateRouteAmount(route, roundedAmountBN);
|
|
20036
|
-
return
|
|
20037
|
-
|
|
19490
|
+
return _context3.abrupt("return", route);
|
|
20038
19491
|
case 10:
|
|
20039
19492
|
case "end":
|
|
20040
|
-
return
|
|
19493
|
+
return _context3.stop();
|
|
20041
19494
|
}
|
|
20042
19495
|
}
|
|
20043
|
-
},
|
|
19496
|
+
}, _callee3);
|
|
20044
19497
|
}));
|
|
20045
|
-
|
|
20046
|
-
|
|
20047
|
-
return _ref7.apply(this, arguments);
|
|
19498
|
+
return function roundAmount(_x3, _x4) {
|
|
19499
|
+
return _ref4.apply(this, arguments);
|
|
20048
19500
|
};
|
|
20049
19501
|
}();
|
|
20050
|
-
|
|
20051
19502
|
var roundAmounts = /*#__PURE__*/function () {
|
|
20052
|
-
var
|
|
20053
|
-
return regenerator.wrap(function
|
|
19503
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(routes) {
|
|
19504
|
+
return regenerator.wrap(function _callee4$(_context4) {
|
|
20054
19505
|
while (1) {
|
|
20055
|
-
switch (
|
|
19506
|
+
switch (_context4.prev = _context4.next) {
|
|
20056
19507
|
case 0:
|
|
20057
|
-
return
|
|
19508
|
+
return _context4.abrupt("return", Promise.all(routes.map(function (route) {
|
|
20058
19509
|
return roundAmount(route);
|
|
20059
19510
|
})));
|
|
20060
|
-
|
|
20061
19511
|
case 1:
|
|
20062
19512
|
case "end":
|
|
20063
|
-
return
|
|
19513
|
+
return _context4.stop();
|
|
20064
19514
|
}
|
|
20065
19515
|
}
|
|
20066
|
-
},
|
|
19516
|
+
}, _callee4);
|
|
20067
19517
|
}));
|
|
20068
|
-
|
|
20069
|
-
|
|
20070
|
-
return _ref8.apply(this, arguments);
|
|
19518
|
+
return function roundAmounts(_x5) {
|
|
19519
|
+
return _ref5.apply(this, arguments);
|
|
20071
19520
|
};
|
|
20072
19521
|
}();
|
|
20073
|
-
|
|
20074
19522
|
var updateRouteWithNewPrice = /*#__PURE__*/function () {
|
|
20075
|
-
var
|
|
20076
|
-
return regenerator.wrap(function
|
|
19523
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5() {
|
|
19524
|
+
return regenerator.wrap(function _callee5$(_context5) {
|
|
20077
19525
|
while (1) {
|
|
20078
|
-
switch (
|
|
19526
|
+
switch (_context5.prev = _context5.next) {
|
|
20079
19527
|
case 0:
|
|
20080
19528
|
setSelectedRoute(_objectSpread({}, updatedRouteWithNewPrice));
|
|
20081
19529
|
setUpdatedRouteWithNewPrice(null);
|
|
20082
|
-
|
|
20083
19530
|
case 2:
|
|
20084
19531
|
case "end":
|
|
20085
|
-
return
|
|
19532
|
+
return _context5.stop();
|
|
20086
19533
|
}
|
|
20087
19534
|
}
|
|
20088
|
-
},
|
|
19535
|
+
}, _callee5);
|
|
20089
19536
|
}));
|
|
20090
|
-
|
|
20091
19537
|
return function updateRouteWithNewPrice() {
|
|
20092
|
-
return
|
|
19538
|
+
return _ref6.apply(this, arguments);
|
|
20093
19539
|
};
|
|
20094
19540
|
}();
|
|
20095
|
-
|
|
20096
|
-
useEffect(function () {
|
|
20097
|
-
function updateRouteWithAmountInWithSlippage() {
|
|
20098
|
-
return _updateRouteWithAmountInWithSlippage.apply(this, arguments);
|
|
20099
|
-
}
|
|
20100
|
-
|
|
20101
|
-
function _updateRouteWithAmountInWithSlippage() {
|
|
20102
|
-
_updateRouteWithAmountInWithSlippage = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9() {
|
|
20103
|
-
var amountInWithSlippage;
|
|
20104
|
-
return regenerator.wrap(function _callee9$(_context9) {
|
|
20105
|
-
while (1) {
|
|
20106
|
-
switch (_context9.prev = _context9.next) {
|
|
20107
|
-
case 0:
|
|
20108
|
-
_context9.next = 2;
|
|
20109
|
-
return calculateAmountInWithSlippage(selectedRoute);
|
|
20110
|
-
|
|
20111
|
-
case 2:
|
|
20112
|
-
amountInWithSlippage = _context9.sent;
|
|
20113
|
-
|
|
20114
|
-
if (!amountInWithSlippage) {
|
|
20115
|
-
_context9.next = 8;
|
|
20116
|
-
break;
|
|
20117
|
-
}
|
|
20118
|
-
|
|
20119
|
-
_context9.next = 6;
|
|
20120
|
-
return roundAmount(selectedRoute, amountInWithSlippage);
|
|
20121
|
-
|
|
20122
|
-
case 6:
|
|
20123
|
-
console.log(222222);
|
|
20124
|
-
setUpdatedRouteWithNewPrice(selectedRoute);
|
|
20125
|
-
|
|
20126
|
-
case 8:
|
|
20127
|
-
case "end":
|
|
20128
|
-
return _context9.stop();
|
|
20129
|
-
}
|
|
20130
|
-
}
|
|
20131
|
-
}, _callee9);
|
|
20132
|
-
}));
|
|
20133
|
-
return _updateRouteWithAmountInWithSlippage.apply(this, arguments);
|
|
20134
|
-
}
|
|
20135
|
-
|
|
20136
|
-
if (selectedRoute) {
|
|
20137
|
-
updateRouteWithAmountInWithSlippage();
|
|
20138
|
-
}
|
|
20139
|
-
}, [selectedRoute]);
|
|
20140
19541
|
useEffect(function () {
|
|
20141
19542
|
var timeout = setTimeout(function () {
|
|
20142
19543
|
setReloadCount(reloadCount + 1);
|
|
@@ -20173,55 +19574,42 @@ var PaymentValueContext = /*#__PURE__*/React.createContext();
|
|
|
20173
19574
|
|
|
20174
19575
|
var PaymentValueProvider = (function (props) {
|
|
20175
19576
|
var _useContext = useContext(ErrorContext),
|
|
20176
|
-
|
|
20177
|
-
|
|
19577
|
+
setError = _useContext.setError;
|
|
20178
19578
|
var _useContext2 = useContext(WalletContext),
|
|
20179
|
-
|
|
20180
|
-
|
|
19579
|
+
account = _useContext2.account;
|
|
20181
19580
|
var _useContext3 = useContext(UpdatableContext),
|
|
20182
|
-
|
|
20183
|
-
|
|
19581
|
+
updatable = _useContext3.updatable;
|
|
20184
19582
|
var _useContext4 = useContext(ConfigurationContext),
|
|
20185
|
-
|
|
20186
|
-
|
|
20187
|
-
|
|
19583
|
+
configuredAmount = _useContext4.amount,
|
|
19584
|
+
currencyCode = _useContext4.currencyCode;
|
|
20188
19585
|
var _useContext5 = useContext(ChangableAmountContext),
|
|
20189
|
-
|
|
20190
|
-
|
|
19586
|
+
amount = _useContext5.amount;
|
|
20191
19587
|
var _useContext6 = useContext(PaymentContext),
|
|
20192
|
-
|
|
20193
|
-
|
|
19588
|
+
payment = _useContext6.payment;
|
|
20194
19589
|
var _useState = useState(),
|
|
20195
|
-
|
|
20196
|
-
|
|
20197
|
-
|
|
20198
|
-
|
|
19590
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
19591
|
+
paymentValue = _useState2[0],
|
|
19592
|
+
setPaymentValue = _useState2[1];
|
|
20199
19593
|
var _useState3 = useState(),
|
|
20200
|
-
|
|
20201
|
-
|
|
20202
|
-
|
|
20203
|
-
|
|
19594
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
19595
|
+
displayedPaymentValue = _useState4[0],
|
|
19596
|
+
setDisplayedPaymentValue = _useState4[1];
|
|
20204
19597
|
var _useState5 = useState(),
|
|
20205
|
-
|
|
20206
|
-
|
|
20207
|
-
|
|
20208
|
-
|
|
19598
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
19599
|
+
paymentValueLoss = _useState6[0],
|
|
19600
|
+
setPaymentValueLoss = _useState6[1];
|
|
20209
19601
|
var _useContext7 = useContext(ConfigurationContext),
|
|
20210
|
-
|
|
20211
|
-
|
|
19602
|
+
currency = _useContext7.currency;
|
|
20212
19603
|
var _useState7 = useState(0),
|
|
20213
|
-
|
|
20214
|
-
|
|
20215
|
-
|
|
20216
|
-
|
|
19604
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
19605
|
+
reloadCount = _useState8[0],
|
|
19606
|
+
setReloadCount = _useState8[1];
|
|
20217
19607
|
var updatePaymentValue = function updatePaymentValue(_ref) {
|
|
20218
19608
|
var updatable = _ref.updatable,
|
|
20219
|
-
|
|
20220
|
-
|
|
19609
|
+
payment = _ref.payment;
|
|
20221
19610
|
if (updatable == false || (payment === null || payment === void 0 ? void 0 : payment.route) == undefined) {
|
|
20222
19611
|
return;
|
|
20223
19612
|
}
|
|
20224
|
-
|
|
20225
19613
|
Promise.all([route({
|
|
20226
19614
|
blockchain: payment.route.blockchain,
|
|
20227
19615
|
tokenIn: payment.route.fromToken.address,
|
|
@@ -20241,27 +19629,22 @@ var PaymentValueProvider = (function (props) {
|
|
|
20241
19629
|
address: CONSTANTS[payment.route.blockchain].USD
|
|
20242
19630
|
}).decimals()]).then(function (_ref2) {
|
|
20243
19631
|
var _ref3 = _slicedToArray(_ref2, 3),
|
|
20244
|
-
|
|
20245
|
-
|
|
20246
|
-
|
|
20247
|
-
|
|
19632
|
+
fromTokenUSDExchangeRoutes = _ref3[0],
|
|
19633
|
+
reverseRoutes = _ref3[1],
|
|
19634
|
+
USDDecimals = _ref3[2];
|
|
20248
19635
|
var fromTokenUSDRoute = fromTokenUSDExchangeRoutes[0];
|
|
20249
19636
|
var reverseRoute = reverseRoutes[0];
|
|
20250
|
-
|
|
20251
19637
|
if (reverseRoute) {
|
|
20252
19638
|
var reverseAmountOutBN = ethers.BigNumber.from(reverseRoute.amountOut);
|
|
20253
19639
|
var paymentAmountInBN = ethers.BigNumber.from(payment.route.fromAmount);
|
|
20254
19640
|
var divPercent = 100 - reverseAmountOutBN.mul(ethers.BigNumber.from('100')).div(paymentAmountInBN).abs().toString();
|
|
20255
|
-
|
|
20256
19641
|
if (divPercent >= 10) {
|
|
20257
19642
|
setPaymentValueLoss(divPercent);
|
|
20258
19643
|
} else {
|
|
20259
19644
|
setPaymentValueLoss(null);
|
|
20260
19645
|
}
|
|
20261
19646
|
}
|
|
20262
|
-
|
|
20263
19647
|
var fromTokenUSDAmount;
|
|
20264
|
-
|
|
20265
19648
|
if (payment.route.fromToken.address.toLowerCase() == CONSTANTS[payment.route.blockchain].USD.toLowerCase()) {
|
|
20266
19649
|
fromTokenUSDAmount = payment.route.fromAmount.toString();
|
|
20267
19650
|
} else if (fromTokenUSDRoute == undefined) {
|
|
@@ -20270,7 +19653,6 @@ var PaymentValueProvider = (function (props) {
|
|
|
20270
19653
|
} else {
|
|
20271
19654
|
fromTokenUSDAmount = fromTokenUSDRoute.amountOut.toString();
|
|
20272
19655
|
}
|
|
20273
|
-
|
|
20274
19656
|
var fromTokenUSDValue = ethers.utils.formatUnits(fromTokenUSDAmount, USDDecimals);
|
|
20275
19657
|
Currency.fromUSD({
|
|
20276
19658
|
amount: fromTokenUSDValue,
|
|
@@ -20278,7 +19660,6 @@ var PaymentValueProvider = (function (props) {
|
|
|
20278
19660
|
}).then(setPaymentValue);
|
|
20279
19661
|
})["catch"](setError);
|
|
20280
19662
|
};
|
|
20281
|
-
|
|
20282
19663
|
useEffect(function () {
|
|
20283
19664
|
if (paymentValue && amount && configuredAmount && configuredAmount.currency && configuredAmount.fix) {
|
|
20284
19665
|
setDisplayedPaymentValue(paymentValue.toString());
|
|
@@ -20323,14 +19704,12 @@ var PaymentValueProvider = (function (props) {
|
|
|
20323
19704
|
|
|
20324
19705
|
var DonationRoutingProvider = (function (props) {
|
|
20325
19706
|
var _useContext = useContext(ChangableAmountContext),
|
|
20326
|
-
|
|
20327
|
-
|
|
20328
|
-
|
|
19707
|
+
acceptWithAmount = _useContext.acceptWithAmount,
|
|
19708
|
+
setMaxRoute = _useContext.setMaxRoute;
|
|
20329
19709
|
var _useContext2 = useContext(ConfigurationContext),
|
|
20330
|
-
|
|
20331
|
-
|
|
20332
|
-
|
|
20333
|
-
|
|
19710
|
+
blacklist = _useContext2.blacklist,
|
|
19711
|
+
whitelist = _useContext2.whitelist,
|
|
19712
|
+
fee = _useContext2.fee;
|
|
20334
19713
|
return /*#__PURE__*/React.createElement(DonationRoutingContext.Provider, {
|
|
20335
19714
|
value: {}
|
|
20336
19715
|
}, /*#__PURE__*/React.createElement(PaymentRoutingProvider, {
|
|
@@ -20347,9 +19726,7 @@ var DonationRoutingProvider = (function (props) {
|
|
|
20347
19726
|
|
|
20348
19727
|
var format = (function (input) {
|
|
20349
19728
|
var _float = round(input);
|
|
20350
|
-
|
|
20351
19729
|
var floatToString = _float.toString();
|
|
20352
|
-
|
|
20353
19730
|
if (new RegExp(/\./).test(floatToString)) {
|
|
20354
19731
|
var exploded = floatToString.split('.');
|
|
20355
19732
|
return new Intl.NumberFormat().format(parseInt(exploded[0])) + '.' + exploded[1];
|
|
@@ -20360,81 +19737,61 @@ var format = (function (input) {
|
|
|
20360
19737
|
|
|
20361
19738
|
var ChangeAmountDialog = (function (props) {
|
|
20362
19739
|
var _useContext = useContext(NavigateStackContext),
|
|
20363
|
-
|
|
20364
|
-
|
|
19740
|
+
navigate = _useContext.navigate;
|
|
20365
19741
|
var _useContext2 = useContext(ErrorContext);
|
|
20366
|
-
|
|
20367
|
-
|
|
19742
|
+
_useContext2.setError;
|
|
20368
19743
|
var _useContext3 = useContext(WalletContext);
|
|
20369
|
-
|
|
20370
|
-
|
|
19744
|
+
_useContext3.account;
|
|
20371
19745
|
var _useContext4 = useContext(ChangableAmountContext),
|
|
20372
|
-
|
|
20373
|
-
|
|
20374
|
-
|
|
20375
|
-
|
|
19746
|
+
amount = _useContext4.amount,
|
|
19747
|
+
setAmount = _useContext4.setAmount,
|
|
19748
|
+
maxAmount = _useContext4.maxAmount;
|
|
20376
19749
|
var _useContext5 = useContext(PaymentValueContext);
|
|
20377
|
-
|
|
20378
|
-
|
|
19750
|
+
_useContext5.displayedPaymentValue;
|
|
20379
19751
|
var _useState = useState(amount),
|
|
20380
|
-
|
|
20381
|
-
|
|
20382
|
-
|
|
20383
|
-
|
|
19752
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
19753
|
+
inputAmount = _useState2[0],
|
|
19754
|
+
setInputAmount = _useState2[1];
|
|
20384
19755
|
var _useContext6 = useContext(ConfigurationContext),
|
|
20385
|
-
|
|
20386
|
-
|
|
20387
|
-
|
|
19756
|
+
currencyCode = _useContext6.currencyCode,
|
|
19757
|
+
amountConfiguration = _useContext6.amount;
|
|
20388
19758
|
var _useContext7 = useContext(PaymentRoutingContext);
|
|
20389
|
-
|
|
20390
|
-
|
|
20391
|
-
|
|
19759
|
+
_useContext7.allRoutes;
|
|
19760
|
+
var setSelectedRoute = _useContext7.setSelectedRoute;
|
|
20392
19761
|
var min = _typeof(amountConfiguration) == "object" && amountConfiguration.min ? amountConfiguration.min : 1;
|
|
20393
19762
|
var step = _typeof(amountConfiguration) == "object" && amountConfiguration.step ? amountConfiguration.step : 1;
|
|
20394
19763
|
var displayedCurrencyCode = amountConfiguration != undefined && amountConfiguration.token ? null : currencyCode;
|
|
20395
|
-
|
|
20396
19764
|
var changeAmountAndGoBack = function changeAmountAndGoBack() {
|
|
20397
19765
|
var newAmount = toValidValue(parseFloat(inputAmount));
|
|
20398
|
-
|
|
20399
19766
|
if (newAmount != amount) {
|
|
20400
19767
|
setSelectedRoute(undefined);
|
|
20401
19768
|
setAmount(newAmount);
|
|
20402
19769
|
}
|
|
20403
|
-
|
|
20404
19770
|
navigate('back');
|
|
20405
19771
|
};
|
|
20406
|
-
|
|
20407
19772
|
var changeAmount = function changeAmount(value) {
|
|
20408
19773
|
if (Number.isNaN(value)) {
|
|
20409
19774
|
return;
|
|
20410
19775
|
}
|
|
20411
|
-
|
|
20412
19776
|
setInputAmount(value);
|
|
20413
19777
|
};
|
|
20414
|
-
|
|
20415
19778
|
var toValidStep = function toValidStep(value) {
|
|
20416
19779
|
if (step) {
|
|
20417
19780
|
value = parseFloat(new Decimal(Math.floor(new Decimal(value).div(step))).mul(step).toString());
|
|
20418
19781
|
}
|
|
20419
|
-
|
|
20420
19782
|
return value;
|
|
20421
19783
|
};
|
|
20422
|
-
|
|
20423
19784
|
var toValidValue = function toValidValue(value) {
|
|
20424
19785
|
value = toValidStep(value);
|
|
20425
|
-
|
|
20426
19786
|
if (maxAmount) {
|
|
20427
19787
|
value = Math.max(min, Math.min(value, maxAmount));
|
|
20428
19788
|
}
|
|
20429
|
-
|
|
20430
19789
|
value = toValidStep(value);
|
|
20431
19790
|
return value;
|
|
20432
19791
|
};
|
|
20433
|
-
|
|
20434
19792
|
var setValidValue = function setValidValue(value) {
|
|
20435
19793
|
setInputAmount(toValidValue(value));
|
|
20436
19794
|
};
|
|
20437
|
-
|
|
20438
19795
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
20439
19796
|
stacked: true,
|
|
20440
19797
|
header: /*#__PURE__*/React.createElement("div", {
|
|
@@ -20489,8 +19846,7 @@ var ChangeAmountDialog = (function (props) {
|
|
|
20489
19846
|
|
|
20490
19847
|
var ChangePaymentSkeleton = (function (props) {
|
|
20491
19848
|
var _useContext = useContext(PaymentValueContext),
|
|
20492
|
-
|
|
20493
|
-
|
|
19849
|
+
paymentValue = _useContext.paymentValue;
|
|
20494
19850
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
20495
19851
|
stacked: true,
|
|
20496
19852
|
header: /*#__PURE__*/React.createElement("div", {
|
|
@@ -20522,34 +19878,27 @@ var ChangePaymentSkeleton = (function (props) {
|
|
|
20522
19878
|
|
|
20523
19879
|
var ChangePaymentDialog = (function (props) {
|
|
20524
19880
|
var _useContext = useContext(ErrorContext),
|
|
20525
|
-
|
|
20526
|
-
|
|
19881
|
+
setError = _useContext.setError;
|
|
20527
19882
|
var _useContext2 = useContext(PaymentRoutingContext),
|
|
20528
|
-
|
|
20529
|
-
|
|
20530
|
-
|
|
19883
|
+
allRoutes = _useContext2.allRoutes,
|
|
19884
|
+
setSelectedRoute = _useContext2.setSelectedRoute;
|
|
20531
19885
|
var _useContext3 = useContext(PaymentValueContext);
|
|
20532
|
-
|
|
20533
|
-
|
|
20534
|
-
|
|
19886
|
+
_useContext3.paymentValue;
|
|
19887
|
+
var displayedPaymentValue = _useContext3.displayedPaymentValue;
|
|
20535
19888
|
var _useContext4 = useContext(NavigateStackContext),
|
|
20536
|
-
|
|
20537
|
-
|
|
19889
|
+
navigate = _useContext4.navigate;
|
|
20538
19890
|
var _useState = useState([]),
|
|
20539
|
-
|
|
20540
|
-
|
|
20541
|
-
|
|
20542
|
-
|
|
19891
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
19892
|
+
allPaymentRoutesWithData = _useState2[0],
|
|
19893
|
+
setAllPaymentRoutesWithData = _useState2[1];
|
|
20543
19894
|
var _useState3 = useState([]),
|
|
20544
|
-
|
|
20545
|
-
|
|
20546
|
-
|
|
20547
|
-
|
|
19895
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
19896
|
+
cards = _useState4[0],
|
|
19897
|
+
setCards = _useState4[1];
|
|
20548
19898
|
useEffect(function () {
|
|
20549
19899
|
if (allRoutes == undefined) {
|
|
20550
19900
|
return;
|
|
20551
19901
|
}
|
|
20552
|
-
|
|
20553
19902
|
Promise.all(allRoutes.map(function (route) {
|
|
20554
19903
|
route.exchangeRoutes[0];
|
|
20555
19904
|
route.fromToken;
|
|
@@ -20604,11 +19953,9 @@ var ChangePaymentDialog = (function (props) {
|
|
|
20604
19953
|
}, /*#__PURE__*/React.createElement("small", null, format(round(parseFloat(payment.route.fromBalance.toString()) / Math.pow(10, payment.decimals), 'down')))))));
|
|
20605
19954
|
}));
|
|
20606
19955
|
}, [allPaymentRoutesWithData]);
|
|
20607
|
-
|
|
20608
19956
|
if (allPaymentRoutesWithData.length == 0 || cards.length == 0) {
|
|
20609
19957
|
return /*#__PURE__*/React.createElement(ChangePaymentSkeleton, null);
|
|
20610
19958
|
}
|
|
20611
|
-
|
|
20612
19959
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
20613
19960
|
stacked: true,
|
|
20614
19961
|
header: /*#__PURE__*/React.createElement("div", {
|
|
@@ -20629,8 +19976,7 @@ var ChangePaymentDialog = (function (props) {
|
|
|
20629
19976
|
|
|
20630
19977
|
var DonationOverviewSkeleton = (function (props) {
|
|
20631
19978
|
var _useContext = useContext(ConfigurationContext),
|
|
20632
|
-
|
|
20633
|
-
|
|
19979
|
+
title = _useContext.title;
|
|
20634
19980
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
20635
19981
|
header: /*#__PURE__*/React.createElement("div", {
|
|
20636
19982
|
className: "PaddingTopS PaddingLeftM PaddingRightM TextLeft"
|
|
@@ -20728,42 +20074,34 @@ var LoadingText = (function (props) {
|
|
|
20728
20074
|
|
|
20729
20075
|
var Footer = (function () {
|
|
20730
20076
|
var _useContext = useContext(ChangableAmountContext);
|
|
20731
|
-
|
|
20732
|
-
|
|
20733
|
-
|
|
20077
|
+
_useContext.amount;
|
|
20078
|
+
_useContext.amountsMissing;
|
|
20734
20079
|
var _useContext2 = useContext(PaymentTrackingContext),
|
|
20735
|
-
|
|
20736
|
-
|
|
20737
|
-
|
|
20738
|
-
|
|
20080
|
+
tracking = _useContext2.tracking,
|
|
20081
|
+
release = _useContext2.release,
|
|
20082
|
+
forwardTo = _useContext2.forwardTo;
|
|
20739
20083
|
var _useContext3 = useContext(PaymentContext),
|
|
20740
|
-
|
|
20741
|
-
|
|
20742
|
-
|
|
20743
|
-
|
|
20744
|
-
|
|
20745
|
-
|
|
20746
|
-
|
|
20084
|
+
payment = _useContext3.payment,
|
|
20085
|
+
paymentState = _useContext3.paymentState,
|
|
20086
|
+
pay = _useContext3.pay,
|
|
20087
|
+
transaction = _useContext3.transaction,
|
|
20088
|
+
approve = _useContext3.approve,
|
|
20089
|
+
approvalTransaction = _useContext3.approvalTransaction;
|
|
20747
20090
|
var _useContext4 = useContext(PaymentValueContext);
|
|
20748
|
-
|
|
20749
|
-
|
|
20750
|
-
|
|
20751
|
-
|
|
20091
|
+
_useContext4.paymentValue;
|
|
20092
|
+
var displayedPaymentValue = _useContext4.displayedPaymentValue,
|
|
20093
|
+
paymentValueLoss = _useContext4.paymentValueLoss;
|
|
20752
20094
|
var _useContext5 = useContext(PaymentRoutingContext),
|
|
20753
|
-
|
|
20754
|
-
|
|
20755
|
-
|
|
20095
|
+
updatedRouteWithNewPrice = _useContext5.updatedRouteWithNewPrice,
|
|
20096
|
+
updateRouteWithNewPrice = _useContext5.updateRouteWithNewPrice;
|
|
20756
20097
|
var _useContext6 = useContext(NavigateStackContext);
|
|
20757
|
-
|
|
20758
|
-
|
|
20098
|
+
_useContext6.navigate;
|
|
20759
20099
|
var _useContext7 = useContext(ClosableContext),
|
|
20760
|
-
|
|
20761
|
-
|
|
20100
|
+
close = _useContext7.close;
|
|
20762
20101
|
var trackingInfo = function trackingInfo() {
|
|
20763
20102
|
if (tracking != true) {
|
|
20764
20103
|
return null;
|
|
20765
20104
|
}
|
|
20766
|
-
|
|
20767
20105
|
if (release) {
|
|
20768
20106
|
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
20769
20107
|
className: "Card transparent small disabled"
|
|
@@ -20798,7 +20136,6 @@ var Footer = (function () {
|
|
|
20798
20136
|
}, "Validating payment")))));
|
|
20799
20137
|
}
|
|
20800
20138
|
};
|
|
20801
|
-
|
|
20802
20139
|
var additionalPaymentInformation = function additionalPaymentInformation() {
|
|
20803
20140
|
if (paymentState == 'paying' && transaction == undefined) {
|
|
20804
20141
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -20818,7 +20155,7 @@ var Footer = (function () {
|
|
|
20818
20155
|
}, /*#__PURE__*/React.createElement("div", {
|
|
20819
20156
|
className: "Opacity05"
|
|
20820
20157
|
}, "Confirm transaction in your wallet")))));
|
|
20821
|
-
} else if (paymentState == '
|
|
20158
|
+
} else if (paymentState == 'success') {
|
|
20822
20159
|
return /*#__PURE__*/React.createElement("div", {
|
|
20823
20160
|
className: "PaddingBottomS"
|
|
20824
20161
|
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("a", {
|
|
@@ -20842,7 +20179,6 @@ var Footer = (function () {
|
|
|
20842
20179
|
}, "Payment confirmed"))))), trackingInfo());
|
|
20843
20180
|
}
|
|
20844
20181
|
};
|
|
20845
|
-
|
|
20846
20182
|
var approvalButton = function approvalButton() {
|
|
20847
20183
|
if (payment.route == undefined || !payment.route.approvalRequired || payment.route.directTransfer) {
|
|
20848
20184
|
return null;
|
|
@@ -20866,7 +20202,6 @@ var Footer = (function () {
|
|
|
20866
20202
|
}, /*#__PURE__*/React.createElement(LoadingText, null, "Approving")));
|
|
20867
20203
|
}
|
|
20868
20204
|
};
|
|
20869
|
-
|
|
20870
20205
|
var mainAction = function mainAction() {
|
|
20871
20206
|
if (updatedRouteWithNewPrice) {
|
|
20872
20207
|
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
@@ -20895,7 +20230,6 @@ var Footer = (function () {
|
|
|
20895
20230
|
if (payment.route.approvalRequired && !payment.route.directTransfer) {
|
|
20896
20231
|
return;
|
|
20897
20232
|
}
|
|
20898
|
-
|
|
20899
20233
|
pay();
|
|
20900
20234
|
}
|
|
20901
20235
|
}, "Pay ", displayedPaymentValue);
|
|
@@ -20907,7 +20241,7 @@ var Footer = (function () {
|
|
|
20907
20241
|
target: "_blank",
|
|
20908
20242
|
rel: "noopener noreferrer"
|
|
20909
20243
|
}, /*#__PURE__*/React.createElement(LoadingText, null, "Paying"));
|
|
20910
|
-
} else if (paymentState == '
|
|
20244
|
+
} else if (paymentState == 'success') {
|
|
20911
20245
|
if (tracking == true) {
|
|
20912
20246
|
if (release) {
|
|
20913
20247
|
if (forwardTo) {
|
|
@@ -20936,32 +20270,25 @@ var Footer = (function () {
|
|
|
20936
20270
|
}
|
|
20937
20271
|
}
|
|
20938
20272
|
};
|
|
20939
|
-
|
|
20940
20273
|
return /*#__PURE__*/React.createElement("div", null, approvalButton(), additionalPaymentInformation(), mainAction());
|
|
20941
20274
|
});
|
|
20942
20275
|
|
|
20943
20276
|
var DonationOverviewDialog = (function (props) {
|
|
20944
20277
|
var _useContext = useContext(ConfigurationContext);
|
|
20945
|
-
|
|
20946
|
-
|
|
20947
|
-
|
|
20278
|
+
_useContext.currencyCode;
|
|
20279
|
+
var title = _useContext.title;
|
|
20948
20280
|
var _useContext2 = useContext(ChangableAmountContext);
|
|
20949
|
-
|
|
20950
|
-
|
|
20281
|
+
_useContext2.amount;
|
|
20951
20282
|
var _useContext3 = useContext(PaymentContext),
|
|
20952
|
-
|
|
20953
|
-
|
|
20954
|
-
|
|
20283
|
+
payment = _useContext3.payment,
|
|
20284
|
+
paymentState = _useContext3.paymentState;
|
|
20955
20285
|
var _useContext4 = useContext(PaymentValueContext),
|
|
20956
|
-
|
|
20957
|
-
|
|
20286
|
+
displayedPaymentValue = _useContext4.displayedPaymentValue;
|
|
20958
20287
|
var _useContext5 = useContext(NavigateStackContext),
|
|
20959
|
-
|
|
20960
|
-
|
|
20288
|
+
navigate = _useContext5.navigate;
|
|
20961
20289
|
if (payment == undefined) {
|
|
20962
20290
|
return /*#__PURE__*/React.createElement(DonationOverviewSkeleton, null);
|
|
20963
20291
|
}
|
|
20964
|
-
|
|
20965
20292
|
var blockchain = Blockchain.findByName(payment.blockchain);
|
|
20966
20293
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
20967
20294
|
header: /*#__PURE__*/React.createElement("div", {
|
|
@@ -20978,7 +20305,6 @@ var DonationOverviewDialog = (function (props) {
|
|
|
20978
20305
|
if (paymentState != 'initialized') {
|
|
20979
20306
|
return;
|
|
20980
20307
|
}
|
|
20981
|
-
|
|
20982
20308
|
navigate('ChangeAmount');
|
|
20983
20309
|
}
|
|
20984
20310
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -21000,7 +20326,6 @@ var DonationOverviewDialog = (function (props) {
|
|
|
21000
20326
|
if (paymentState != 'initialized') {
|
|
21001
20327
|
return;
|
|
21002
20328
|
}
|
|
21003
|
-
|
|
21004
20329
|
navigate('ChangePayment');
|
|
21005
20330
|
}
|
|
21006
20331
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -21037,13 +20362,11 @@ var DonationOverviewDialog = (function (props) {
|
|
|
21037
20362
|
});
|
|
21038
20363
|
});
|
|
21039
20364
|
|
|
21040
|
-
var
|
|
20365
|
+
var PaymentFailedDialog = (function () {
|
|
21041
20366
|
var _useContext = useContext(ClosableContext),
|
|
21042
|
-
|
|
21043
|
-
|
|
20367
|
+
close = _useContext.close;
|
|
21044
20368
|
var _useContext2 = useContext(PaymentContext),
|
|
21045
|
-
|
|
21046
|
-
|
|
20369
|
+
transaction = _useContext2.transaction;
|
|
21047
20370
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
21048
20371
|
stacked: false,
|
|
21049
20372
|
header: /*#__PURE__*/React.createElement("div", {
|
|
@@ -21086,11 +20409,9 @@ var ConnectGraphic = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAHQCAMA
|
|
|
21086
20409
|
|
|
21087
20410
|
var WrongNetworkDialog = (function (props) {
|
|
21088
20411
|
var _useContext = useContext(PaymentContext),
|
|
21089
|
-
|
|
21090
|
-
|
|
20412
|
+
payment = _useContext.payment;
|
|
21091
20413
|
var _useContext2 = useContext(NavigateStackContext),
|
|
21092
|
-
|
|
21093
|
-
|
|
20414
|
+
navigate = _useContext2.navigate;
|
|
21094
20415
|
var blockchain = Blockchain.findByName(payment.route.blockchain);
|
|
21095
20416
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
21096
20417
|
stacked: true,
|
|
@@ -21126,12 +20447,10 @@ var WrongNetworkDialog = (function (props) {
|
|
|
21126
20447
|
|
|
21127
20448
|
var DonationStack = (function (props) {
|
|
21128
20449
|
var _useContext = useContext(ClosableContext),
|
|
21129
|
-
|
|
21130
|
-
|
|
21131
|
-
|
|
20450
|
+
open = _useContext.open,
|
|
20451
|
+
close = _useContext.close;
|
|
21132
20452
|
var _useContext2 = useContext(NavigateContext),
|
|
21133
|
-
|
|
21134
|
-
|
|
20453
|
+
setNavigator = _useContext2.setNavigator;
|
|
21135
20454
|
return /*#__PURE__*/React.createElement(ReactDialogStack, {
|
|
21136
20455
|
setNavigator: setNavigator,
|
|
21137
20456
|
open: open,
|
|
@@ -21143,7 +20462,7 @@ var DonationStack = (function (props) {
|
|
|
21143
20462
|
DonationOverview: /*#__PURE__*/React.createElement(DonationOverviewDialog, null),
|
|
21144
20463
|
ChangeAmount: /*#__PURE__*/React.createElement(ChangeAmountDialog, null),
|
|
21145
20464
|
ChangePayment: /*#__PURE__*/React.createElement(ChangePaymentDialog, null),
|
|
21146
|
-
|
|
20465
|
+
PaymentFailed: /*#__PURE__*/React.createElement(PaymentFailedDialog, null),
|
|
21147
20466
|
WrongNetwork: /*#__PURE__*/React.createElement(WrongNetworkDialog, null)
|
|
21148
20467
|
}
|
|
21149
20468
|
});
|
|
@@ -21151,23 +20470,19 @@ var DonationStack = (function (props) {
|
|
|
21151
20470
|
|
|
21152
20471
|
var NavigateProvider = (function (props) {
|
|
21153
20472
|
var navigator;
|
|
21154
|
-
|
|
21155
20473
|
var setNavigator = function setNavigator(_navigator) {
|
|
21156
20474
|
navigator = _navigator;
|
|
21157
20475
|
};
|
|
21158
|
-
|
|
21159
20476
|
var navigate = function navigate(dialog) {
|
|
21160
20477
|
if (navigator) {
|
|
21161
20478
|
navigator.navigate(dialog);
|
|
21162
20479
|
}
|
|
21163
20480
|
};
|
|
21164
|
-
|
|
21165
20481
|
var set = function set(dialogs) {
|
|
21166
20482
|
if (navigator) {
|
|
21167
20483
|
navigator.set(dialogs);
|
|
21168
20484
|
}
|
|
21169
20485
|
};
|
|
21170
|
-
|
|
21171
20486
|
return /*#__PURE__*/React.createElement(NavigateContext.Provider, {
|
|
21172
20487
|
value: {
|
|
21173
20488
|
navigate: navigate,
|
|
@@ -21179,58 +20494,46 @@ var NavigateProvider = (function (props) {
|
|
|
21179
20494
|
|
|
21180
20495
|
var PaymentTrackingProvider = (function (props) {
|
|
21181
20496
|
var _useContext = useContext(ErrorContext);
|
|
21182
|
-
|
|
21183
|
-
|
|
20497
|
+
_useContext.errorCallback;
|
|
21184
20498
|
var _useContext2 = useContext(ConfigurationContext),
|
|
21185
|
-
|
|
21186
|
-
|
|
21187
|
-
|
|
21188
|
-
|
|
21189
|
-
|
|
21190
|
-
|
|
20499
|
+
track = _useContext2.track,
|
|
20500
|
+
validated = _useContext2.validated,
|
|
20501
|
+
integration = _useContext2.integration,
|
|
20502
|
+
link = _useContext2.link,
|
|
20503
|
+
type = _useContext2.type;
|
|
21191
20504
|
var _useState = useState(),
|
|
21192
|
-
|
|
21193
|
-
|
|
21194
|
-
|
|
21195
|
-
|
|
20505
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
20506
|
+
transaction = _useState2[0],
|
|
20507
|
+
setTransaction = _useState2[1];
|
|
21196
20508
|
var _useState3 = useState(),
|
|
21197
|
-
|
|
21198
|
-
|
|
21199
|
-
|
|
21200
|
-
|
|
20509
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
20510
|
+
afterBlock = _useState4[0],
|
|
20511
|
+
setAfterBlock = _useState4[1];
|
|
21201
20512
|
var _useState5 = useState(),
|
|
21202
|
-
|
|
21203
|
-
|
|
21204
|
-
|
|
21205
|
-
|
|
20513
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
20514
|
+
paymentRoute = _useState6[0],
|
|
20515
|
+
setPaymentRoute = _useState6[1];
|
|
21206
20516
|
var _useState7 = useState(!!(track && (track.endpoint || typeof track.method == 'function') && track.async != true)),
|
|
21207
|
-
|
|
21208
|
-
|
|
21209
|
-
|
|
20517
|
+
_useState8 = _slicedToArray(_useState7, 1),
|
|
20518
|
+
tracking = _useState8[0];
|
|
21210
20519
|
var _useState9 = useState(!!(track && track.poll && (track.poll.endpoint || typeof track.poll.method == 'function') && track.async != true)),
|
|
21211
|
-
|
|
21212
|
-
|
|
21213
|
-
|
|
20520
|
+
_useState10 = _slicedToArray(_useState9, 1),
|
|
20521
|
+
polling = _useState10[0];
|
|
21214
20522
|
var _useState11 = useState(false),
|
|
21215
|
-
|
|
21216
|
-
|
|
21217
|
-
|
|
21218
|
-
|
|
20523
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
20524
|
+
release = _useState12[0],
|
|
20525
|
+
setRelease = _useState12[1];
|
|
21219
20526
|
var _useState13 = useState(),
|
|
21220
|
-
|
|
21221
|
-
|
|
21222
|
-
|
|
21223
|
-
|
|
20527
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
20528
|
+
forwardTo = _useState14[0],
|
|
20529
|
+
setForwardTo = _useState14[1];
|
|
21224
20530
|
var _useContext3 = useContext(ClosableContext),
|
|
21225
|
-
|
|
21226
|
-
|
|
20531
|
+
setClosable = _useContext3.setClosable;
|
|
21227
20532
|
var _useContext4 = useContext(NavigateContext),
|
|
21228
|
-
|
|
21229
|
-
|
|
21230
|
-
|
|
20533
|
+
navigate = _useContext4.navigate;
|
|
20534
|
+
_useContext4.set;
|
|
21231
20535
|
var openSocket = function openSocket(transaction) {
|
|
21232
20536
|
var socket = new WebSocket('wss://integrate.depay.com/cable');
|
|
21233
|
-
|
|
21234
20537
|
socket.onopen = function (event) {
|
|
21235
20538
|
var msg = {
|
|
21236
20539
|
command: 'subscribe',
|
|
@@ -21243,31 +20546,20 @@ var PaymentTrackingProvider = (function (props) {
|
|
|
21243
20546
|
};
|
|
21244
20547
|
socket.send(JSON.stringify(msg));
|
|
21245
20548
|
};
|
|
21246
|
-
|
|
21247
20549
|
socket.onclose = function (event) {};
|
|
21248
|
-
|
|
21249
20550
|
socket.onmessage = function (event) {
|
|
21250
20551
|
var item = JSON.parse(event.data);
|
|
21251
|
-
|
|
21252
20552
|
if (item.type === "ping" || !item.message) {
|
|
21253
20553
|
return;
|
|
21254
20554
|
}
|
|
21255
|
-
|
|
21256
|
-
if (item.message.status == 'failed') {
|
|
21257
|
-
setClosable(true);
|
|
21258
|
-
set(['PaymentError']);
|
|
21259
|
-
}
|
|
21260
|
-
|
|
21261
20555
|
if (validated) {
|
|
21262
20556
|
validated(item.message.status == 'success');
|
|
21263
20557
|
}
|
|
21264
|
-
|
|
21265
20558
|
if (item.message.release) {
|
|
21266
20559
|
setRelease(true);
|
|
21267
20560
|
setClosable(!item.message.forward_to);
|
|
21268
20561
|
setForwardTo(item.message.forward_to);
|
|
21269
20562
|
socket.close();
|
|
21270
|
-
|
|
21271
20563
|
if (!!item.message.forward_to) {
|
|
21272
20564
|
setTimeout(function () {
|
|
21273
20565
|
props.document.location.href = item.message.forward_to;
|
|
@@ -21275,31 +20567,23 @@ var PaymentTrackingProvider = (function (props) {
|
|
|
21275
20567
|
}
|
|
21276
20568
|
}
|
|
21277
20569
|
};
|
|
21278
|
-
|
|
21279
20570
|
socket.onerror = function (error) {
|
|
21280
20571
|
console.log('WebSocket Error: ' + error);
|
|
21281
20572
|
};
|
|
21282
20573
|
};
|
|
21283
|
-
|
|
21284
20574
|
var retryStartTracking = function retryStartTracking(transaction, afterBlock, paymentRoute, attempt) {
|
|
21285
20575
|
attempt = parseInt(attempt || 1, 10);
|
|
21286
|
-
console.log('attempt', attempt);
|
|
21287
|
-
console.log('track.attempts', track === null || track === void 0 ? void 0 : track.attempts);
|
|
21288
|
-
|
|
21289
20576
|
if (attempt < ((track === null || track === void 0 ? void 0 : track.attempts) || 40)) {
|
|
21290
20577
|
setTimeout(function () {
|
|
21291
20578
|
startTracking(transaction, afterBlock, paymentRoute, attempt + 1);
|
|
21292
20579
|
}, 3000);
|
|
21293
20580
|
} else {
|
|
21294
|
-
console.log('navigate TrackingFailed');
|
|
21295
20581
|
navigate('TrackingFailed');
|
|
21296
20582
|
}
|
|
21297
20583
|
};
|
|
21298
|
-
|
|
21299
20584
|
var continueTryTracking = function continueTryTracking() {
|
|
21300
20585
|
retryStartTracking(transaction, afterBlock, paymentRoute, 1);
|
|
21301
20586
|
};
|
|
21302
|
-
|
|
21303
20587
|
var callTracking = function callTracking(payment) {
|
|
21304
20588
|
if (track.endpoint) {
|
|
21305
20589
|
return fetch(track.endpoint, {
|
|
@@ -21315,10 +20599,8 @@ var PaymentTrackingProvider = (function (props) {
|
|
|
21315
20599
|
throw 'No tracking defined!';
|
|
21316
20600
|
}
|
|
21317
20601
|
};
|
|
21318
|
-
|
|
21319
20602
|
var startTracking = function startTracking(transaction, afterBlock, paymentRoute, attempt) {
|
|
21320
20603
|
var _paymentRoute$feeAmou;
|
|
21321
|
-
|
|
21322
20604
|
callTracking({
|
|
21323
20605
|
blockchain: transaction.blockchain,
|
|
21324
20606
|
transaction: transaction.id.toLowerCase(),
|
|
@@ -21341,12 +20623,10 @@ var PaymentTrackingProvider = (function (props) {
|
|
|
21341
20623
|
retryStartTracking(transaction, afterBlock, paymentRoute, attempt);
|
|
21342
20624
|
});
|
|
21343
20625
|
};
|
|
21344
|
-
|
|
21345
20626
|
var pollStatus = function pollStatus(polling, transaction, afterBlock, paymentRoute, pollingInterval) {
|
|
21346
20627
|
if (!polling || transaction == undefined || afterBlock == undefined || paymentRoute == undefined) {
|
|
21347
20628
|
return;
|
|
21348
20629
|
}
|
|
21349
|
-
|
|
21350
20630
|
var payment = {
|
|
21351
20631
|
blockchain: transaction.blockchain,
|
|
21352
20632
|
transaction: transaction.id.toLowerCase(),
|
|
@@ -21355,7 +20635,6 @@ var PaymentTrackingProvider = (function (props) {
|
|
|
21355
20635
|
after_block: afterBlock,
|
|
21356
20636
|
to_token: paymentRoute.toToken.address
|
|
21357
20637
|
};
|
|
21358
|
-
|
|
21359
20638
|
var handleResponse = function handleResponse(response) {
|
|
21360
20639
|
if (response.status == 200 || response.status == 201) {
|
|
21361
20640
|
response.json().then(function (data) {
|
|
@@ -21374,7 +20653,6 @@ var PaymentTrackingProvider = (function (props) {
|
|
|
21374
20653
|
setRelease(true);
|
|
21375
20654
|
}
|
|
21376
20655
|
};
|
|
21377
|
-
|
|
21378
20656
|
if (track.poll.endpoint) {
|
|
21379
20657
|
fetch(track.poll.endpoint, {
|
|
21380
20658
|
method: 'POST',
|
|
@@ -21387,16 +20665,13 @@ var PaymentTrackingProvider = (function (props) {
|
|
|
21387
20665
|
track.poll.method(payment).then(handleResponse);
|
|
21388
20666
|
}
|
|
21389
20667
|
};
|
|
21390
|
-
|
|
21391
20668
|
useEffect(function () {
|
|
21392
20669
|
if (!polling) {
|
|
21393
20670
|
return;
|
|
21394
20671
|
}
|
|
21395
|
-
|
|
21396
20672
|
if (!tracking) {
|
|
21397
20673
|
return;
|
|
21398
20674
|
}
|
|
21399
|
-
|
|
21400
20675
|
var pollingInterval = setInterval(function () {
|
|
21401
20676
|
return pollStatus(polling, transaction, afterBlock, paymentRoute, pollingInterval);
|
|
21402
20677
|
}, 5000);
|
|
@@ -21404,7 +20679,6 @@ var PaymentTrackingProvider = (function (props) {
|
|
|
21404
20679
|
clearInterval(pollingInterval);
|
|
21405
20680
|
};
|
|
21406
20681
|
}, [polling, transaction, afterBlock, paymentRoute]);
|
|
21407
|
-
|
|
21408
20682
|
var storePayment = function storePayment(transaction, afterBlock, paymentRoute, attempt) {
|
|
21409
20683
|
fetch('https://public.depay.com/payments', {
|
|
21410
20684
|
headers: {
|
|
@@ -21445,24 +20719,19 @@ var PaymentTrackingProvider = (function (props) {
|
|
|
21445
20719
|
}, 3000);
|
|
21446
20720
|
});
|
|
21447
20721
|
};
|
|
21448
|
-
|
|
21449
20722
|
var initializeTracking = function initializeTracking(transaction, afterBlock, paymentRoute) {
|
|
21450
20723
|
storePayment(transaction, afterBlock, paymentRoute);
|
|
21451
|
-
|
|
21452
20724
|
if (tracking || track && track.async == true) {
|
|
21453
20725
|
startTracking(transaction, afterBlock, paymentRoute);
|
|
21454
20726
|
}
|
|
21455
|
-
|
|
21456
20727
|
if (tracking == false) {
|
|
21457
20728
|
return;
|
|
21458
20729
|
}
|
|
21459
|
-
|
|
21460
20730
|
setTransaction(transaction);
|
|
21461
20731
|
setAfterBlock(afterBlock);
|
|
21462
20732
|
setPaymentRoute(paymentRoute);
|
|
21463
20733
|
openSocket(transaction);
|
|
21464
20734
|
};
|
|
21465
|
-
|
|
21466
20735
|
return /*#__PURE__*/React.createElement(PaymentTrackingContext.Provider, {
|
|
21467
20736
|
value: {
|
|
21468
20737
|
tracking: tracking,
|
|
@@ -21476,26 +20745,21 @@ var PaymentTrackingProvider = (function (props) {
|
|
|
21476
20745
|
|
|
21477
20746
|
var TransactionTrackingProvider = (function (props) {
|
|
21478
20747
|
var _useState = useState(),
|
|
21479
|
-
|
|
21480
|
-
|
|
21481
|
-
|
|
21482
|
-
|
|
20748
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
20749
|
+
givenTransaction = _useState2[0],
|
|
20750
|
+
setGivenTransaction = _useState2[1];
|
|
21483
20751
|
var _useState3 = useState(),
|
|
21484
|
-
|
|
21485
|
-
|
|
21486
|
-
|
|
21487
|
-
|
|
20752
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
20753
|
+
foundTransaction = _useState4[0],
|
|
20754
|
+
setFoundTransaction = _useState4[1];
|
|
21488
20755
|
var _useState5 = useState(false),
|
|
21489
|
-
|
|
21490
|
-
|
|
21491
|
-
|
|
21492
|
-
|
|
20756
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
20757
|
+
polling = _useState6[0],
|
|
20758
|
+
setPolling = _useState6[1];
|
|
21493
20759
|
var _useContext = useContext(ErrorContext);
|
|
21494
|
-
|
|
21495
|
-
|
|
20760
|
+
_useContext.errorCallback;
|
|
21496
20761
|
var _useContext2 = useContext(ConfigurationContext),
|
|
21497
|
-
|
|
21498
|
-
|
|
20762
|
+
recover = _useContext2.recover;
|
|
21499
20763
|
useEffect(function () {
|
|
21500
20764
|
if (polling) {
|
|
21501
20765
|
var poll = function poll() {
|
|
@@ -21513,7 +20777,6 @@ var TransactionTrackingProvider = (function (props) {
|
|
|
21513
20777
|
}
|
|
21514
20778
|
});
|
|
21515
20779
|
};
|
|
21516
|
-
|
|
21517
20780
|
var pollingInterval = setInterval(poll, 5000);
|
|
21518
20781
|
poll();
|
|
21519
20782
|
return function () {
|
|
@@ -21521,13 +20784,11 @@ var TransactionTrackingProvider = (function (props) {
|
|
|
21521
20784
|
};
|
|
21522
20785
|
}
|
|
21523
20786
|
}, [polling]);
|
|
21524
|
-
|
|
21525
20787
|
var createTracking = function createTracking(transaction, afterBlock, attempt) {
|
|
21526
20788
|
if (attempt > 3) {
|
|
21527
20789
|
console.log('TRANSACTION TRACKING FAILED AFTER 3 ATTEMPTS!');
|
|
21528
20790
|
return;
|
|
21529
20791
|
}
|
|
21530
|
-
|
|
21531
20792
|
fetch('https://public.depay.com/transactions', {
|
|
21532
20793
|
method: 'POST',
|
|
21533
20794
|
headers: {
|
|
@@ -21556,10 +20817,8 @@ var TransactionTrackingProvider = (function (props) {
|
|
|
21556
20817
|
}, 3000);
|
|
21557
20818
|
});
|
|
21558
20819
|
};
|
|
21559
|
-
|
|
21560
20820
|
var openSocket = function openSocket(transaction) {
|
|
21561
20821
|
var socket = new WebSocket('wss://integrate.depay.com/cable');
|
|
21562
|
-
|
|
21563
20822
|
socket.onopen = function (event) {
|
|
21564
20823
|
var msg = {
|
|
21565
20824
|
command: 'subscribe',
|
|
@@ -21572,37 +20831,28 @@ var TransactionTrackingProvider = (function (props) {
|
|
|
21572
20831
|
};
|
|
21573
20832
|
socket.send(JSON.stringify(msg));
|
|
21574
20833
|
};
|
|
21575
|
-
|
|
21576
20834
|
socket.onclose = function (event) {};
|
|
21577
|
-
|
|
21578
20835
|
socket.onmessage = function (event) {
|
|
21579
20836
|
var item = JSON.parse(event.data);
|
|
21580
|
-
|
|
21581
20837
|
if (item.type === "ping") {
|
|
21582
20838
|
return;
|
|
21583
20839
|
}
|
|
21584
|
-
|
|
21585
20840
|
if (item.message && item.message.status && item.message.status != 'pending') {
|
|
21586
20841
|
setFoundTransaction(item.message);
|
|
21587
20842
|
}
|
|
21588
20843
|
};
|
|
21589
|
-
|
|
21590
20844
|
socket.onerror = function (error) {
|
|
21591
20845
|
console.log('WebSocket Error: ' + error);
|
|
21592
20846
|
};
|
|
21593
20847
|
};
|
|
21594
|
-
|
|
21595
20848
|
var initializeTracking = function initializeTracking(transaction, afterBlock) {
|
|
21596
20849
|
setGivenTransaction(transaction);
|
|
21597
|
-
|
|
21598
20850
|
if (recover == undefined) {
|
|
21599
20851
|
createTracking(transaction, afterBlock, 1);
|
|
21600
20852
|
}
|
|
21601
|
-
|
|
21602
20853
|
openSocket(transaction);
|
|
21603
20854
|
setPolling(true);
|
|
21604
20855
|
};
|
|
21605
|
-
|
|
21606
20856
|
useEffect(function () {
|
|
21607
20857
|
if (recover) {
|
|
21608
20858
|
initializeTracking({
|
|
@@ -21623,38 +20873,31 @@ var TransactionTrackingProvider = (function (props) {
|
|
|
21623
20873
|
|
|
21624
20874
|
var WalletProvider = (function (props) {
|
|
21625
20875
|
var _useContext = useContext(ConfigurationContext),
|
|
21626
|
-
|
|
21627
|
-
|
|
20876
|
+
recover = _useContext.recover;
|
|
21628
20877
|
var _useContext2 = useContext(ErrorContext);
|
|
21629
|
-
|
|
21630
|
-
|
|
20878
|
+
_useContext2.setError;
|
|
21631
20879
|
var _useState = useState(),
|
|
21632
|
-
|
|
21633
|
-
|
|
21634
|
-
|
|
21635
|
-
|
|
20880
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
20881
|
+
wallet = _useState2[0],
|
|
20882
|
+
setWallet = _useState2[1];
|
|
21636
20883
|
var _useState3 = useState(),
|
|
21637
|
-
|
|
21638
|
-
|
|
21639
|
-
|
|
21640
|
-
|
|
20884
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
20885
|
+
account = _useState4[0],
|
|
20886
|
+
setAccount = _useState4[1];
|
|
21641
20887
|
var _useState5 = useState(),
|
|
21642
|
-
|
|
21643
|
-
|
|
21644
|
-
|
|
21645
|
-
|
|
20888
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
20889
|
+
walletState = _useState6[0],
|
|
20890
|
+
setWalletState = _useState6[1];
|
|
21646
20891
|
var connected = function connected(_ref) {
|
|
21647
20892
|
var account = _ref.account,
|
|
21648
|
-
|
|
20893
|
+
wallet = _ref.wallet;
|
|
21649
20894
|
setAccount(account);
|
|
21650
20895
|
setWallet(wallet);
|
|
21651
20896
|
setWalletState('connected');
|
|
21652
|
-
|
|
21653
20897
|
if (props.connected) {
|
|
21654
20898
|
props.connected(account);
|
|
21655
20899
|
}
|
|
21656
20900
|
};
|
|
21657
|
-
|
|
21658
20901
|
if (walletState == 'connected' || recover != undefined) {
|
|
21659
20902
|
return /*#__PURE__*/React.createElement(WalletContext.Provider, {
|
|
21660
20903
|
value: {
|
|
@@ -21680,33 +20923,26 @@ var preflight$2 = /*#__PURE__*/function () {
|
|
|
21680
20923
|
switch (_context.prev = _context.next) {
|
|
21681
20924
|
case 0:
|
|
21682
20925
|
accept = _ref.accept;
|
|
21683
|
-
|
|
21684
20926
|
if (!(!(accept instanceof Array) || accept.length == 0)) {
|
|
21685
20927
|
_context.next = 3;
|
|
21686
20928
|
break;
|
|
21687
20929
|
}
|
|
21688
|
-
|
|
21689
20930
|
throw 'You need to set the tokens you accept as donation!';
|
|
21690
|
-
|
|
21691
20931
|
case 3:
|
|
21692
20932
|
accept.forEach(function (configuration) {
|
|
21693
20933
|
if (typeof configuration.blockchain === 'undefined') {
|
|
21694
20934
|
throw 'You need to set the blockchain you want to receive the donation on!';
|
|
21695
20935
|
}
|
|
21696
|
-
|
|
21697
20936
|
if (!['ethereum', 'bsc', 'polygon'].includes(configuration.blockchain)) {
|
|
21698
20937
|
throw 'You need to set a supported blockchain!';
|
|
21699
20938
|
}
|
|
21700
|
-
|
|
21701
20939
|
if (typeof configuration.token === 'undefined') {
|
|
21702
20940
|
throw 'You need to set the token you want to receive as donation!';
|
|
21703
20941
|
}
|
|
21704
|
-
|
|
21705
20942
|
if (typeof configuration.receiver === 'undefined') {
|
|
21706
20943
|
throw 'You need to set the receiver address that you want to receive the donation!';
|
|
21707
20944
|
}
|
|
21708
20945
|
});
|
|
21709
|
-
|
|
21710
20946
|
case 4:
|
|
21711
20947
|
case "end":
|
|
21712
20948
|
return _context.stop();
|
|
@@ -21714,27 +20950,24 @@ var preflight$2 = /*#__PURE__*/function () {
|
|
|
21714
20950
|
}
|
|
21715
20951
|
}, _callee);
|
|
21716
20952
|
}));
|
|
21717
|
-
|
|
21718
20953
|
return function preflight(_x) {
|
|
21719
20954
|
return _ref2.apply(this, arguments);
|
|
21720
20955
|
};
|
|
21721
20956
|
}();
|
|
21722
|
-
|
|
21723
20957
|
var Donation = /*#__PURE__*/function () {
|
|
21724
20958
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(_ref3) {
|
|
21725
|
-
var amount, accept, event, sent,
|
|
20959
|
+
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;
|
|
21726
20960
|
return regenerator.wrap(function _callee2$(_context2) {
|
|
21727
20961
|
while (1) {
|
|
21728
20962
|
switch (_context2.prev = _context2.next) {
|
|
21729
20963
|
case 0:
|
|
21730
|
-
amount = _ref3.amount, accept = _ref3.accept, event = _ref3.event, sent = _ref3.sent,
|
|
20964
|
+
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;
|
|
21731
20965
|
requireReactVersion();
|
|
21732
20966
|
_context2.prev = 2;
|
|
21733
20967
|
_context2.next = 5;
|
|
21734
20968
|
return preflight$2({
|
|
21735
20969
|
accept: accept
|
|
21736
20970
|
});
|
|
21737
|
-
|
|
21738
20971
|
case 5:
|
|
21739
20972
|
unmount = mount({
|
|
21740
20973
|
style: style,
|
|
@@ -21757,7 +20990,7 @@ var Donation = /*#__PURE__*/function () {
|
|
|
21757
20990
|
track: track,
|
|
21758
20991
|
fee: fee,
|
|
21759
20992
|
sent: sent,
|
|
21760
|
-
|
|
20993
|
+
succeeded: succeeded,
|
|
21761
20994
|
validated: validated,
|
|
21762
20995
|
failed: failed,
|
|
21763
20996
|
blacklist: blacklist,
|
|
@@ -21790,16 +21023,13 @@ var Donation = /*#__PURE__*/function () {
|
|
|
21790
21023
|
return _context2.abrupt("return", {
|
|
21791
21024
|
unmount: unmount
|
|
21792
21025
|
});
|
|
21793
|
-
|
|
21794
21026
|
case 9:
|
|
21795
21027
|
_context2.prev = 9;
|
|
21796
21028
|
_context2.t0 = _context2["catch"](2);
|
|
21797
21029
|
console.log('critical error', _context2.t0);
|
|
21798
|
-
|
|
21799
21030
|
if (critical != undefined) {
|
|
21800
21031
|
critical(_context2.t0);
|
|
21801
21032
|
}
|
|
21802
|
-
|
|
21803
21033
|
case 13:
|
|
21804
21034
|
case "end":
|
|
21805
21035
|
return _context2.stop();
|
|
@@ -21807,7 +21037,6 @@ var Donation = /*#__PURE__*/function () {
|
|
|
21807
21037
|
}
|
|
21808
21038
|
}, _callee2, null, [[2, 9]]);
|
|
21809
21039
|
}));
|
|
21810
|
-
|
|
21811
21040
|
return function Donation(_x2) {
|
|
21812
21041
|
return _ref4.apply(this, arguments);
|
|
21813
21042
|
};
|
|
@@ -21815,23 +21044,19 @@ var Donation = /*#__PURE__*/function () {
|
|
|
21815
21044
|
|
|
21816
21045
|
var SignLoginDialog = (function (props) {
|
|
21817
21046
|
var _useContext = useContext(ErrorContext),
|
|
21818
|
-
|
|
21819
|
-
|
|
21047
|
+
setError = _useContext.setError;
|
|
21820
21048
|
var _useContext2 = useContext(ConfigurationContext),
|
|
21821
|
-
|
|
21822
|
-
|
|
21823
|
-
|
|
21049
|
+
message = _useContext2.message,
|
|
21050
|
+
endpoint = _useContext2.endpoint;
|
|
21824
21051
|
var _useContext3 = useContext(ConfigurationContext),
|
|
21825
|
-
|
|
21826
|
-
|
|
21827
|
-
var wallet = getWallet();
|
|
21052
|
+
recover = _useContext3.recover;
|
|
21053
|
+
var wallet = getWallets()[0];
|
|
21828
21054
|
wallet !== null && wallet !== void 0 && wallet.name ? wallet.name : 'wallet';
|
|
21829
21055
|
var walletLogo = wallet !== null && wallet !== void 0 && wallet.logo ? wallet.logo : undefined;
|
|
21830
|
-
|
|
21831
21056
|
if (typeof recover != 'function') {
|
|
21832
21057
|
recover = function recover(_ref) {
|
|
21833
21058
|
var message = _ref.message,
|
|
21834
|
-
|
|
21059
|
+
signature = _ref.signature;
|
|
21835
21060
|
return new Promise(function (resolve, reject) {
|
|
21836
21061
|
fetch(endpoint, {
|
|
21837
21062
|
method: 'POST',
|
|
@@ -21856,7 +21081,6 @@ var SignLoginDialog = (function (props) {
|
|
|
21856
21081
|
});
|
|
21857
21082
|
};
|
|
21858
21083
|
}
|
|
21859
|
-
|
|
21860
21084
|
var login = function login() {
|
|
21861
21085
|
wallet.sign(message).then(function (signature) {
|
|
21862
21086
|
recover({
|
|
@@ -21869,7 +21093,6 @@ var SignLoginDialog = (function (props) {
|
|
|
21869
21093
|
}
|
|
21870
21094
|
});
|
|
21871
21095
|
};
|
|
21872
|
-
|
|
21873
21096
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
21874
21097
|
body: /*#__PURE__*/React.createElement("div", {
|
|
21875
21098
|
className: "TextCenter"
|
|
@@ -21896,14 +21119,12 @@ var SignLoginDialog = (function (props) {
|
|
|
21896
21119
|
|
|
21897
21120
|
var LoginStack = (function (props) {
|
|
21898
21121
|
var _useContext = useContext(ClosableContext),
|
|
21899
|
-
|
|
21900
|
-
|
|
21901
|
-
|
|
21122
|
+
open = _useContext.open,
|
|
21123
|
+
close = _useContext.close;
|
|
21902
21124
|
var _useState = useState(true),
|
|
21903
|
-
|
|
21904
|
-
|
|
21905
|
-
|
|
21906
|
-
|
|
21125
|
+
_useState2 = _slicedToArray(_useState, 2);
|
|
21126
|
+
_useState2[0];
|
|
21127
|
+
_useState2[1];
|
|
21907
21128
|
return /*#__PURE__*/React.createElement(ReactDialogStack, {
|
|
21908
21129
|
open: open,
|
|
21909
21130
|
close: close,
|
|
@@ -21922,7 +21143,6 @@ var LoginStack = (function (props) {
|
|
|
21922
21143
|
var Login = function Login(options) {
|
|
21923
21144
|
requireReactVersion();
|
|
21924
21145
|
var style, error, document, message, endpoint, recover;
|
|
21925
|
-
|
|
21926
21146
|
if (_typeof(options) == 'object') {
|
|
21927
21147
|
style = options.style;
|
|
21928
21148
|
error = options.error;
|
|
@@ -21931,7 +21151,6 @@ var Login = function Login(options) {
|
|
|
21931
21151
|
endpoint = options.endpoint;
|
|
21932
21152
|
recover = options.recover;
|
|
21933
21153
|
}
|
|
21934
|
-
|
|
21935
21154
|
return new Promise( /*#__PURE__*/function () {
|
|
21936
21155
|
var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(_resolve, reject) {
|
|
21937
21156
|
return regenerator.wrap(function _callee$(_context) {
|
|
@@ -21947,7 +21166,6 @@ var Login = function Login(options) {
|
|
|
21947
21166
|
reject('USER_CLOSED_DIALOG');
|
|
21948
21167
|
unmount();
|
|
21949
21168
|
};
|
|
21950
|
-
|
|
21951
21169
|
return function (container) {
|
|
21952
21170
|
return /*#__PURE__*/React.createElement(ErrorProvider, {
|
|
21953
21171
|
errorCallback: error,
|
|
@@ -21966,14 +21184,12 @@ var Login = function Login(options) {
|
|
|
21966
21184
|
container: container,
|
|
21967
21185
|
resolve: function resolve(account) {
|
|
21968
21186
|
unmount();
|
|
21969
|
-
|
|
21970
21187
|
_resolve(account);
|
|
21971
21188
|
}
|
|
21972
21189
|
}), /*#__PURE__*/React.createElement(PoweredBy, null)))));
|
|
21973
21190
|
};
|
|
21974
21191
|
});
|
|
21975
21192
|
})["catch"](reject);
|
|
21976
|
-
|
|
21977
21193
|
case 1:
|
|
21978
21194
|
case "end":
|
|
21979
21195
|
return _context.stop();
|
|
@@ -21981,7 +21197,6 @@ var Login = function Login(options) {
|
|
|
21981
21197
|
}
|
|
21982
21198
|
}, _callee);
|
|
21983
21199
|
}));
|
|
21984
|
-
|
|
21985
21200
|
return function (_x, _x2) {
|
|
21986
21201
|
return _ref.apply(this, arguments);
|
|
21987
21202
|
};
|
|
@@ -21992,15 +21207,13 @@ var PaymentAmountRoutingContext = /*#__PURE__*/React.createContext();
|
|
|
21992
21207
|
|
|
21993
21208
|
var PaymentAmountRoutingProvider = (function (props) {
|
|
21994
21209
|
var _useContext = useContext(ChangableAmountContext),
|
|
21995
|
-
|
|
21996
|
-
|
|
21997
|
-
|
|
21998
|
-
|
|
21210
|
+
amountsMissing = _useContext.amountsMissing,
|
|
21211
|
+
acceptWithAmount = _useContext.acceptWithAmount,
|
|
21212
|
+
setMaxRoute = _useContext.setMaxRoute;
|
|
21999
21213
|
var _useState = useState(),
|
|
22000
|
-
|
|
22001
|
-
|
|
22002
|
-
|
|
22003
|
-
|
|
21214
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
21215
|
+
accept = _useState2[0],
|
|
21216
|
+
setAccept = _useState2[1];
|
|
22004
21217
|
useEffect(function () {
|
|
22005
21218
|
if (amountsMissing) {
|
|
22006
21219
|
if (acceptWithAmount) {
|
|
@@ -22024,13 +21237,11 @@ var PaymentAmountRoutingProvider = (function (props) {
|
|
|
22024
21237
|
|
|
22025
21238
|
var PaymentOverviewSkeleton = (function (props) {
|
|
22026
21239
|
var _useContext = useContext(ChangableAmountContext),
|
|
22027
|
-
|
|
22028
|
-
|
|
22029
|
-
|
|
21240
|
+
amountsMissing = _useContext.amountsMissing,
|
|
21241
|
+
fixedAmount = _useContext.fixedAmount;
|
|
22030
21242
|
var _useContext2 = useContext(PaymentRoutingContext),
|
|
22031
|
-
|
|
22032
|
-
|
|
22033
|
-
|
|
21243
|
+
slowRouting = _useContext2.slowRouting,
|
|
21244
|
+
selectedRoute = _useContext2.selectedRoute;
|
|
22034
21245
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
22035
21246
|
header: /*#__PURE__*/React.createElement("div", {
|
|
22036
21247
|
className: "PaddingTopS PaddingLeftM PaddingRightM TextLeft"
|
|
@@ -22064,29 +21275,23 @@ var PaymentOverviewSkeleton = (function (props) {
|
|
|
22064
21275
|
|
|
22065
21276
|
var PaymentOverviewDialog = (function (props) {
|
|
22066
21277
|
var _useContext = useContext(ConfigurationContext),
|
|
22067
|
-
|
|
22068
|
-
|
|
22069
|
-
|
|
21278
|
+
currencyCode = _useContext.currencyCode,
|
|
21279
|
+
recover = _useContext.recover;
|
|
22070
21280
|
var _useContext2 = useContext(PaymentContext),
|
|
22071
|
-
|
|
22072
|
-
|
|
22073
|
-
|
|
21281
|
+
payment = _useContext2.payment,
|
|
21282
|
+
paymentState = _useContext2.paymentState;
|
|
22074
21283
|
var _useContext3 = useContext(ChangableAmountContext),
|
|
22075
|
-
|
|
22076
|
-
|
|
22077
|
-
|
|
22078
|
-
|
|
22079
|
-
|
|
21284
|
+
amount = _useContext3.amount,
|
|
21285
|
+
amountsMissing = _useContext3.amountsMissing,
|
|
21286
|
+
fixedAmount = _useContext3.fixedAmount,
|
|
21287
|
+
fixedCurrency = _useContext3.fixedCurrency;
|
|
22080
21288
|
var _useContext4 = useContext(PaymentValueContext),
|
|
22081
|
-
|
|
22082
|
-
|
|
21289
|
+
paymentValue = _useContext4.paymentValue;
|
|
22083
21290
|
var _useContext5 = useContext(NavigateStackContext),
|
|
22084
|
-
|
|
22085
|
-
|
|
21291
|
+
navigate = _useContext5.navigate;
|
|
22086
21292
|
if (payment == undefined || recover == undefined && paymentValue == undefined) {
|
|
22087
21293
|
return /*#__PURE__*/React.createElement(PaymentOverviewSkeleton, null);
|
|
22088
21294
|
}
|
|
22089
|
-
|
|
22090
21295
|
var blockchain = Blockchain.findByName(payment.blockchain);
|
|
22091
21296
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
22092
21297
|
header: /*#__PURE__*/React.createElement("div", {
|
|
@@ -22103,7 +21308,6 @@ var PaymentOverviewDialog = (function (props) {
|
|
|
22103
21308
|
if (paymentState != 'initialized') {
|
|
22104
21309
|
return;
|
|
22105
21310
|
}
|
|
22106
|
-
|
|
22107
21311
|
navigate('ChangeAmount');
|
|
22108
21312
|
}
|
|
22109
21313
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -22128,7 +21332,6 @@ var PaymentOverviewDialog = (function (props) {
|
|
|
22128
21332
|
if (paymentState != 'initialized') {
|
|
22129
21333
|
return;
|
|
22130
21334
|
}
|
|
22131
|
-
|
|
22132
21335
|
navigate('ChangePayment');
|
|
22133
21336
|
}
|
|
22134
21337
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -22167,19 +21370,15 @@ var PaymentOverviewDialog = (function (props) {
|
|
|
22167
21370
|
|
|
22168
21371
|
var TrackingFailedDialog = (function () {
|
|
22169
21372
|
var _useContext = useContext(PaymentTrackingContext),
|
|
22170
|
-
|
|
22171
|
-
|
|
21373
|
+
continueTryTracking = _useContext.continueTryTracking;
|
|
22172
21374
|
var _useContext2 = useContext(PaymentContext),
|
|
22173
|
-
|
|
22174
|
-
|
|
21375
|
+
transaction = _useContext2.transaction;
|
|
22175
21376
|
var _useContext3 = useContext(NavigateStackContext),
|
|
22176
|
-
|
|
22177
|
-
|
|
21377
|
+
navigate = _useContext3.navigate;
|
|
22178
21378
|
var tryAgain = function tryAgain() {
|
|
22179
21379
|
continueTryTracking();
|
|
22180
21380
|
navigate('back');
|
|
22181
21381
|
};
|
|
22182
|
-
|
|
22183
21382
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
22184
21383
|
stacked: false,
|
|
22185
21384
|
header: /*#__PURE__*/React.createElement("div", {
|
|
@@ -22215,12 +21414,10 @@ var TrackingFailedDialog = (function () {
|
|
|
22215
21414
|
|
|
22216
21415
|
var PaymentStack = (function (props) {
|
|
22217
21416
|
var _useContext = useContext(ClosableContext),
|
|
22218
|
-
|
|
22219
|
-
|
|
22220
|
-
|
|
21417
|
+
open = _useContext.open,
|
|
21418
|
+
close = _useContext.close;
|
|
22221
21419
|
var _useContext2 = useContext(NavigateContext),
|
|
22222
|
-
|
|
22223
|
-
|
|
21420
|
+
setNavigator = _useContext2.setNavigator;
|
|
22224
21421
|
return /*#__PURE__*/React.createElement(ReactDialogStack, {
|
|
22225
21422
|
setNavigator: setNavigator,
|
|
22226
21423
|
open: open,
|
|
@@ -22232,7 +21429,7 @@ var PaymentStack = (function (props) {
|
|
|
22232
21429
|
PaymentOverview: /*#__PURE__*/React.createElement(PaymentOverviewDialog, null),
|
|
22233
21430
|
ChangeAmount: /*#__PURE__*/React.createElement(ChangeAmountDialog, null),
|
|
22234
21431
|
ChangePayment: /*#__PURE__*/React.createElement(ChangePaymentDialog, null),
|
|
22235
|
-
|
|
21432
|
+
PaymentFailed: /*#__PURE__*/React.createElement(PaymentFailedDialog, null),
|
|
22236
21433
|
WrongNetwork: /*#__PURE__*/React.createElement(WrongNetworkDialog, null),
|
|
22237
21434
|
TrackingFailed: /*#__PURE__*/React.createElement(TrackingFailedDialog, null)
|
|
22238
21435
|
}
|
|
@@ -22247,37 +21444,29 @@ var preflight$1 = /*#__PURE__*/function () {
|
|
|
22247
21444
|
switch (_context.prev = _context.next) {
|
|
22248
21445
|
case 0:
|
|
22249
21446
|
accept = _ref.accept, recover = _ref.recover;
|
|
22250
|
-
|
|
22251
21447
|
if (!recover) {
|
|
22252
21448
|
_context.next = 3;
|
|
22253
21449
|
break;
|
|
22254
21450
|
}
|
|
22255
|
-
|
|
22256
21451
|
return _context.abrupt("return");
|
|
22257
|
-
|
|
22258
21452
|
case 3:
|
|
22259
21453
|
accept.forEach(function (configuration) {
|
|
22260
21454
|
if (typeof configuration.blockchain === 'undefined') {
|
|
22261
21455
|
throw 'You need to set the blockchain your want to receive the payment on!';
|
|
22262
21456
|
}
|
|
22263
|
-
|
|
22264
21457
|
if (!['ethereum', 'bsc', 'polygon'].includes(configuration.blockchain)) {
|
|
22265
21458
|
throw 'You need to set a supported blockchain!';
|
|
22266
21459
|
}
|
|
22267
|
-
|
|
22268
21460
|
if (typeof configuration.token === 'undefined' && typeof configuration.fromToken === 'undefined' && typeof configuration.fromAmount === 'undefined' && typeof configuration.toToken === 'undefined') {
|
|
22269
21461
|
throw 'You need to set the token you want to receive as payment!';
|
|
22270
21462
|
}
|
|
22271
|
-
|
|
22272
21463
|
if (typeof configuration.token === 'undefined' && typeof configuration.fromToken !== 'undefined' && typeof configuration.fromAmount === 'undefined' && typeof configuration.toToken === 'undefined') {
|
|
22273
21464
|
throw 'You need to set the fromToken, fromAmount and toToken!';
|
|
22274
21465
|
}
|
|
22275
|
-
|
|
22276
21466
|
if (typeof configuration.receiver === 'undefined') {
|
|
22277
21467
|
throw 'You need to set the receiver address that you want to receive the payment!';
|
|
22278
21468
|
}
|
|
22279
21469
|
});
|
|
22280
|
-
|
|
22281
21470
|
case 4:
|
|
22282
21471
|
case "end":
|
|
22283
21472
|
return _context.stop();
|
|
@@ -22285,20 +21474,18 @@ var preflight$1 = /*#__PURE__*/function () {
|
|
|
22285
21474
|
}
|
|
22286
21475
|
}, _callee);
|
|
22287
21476
|
}));
|
|
22288
|
-
|
|
22289
21477
|
return function preflight(_x) {
|
|
22290
21478
|
return _ref2.apply(this, arguments);
|
|
22291
21479
|
};
|
|
22292
21480
|
}();
|
|
22293
|
-
|
|
22294
21481
|
var Payment = /*#__PURE__*/function () {
|
|
22295
21482
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(_ref3) {
|
|
22296
|
-
var accept, amount, event, sent,
|
|
21483
|
+
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;
|
|
22297
21484
|
return regenerator.wrap(function _callee2$(_context2) {
|
|
22298
21485
|
while (1) {
|
|
22299
21486
|
switch (_context2.prev = _context2.next) {
|
|
22300
21487
|
case 0:
|
|
22301
|
-
accept = _ref3.accept, amount = _ref3.amount, event = _ref3.event, sent = _ref3.sent,
|
|
21488
|
+
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;
|
|
22302
21489
|
requireReactVersion();
|
|
22303
21490
|
_context2.prev = 2;
|
|
22304
21491
|
_context2.next = 5;
|
|
@@ -22306,7 +21493,6 @@ var Payment = /*#__PURE__*/function () {
|
|
|
22306
21493
|
accept: accept,
|
|
22307
21494
|
recover: recover
|
|
22308
21495
|
});
|
|
22309
|
-
|
|
22310
21496
|
case 5:
|
|
22311
21497
|
unmount = mount({
|
|
22312
21498
|
style: style,
|
|
@@ -22328,7 +21514,7 @@ var Payment = /*#__PURE__*/function () {
|
|
|
22328
21514
|
currency: currency,
|
|
22329
21515
|
event: event,
|
|
22330
21516
|
sent: sent,
|
|
22331
|
-
|
|
21517
|
+
succeeded: succeeded,
|
|
22332
21518
|
validated: validated,
|
|
22333
21519
|
failed: failed,
|
|
22334
21520
|
whitelist: whitelist,
|
|
@@ -22370,16 +21556,13 @@ var Payment = /*#__PURE__*/function () {
|
|
|
22370
21556
|
return _context2.abrupt("return", {
|
|
22371
21557
|
unmount: unmount
|
|
22372
21558
|
});
|
|
22373
|
-
|
|
22374
21559
|
case 9:
|
|
22375
21560
|
_context2.prev = 9;
|
|
22376
21561
|
_context2.t0 = _context2["catch"](2);
|
|
22377
21562
|
console.log('critical error', _context2.t0);
|
|
22378
|
-
|
|
22379
21563
|
if (critical != undefined) {
|
|
22380
21564
|
critical(_context2.t0);
|
|
22381
21565
|
}
|
|
22382
|
-
|
|
22383
21566
|
case 13:
|
|
22384
21567
|
case "end":
|
|
22385
21568
|
return _context2.stop();
|
|
@@ -22387,19 +21570,17 @@ var Payment = /*#__PURE__*/function () {
|
|
|
22387
21570
|
}
|
|
22388
21571
|
}, _callee2, null, [[2, 9]]);
|
|
22389
21572
|
}));
|
|
22390
|
-
|
|
22391
21573
|
return function Payment(_x2) {
|
|
22392
21574
|
return _ref4.apply(this, arguments);
|
|
22393
21575
|
};
|
|
22394
21576
|
}();
|
|
22395
|
-
|
|
22396
21577
|
Payment.preload = function (_ref5) {
|
|
22397
21578
|
var account = _ref5.account,
|
|
22398
|
-
|
|
22399
|
-
|
|
22400
|
-
|
|
22401
|
-
|
|
22402
|
-
|
|
21579
|
+
accept = _ref5.accept,
|
|
21580
|
+
whitelist = _ref5.whitelist,
|
|
21581
|
+
blacklist = _ref5.blacklist,
|
|
21582
|
+
event = _ref5.event,
|
|
21583
|
+
fee = _ref5.fee;
|
|
22403
21584
|
routePayments({
|
|
22404
21585
|
account: account,
|
|
22405
21586
|
accept: accept,
|
|
@@ -22416,25 +21597,21 @@ var ToTokenContext = /*#__PURE__*/React.createContext();
|
|
|
22416
21597
|
|
|
22417
21598
|
var ToTokenProvider = (function (props) {
|
|
22418
21599
|
var _useContext = useContext(PaymentContext),
|
|
22419
|
-
|
|
22420
|
-
|
|
21600
|
+
payment = _useContext.payment;
|
|
22421
21601
|
var _useState = useState(),
|
|
22422
|
-
|
|
22423
|
-
|
|
22424
|
-
|
|
22425
|
-
|
|
21602
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
21603
|
+
toToken = _useState2[0],
|
|
21604
|
+
setToToken = _useState2[1];
|
|
22426
21605
|
var _useState3 = useState(),
|
|
22427
|
-
|
|
22428
|
-
|
|
22429
|
-
|
|
22430
|
-
|
|
21606
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
21607
|
+
toTokenReadableAmount = _useState4[0],
|
|
21608
|
+
setToTokenReadableAmount = _useState4[1];
|
|
22431
21609
|
useEffect(function () {
|
|
22432
21610
|
if (payment) {
|
|
22433
21611
|
Promise.all([payment.route.toToken.symbol(), payment.route.toToken.readable(payment.route.toAmount)]).then(function (_ref) {
|
|
22434
21612
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
22435
|
-
|
|
22436
|
-
|
|
22437
|
-
|
|
21613
|
+
symbol = _ref2[0],
|
|
21614
|
+
readableAmount = _ref2[1];
|
|
22438
21615
|
setToToken({
|
|
22439
21616
|
address: payment.route.toToken.address,
|
|
22440
21617
|
symbol: symbol
|
|
@@ -22453,29 +21630,23 @@ var ToTokenProvider = (function (props) {
|
|
|
22453
21630
|
|
|
22454
21631
|
var SaleRoutingProvider = (function (props) {
|
|
22455
21632
|
var _useContext = useContext(ChangableAmountContext),
|
|
22456
|
-
|
|
22457
|
-
|
|
22458
|
-
|
|
21633
|
+
acceptWithAmount = _useContext.acceptWithAmount,
|
|
21634
|
+
setMaxRoute = _useContext.setMaxRoute;
|
|
22459
21635
|
var _useContext2 = useContext(ConfigurationContext),
|
|
22460
|
-
|
|
22461
|
-
|
|
21636
|
+
sell = _useContext2.sell;
|
|
22462
21637
|
var _useContext3 = useContext(ConfigurationContext),
|
|
22463
|
-
|
|
22464
|
-
|
|
21638
|
+
blacklist = _useContext3.blacklist;
|
|
22465
21639
|
if (blacklist == undefined) {
|
|
22466
21640
|
blacklist = {};
|
|
22467
21641
|
}
|
|
22468
|
-
|
|
22469
21642
|
for (var blockchain in sell) {
|
|
22470
21643
|
var token = sell[blockchain];
|
|
22471
|
-
|
|
22472
21644
|
if (blacklist[blockchain] instanceof Array) {
|
|
22473
21645
|
blacklist[blockchain].push(token);
|
|
22474
21646
|
} else {
|
|
22475
21647
|
blacklist[blockchain] = [token];
|
|
22476
21648
|
}
|
|
22477
21649
|
}
|
|
22478
|
-
|
|
22479
21650
|
return /*#__PURE__*/React.createElement(SaleRoutingContext.Provider, {
|
|
22480
21651
|
value: {}
|
|
22481
21652
|
}, /*#__PURE__*/React.createElement(PaymentRoutingProvider, {
|
|
@@ -22523,31 +21694,24 @@ var SaleOverviewSkeleton = (function (props) {
|
|
|
22523
21694
|
|
|
22524
21695
|
var SaleOverviewDialog = (function (props) {
|
|
22525
21696
|
var _useContext = useContext(ChangableAmountContext);
|
|
22526
|
-
|
|
22527
|
-
|
|
21697
|
+
_useContext.amount;
|
|
22528
21698
|
var _useContext2 = useContext(ConfigurationContext),
|
|
22529
|
-
|
|
22530
|
-
|
|
22531
|
-
|
|
21699
|
+
tokenImage = _useContext2.tokenImage,
|
|
21700
|
+
amountConfiguration = _useContext2.amount;
|
|
22532
21701
|
var _useContext3 = useContext(PaymentValueContext),
|
|
22533
|
-
|
|
22534
|
-
|
|
21702
|
+
paymentValue = _useContext3.paymentValue;
|
|
22535
21703
|
var _useContext4 = useContext(PaymentContext),
|
|
22536
|
-
|
|
22537
|
-
|
|
22538
|
-
|
|
21704
|
+
payment = _useContext4.payment,
|
|
21705
|
+
paymentState = _useContext4.paymentState;
|
|
22539
21706
|
var _useContext5 = useContext(NavigateStackContext),
|
|
22540
|
-
|
|
22541
|
-
|
|
21707
|
+
navigate = _useContext5.navigate;
|
|
22542
21708
|
var _useContext6 = useContext(ToTokenContext),
|
|
22543
|
-
|
|
22544
|
-
|
|
22545
|
-
|
|
21709
|
+
toToken = _useContext6.toToken,
|
|
21710
|
+
toTokenReadableAmount = _useContext6.toTokenReadableAmount;
|
|
22546
21711
|
var _useState = useState(),
|
|
22547
|
-
|
|
22548
|
-
|
|
22549
|
-
|
|
22550
|
-
|
|
21712
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
21713
|
+
salePerTokenValue = _useState2[0],
|
|
21714
|
+
setSalePerTokenValue = _useState2[1];
|
|
22551
21715
|
useEffect(function () {
|
|
22552
21716
|
if (paymentValue && (amountConfiguration == undefined || amountConfiguration.token != true) && toTokenReadableAmount) {
|
|
22553
21717
|
var UsdAmountPerToken = paymentValue.amount / parseFloat(toTokenReadableAmount);
|
|
@@ -22559,19 +21723,15 @@ var SaleOverviewDialog = (function (props) {
|
|
|
22559
21723
|
amount: 0,
|
|
22560
21724
|
code: paymentValue.code
|
|
22561
21725
|
}).toString();
|
|
22562
|
-
|
|
22563
21726
|
if (readableLocalizedAmountPerToken != zero) {
|
|
22564
21727
|
setSalePerTokenValue(readableLocalizedAmountPerToken);
|
|
22565
21728
|
}
|
|
22566
21729
|
}
|
|
22567
21730
|
}, [paymentValue, toTokenReadableAmount]);
|
|
22568
|
-
|
|
22569
21731
|
if (toToken == undefined || toTokenReadableAmount == undefined || payment == undefined || paymentValue == undefined) {
|
|
22570
21732
|
return /*#__PURE__*/React.createElement(SaleOverviewSkeleton, null);
|
|
22571
21733
|
}
|
|
22572
|
-
|
|
22573
21734
|
var tokenImageElement;
|
|
22574
|
-
|
|
22575
21735
|
if (tokenImage) {
|
|
22576
21736
|
tokenImageElement = /*#__PURE__*/React.createElement("img", {
|
|
22577
21737
|
src: tokenImage
|
|
@@ -22582,7 +21742,6 @@ var SaleOverviewDialog = (function (props) {
|
|
|
22582
21742
|
address: toToken.address
|
|
22583
21743
|
});
|
|
22584
21744
|
}
|
|
22585
|
-
|
|
22586
21745
|
var blockchain = Blockchain.findByName(payment.blockchain);
|
|
22587
21746
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
22588
21747
|
header: /*#__PURE__*/React.createElement("div", {
|
|
@@ -22599,7 +21758,6 @@ var SaleOverviewDialog = (function (props) {
|
|
|
22599
21758
|
if (paymentState != 'initialized') {
|
|
22600
21759
|
return;
|
|
22601
21760
|
}
|
|
22602
|
-
|
|
22603
21761
|
navigate('ChangeAmount');
|
|
22604
21762
|
}
|
|
22605
21763
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -22635,7 +21793,6 @@ var SaleOverviewDialog = (function (props) {
|
|
|
22635
21793
|
if (paymentState != 'initialized') {
|
|
22636
21794
|
return;
|
|
22637
21795
|
}
|
|
22638
|
-
|
|
22639
21796
|
navigate('ChangePayment');
|
|
22640
21797
|
}
|
|
22641
21798
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -22669,12 +21826,10 @@ var SaleOverviewDialog = (function (props) {
|
|
|
22669
21826
|
|
|
22670
21827
|
var SaleStack = (function (props) {
|
|
22671
21828
|
var _useContext = useContext(ClosableContext),
|
|
22672
|
-
|
|
22673
|
-
|
|
22674
|
-
|
|
21829
|
+
open = _useContext.open,
|
|
21830
|
+
close = _useContext.close;
|
|
22675
21831
|
var _useContext2 = useContext(NavigateContext),
|
|
22676
|
-
|
|
22677
|
-
|
|
21832
|
+
setNavigator = _useContext2.setNavigator;
|
|
22678
21833
|
return /*#__PURE__*/React.createElement(ReactDialogStack, {
|
|
22679
21834
|
setNavigator: setNavigator,
|
|
22680
21835
|
open: open,
|
|
@@ -22687,7 +21842,7 @@ var SaleStack = (function (props) {
|
|
|
22687
21842
|
ChangeAmount: /*#__PURE__*/React.createElement(ChangeAmountDialog, null),
|
|
22688
21843
|
ChangePayment: /*#__PURE__*/React.createElement(ChangePaymentDialog, null),
|
|
22689
21844
|
NoPaymentMethodFound: /*#__PURE__*/React.createElement(NoPaymentMethodFoundDialog, null),
|
|
22690
|
-
|
|
21845
|
+
PaymentFailed: /*#__PURE__*/React.createElement(PaymentFailedDialog, null),
|
|
22691
21846
|
WrongNetwork: /*#__PURE__*/React.createElement(WrongNetworkDialog, null)
|
|
22692
21847
|
}
|
|
22693
21848
|
});
|
|
@@ -22701,30 +21856,23 @@ var preflight = /*#__PURE__*/function () {
|
|
|
22701
21856
|
switch (_context.prev = _context.next) {
|
|
22702
21857
|
case 0:
|
|
22703
21858
|
sell = _ref.sell;
|
|
22704
|
-
|
|
22705
21859
|
if (!(_typeof(sell) != 'object')) {
|
|
22706
21860
|
_context.next = 3;
|
|
22707
21861
|
break;
|
|
22708
21862
|
}
|
|
22709
|
-
|
|
22710
21863
|
throw 'You need to configure at least 1 "blockchain": "token"';
|
|
22711
|
-
|
|
22712
21864
|
case 3:
|
|
22713
21865
|
if (!(Object.keys(sell).length == 0)) {
|
|
22714
21866
|
_context.next = 5;
|
|
22715
21867
|
break;
|
|
22716
21868
|
}
|
|
22717
|
-
|
|
22718
21869
|
throw 'You need to configure at least 1 "blockchain": "token"';
|
|
22719
|
-
|
|
22720
21870
|
case 5:
|
|
22721
21871
|
if (!(Object.values(sell).length == 0)) {
|
|
22722
21872
|
_context.next = 7;
|
|
22723
21873
|
break;
|
|
22724
21874
|
}
|
|
22725
|
-
|
|
22726
21875
|
throw 'You need to configure at least 1 "blockchain": "token"';
|
|
22727
|
-
|
|
22728
21876
|
case 7:
|
|
22729
21877
|
case "end":
|
|
22730
21878
|
return _context.stop();
|
|
@@ -22732,27 +21880,24 @@ var preflight = /*#__PURE__*/function () {
|
|
|
22732
21880
|
}
|
|
22733
21881
|
}, _callee);
|
|
22734
21882
|
}));
|
|
22735
|
-
|
|
22736
21883
|
return function preflight(_x) {
|
|
22737
21884
|
return _ref2.apply(this, arguments);
|
|
22738
21885
|
};
|
|
22739
21886
|
}();
|
|
22740
|
-
|
|
22741
21887
|
var Sale = /*#__PURE__*/function () {
|
|
22742
21888
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(_ref3) {
|
|
22743
|
-
var amount, sell, sent,
|
|
21889
|
+
var amount, sell, sent, succeeded, failed, error, critical, style, blacklist, providers, currency, connected, closed, tokenImage, closable, integration, document, accept, unmount;
|
|
22744
21890
|
return regenerator.wrap(function _callee2$(_context2) {
|
|
22745
21891
|
while (1) {
|
|
22746
21892
|
switch (_context2.prev = _context2.next) {
|
|
22747
21893
|
case 0:
|
|
22748
|
-
amount = _ref3.amount, sell = _ref3.sell, sent = _ref3.sent,
|
|
21894
|
+
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;
|
|
22749
21895
|
requireReactVersion();
|
|
22750
21896
|
_context2.prev = 2;
|
|
22751
21897
|
_context2.next = 5;
|
|
22752
21898
|
return preflight({
|
|
22753
21899
|
sell: sell
|
|
22754
21900
|
});
|
|
22755
|
-
|
|
22756
21901
|
case 5:
|
|
22757
21902
|
accept = Object.keys(sell).map(function (key) {
|
|
22758
21903
|
return {
|
|
@@ -22778,7 +21923,7 @@ var Sale = /*#__PURE__*/function () {
|
|
|
22778
21923
|
sell: sell,
|
|
22779
21924
|
currency: currency,
|
|
22780
21925
|
sent: sent,
|
|
22781
|
-
|
|
21926
|
+
succeeded: succeeded,
|
|
22782
21927
|
failed: failed,
|
|
22783
21928
|
blacklist: blacklist,
|
|
22784
21929
|
providers: providers,
|
|
@@ -22807,16 +21952,13 @@ var Sale = /*#__PURE__*/function () {
|
|
|
22807
21952
|
return _context2.abrupt("return", {
|
|
22808
21953
|
unmount: unmount
|
|
22809
21954
|
});
|
|
22810
|
-
|
|
22811
21955
|
case 10:
|
|
22812
21956
|
_context2.prev = 10;
|
|
22813
21957
|
_context2.t0 = _context2["catch"](2);
|
|
22814
21958
|
console.log('critical error', _context2.t0);
|
|
22815
|
-
|
|
22816
21959
|
if (critical != undefined) {
|
|
22817
21960
|
critical(_context2.t0);
|
|
22818
21961
|
}
|
|
22819
|
-
|
|
22820
21962
|
case 14:
|
|
22821
21963
|
case "end":
|
|
22822
21964
|
return _context2.stop();
|
|
@@ -22824,7 +21966,6 @@ var Sale = /*#__PURE__*/function () {
|
|
|
22824
21966
|
}
|
|
22825
21967
|
}, _callee2, null, [[2, 10]]);
|
|
22826
21968
|
}));
|
|
22827
|
-
|
|
22828
21969
|
return function Sale(_x2) {
|
|
22829
21970
|
return _ref4.apply(this, arguments);
|
|
22830
21971
|
};
|
|
@@ -22834,10 +21975,9 @@ var SelectionContext = /*#__PURE__*/React.createContext();
|
|
|
22834
21975
|
|
|
22835
21976
|
var SelectionProvider = (function (props) {
|
|
22836
21977
|
var _useState = useState({}),
|
|
22837
|
-
|
|
22838
|
-
|
|
22839
|
-
|
|
22840
|
-
|
|
21978
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
21979
|
+
selection = _useState2[0],
|
|
21980
|
+
setSelection = _useState2[1];
|
|
22841
21981
|
return /*#__PURE__*/React.createElement(SelectionContext.Provider, {
|
|
22842
21982
|
value: {
|
|
22843
21983
|
selection: selection,
|
|
@@ -22871,25 +22011,20 @@ var msToTime = (function (ms) {
|
|
|
22871
22011
|
|
|
22872
22012
|
var ConfirmTokenSelectionDialog = (function (props) {
|
|
22873
22013
|
var _useContext = useContext(SelectionContext),
|
|
22874
|
-
|
|
22875
|
-
|
|
22014
|
+
selection = _useContext.selection;
|
|
22876
22015
|
var _useContext2 = useContext(ClosableContext),
|
|
22877
|
-
|
|
22878
|
-
|
|
22016
|
+
setOpen = _useContext2.setOpen;
|
|
22879
22017
|
var token = selection.token;
|
|
22880
22018
|
var address = token.address || token.external_id;
|
|
22881
22019
|
var logo = token.logo || token.image;
|
|
22882
22020
|
var blockchain = Blockchain.findByName(token.blockchain);
|
|
22883
22021
|
var age = token.first_transfer ? msToTime(new Date() - new Date(token.first_transfer)) : undefined;
|
|
22884
|
-
|
|
22885
22022
|
if (age) {
|
|
22886
22023
|
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) {
|
|
22887
22024
|
return n;
|
|
22888
22025
|
}).join(' ');
|
|
22889
22026
|
}
|
|
22890
|
-
|
|
22891
22027
|
var holders = token.unique_senders ? token.unique_senders : undefined;
|
|
22892
|
-
|
|
22893
22028
|
if (holders) {
|
|
22894
22029
|
if (holders > 1000000) {
|
|
22895
22030
|
holders = "Millions";
|
|
@@ -22903,7 +22038,6 @@ var ConfirmTokenSelectionDialog = (function (props) {
|
|
|
22903
22038
|
holders = "Only a Few!!!";
|
|
22904
22039
|
}
|
|
22905
22040
|
}
|
|
22906
|
-
|
|
22907
22041
|
var onClickConfirm = function onClickConfirm() {
|
|
22908
22042
|
setOpen(false);
|
|
22909
22043
|
props.resolve({
|
|
@@ -22916,7 +22050,6 @@ var ConfirmTokenSelectionDialog = (function (props) {
|
|
|
22916
22050
|
});
|
|
22917
22051
|
setTimeout(props.unmount, 300);
|
|
22918
22052
|
};
|
|
22919
|
-
|
|
22920
22053
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
22921
22054
|
header: /*#__PURE__*/React.createElement("div", {
|
|
22922
22055
|
className: "PaddingTopS PaddingLeftM PaddingRightM TextLeft"
|
|
@@ -22974,26 +22107,21 @@ var ConfirmTokenSelectionDialog = (function (props) {
|
|
|
22974
22107
|
|
|
22975
22108
|
var SelectBlockchainDialog = (function (props) {
|
|
22976
22109
|
var _useContext = useContext(SelectionContext),
|
|
22977
|
-
|
|
22978
|
-
|
|
22110
|
+
setSelection = _useContext.setSelection;
|
|
22979
22111
|
var _useContext2 = useContext(NavigateStackContext),
|
|
22980
|
-
|
|
22981
|
-
|
|
22112
|
+
navigate = _useContext2.navigate;
|
|
22982
22113
|
var stacked = Object.keys(props.selection).length > 1;
|
|
22983
22114
|
var blockchains = [Blockchain.findByName('ethereum'), Blockchain.findByName('bsc'), Blockchain.findByName('polygon')];
|
|
22984
|
-
|
|
22985
22115
|
var selectBlockchain = function selectBlockchain(blockchain) {
|
|
22986
22116
|
setSelection(Object.assign(props.selection, {
|
|
22987
22117
|
blockchain: blockchain
|
|
22988
22118
|
}));
|
|
22989
|
-
|
|
22990
22119
|
if (stacked) {
|
|
22991
22120
|
navigate('back');
|
|
22992
22121
|
} else {
|
|
22993
22122
|
props.resolve(blockchain);
|
|
22994
22123
|
}
|
|
22995
22124
|
};
|
|
22996
|
-
|
|
22997
22125
|
var elements = blockchains.map(function (blockchain, index) {
|
|
22998
22126
|
return /*#__PURE__*/React.createElement("div", {
|
|
22999
22127
|
key: index,
|
|
@@ -23031,42 +22159,33 @@ var SelectBlockchainDialog = (function (props) {
|
|
|
23031
22159
|
|
|
23032
22160
|
var SelectTokenDialog = (function (props) {
|
|
23033
22161
|
var _useContext = useContext(NavigateStackContext),
|
|
23034
|
-
|
|
23035
|
-
|
|
22162
|
+
navigate = _useContext.navigate;
|
|
23036
22163
|
var _useContext2 = useContext(ClosableContext),
|
|
23037
|
-
|
|
23038
|
-
|
|
22164
|
+
setOpen = _useContext2.setOpen;
|
|
23039
22165
|
var _useContext3 = useContext(SelectionContext),
|
|
23040
|
-
|
|
23041
|
-
|
|
22166
|
+
setSelection = _useContext3.setSelection;
|
|
23042
22167
|
var _useState = useState(''),
|
|
23043
|
-
|
|
23044
|
-
|
|
23045
|
-
|
|
23046
|
-
|
|
22168
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
22169
|
+
searchTerm = _useState2[0],
|
|
22170
|
+
setSearchTerm = _useState2[1];
|
|
23047
22171
|
var _useState3 = useState(),
|
|
23048
|
-
|
|
23049
|
-
|
|
23050
|
-
|
|
23051
|
-
|
|
22172
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
22173
|
+
blockchain = _useState4[0],
|
|
22174
|
+
setBlockchain = _useState4[1];
|
|
23052
22175
|
var _useState5 = useState(false),
|
|
23053
|
-
|
|
23054
|
-
|
|
23055
|
-
|
|
23056
|
-
|
|
22176
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
22177
|
+
showAddToken = _useState6[0],
|
|
22178
|
+
setShowAddToken = _useState6[1];
|
|
23057
22179
|
var _useState7 = useState([]),
|
|
23058
|
-
|
|
23059
|
-
|
|
23060
|
-
|
|
23061
|
-
|
|
22180
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
22181
|
+
tokens = _useState8[0],
|
|
22182
|
+
setTokens = _useState8[1];
|
|
23062
22183
|
var _useState9 = useState(),
|
|
23063
|
-
|
|
23064
|
-
|
|
23065
|
-
|
|
23066
|
-
|
|
22184
|
+
_useState10 = _slicedToArray(_useState9, 2);
|
|
22185
|
+
_useState10[0];
|
|
22186
|
+
_useState10[1];
|
|
23067
22187
|
var searchElement = useRef();
|
|
23068
|
-
var wallet =
|
|
23069
|
-
|
|
22188
|
+
var wallet = getWallets()[0];
|
|
23070
22189
|
var startWithBlockchain = function startWithBlockchain(name) {
|
|
23071
22190
|
var blockchain = Blockchain.findByName(name);
|
|
23072
22191
|
setBlockchain(blockchain);
|
|
@@ -23076,12 +22195,10 @@ var SelectTokenDialog = (function (props) {
|
|
|
23076
22195
|
}));
|
|
23077
22196
|
setTokens(blockchain.tokens);
|
|
23078
22197
|
};
|
|
23079
|
-
|
|
23080
22198
|
useEffect(function () {
|
|
23081
22199
|
if (wallet) {
|
|
23082
22200
|
wallet.connectedTo().then(function (name) {
|
|
23083
22201
|
var blockchain = Blockchain.findByName(name);
|
|
23084
|
-
|
|
23085
22202
|
if (name && name.length && blockchain && blockchain.tokens && blockchain.tokens.length) {
|
|
23086
22203
|
startWithBlockchain(name);
|
|
23087
22204
|
} else {
|
|
@@ -23096,27 +22213,22 @@ var SelectTokenDialog = (function (props) {
|
|
|
23096
22213
|
if (props.selection.blockchain) {
|
|
23097
22214
|
setBlockchain(props.selection.blockchain);
|
|
23098
22215
|
setTokens(props.selection.blockchain.tokens);
|
|
23099
|
-
|
|
23100
22216
|
if (searchElement.current) {
|
|
23101
22217
|
searchElement.current.value = '';
|
|
23102
22218
|
searchElement.current.focus();
|
|
23103
22219
|
}
|
|
23104
22220
|
}
|
|
23105
22221
|
}, [props.selection, props.selection.blockchain]);
|
|
23106
|
-
|
|
23107
22222
|
var onClickChangeBlockchain = function onClickChangeBlockchain() {
|
|
23108
22223
|
navigate('SelectBlockchain');
|
|
23109
22224
|
};
|
|
23110
|
-
|
|
23111
22225
|
var onClickAddToken = function onClickAddToken() {
|
|
23112
22226
|
setShowAddToken(true);
|
|
23113
|
-
|
|
23114
22227
|
if (searchElement.current) {
|
|
23115
22228
|
searchElement.current.value = '';
|
|
23116
22229
|
searchElement.current.focus();
|
|
23117
22230
|
}
|
|
23118
22231
|
};
|
|
23119
|
-
|
|
23120
22232
|
var searchTokens = useCallback(lodash.debounce(function (term, blockchainName) {
|
|
23121
22233
|
fetch("https://public.depay.com/tokens/search?blockchain=".concat(blockchainName, "&term=").concat(term)).then(function (response) {
|
|
23122
22234
|
if (response.status == 200) {
|
|
@@ -23132,32 +22244,26 @@ var SelectTokenDialog = (function (props) {
|
|
|
23132
22244
|
return reject;
|
|
23133
22245
|
});
|
|
23134
22246
|
}, 300), []);
|
|
23135
|
-
|
|
23136
22247
|
var onChangeSearch = function onChangeSearch(event) {
|
|
23137
22248
|
var term = event.target.value;
|
|
23138
22249
|
setSearchTerm(term);
|
|
23139
|
-
|
|
23140
22250
|
if (term.match(/^0x/)) {
|
|
23141
22251
|
setTokens([]);
|
|
23142
22252
|
var token;
|
|
23143
|
-
|
|
23144
22253
|
try {
|
|
23145
22254
|
token = new Token({
|
|
23146
22255
|
blockchain: blockchain.name,
|
|
23147
22256
|
address: term
|
|
23148
22257
|
});
|
|
23149
22258
|
} catch (_unused) {}
|
|
23150
|
-
|
|
23151
22259
|
if (token == undefined) {
|
|
23152
22260
|
return;
|
|
23153
22261
|
}
|
|
23154
|
-
|
|
23155
22262
|
Promise.all([token.name(), token.symbol(), token.decimals()]).then(function (_ref) {
|
|
23156
22263
|
var _ref2 = _slicedToArray(_ref, 3),
|
|
23157
|
-
|
|
23158
|
-
|
|
23159
|
-
|
|
23160
|
-
|
|
22264
|
+
name = _ref2[0],
|
|
22265
|
+
symbol = _ref2[1],
|
|
22266
|
+
decimals = _ref2[2];
|
|
23161
22267
|
setTokens([{
|
|
23162
22268
|
name: name,
|
|
23163
22269
|
symbol: symbol,
|
|
@@ -23173,7 +22279,6 @@ var SelectTokenDialog = (function (props) {
|
|
|
23173
22279
|
setTokens(blockchain.tokens);
|
|
23174
22280
|
}
|
|
23175
22281
|
};
|
|
23176
|
-
|
|
23177
22282
|
var select = function select(token) {
|
|
23178
22283
|
if (blockchain.tokens.find(function (majorToken) {
|
|
23179
22284
|
return majorToken.address.toLowerCase() == (token.address || token.external_id).toLowerCase();
|
|
@@ -23195,7 +22300,6 @@ var SelectTokenDialog = (function (props) {
|
|
|
23195
22300
|
navigate('ConfirmTokenSelection');
|
|
23196
22301
|
}
|
|
23197
22302
|
};
|
|
23198
|
-
|
|
23199
22303
|
var elements = tokens.map(function (token, index) {
|
|
23200
22304
|
return /*#__PURE__*/React.createElement("div", {
|
|
23201
22305
|
key: "".concat(index, "-").concat(token.address),
|
|
@@ -23226,11 +22330,9 @@ var SelectTokenDialog = (function (props) {
|
|
|
23226
22330
|
className: "CardText"
|
|
23227
22331
|
}, token.name))));
|
|
23228
22332
|
});
|
|
23229
|
-
|
|
23230
22333
|
if (blockchain == undefined) {
|
|
23231
22334
|
return null;
|
|
23232
22335
|
}
|
|
23233
|
-
|
|
23234
22336
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
23235
22337
|
header: /*#__PURE__*/React.createElement("div", {
|
|
23236
22338
|
className: "PaddingTopS PaddingLeftM PaddingRightM TextLeft"
|
|
@@ -23283,22 +22385,17 @@ var SelectTokenDialog = (function (props) {
|
|
|
23283
22385
|
|
|
23284
22386
|
var SelectStack = (function (props) {
|
|
23285
22387
|
var _useContext = useContext(ConfigurationContext),
|
|
23286
|
-
|
|
23287
|
-
|
|
22388
|
+
what = _useContext.what;
|
|
23288
22389
|
var _useContext2 = useContext(ClosableContext),
|
|
23289
|
-
|
|
23290
|
-
|
|
23291
|
-
|
|
22390
|
+
open = _useContext2.open,
|
|
22391
|
+
close = _useContext2.close;
|
|
23292
22392
|
var _useContext3 = useContext(SelectionContext),
|
|
23293
|
-
|
|
23294
|
-
|
|
22393
|
+
selection = _useContext3.selection;
|
|
23295
22394
|
var start;
|
|
23296
|
-
|
|
23297
22395
|
switch (what) {
|
|
23298
22396
|
default:
|
|
23299
22397
|
start = 'SelectToken';
|
|
23300
22398
|
}
|
|
23301
|
-
|
|
23302
22399
|
return /*#__PURE__*/React.createElement(ReactDialogStack, {
|
|
23303
22400
|
open: open,
|
|
23304
22401
|
close: close,
|
|
@@ -23327,22 +22424,18 @@ var SelectStack = (function (props) {
|
|
|
23327
22424
|
var Select = function Select(options) {
|
|
23328
22425
|
requireReactVersion();
|
|
23329
22426
|
var style, error, document, what;
|
|
23330
|
-
|
|
23331
22427
|
if (_typeof(options) == 'object') {
|
|
23332
22428
|
style = options.style;
|
|
23333
22429
|
error = options.error;
|
|
23334
22430
|
document = options.document;
|
|
23335
22431
|
what = options.what;
|
|
23336
22432
|
}
|
|
23337
|
-
|
|
23338
22433
|
var startupError;
|
|
23339
|
-
|
|
23340
22434
|
if (what == undefined) {
|
|
23341
22435
|
startupError = '"what" needs to be configured!';
|
|
23342
22436
|
} else if (['token'].indexOf(what) < 0) {
|
|
23343
22437
|
startupError = "Unknown \"what\" configured: ".concat(what, "!");
|
|
23344
22438
|
}
|
|
23345
|
-
|
|
23346
22439
|
return new Promise( /*#__PURE__*/function () {
|
|
23347
22440
|
var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(resolve, reject) {
|
|
23348
22441
|
return regenerator.wrap(function _callee$(_context) {
|
|
@@ -23357,7 +22450,6 @@ var Select = function Select(options) {
|
|
|
23357
22450
|
reject('USER_CLOSED_DIALOG');
|
|
23358
22451
|
unmount();
|
|
23359
22452
|
};
|
|
23360
|
-
|
|
23361
22453
|
return function (container) {
|
|
23362
22454
|
return /*#__PURE__*/React.createElement(ErrorProvider, {
|
|
23363
22455
|
error: startupError,
|
|
@@ -23378,7 +22470,6 @@ var Select = function Select(options) {
|
|
|
23378
22470
|
})), /*#__PURE__*/React.createElement(PoweredBy, null)))));
|
|
23379
22471
|
};
|
|
23380
22472
|
});
|
|
23381
|
-
|
|
23382
22473
|
case 1:
|
|
23383
22474
|
case "end":
|
|
23384
22475
|
return _context.stop();
|
|
@@ -23386,7 +22477,6 @@ var Select = function Select(options) {
|
|
|
23386
22477
|
}
|
|
23387
22478
|
}, _callee);
|
|
23388
22479
|
}));
|
|
23389
|
-
|
|
23390
22480
|
return function (_x, _x2) {
|
|
23391
22481
|
return _ref.apply(this, arguments);
|
|
23392
22482
|
};
|
|
@@ -23399,8 +22489,7 @@ var DePayWidgets = {
|
|
|
23399
22489
|
Login: Login,
|
|
23400
22490
|
Payment: Payment,
|
|
23401
22491
|
Sale: Sale,
|
|
23402
|
-
Select: Select
|
|
23403
|
-
provider: provider
|
|
22492
|
+
Select: Select
|
|
23404
22493
|
};
|
|
23405
22494
|
|
|
23406
22495
|
export { DePayWidgets as default };
|