@depay/widgets 7.16.4 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -14
- package/dist/esm/index.bundle.js +22 -18
- package/dist/esm/index.js +528 -1438
- package/dist/umd/index.bundle.js +22 -18
- package/dist/umd/index.js +526 -1436
- 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 (_amountInWithSlippage == undefined || selectedRoute.fromAmount != _amountInWithSlippage.toString()) {
|
|
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,145 +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 = 7;
|
|
20116
|
-
break;
|
|
20117
|
-
}
|
|
20118
|
-
|
|
20119
|
-
_context9.next = 6;
|
|
20120
|
-
return roundAmount(selectedRoute, amountInWithSlippage);
|
|
20121
|
-
|
|
20122
|
-
case 6:
|
|
20123
|
-
setUpdatedRouteWithNewPrice(selectedRoute);
|
|
20124
|
-
|
|
20125
|
-
case 7:
|
|
20126
|
-
case "end":
|
|
20127
|
-
return _context9.stop();
|
|
20128
|
-
}
|
|
20129
|
-
}
|
|
20130
|
-
}, _callee9);
|
|
20131
|
-
}));
|
|
20132
|
-
return _updateRouteWithAmountInWithSlippage.apply(this, arguments);
|
|
20133
|
-
}
|
|
20134
|
-
|
|
20135
|
-
if (selectedRoute) {
|
|
20136
|
-
updateRouteWithAmountInWithSlippage();
|
|
20137
|
-
}
|
|
20138
|
-
}, [selectedRoute]);
|
|
20139
19541
|
useEffect(function () {
|
|
20140
19542
|
var timeout = setTimeout(function () {
|
|
20141
19543
|
setReloadCount(reloadCount + 1);
|
|
@@ -20172,55 +19574,42 @@ var PaymentValueContext = /*#__PURE__*/React.createContext();
|
|
|
20172
19574
|
|
|
20173
19575
|
var PaymentValueProvider = (function (props) {
|
|
20174
19576
|
var _useContext = useContext(ErrorContext),
|
|
20175
|
-
|
|
20176
|
-
|
|
19577
|
+
setError = _useContext.setError;
|
|
20177
19578
|
var _useContext2 = useContext(WalletContext),
|
|
20178
|
-
|
|
20179
|
-
|
|
19579
|
+
account = _useContext2.account;
|
|
20180
19580
|
var _useContext3 = useContext(UpdatableContext),
|
|
20181
|
-
|
|
20182
|
-
|
|
19581
|
+
updatable = _useContext3.updatable;
|
|
20183
19582
|
var _useContext4 = useContext(ConfigurationContext),
|
|
20184
|
-
|
|
20185
|
-
|
|
20186
|
-
|
|
19583
|
+
configuredAmount = _useContext4.amount,
|
|
19584
|
+
currencyCode = _useContext4.currencyCode;
|
|
20187
19585
|
var _useContext5 = useContext(ChangableAmountContext),
|
|
20188
|
-
|
|
20189
|
-
|
|
19586
|
+
amount = _useContext5.amount;
|
|
20190
19587
|
var _useContext6 = useContext(PaymentContext),
|
|
20191
|
-
|
|
20192
|
-
|
|
19588
|
+
payment = _useContext6.payment;
|
|
20193
19589
|
var _useState = useState(),
|
|
20194
|
-
|
|
20195
|
-
|
|
20196
|
-
|
|
20197
|
-
|
|
19590
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
19591
|
+
paymentValue = _useState2[0],
|
|
19592
|
+
setPaymentValue = _useState2[1];
|
|
20198
19593
|
var _useState3 = useState(),
|
|
20199
|
-
|
|
20200
|
-
|
|
20201
|
-
|
|
20202
|
-
|
|
19594
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
19595
|
+
displayedPaymentValue = _useState4[0],
|
|
19596
|
+
setDisplayedPaymentValue = _useState4[1];
|
|
20203
19597
|
var _useState5 = useState(),
|
|
20204
|
-
|
|
20205
|
-
|
|
20206
|
-
|
|
20207
|
-
|
|
19598
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
19599
|
+
paymentValueLoss = _useState6[0],
|
|
19600
|
+
setPaymentValueLoss = _useState6[1];
|
|
20208
19601
|
var _useContext7 = useContext(ConfigurationContext),
|
|
20209
|
-
|
|
20210
|
-
|
|
19602
|
+
currency = _useContext7.currency;
|
|
20211
19603
|
var _useState7 = useState(0),
|
|
20212
|
-
|
|
20213
|
-
|
|
20214
|
-
|
|
20215
|
-
|
|
19604
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
19605
|
+
reloadCount = _useState8[0],
|
|
19606
|
+
setReloadCount = _useState8[1];
|
|
20216
19607
|
var updatePaymentValue = function updatePaymentValue(_ref) {
|
|
20217
19608
|
var updatable = _ref.updatable,
|
|
20218
|
-
|
|
20219
|
-
|
|
19609
|
+
payment = _ref.payment;
|
|
20220
19610
|
if (updatable == false || (payment === null || payment === void 0 ? void 0 : payment.route) == undefined) {
|
|
20221
19611
|
return;
|
|
20222
19612
|
}
|
|
20223
|
-
|
|
20224
19613
|
Promise.all([route({
|
|
20225
19614
|
blockchain: payment.route.blockchain,
|
|
20226
19615
|
tokenIn: payment.route.fromToken.address,
|
|
@@ -20240,27 +19629,22 @@ var PaymentValueProvider = (function (props) {
|
|
|
20240
19629
|
address: CONSTANTS[payment.route.blockchain].USD
|
|
20241
19630
|
}).decimals()]).then(function (_ref2) {
|
|
20242
19631
|
var _ref3 = _slicedToArray(_ref2, 3),
|
|
20243
|
-
|
|
20244
|
-
|
|
20245
|
-
|
|
20246
|
-
|
|
19632
|
+
fromTokenUSDExchangeRoutes = _ref3[0],
|
|
19633
|
+
reverseRoutes = _ref3[1],
|
|
19634
|
+
USDDecimals = _ref3[2];
|
|
20247
19635
|
var fromTokenUSDRoute = fromTokenUSDExchangeRoutes[0];
|
|
20248
19636
|
var reverseRoute = reverseRoutes[0];
|
|
20249
|
-
|
|
20250
19637
|
if (reverseRoute) {
|
|
20251
19638
|
var reverseAmountOutBN = ethers.BigNumber.from(reverseRoute.amountOut);
|
|
20252
19639
|
var paymentAmountInBN = ethers.BigNumber.from(payment.route.fromAmount);
|
|
20253
19640
|
var divPercent = 100 - reverseAmountOutBN.mul(ethers.BigNumber.from('100')).div(paymentAmountInBN).abs().toString();
|
|
20254
|
-
|
|
20255
19641
|
if (divPercent >= 10) {
|
|
20256
19642
|
setPaymentValueLoss(divPercent);
|
|
20257
19643
|
} else {
|
|
20258
19644
|
setPaymentValueLoss(null);
|
|
20259
19645
|
}
|
|
20260
19646
|
}
|
|
20261
|
-
|
|
20262
19647
|
var fromTokenUSDAmount;
|
|
20263
|
-
|
|
20264
19648
|
if (payment.route.fromToken.address.toLowerCase() == CONSTANTS[payment.route.blockchain].USD.toLowerCase()) {
|
|
20265
19649
|
fromTokenUSDAmount = payment.route.fromAmount.toString();
|
|
20266
19650
|
} else if (fromTokenUSDRoute == undefined) {
|
|
@@ -20269,7 +19653,6 @@ var PaymentValueProvider = (function (props) {
|
|
|
20269
19653
|
} else {
|
|
20270
19654
|
fromTokenUSDAmount = fromTokenUSDRoute.amountOut.toString();
|
|
20271
19655
|
}
|
|
20272
|
-
|
|
20273
19656
|
var fromTokenUSDValue = ethers.utils.formatUnits(fromTokenUSDAmount, USDDecimals);
|
|
20274
19657
|
Currency.fromUSD({
|
|
20275
19658
|
amount: fromTokenUSDValue,
|
|
@@ -20277,7 +19660,6 @@ var PaymentValueProvider = (function (props) {
|
|
|
20277
19660
|
}).then(setPaymentValue);
|
|
20278
19661
|
})["catch"](setError);
|
|
20279
19662
|
};
|
|
20280
|
-
|
|
20281
19663
|
useEffect(function () {
|
|
20282
19664
|
if (paymentValue && amount && configuredAmount && configuredAmount.currency && configuredAmount.fix) {
|
|
20283
19665
|
setDisplayedPaymentValue(paymentValue.toString());
|
|
@@ -20322,14 +19704,12 @@ var PaymentValueProvider = (function (props) {
|
|
|
20322
19704
|
|
|
20323
19705
|
var DonationRoutingProvider = (function (props) {
|
|
20324
19706
|
var _useContext = useContext(ChangableAmountContext),
|
|
20325
|
-
|
|
20326
|
-
|
|
20327
|
-
|
|
19707
|
+
acceptWithAmount = _useContext.acceptWithAmount,
|
|
19708
|
+
setMaxRoute = _useContext.setMaxRoute;
|
|
20328
19709
|
var _useContext2 = useContext(ConfigurationContext),
|
|
20329
|
-
|
|
20330
|
-
|
|
20331
|
-
|
|
20332
|
-
|
|
19710
|
+
blacklist = _useContext2.blacklist,
|
|
19711
|
+
whitelist = _useContext2.whitelist,
|
|
19712
|
+
fee = _useContext2.fee;
|
|
20333
19713
|
return /*#__PURE__*/React.createElement(DonationRoutingContext.Provider, {
|
|
20334
19714
|
value: {}
|
|
20335
19715
|
}, /*#__PURE__*/React.createElement(PaymentRoutingProvider, {
|
|
@@ -20346,9 +19726,7 @@ var DonationRoutingProvider = (function (props) {
|
|
|
20346
19726
|
|
|
20347
19727
|
var format = (function (input) {
|
|
20348
19728
|
var _float = round(input);
|
|
20349
|
-
|
|
20350
19729
|
var floatToString = _float.toString();
|
|
20351
|
-
|
|
20352
19730
|
if (new RegExp(/\./).test(floatToString)) {
|
|
20353
19731
|
var exploded = floatToString.split('.');
|
|
20354
19732
|
return new Intl.NumberFormat().format(parseInt(exploded[0])) + '.' + exploded[1];
|
|
@@ -20359,81 +19737,61 @@ var format = (function (input) {
|
|
|
20359
19737
|
|
|
20360
19738
|
var ChangeAmountDialog = (function (props) {
|
|
20361
19739
|
var _useContext = useContext(NavigateStackContext),
|
|
20362
|
-
|
|
20363
|
-
|
|
19740
|
+
navigate = _useContext.navigate;
|
|
20364
19741
|
var _useContext2 = useContext(ErrorContext);
|
|
20365
|
-
|
|
20366
|
-
|
|
19742
|
+
_useContext2.setError;
|
|
20367
19743
|
var _useContext3 = useContext(WalletContext);
|
|
20368
|
-
|
|
20369
|
-
|
|
19744
|
+
_useContext3.account;
|
|
20370
19745
|
var _useContext4 = useContext(ChangableAmountContext),
|
|
20371
|
-
|
|
20372
|
-
|
|
20373
|
-
|
|
20374
|
-
|
|
19746
|
+
amount = _useContext4.amount,
|
|
19747
|
+
setAmount = _useContext4.setAmount,
|
|
19748
|
+
maxAmount = _useContext4.maxAmount;
|
|
20375
19749
|
var _useContext5 = useContext(PaymentValueContext);
|
|
20376
|
-
|
|
20377
|
-
|
|
19750
|
+
_useContext5.displayedPaymentValue;
|
|
20378
19751
|
var _useState = useState(amount),
|
|
20379
|
-
|
|
20380
|
-
|
|
20381
|
-
|
|
20382
|
-
|
|
19752
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
19753
|
+
inputAmount = _useState2[0],
|
|
19754
|
+
setInputAmount = _useState2[1];
|
|
20383
19755
|
var _useContext6 = useContext(ConfigurationContext),
|
|
20384
|
-
|
|
20385
|
-
|
|
20386
|
-
|
|
19756
|
+
currencyCode = _useContext6.currencyCode,
|
|
19757
|
+
amountConfiguration = _useContext6.amount;
|
|
20387
19758
|
var _useContext7 = useContext(PaymentRoutingContext);
|
|
20388
|
-
|
|
20389
|
-
|
|
20390
|
-
|
|
19759
|
+
_useContext7.allRoutes;
|
|
19760
|
+
var setSelectedRoute = _useContext7.setSelectedRoute;
|
|
20391
19761
|
var min = _typeof(amountConfiguration) == "object" && amountConfiguration.min ? amountConfiguration.min : 1;
|
|
20392
19762
|
var step = _typeof(amountConfiguration) == "object" && amountConfiguration.step ? amountConfiguration.step : 1;
|
|
20393
19763
|
var displayedCurrencyCode = amountConfiguration != undefined && amountConfiguration.token ? null : currencyCode;
|
|
20394
|
-
|
|
20395
19764
|
var changeAmountAndGoBack = function changeAmountAndGoBack() {
|
|
20396
19765
|
var newAmount = toValidValue(parseFloat(inputAmount));
|
|
20397
|
-
|
|
20398
19766
|
if (newAmount != amount) {
|
|
20399
19767
|
setSelectedRoute(undefined);
|
|
20400
19768
|
setAmount(newAmount);
|
|
20401
19769
|
}
|
|
20402
|
-
|
|
20403
19770
|
navigate('back');
|
|
20404
19771
|
};
|
|
20405
|
-
|
|
20406
19772
|
var changeAmount = function changeAmount(value) {
|
|
20407
19773
|
if (Number.isNaN(value)) {
|
|
20408
19774
|
return;
|
|
20409
19775
|
}
|
|
20410
|
-
|
|
20411
19776
|
setInputAmount(value);
|
|
20412
19777
|
};
|
|
20413
|
-
|
|
20414
19778
|
var toValidStep = function toValidStep(value) {
|
|
20415
19779
|
if (step) {
|
|
20416
19780
|
value = parseFloat(new Decimal(Math.floor(new Decimal(value).div(step))).mul(step).toString());
|
|
20417
19781
|
}
|
|
20418
|
-
|
|
20419
19782
|
return value;
|
|
20420
19783
|
};
|
|
20421
|
-
|
|
20422
19784
|
var toValidValue = function toValidValue(value) {
|
|
20423
19785
|
value = toValidStep(value);
|
|
20424
|
-
|
|
20425
19786
|
if (maxAmount) {
|
|
20426
19787
|
value = Math.max(min, Math.min(value, maxAmount));
|
|
20427
19788
|
}
|
|
20428
|
-
|
|
20429
19789
|
value = toValidStep(value);
|
|
20430
19790
|
return value;
|
|
20431
19791
|
};
|
|
20432
|
-
|
|
20433
19792
|
var setValidValue = function setValidValue(value) {
|
|
20434
19793
|
setInputAmount(toValidValue(value));
|
|
20435
19794
|
};
|
|
20436
|
-
|
|
20437
19795
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
20438
19796
|
stacked: true,
|
|
20439
19797
|
header: /*#__PURE__*/React.createElement("div", {
|
|
@@ -20488,8 +19846,7 @@ var ChangeAmountDialog = (function (props) {
|
|
|
20488
19846
|
|
|
20489
19847
|
var ChangePaymentSkeleton = (function (props) {
|
|
20490
19848
|
var _useContext = useContext(PaymentValueContext),
|
|
20491
|
-
|
|
20492
|
-
|
|
19849
|
+
paymentValue = _useContext.paymentValue;
|
|
20493
19850
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
20494
19851
|
stacked: true,
|
|
20495
19852
|
header: /*#__PURE__*/React.createElement("div", {
|
|
@@ -20521,34 +19878,27 @@ var ChangePaymentSkeleton = (function (props) {
|
|
|
20521
19878
|
|
|
20522
19879
|
var ChangePaymentDialog = (function (props) {
|
|
20523
19880
|
var _useContext = useContext(ErrorContext),
|
|
20524
|
-
|
|
20525
|
-
|
|
19881
|
+
setError = _useContext.setError;
|
|
20526
19882
|
var _useContext2 = useContext(PaymentRoutingContext),
|
|
20527
|
-
|
|
20528
|
-
|
|
20529
|
-
|
|
19883
|
+
allRoutes = _useContext2.allRoutes,
|
|
19884
|
+
setSelectedRoute = _useContext2.setSelectedRoute;
|
|
20530
19885
|
var _useContext3 = useContext(PaymentValueContext);
|
|
20531
|
-
|
|
20532
|
-
|
|
20533
|
-
|
|
19886
|
+
_useContext3.paymentValue;
|
|
19887
|
+
var displayedPaymentValue = _useContext3.displayedPaymentValue;
|
|
20534
19888
|
var _useContext4 = useContext(NavigateStackContext),
|
|
20535
|
-
|
|
20536
|
-
|
|
19889
|
+
navigate = _useContext4.navigate;
|
|
20537
19890
|
var _useState = useState([]),
|
|
20538
|
-
|
|
20539
|
-
|
|
20540
|
-
|
|
20541
|
-
|
|
19891
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
19892
|
+
allPaymentRoutesWithData = _useState2[0],
|
|
19893
|
+
setAllPaymentRoutesWithData = _useState2[1];
|
|
20542
19894
|
var _useState3 = useState([]),
|
|
20543
|
-
|
|
20544
|
-
|
|
20545
|
-
|
|
20546
|
-
|
|
19895
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
19896
|
+
cards = _useState4[0],
|
|
19897
|
+
setCards = _useState4[1];
|
|
20547
19898
|
useEffect(function () {
|
|
20548
19899
|
if (allRoutes == undefined) {
|
|
20549
19900
|
return;
|
|
20550
19901
|
}
|
|
20551
|
-
|
|
20552
19902
|
Promise.all(allRoutes.map(function (route) {
|
|
20553
19903
|
route.exchangeRoutes[0];
|
|
20554
19904
|
route.fromToken;
|
|
@@ -20603,11 +19953,9 @@ var ChangePaymentDialog = (function (props) {
|
|
|
20603
19953
|
}, /*#__PURE__*/React.createElement("small", null, format(round(parseFloat(payment.route.fromBalance.toString()) / Math.pow(10, payment.decimals), 'down')))))));
|
|
20604
19954
|
}));
|
|
20605
19955
|
}, [allPaymentRoutesWithData]);
|
|
20606
|
-
|
|
20607
19956
|
if (allPaymentRoutesWithData.length == 0 || cards.length == 0) {
|
|
20608
19957
|
return /*#__PURE__*/React.createElement(ChangePaymentSkeleton, null);
|
|
20609
19958
|
}
|
|
20610
|
-
|
|
20611
19959
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
20612
19960
|
stacked: true,
|
|
20613
19961
|
header: /*#__PURE__*/React.createElement("div", {
|
|
@@ -20628,8 +19976,7 @@ var ChangePaymentDialog = (function (props) {
|
|
|
20628
19976
|
|
|
20629
19977
|
var DonationOverviewSkeleton = (function (props) {
|
|
20630
19978
|
var _useContext = useContext(ConfigurationContext),
|
|
20631
|
-
|
|
20632
|
-
|
|
19979
|
+
title = _useContext.title;
|
|
20633
19980
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
20634
19981
|
header: /*#__PURE__*/React.createElement("div", {
|
|
20635
19982
|
className: "PaddingTopS PaddingLeftM PaddingRightM TextLeft"
|
|
@@ -20727,42 +20074,34 @@ var LoadingText = (function (props) {
|
|
|
20727
20074
|
|
|
20728
20075
|
var Footer = (function () {
|
|
20729
20076
|
var _useContext = useContext(ChangableAmountContext);
|
|
20730
|
-
|
|
20731
|
-
|
|
20732
|
-
|
|
20077
|
+
_useContext.amount;
|
|
20078
|
+
_useContext.amountsMissing;
|
|
20733
20079
|
var _useContext2 = useContext(PaymentTrackingContext),
|
|
20734
|
-
|
|
20735
|
-
|
|
20736
|
-
|
|
20737
|
-
|
|
20080
|
+
tracking = _useContext2.tracking,
|
|
20081
|
+
release = _useContext2.release,
|
|
20082
|
+
forwardTo = _useContext2.forwardTo;
|
|
20738
20083
|
var _useContext3 = useContext(PaymentContext),
|
|
20739
|
-
|
|
20740
|
-
|
|
20741
|
-
|
|
20742
|
-
|
|
20743
|
-
|
|
20744
|
-
|
|
20745
|
-
|
|
20084
|
+
payment = _useContext3.payment,
|
|
20085
|
+
paymentState = _useContext3.paymentState,
|
|
20086
|
+
pay = _useContext3.pay,
|
|
20087
|
+
transaction = _useContext3.transaction,
|
|
20088
|
+
approve = _useContext3.approve,
|
|
20089
|
+
approvalTransaction = _useContext3.approvalTransaction;
|
|
20746
20090
|
var _useContext4 = useContext(PaymentValueContext);
|
|
20747
|
-
|
|
20748
|
-
|
|
20749
|
-
|
|
20750
|
-
|
|
20091
|
+
_useContext4.paymentValue;
|
|
20092
|
+
var displayedPaymentValue = _useContext4.displayedPaymentValue,
|
|
20093
|
+
paymentValueLoss = _useContext4.paymentValueLoss;
|
|
20751
20094
|
var _useContext5 = useContext(PaymentRoutingContext),
|
|
20752
|
-
|
|
20753
|
-
|
|
20754
|
-
|
|
20095
|
+
updatedRouteWithNewPrice = _useContext5.updatedRouteWithNewPrice,
|
|
20096
|
+
updateRouteWithNewPrice = _useContext5.updateRouteWithNewPrice;
|
|
20755
20097
|
var _useContext6 = useContext(NavigateStackContext);
|
|
20756
|
-
|
|
20757
|
-
|
|
20098
|
+
_useContext6.navigate;
|
|
20758
20099
|
var _useContext7 = useContext(ClosableContext),
|
|
20759
|
-
|
|
20760
|
-
|
|
20100
|
+
close = _useContext7.close;
|
|
20761
20101
|
var trackingInfo = function trackingInfo() {
|
|
20762
20102
|
if (tracking != true) {
|
|
20763
20103
|
return null;
|
|
20764
20104
|
}
|
|
20765
|
-
|
|
20766
20105
|
if (release) {
|
|
20767
20106
|
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
20768
20107
|
className: "Card transparent small disabled"
|
|
@@ -20797,7 +20136,6 @@ var Footer = (function () {
|
|
|
20797
20136
|
}, "Validating payment")))));
|
|
20798
20137
|
}
|
|
20799
20138
|
};
|
|
20800
|
-
|
|
20801
20139
|
var additionalPaymentInformation = function additionalPaymentInformation() {
|
|
20802
20140
|
if (paymentState == 'paying' && transaction == undefined) {
|
|
20803
20141
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -20817,7 +20155,7 @@ var Footer = (function () {
|
|
|
20817
20155
|
}, /*#__PURE__*/React.createElement("div", {
|
|
20818
20156
|
className: "Opacity05"
|
|
20819
20157
|
}, "Confirm transaction in your wallet")))));
|
|
20820
|
-
} else if (paymentState == '
|
|
20158
|
+
} else if (paymentState == 'success') {
|
|
20821
20159
|
return /*#__PURE__*/React.createElement("div", {
|
|
20822
20160
|
className: "PaddingBottomS"
|
|
20823
20161
|
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("a", {
|
|
@@ -20841,7 +20179,6 @@ var Footer = (function () {
|
|
|
20841
20179
|
}, "Payment confirmed"))))), trackingInfo());
|
|
20842
20180
|
}
|
|
20843
20181
|
};
|
|
20844
|
-
|
|
20845
20182
|
var approvalButton = function approvalButton() {
|
|
20846
20183
|
if (payment.route == undefined || !payment.route.approvalRequired || payment.route.directTransfer) {
|
|
20847
20184
|
return null;
|
|
@@ -20865,7 +20202,6 @@ var Footer = (function () {
|
|
|
20865
20202
|
}, /*#__PURE__*/React.createElement(LoadingText, null, "Approving")));
|
|
20866
20203
|
}
|
|
20867
20204
|
};
|
|
20868
|
-
|
|
20869
20205
|
var mainAction = function mainAction() {
|
|
20870
20206
|
if (updatedRouteWithNewPrice) {
|
|
20871
20207
|
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
@@ -20894,7 +20230,6 @@ var Footer = (function () {
|
|
|
20894
20230
|
if (payment.route.approvalRequired && !payment.route.directTransfer) {
|
|
20895
20231
|
return;
|
|
20896
20232
|
}
|
|
20897
|
-
|
|
20898
20233
|
pay();
|
|
20899
20234
|
}
|
|
20900
20235
|
}, "Pay ", displayedPaymentValue);
|
|
@@ -20906,7 +20241,7 @@ var Footer = (function () {
|
|
|
20906
20241
|
target: "_blank",
|
|
20907
20242
|
rel: "noopener noreferrer"
|
|
20908
20243
|
}, /*#__PURE__*/React.createElement(LoadingText, null, "Paying"));
|
|
20909
|
-
} else if (paymentState == '
|
|
20244
|
+
} else if (paymentState == 'success') {
|
|
20910
20245
|
if (tracking == true) {
|
|
20911
20246
|
if (release) {
|
|
20912
20247
|
if (forwardTo) {
|
|
@@ -20935,32 +20270,25 @@ var Footer = (function () {
|
|
|
20935
20270
|
}
|
|
20936
20271
|
}
|
|
20937
20272
|
};
|
|
20938
|
-
|
|
20939
20273
|
return /*#__PURE__*/React.createElement("div", null, approvalButton(), additionalPaymentInformation(), mainAction());
|
|
20940
20274
|
});
|
|
20941
20275
|
|
|
20942
20276
|
var DonationOverviewDialog = (function (props) {
|
|
20943
20277
|
var _useContext = useContext(ConfigurationContext);
|
|
20944
|
-
|
|
20945
|
-
|
|
20946
|
-
|
|
20278
|
+
_useContext.currencyCode;
|
|
20279
|
+
var title = _useContext.title;
|
|
20947
20280
|
var _useContext2 = useContext(ChangableAmountContext);
|
|
20948
|
-
|
|
20949
|
-
|
|
20281
|
+
_useContext2.amount;
|
|
20950
20282
|
var _useContext3 = useContext(PaymentContext),
|
|
20951
|
-
|
|
20952
|
-
|
|
20953
|
-
|
|
20283
|
+
payment = _useContext3.payment,
|
|
20284
|
+
paymentState = _useContext3.paymentState;
|
|
20954
20285
|
var _useContext4 = useContext(PaymentValueContext),
|
|
20955
|
-
|
|
20956
|
-
|
|
20286
|
+
displayedPaymentValue = _useContext4.displayedPaymentValue;
|
|
20957
20287
|
var _useContext5 = useContext(NavigateStackContext),
|
|
20958
|
-
|
|
20959
|
-
|
|
20288
|
+
navigate = _useContext5.navigate;
|
|
20960
20289
|
if (payment == undefined) {
|
|
20961
20290
|
return /*#__PURE__*/React.createElement(DonationOverviewSkeleton, null);
|
|
20962
20291
|
}
|
|
20963
|
-
|
|
20964
20292
|
var blockchain = Blockchain.findByName(payment.blockchain);
|
|
20965
20293
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
20966
20294
|
header: /*#__PURE__*/React.createElement("div", {
|
|
@@ -20977,7 +20305,6 @@ var DonationOverviewDialog = (function (props) {
|
|
|
20977
20305
|
if (paymentState != 'initialized') {
|
|
20978
20306
|
return;
|
|
20979
20307
|
}
|
|
20980
|
-
|
|
20981
20308
|
navigate('ChangeAmount');
|
|
20982
20309
|
}
|
|
20983
20310
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -20999,7 +20326,6 @@ var DonationOverviewDialog = (function (props) {
|
|
|
20999
20326
|
if (paymentState != 'initialized') {
|
|
21000
20327
|
return;
|
|
21001
20328
|
}
|
|
21002
|
-
|
|
21003
20329
|
navigate('ChangePayment');
|
|
21004
20330
|
}
|
|
21005
20331
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -21036,13 +20362,11 @@ var DonationOverviewDialog = (function (props) {
|
|
|
21036
20362
|
});
|
|
21037
20363
|
});
|
|
21038
20364
|
|
|
21039
|
-
var
|
|
20365
|
+
var PaymentFailedDialog = (function () {
|
|
21040
20366
|
var _useContext = useContext(ClosableContext),
|
|
21041
|
-
|
|
21042
|
-
|
|
20367
|
+
close = _useContext.close;
|
|
21043
20368
|
var _useContext2 = useContext(PaymentContext),
|
|
21044
|
-
|
|
21045
|
-
|
|
20369
|
+
transaction = _useContext2.transaction;
|
|
21046
20370
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
21047
20371
|
stacked: false,
|
|
21048
20372
|
header: /*#__PURE__*/React.createElement("div", {
|
|
@@ -21085,11 +20409,9 @@ var ConnectGraphic = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAHQCAMA
|
|
|
21085
20409
|
|
|
21086
20410
|
var WrongNetworkDialog = (function (props) {
|
|
21087
20411
|
var _useContext = useContext(PaymentContext),
|
|
21088
|
-
|
|
21089
|
-
|
|
20412
|
+
payment = _useContext.payment;
|
|
21090
20413
|
var _useContext2 = useContext(NavigateStackContext),
|
|
21091
|
-
|
|
21092
|
-
|
|
20414
|
+
navigate = _useContext2.navigate;
|
|
21093
20415
|
var blockchain = Blockchain.findByName(payment.route.blockchain);
|
|
21094
20416
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
21095
20417
|
stacked: true,
|
|
@@ -21125,12 +20447,10 @@ var WrongNetworkDialog = (function (props) {
|
|
|
21125
20447
|
|
|
21126
20448
|
var DonationStack = (function (props) {
|
|
21127
20449
|
var _useContext = useContext(ClosableContext),
|
|
21128
|
-
|
|
21129
|
-
|
|
21130
|
-
|
|
20450
|
+
open = _useContext.open,
|
|
20451
|
+
close = _useContext.close;
|
|
21131
20452
|
var _useContext2 = useContext(NavigateContext),
|
|
21132
|
-
|
|
21133
|
-
|
|
20453
|
+
setNavigator = _useContext2.setNavigator;
|
|
21134
20454
|
return /*#__PURE__*/React.createElement(ReactDialogStack, {
|
|
21135
20455
|
setNavigator: setNavigator,
|
|
21136
20456
|
open: open,
|
|
@@ -21142,7 +20462,7 @@ var DonationStack = (function (props) {
|
|
|
21142
20462
|
DonationOverview: /*#__PURE__*/React.createElement(DonationOverviewDialog, null),
|
|
21143
20463
|
ChangeAmount: /*#__PURE__*/React.createElement(ChangeAmountDialog, null),
|
|
21144
20464
|
ChangePayment: /*#__PURE__*/React.createElement(ChangePaymentDialog, null),
|
|
21145
|
-
|
|
20465
|
+
PaymentFailed: /*#__PURE__*/React.createElement(PaymentFailedDialog, null),
|
|
21146
20466
|
WrongNetwork: /*#__PURE__*/React.createElement(WrongNetworkDialog, null)
|
|
21147
20467
|
}
|
|
21148
20468
|
});
|
|
@@ -21150,23 +20470,19 @@ var DonationStack = (function (props) {
|
|
|
21150
20470
|
|
|
21151
20471
|
var NavigateProvider = (function (props) {
|
|
21152
20472
|
var navigator;
|
|
21153
|
-
|
|
21154
20473
|
var setNavigator = function setNavigator(_navigator) {
|
|
21155
20474
|
navigator = _navigator;
|
|
21156
20475
|
};
|
|
21157
|
-
|
|
21158
20476
|
var navigate = function navigate(dialog) {
|
|
21159
20477
|
if (navigator) {
|
|
21160
20478
|
navigator.navigate(dialog);
|
|
21161
20479
|
}
|
|
21162
20480
|
};
|
|
21163
|
-
|
|
21164
20481
|
var set = function set(dialogs) {
|
|
21165
20482
|
if (navigator) {
|
|
21166
20483
|
navigator.set(dialogs);
|
|
21167
20484
|
}
|
|
21168
20485
|
};
|
|
21169
|
-
|
|
21170
20486
|
return /*#__PURE__*/React.createElement(NavigateContext.Provider, {
|
|
21171
20487
|
value: {
|
|
21172
20488
|
navigate: navigate,
|
|
@@ -21178,58 +20494,46 @@ var NavigateProvider = (function (props) {
|
|
|
21178
20494
|
|
|
21179
20495
|
var PaymentTrackingProvider = (function (props) {
|
|
21180
20496
|
var _useContext = useContext(ErrorContext);
|
|
21181
|
-
|
|
21182
|
-
|
|
20497
|
+
_useContext.errorCallback;
|
|
21183
20498
|
var _useContext2 = useContext(ConfigurationContext),
|
|
21184
|
-
|
|
21185
|
-
|
|
21186
|
-
|
|
21187
|
-
|
|
21188
|
-
|
|
21189
|
-
|
|
20499
|
+
track = _useContext2.track,
|
|
20500
|
+
validated = _useContext2.validated,
|
|
20501
|
+
integration = _useContext2.integration,
|
|
20502
|
+
link = _useContext2.link,
|
|
20503
|
+
type = _useContext2.type;
|
|
21190
20504
|
var _useState = useState(),
|
|
21191
|
-
|
|
21192
|
-
|
|
21193
|
-
|
|
21194
|
-
|
|
20505
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
20506
|
+
transaction = _useState2[0],
|
|
20507
|
+
setTransaction = _useState2[1];
|
|
21195
20508
|
var _useState3 = useState(),
|
|
21196
|
-
|
|
21197
|
-
|
|
21198
|
-
|
|
21199
|
-
|
|
20509
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
20510
|
+
afterBlock = _useState4[0],
|
|
20511
|
+
setAfterBlock = _useState4[1];
|
|
21200
20512
|
var _useState5 = useState(),
|
|
21201
|
-
|
|
21202
|
-
|
|
21203
|
-
|
|
21204
|
-
|
|
20513
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
20514
|
+
paymentRoute = _useState6[0],
|
|
20515
|
+
setPaymentRoute = _useState6[1];
|
|
21205
20516
|
var _useState7 = useState(!!(track && (track.endpoint || typeof track.method == 'function') && track.async != true)),
|
|
21206
|
-
|
|
21207
|
-
|
|
21208
|
-
|
|
20517
|
+
_useState8 = _slicedToArray(_useState7, 1),
|
|
20518
|
+
tracking = _useState8[0];
|
|
21209
20519
|
var _useState9 = useState(!!(track && track.poll && (track.poll.endpoint || typeof track.poll.method == 'function') && track.async != true)),
|
|
21210
|
-
|
|
21211
|
-
|
|
21212
|
-
|
|
20520
|
+
_useState10 = _slicedToArray(_useState9, 1),
|
|
20521
|
+
polling = _useState10[0];
|
|
21213
20522
|
var _useState11 = useState(false),
|
|
21214
|
-
|
|
21215
|
-
|
|
21216
|
-
|
|
21217
|
-
|
|
20523
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
20524
|
+
release = _useState12[0],
|
|
20525
|
+
setRelease = _useState12[1];
|
|
21218
20526
|
var _useState13 = useState(),
|
|
21219
|
-
|
|
21220
|
-
|
|
21221
|
-
|
|
21222
|
-
|
|
20527
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
20528
|
+
forwardTo = _useState14[0],
|
|
20529
|
+
setForwardTo = _useState14[1];
|
|
21223
20530
|
var _useContext3 = useContext(ClosableContext),
|
|
21224
|
-
|
|
21225
|
-
|
|
20531
|
+
setClosable = _useContext3.setClosable;
|
|
21226
20532
|
var _useContext4 = useContext(NavigateContext),
|
|
21227
|
-
|
|
21228
|
-
|
|
21229
|
-
|
|
20533
|
+
navigate = _useContext4.navigate;
|
|
20534
|
+
_useContext4.set;
|
|
21230
20535
|
var openSocket = function openSocket(transaction) {
|
|
21231
20536
|
var socket = new WebSocket('wss://integrate.depay.com/cable');
|
|
21232
|
-
|
|
21233
20537
|
socket.onopen = function (event) {
|
|
21234
20538
|
var msg = {
|
|
21235
20539
|
command: 'subscribe',
|
|
@@ -21242,31 +20546,20 @@ var PaymentTrackingProvider = (function (props) {
|
|
|
21242
20546
|
};
|
|
21243
20547
|
socket.send(JSON.stringify(msg));
|
|
21244
20548
|
};
|
|
21245
|
-
|
|
21246
20549
|
socket.onclose = function (event) {};
|
|
21247
|
-
|
|
21248
20550
|
socket.onmessage = function (event) {
|
|
21249
20551
|
var item = JSON.parse(event.data);
|
|
21250
|
-
|
|
21251
20552
|
if (item.type === "ping" || !item.message) {
|
|
21252
20553
|
return;
|
|
21253
20554
|
}
|
|
21254
|
-
|
|
21255
|
-
if (item.message.status == 'failed') {
|
|
21256
|
-
setClosable(true);
|
|
21257
|
-
set(['PaymentError']);
|
|
21258
|
-
}
|
|
21259
|
-
|
|
21260
20555
|
if (validated) {
|
|
21261
20556
|
validated(item.message.status == 'success');
|
|
21262
20557
|
}
|
|
21263
|
-
|
|
21264
20558
|
if (item.message.release) {
|
|
21265
20559
|
setRelease(true);
|
|
21266
20560
|
setClosable(!item.message.forward_to);
|
|
21267
20561
|
setForwardTo(item.message.forward_to);
|
|
21268
20562
|
socket.close();
|
|
21269
|
-
|
|
21270
20563
|
if (!!item.message.forward_to) {
|
|
21271
20564
|
setTimeout(function () {
|
|
21272
20565
|
props.document.location.href = item.message.forward_to;
|
|
@@ -21274,31 +20567,23 @@ var PaymentTrackingProvider = (function (props) {
|
|
|
21274
20567
|
}
|
|
21275
20568
|
}
|
|
21276
20569
|
};
|
|
21277
|
-
|
|
21278
20570
|
socket.onerror = function (error) {
|
|
21279
20571
|
console.log('WebSocket Error: ' + error);
|
|
21280
20572
|
};
|
|
21281
20573
|
};
|
|
21282
|
-
|
|
21283
20574
|
var retryStartTracking = function retryStartTracking(transaction, afterBlock, paymentRoute, attempt) {
|
|
21284
20575
|
attempt = parseInt(attempt || 1, 10);
|
|
21285
|
-
console.log('attempt', attempt);
|
|
21286
|
-
console.log('track.attempts', track === null || track === void 0 ? void 0 : track.attempts);
|
|
21287
|
-
|
|
21288
20576
|
if (attempt < ((track === null || track === void 0 ? void 0 : track.attempts) || 40)) {
|
|
21289
20577
|
setTimeout(function () {
|
|
21290
20578
|
startTracking(transaction, afterBlock, paymentRoute, attempt + 1);
|
|
21291
20579
|
}, 3000);
|
|
21292
20580
|
} else {
|
|
21293
|
-
console.log('navigate TrackingFailed');
|
|
21294
20581
|
navigate('TrackingFailed');
|
|
21295
20582
|
}
|
|
21296
20583
|
};
|
|
21297
|
-
|
|
21298
20584
|
var continueTryTracking = function continueTryTracking() {
|
|
21299
20585
|
retryStartTracking(transaction, afterBlock, paymentRoute, 1);
|
|
21300
20586
|
};
|
|
21301
|
-
|
|
21302
20587
|
var callTracking = function callTracking(payment) {
|
|
21303
20588
|
if (track.endpoint) {
|
|
21304
20589
|
return fetch(track.endpoint, {
|
|
@@ -21314,10 +20599,8 @@ var PaymentTrackingProvider = (function (props) {
|
|
|
21314
20599
|
throw 'No tracking defined!';
|
|
21315
20600
|
}
|
|
21316
20601
|
};
|
|
21317
|
-
|
|
21318
20602
|
var startTracking = function startTracking(transaction, afterBlock, paymentRoute, attempt) {
|
|
21319
20603
|
var _paymentRoute$feeAmou;
|
|
21320
|
-
|
|
21321
20604
|
callTracking({
|
|
21322
20605
|
blockchain: transaction.blockchain,
|
|
21323
20606
|
transaction: transaction.id.toLowerCase(),
|
|
@@ -21340,12 +20623,10 @@ var PaymentTrackingProvider = (function (props) {
|
|
|
21340
20623
|
retryStartTracking(transaction, afterBlock, paymentRoute, attempt);
|
|
21341
20624
|
});
|
|
21342
20625
|
};
|
|
21343
|
-
|
|
21344
20626
|
var pollStatus = function pollStatus(polling, transaction, afterBlock, paymentRoute, pollingInterval) {
|
|
21345
20627
|
if (!polling || transaction == undefined || afterBlock == undefined || paymentRoute == undefined) {
|
|
21346
20628
|
return;
|
|
21347
20629
|
}
|
|
21348
|
-
|
|
21349
20630
|
var payment = {
|
|
21350
20631
|
blockchain: transaction.blockchain,
|
|
21351
20632
|
transaction: transaction.id.toLowerCase(),
|
|
@@ -21354,7 +20635,6 @@ var PaymentTrackingProvider = (function (props) {
|
|
|
21354
20635
|
after_block: afterBlock,
|
|
21355
20636
|
to_token: paymentRoute.toToken.address
|
|
21356
20637
|
};
|
|
21357
|
-
|
|
21358
20638
|
var handleResponse = function handleResponse(response) {
|
|
21359
20639
|
if (response.status == 200 || response.status == 201) {
|
|
21360
20640
|
response.json().then(function (data) {
|
|
@@ -21373,7 +20653,6 @@ var PaymentTrackingProvider = (function (props) {
|
|
|
21373
20653
|
setRelease(true);
|
|
21374
20654
|
}
|
|
21375
20655
|
};
|
|
21376
|
-
|
|
21377
20656
|
if (track.poll.endpoint) {
|
|
21378
20657
|
fetch(track.poll.endpoint, {
|
|
21379
20658
|
method: 'POST',
|
|
@@ -21386,16 +20665,13 @@ var PaymentTrackingProvider = (function (props) {
|
|
|
21386
20665
|
track.poll.method(payment).then(handleResponse);
|
|
21387
20666
|
}
|
|
21388
20667
|
};
|
|
21389
|
-
|
|
21390
20668
|
useEffect(function () {
|
|
21391
20669
|
if (!polling) {
|
|
21392
20670
|
return;
|
|
21393
20671
|
}
|
|
21394
|
-
|
|
21395
20672
|
if (!tracking) {
|
|
21396
20673
|
return;
|
|
21397
20674
|
}
|
|
21398
|
-
|
|
21399
20675
|
var pollingInterval = setInterval(function () {
|
|
21400
20676
|
return pollStatus(polling, transaction, afterBlock, paymentRoute, pollingInterval);
|
|
21401
20677
|
}, 5000);
|
|
@@ -21403,7 +20679,6 @@ var PaymentTrackingProvider = (function (props) {
|
|
|
21403
20679
|
clearInterval(pollingInterval);
|
|
21404
20680
|
};
|
|
21405
20681
|
}, [polling, transaction, afterBlock, paymentRoute]);
|
|
21406
|
-
|
|
21407
20682
|
var storePayment = function storePayment(transaction, afterBlock, paymentRoute, attempt) {
|
|
21408
20683
|
fetch('https://public.depay.com/payments', {
|
|
21409
20684
|
headers: {
|
|
@@ -21444,24 +20719,19 @@ var PaymentTrackingProvider = (function (props) {
|
|
|
21444
20719
|
}, 3000);
|
|
21445
20720
|
});
|
|
21446
20721
|
};
|
|
21447
|
-
|
|
21448
20722
|
var initializeTracking = function initializeTracking(transaction, afterBlock, paymentRoute) {
|
|
21449
20723
|
storePayment(transaction, afterBlock, paymentRoute);
|
|
21450
|
-
|
|
21451
20724
|
if (tracking || track && track.async == true) {
|
|
21452
20725
|
startTracking(transaction, afterBlock, paymentRoute);
|
|
21453
20726
|
}
|
|
21454
|
-
|
|
21455
20727
|
if (tracking == false) {
|
|
21456
20728
|
return;
|
|
21457
20729
|
}
|
|
21458
|
-
|
|
21459
20730
|
setTransaction(transaction);
|
|
21460
20731
|
setAfterBlock(afterBlock);
|
|
21461
20732
|
setPaymentRoute(paymentRoute);
|
|
21462
20733
|
openSocket(transaction);
|
|
21463
20734
|
};
|
|
21464
|
-
|
|
21465
20735
|
return /*#__PURE__*/React.createElement(PaymentTrackingContext.Provider, {
|
|
21466
20736
|
value: {
|
|
21467
20737
|
tracking: tracking,
|
|
@@ -21475,26 +20745,21 @@ var PaymentTrackingProvider = (function (props) {
|
|
|
21475
20745
|
|
|
21476
20746
|
var TransactionTrackingProvider = (function (props) {
|
|
21477
20747
|
var _useState = useState(),
|
|
21478
|
-
|
|
21479
|
-
|
|
21480
|
-
|
|
21481
|
-
|
|
20748
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
20749
|
+
givenTransaction = _useState2[0],
|
|
20750
|
+
setGivenTransaction = _useState2[1];
|
|
21482
20751
|
var _useState3 = useState(),
|
|
21483
|
-
|
|
21484
|
-
|
|
21485
|
-
|
|
21486
|
-
|
|
20752
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
20753
|
+
foundTransaction = _useState4[0],
|
|
20754
|
+
setFoundTransaction = _useState4[1];
|
|
21487
20755
|
var _useState5 = useState(false),
|
|
21488
|
-
|
|
21489
|
-
|
|
21490
|
-
|
|
21491
|
-
|
|
20756
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
20757
|
+
polling = _useState6[0],
|
|
20758
|
+
setPolling = _useState6[1];
|
|
21492
20759
|
var _useContext = useContext(ErrorContext);
|
|
21493
|
-
|
|
21494
|
-
|
|
20760
|
+
_useContext.errorCallback;
|
|
21495
20761
|
var _useContext2 = useContext(ConfigurationContext),
|
|
21496
|
-
|
|
21497
|
-
|
|
20762
|
+
recover = _useContext2.recover;
|
|
21498
20763
|
useEffect(function () {
|
|
21499
20764
|
if (polling) {
|
|
21500
20765
|
var poll = function poll() {
|
|
@@ -21512,7 +20777,6 @@ var TransactionTrackingProvider = (function (props) {
|
|
|
21512
20777
|
}
|
|
21513
20778
|
});
|
|
21514
20779
|
};
|
|
21515
|
-
|
|
21516
20780
|
var pollingInterval = setInterval(poll, 5000);
|
|
21517
20781
|
poll();
|
|
21518
20782
|
return function () {
|
|
@@ -21520,13 +20784,11 @@ var TransactionTrackingProvider = (function (props) {
|
|
|
21520
20784
|
};
|
|
21521
20785
|
}
|
|
21522
20786
|
}, [polling]);
|
|
21523
|
-
|
|
21524
20787
|
var createTracking = function createTracking(transaction, afterBlock, attempt) {
|
|
21525
20788
|
if (attempt > 3) {
|
|
21526
20789
|
console.log('TRANSACTION TRACKING FAILED AFTER 3 ATTEMPTS!');
|
|
21527
20790
|
return;
|
|
21528
20791
|
}
|
|
21529
|
-
|
|
21530
20792
|
fetch('https://public.depay.com/transactions', {
|
|
21531
20793
|
method: 'POST',
|
|
21532
20794
|
headers: {
|
|
@@ -21555,10 +20817,8 @@ var TransactionTrackingProvider = (function (props) {
|
|
|
21555
20817
|
}, 3000);
|
|
21556
20818
|
});
|
|
21557
20819
|
};
|
|
21558
|
-
|
|
21559
20820
|
var openSocket = function openSocket(transaction) {
|
|
21560
20821
|
var socket = new WebSocket('wss://integrate.depay.com/cable');
|
|
21561
|
-
|
|
21562
20822
|
socket.onopen = function (event) {
|
|
21563
20823
|
var msg = {
|
|
21564
20824
|
command: 'subscribe',
|
|
@@ -21571,37 +20831,28 @@ var TransactionTrackingProvider = (function (props) {
|
|
|
21571
20831
|
};
|
|
21572
20832
|
socket.send(JSON.stringify(msg));
|
|
21573
20833
|
};
|
|
21574
|
-
|
|
21575
20834
|
socket.onclose = function (event) {};
|
|
21576
|
-
|
|
21577
20835
|
socket.onmessage = function (event) {
|
|
21578
20836
|
var item = JSON.parse(event.data);
|
|
21579
|
-
|
|
21580
20837
|
if (item.type === "ping") {
|
|
21581
20838
|
return;
|
|
21582
20839
|
}
|
|
21583
|
-
|
|
21584
20840
|
if (item.message && item.message.status && item.message.status != 'pending') {
|
|
21585
20841
|
setFoundTransaction(item.message);
|
|
21586
20842
|
}
|
|
21587
20843
|
};
|
|
21588
|
-
|
|
21589
20844
|
socket.onerror = function (error) {
|
|
21590
20845
|
console.log('WebSocket Error: ' + error);
|
|
21591
20846
|
};
|
|
21592
20847
|
};
|
|
21593
|
-
|
|
21594
20848
|
var initializeTracking = function initializeTracking(transaction, afterBlock) {
|
|
21595
20849
|
setGivenTransaction(transaction);
|
|
21596
|
-
|
|
21597
20850
|
if (recover == undefined) {
|
|
21598
20851
|
createTracking(transaction, afterBlock, 1);
|
|
21599
20852
|
}
|
|
21600
|
-
|
|
21601
20853
|
openSocket(transaction);
|
|
21602
20854
|
setPolling(true);
|
|
21603
20855
|
};
|
|
21604
|
-
|
|
21605
20856
|
useEffect(function () {
|
|
21606
20857
|
if (recover) {
|
|
21607
20858
|
initializeTracking({
|
|
@@ -21622,38 +20873,31 @@ var TransactionTrackingProvider = (function (props) {
|
|
|
21622
20873
|
|
|
21623
20874
|
var WalletProvider = (function (props) {
|
|
21624
20875
|
var _useContext = useContext(ConfigurationContext),
|
|
21625
|
-
|
|
21626
|
-
|
|
20876
|
+
recover = _useContext.recover;
|
|
21627
20877
|
var _useContext2 = useContext(ErrorContext);
|
|
21628
|
-
|
|
21629
|
-
|
|
20878
|
+
_useContext2.setError;
|
|
21630
20879
|
var _useState = useState(),
|
|
21631
|
-
|
|
21632
|
-
|
|
21633
|
-
|
|
21634
|
-
|
|
20880
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
20881
|
+
wallet = _useState2[0],
|
|
20882
|
+
setWallet = _useState2[1];
|
|
21635
20883
|
var _useState3 = useState(),
|
|
21636
|
-
|
|
21637
|
-
|
|
21638
|
-
|
|
21639
|
-
|
|
20884
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
20885
|
+
account = _useState4[0],
|
|
20886
|
+
setAccount = _useState4[1];
|
|
21640
20887
|
var _useState5 = useState(),
|
|
21641
|
-
|
|
21642
|
-
|
|
21643
|
-
|
|
21644
|
-
|
|
20888
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
20889
|
+
walletState = _useState6[0],
|
|
20890
|
+
setWalletState = _useState6[1];
|
|
21645
20891
|
var connected = function connected(_ref) {
|
|
21646
20892
|
var account = _ref.account,
|
|
21647
|
-
|
|
20893
|
+
wallet = _ref.wallet;
|
|
21648
20894
|
setAccount(account);
|
|
21649
20895
|
setWallet(wallet);
|
|
21650
20896
|
setWalletState('connected');
|
|
21651
|
-
|
|
21652
20897
|
if (props.connected) {
|
|
21653
20898
|
props.connected(account);
|
|
21654
20899
|
}
|
|
21655
20900
|
};
|
|
21656
|
-
|
|
21657
20901
|
if (walletState == 'connected' || recover != undefined) {
|
|
21658
20902
|
return /*#__PURE__*/React.createElement(WalletContext.Provider, {
|
|
21659
20903
|
value: {
|
|
@@ -21679,33 +20923,26 @@ var preflight$2 = /*#__PURE__*/function () {
|
|
|
21679
20923
|
switch (_context.prev = _context.next) {
|
|
21680
20924
|
case 0:
|
|
21681
20925
|
accept = _ref.accept;
|
|
21682
|
-
|
|
21683
20926
|
if (!(!(accept instanceof Array) || accept.length == 0)) {
|
|
21684
20927
|
_context.next = 3;
|
|
21685
20928
|
break;
|
|
21686
20929
|
}
|
|
21687
|
-
|
|
21688
20930
|
throw 'You need to set the tokens you accept as donation!';
|
|
21689
|
-
|
|
21690
20931
|
case 3:
|
|
21691
20932
|
accept.forEach(function (configuration) {
|
|
21692
20933
|
if (typeof configuration.blockchain === 'undefined') {
|
|
21693
20934
|
throw 'You need to set the blockchain you want to receive the donation on!';
|
|
21694
20935
|
}
|
|
21695
|
-
|
|
21696
20936
|
if (!['ethereum', 'bsc', 'polygon'].includes(configuration.blockchain)) {
|
|
21697
20937
|
throw 'You need to set a supported blockchain!';
|
|
21698
20938
|
}
|
|
21699
|
-
|
|
21700
20939
|
if (typeof configuration.token === 'undefined') {
|
|
21701
20940
|
throw 'You need to set the token you want to receive as donation!';
|
|
21702
20941
|
}
|
|
21703
|
-
|
|
21704
20942
|
if (typeof configuration.receiver === 'undefined') {
|
|
21705
20943
|
throw 'You need to set the receiver address that you want to receive the donation!';
|
|
21706
20944
|
}
|
|
21707
20945
|
});
|
|
21708
|
-
|
|
21709
20946
|
case 4:
|
|
21710
20947
|
case "end":
|
|
21711
20948
|
return _context.stop();
|
|
@@ -21713,27 +20950,24 @@ var preflight$2 = /*#__PURE__*/function () {
|
|
|
21713
20950
|
}
|
|
21714
20951
|
}, _callee);
|
|
21715
20952
|
}));
|
|
21716
|
-
|
|
21717
20953
|
return function preflight(_x) {
|
|
21718
20954
|
return _ref2.apply(this, arguments);
|
|
21719
20955
|
};
|
|
21720
20956
|
}();
|
|
21721
|
-
|
|
21722
20957
|
var Donation = /*#__PURE__*/function () {
|
|
21723
20958
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(_ref3) {
|
|
21724
|
-
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;
|
|
21725
20960
|
return regenerator.wrap(function _callee2$(_context2) {
|
|
21726
20961
|
while (1) {
|
|
21727
20962
|
switch (_context2.prev = _context2.next) {
|
|
21728
20963
|
case 0:
|
|
21729
|
-
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;
|
|
21730
20965
|
requireReactVersion();
|
|
21731
20966
|
_context2.prev = 2;
|
|
21732
20967
|
_context2.next = 5;
|
|
21733
20968
|
return preflight$2({
|
|
21734
20969
|
accept: accept
|
|
21735
20970
|
});
|
|
21736
|
-
|
|
21737
20971
|
case 5:
|
|
21738
20972
|
unmount = mount({
|
|
21739
20973
|
style: style,
|
|
@@ -21756,7 +20990,7 @@ var Donation = /*#__PURE__*/function () {
|
|
|
21756
20990
|
track: track,
|
|
21757
20991
|
fee: fee,
|
|
21758
20992
|
sent: sent,
|
|
21759
|
-
|
|
20993
|
+
succeeded: succeeded,
|
|
21760
20994
|
validated: validated,
|
|
21761
20995
|
failed: failed,
|
|
21762
20996
|
blacklist: blacklist,
|
|
@@ -21789,16 +21023,13 @@ var Donation = /*#__PURE__*/function () {
|
|
|
21789
21023
|
return _context2.abrupt("return", {
|
|
21790
21024
|
unmount: unmount
|
|
21791
21025
|
});
|
|
21792
|
-
|
|
21793
21026
|
case 9:
|
|
21794
21027
|
_context2.prev = 9;
|
|
21795
21028
|
_context2.t0 = _context2["catch"](2);
|
|
21796
21029
|
console.log('critical error', _context2.t0);
|
|
21797
|
-
|
|
21798
21030
|
if (critical != undefined) {
|
|
21799
21031
|
critical(_context2.t0);
|
|
21800
21032
|
}
|
|
21801
|
-
|
|
21802
21033
|
case 13:
|
|
21803
21034
|
case "end":
|
|
21804
21035
|
return _context2.stop();
|
|
@@ -21806,7 +21037,6 @@ var Donation = /*#__PURE__*/function () {
|
|
|
21806
21037
|
}
|
|
21807
21038
|
}, _callee2, null, [[2, 9]]);
|
|
21808
21039
|
}));
|
|
21809
|
-
|
|
21810
21040
|
return function Donation(_x2) {
|
|
21811
21041
|
return _ref4.apply(this, arguments);
|
|
21812
21042
|
};
|
|
@@ -21814,23 +21044,19 @@ var Donation = /*#__PURE__*/function () {
|
|
|
21814
21044
|
|
|
21815
21045
|
var SignLoginDialog = (function (props) {
|
|
21816
21046
|
var _useContext = useContext(ErrorContext),
|
|
21817
|
-
|
|
21818
|
-
|
|
21047
|
+
setError = _useContext.setError;
|
|
21819
21048
|
var _useContext2 = useContext(ConfigurationContext),
|
|
21820
|
-
|
|
21821
|
-
|
|
21822
|
-
|
|
21049
|
+
message = _useContext2.message,
|
|
21050
|
+
endpoint = _useContext2.endpoint;
|
|
21823
21051
|
var _useContext3 = useContext(ConfigurationContext),
|
|
21824
|
-
|
|
21825
|
-
|
|
21826
|
-
var wallet = getWallet();
|
|
21052
|
+
recover = _useContext3.recover;
|
|
21053
|
+
var wallet = getWallets()[0];
|
|
21827
21054
|
wallet !== null && wallet !== void 0 && wallet.name ? wallet.name : 'wallet';
|
|
21828
21055
|
var walletLogo = wallet !== null && wallet !== void 0 && wallet.logo ? wallet.logo : undefined;
|
|
21829
|
-
|
|
21830
21056
|
if (typeof recover != 'function') {
|
|
21831
21057
|
recover = function recover(_ref) {
|
|
21832
21058
|
var message = _ref.message,
|
|
21833
|
-
|
|
21059
|
+
signature = _ref.signature;
|
|
21834
21060
|
return new Promise(function (resolve, reject) {
|
|
21835
21061
|
fetch(endpoint, {
|
|
21836
21062
|
method: 'POST',
|
|
@@ -21855,7 +21081,6 @@ var SignLoginDialog = (function (props) {
|
|
|
21855
21081
|
});
|
|
21856
21082
|
};
|
|
21857
21083
|
}
|
|
21858
|
-
|
|
21859
21084
|
var login = function login() {
|
|
21860
21085
|
wallet.sign(message).then(function (signature) {
|
|
21861
21086
|
recover({
|
|
@@ -21868,7 +21093,6 @@ var SignLoginDialog = (function (props) {
|
|
|
21868
21093
|
}
|
|
21869
21094
|
});
|
|
21870
21095
|
};
|
|
21871
|
-
|
|
21872
21096
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
21873
21097
|
body: /*#__PURE__*/React.createElement("div", {
|
|
21874
21098
|
className: "TextCenter"
|
|
@@ -21895,14 +21119,12 @@ var SignLoginDialog = (function (props) {
|
|
|
21895
21119
|
|
|
21896
21120
|
var LoginStack = (function (props) {
|
|
21897
21121
|
var _useContext = useContext(ClosableContext),
|
|
21898
|
-
|
|
21899
|
-
|
|
21900
|
-
|
|
21122
|
+
open = _useContext.open,
|
|
21123
|
+
close = _useContext.close;
|
|
21901
21124
|
var _useState = useState(true),
|
|
21902
|
-
|
|
21903
|
-
|
|
21904
|
-
|
|
21905
|
-
|
|
21125
|
+
_useState2 = _slicedToArray(_useState, 2);
|
|
21126
|
+
_useState2[0];
|
|
21127
|
+
_useState2[1];
|
|
21906
21128
|
return /*#__PURE__*/React.createElement(ReactDialogStack, {
|
|
21907
21129
|
open: open,
|
|
21908
21130
|
close: close,
|
|
@@ -21921,7 +21143,6 @@ var LoginStack = (function (props) {
|
|
|
21921
21143
|
var Login = function Login(options) {
|
|
21922
21144
|
requireReactVersion();
|
|
21923
21145
|
var style, error, document, message, endpoint, recover;
|
|
21924
|
-
|
|
21925
21146
|
if (_typeof(options) == 'object') {
|
|
21926
21147
|
style = options.style;
|
|
21927
21148
|
error = options.error;
|
|
@@ -21930,7 +21151,6 @@ var Login = function Login(options) {
|
|
|
21930
21151
|
endpoint = options.endpoint;
|
|
21931
21152
|
recover = options.recover;
|
|
21932
21153
|
}
|
|
21933
|
-
|
|
21934
21154
|
return new Promise( /*#__PURE__*/function () {
|
|
21935
21155
|
var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(_resolve, reject) {
|
|
21936
21156
|
return regenerator.wrap(function _callee$(_context) {
|
|
@@ -21946,7 +21166,6 @@ var Login = function Login(options) {
|
|
|
21946
21166
|
reject('USER_CLOSED_DIALOG');
|
|
21947
21167
|
unmount();
|
|
21948
21168
|
};
|
|
21949
|
-
|
|
21950
21169
|
return function (container) {
|
|
21951
21170
|
return /*#__PURE__*/React.createElement(ErrorProvider, {
|
|
21952
21171
|
errorCallback: error,
|
|
@@ -21965,14 +21184,12 @@ var Login = function Login(options) {
|
|
|
21965
21184
|
container: container,
|
|
21966
21185
|
resolve: function resolve(account) {
|
|
21967
21186
|
unmount();
|
|
21968
|
-
|
|
21969
21187
|
_resolve(account);
|
|
21970
21188
|
}
|
|
21971
21189
|
}), /*#__PURE__*/React.createElement(PoweredBy, null)))));
|
|
21972
21190
|
};
|
|
21973
21191
|
});
|
|
21974
21192
|
})["catch"](reject);
|
|
21975
|
-
|
|
21976
21193
|
case 1:
|
|
21977
21194
|
case "end":
|
|
21978
21195
|
return _context.stop();
|
|
@@ -21980,7 +21197,6 @@ var Login = function Login(options) {
|
|
|
21980
21197
|
}
|
|
21981
21198
|
}, _callee);
|
|
21982
21199
|
}));
|
|
21983
|
-
|
|
21984
21200
|
return function (_x, _x2) {
|
|
21985
21201
|
return _ref.apply(this, arguments);
|
|
21986
21202
|
};
|
|
@@ -21991,15 +21207,13 @@ var PaymentAmountRoutingContext = /*#__PURE__*/React.createContext();
|
|
|
21991
21207
|
|
|
21992
21208
|
var PaymentAmountRoutingProvider = (function (props) {
|
|
21993
21209
|
var _useContext = useContext(ChangableAmountContext),
|
|
21994
|
-
|
|
21995
|
-
|
|
21996
|
-
|
|
21997
|
-
|
|
21210
|
+
amountsMissing = _useContext.amountsMissing,
|
|
21211
|
+
acceptWithAmount = _useContext.acceptWithAmount,
|
|
21212
|
+
setMaxRoute = _useContext.setMaxRoute;
|
|
21998
21213
|
var _useState = useState(),
|
|
21999
|
-
|
|
22000
|
-
|
|
22001
|
-
|
|
22002
|
-
|
|
21214
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
21215
|
+
accept = _useState2[0],
|
|
21216
|
+
setAccept = _useState2[1];
|
|
22003
21217
|
useEffect(function () {
|
|
22004
21218
|
if (amountsMissing) {
|
|
22005
21219
|
if (acceptWithAmount) {
|
|
@@ -22023,13 +21237,11 @@ var PaymentAmountRoutingProvider = (function (props) {
|
|
|
22023
21237
|
|
|
22024
21238
|
var PaymentOverviewSkeleton = (function (props) {
|
|
22025
21239
|
var _useContext = useContext(ChangableAmountContext),
|
|
22026
|
-
|
|
22027
|
-
|
|
22028
|
-
|
|
21240
|
+
amountsMissing = _useContext.amountsMissing,
|
|
21241
|
+
fixedAmount = _useContext.fixedAmount;
|
|
22029
21242
|
var _useContext2 = useContext(PaymentRoutingContext),
|
|
22030
|
-
|
|
22031
|
-
|
|
22032
|
-
|
|
21243
|
+
slowRouting = _useContext2.slowRouting,
|
|
21244
|
+
selectedRoute = _useContext2.selectedRoute;
|
|
22033
21245
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
22034
21246
|
header: /*#__PURE__*/React.createElement("div", {
|
|
22035
21247
|
className: "PaddingTopS PaddingLeftM PaddingRightM TextLeft"
|
|
@@ -22063,29 +21275,23 @@ var PaymentOverviewSkeleton = (function (props) {
|
|
|
22063
21275
|
|
|
22064
21276
|
var PaymentOverviewDialog = (function (props) {
|
|
22065
21277
|
var _useContext = useContext(ConfigurationContext),
|
|
22066
|
-
|
|
22067
|
-
|
|
22068
|
-
|
|
21278
|
+
currencyCode = _useContext.currencyCode,
|
|
21279
|
+
recover = _useContext.recover;
|
|
22069
21280
|
var _useContext2 = useContext(PaymentContext),
|
|
22070
|
-
|
|
22071
|
-
|
|
22072
|
-
|
|
21281
|
+
payment = _useContext2.payment,
|
|
21282
|
+
paymentState = _useContext2.paymentState;
|
|
22073
21283
|
var _useContext3 = useContext(ChangableAmountContext),
|
|
22074
|
-
|
|
22075
|
-
|
|
22076
|
-
|
|
22077
|
-
|
|
22078
|
-
|
|
21284
|
+
amount = _useContext3.amount,
|
|
21285
|
+
amountsMissing = _useContext3.amountsMissing,
|
|
21286
|
+
fixedAmount = _useContext3.fixedAmount,
|
|
21287
|
+
fixedCurrency = _useContext3.fixedCurrency;
|
|
22079
21288
|
var _useContext4 = useContext(PaymentValueContext),
|
|
22080
|
-
|
|
22081
|
-
|
|
21289
|
+
paymentValue = _useContext4.paymentValue;
|
|
22082
21290
|
var _useContext5 = useContext(NavigateStackContext),
|
|
22083
|
-
|
|
22084
|
-
|
|
21291
|
+
navigate = _useContext5.navigate;
|
|
22085
21292
|
if (payment == undefined || recover == undefined && paymentValue == undefined) {
|
|
22086
21293
|
return /*#__PURE__*/React.createElement(PaymentOverviewSkeleton, null);
|
|
22087
21294
|
}
|
|
22088
|
-
|
|
22089
21295
|
var blockchain = Blockchain.findByName(payment.blockchain);
|
|
22090
21296
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
22091
21297
|
header: /*#__PURE__*/React.createElement("div", {
|
|
@@ -22102,7 +21308,6 @@ var PaymentOverviewDialog = (function (props) {
|
|
|
22102
21308
|
if (paymentState != 'initialized') {
|
|
22103
21309
|
return;
|
|
22104
21310
|
}
|
|
22105
|
-
|
|
22106
21311
|
navigate('ChangeAmount');
|
|
22107
21312
|
}
|
|
22108
21313
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -22127,7 +21332,6 @@ var PaymentOverviewDialog = (function (props) {
|
|
|
22127
21332
|
if (paymentState != 'initialized') {
|
|
22128
21333
|
return;
|
|
22129
21334
|
}
|
|
22130
|
-
|
|
22131
21335
|
navigate('ChangePayment');
|
|
22132
21336
|
}
|
|
22133
21337
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -22166,19 +21370,15 @@ var PaymentOverviewDialog = (function (props) {
|
|
|
22166
21370
|
|
|
22167
21371
|
var TrackingFailedDialog = (function () {
|
|
22168
21372
|
var _useContext = useContext(PaymentTrackingContext),
|
|
22169
|
-
|
|
22170
|
-
|
|
21373
|
+
continueTryTracking = _useContext.continueTryTracking;
|
|
22171
21374
|
var _useContext2 = useContext(PaymentContext),
|
|
22172
|
-
|
|
22173
|
-
|
|
21375
|
+
transaction = _useContext2.transaction;
|
|
22174
21376
|
var _useContext3 = useContext(NavigateStackContext),
|
|
22175
|
-
|
|
22176
|
-
|
|
21377
|
+
navigate = _useContext3.navigate;
|
|
22177
21378
|
var tryAgain = function tryAgain() {
|
|
22178
21379
|
continueTryTracking();
|
|
22179
21380
|
navigate('back');
|
|
22180
21381
|
};
|
|
22181
|
-
|
|
22182
21382
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
22183
21383
|
stacked: false,
|
|
22184
21384
|
header: /*#__PURE__*/React.createElement("div", {
|
|
@@ -22214,12 +21414,10 @@ var TrackingFailedDialog = (function () {
|
|
|
22214
21414
|
|
|
22215
21415
|
var PaymentStack = (function (props) {
|
|
22216
21416
|
var _useContext = useContext(ClosableContext),
|
|
22217
|
-
|
|
22218
|
-
|
|
22219
|
-
|
|
21417
|
+
open = _useContext.open,
|
|
21418
|
+
close = _useContext.close;
|
|
22220
21419
|
var _useContext2 = useContext(NavigateContext),
|
|
22221
|
-
|
|
22222
|
-
|
|
21420
|
+
setNavigator = _useContext2.setNavigator;
|
|
22223
21421
|
return /*#__PURE__*/React.createElement(ReactDialogStack, {
|
|
22224
21422
|
setNavigator: setNavigator,
|
|
22225
21423
|
open: open,
|
|
@@ -22231,7 +21429,7 @@ var PaymentStack = (function (props) {
|
|
|
22231
21429
|
PaymentOverview: /*#__PURE__*/React.createElement(PaymentOverviewDialog, null),
|
|
22232
21430
|
ChangeAmount: /*#__PURE__*/React.createElement(ChangeAmountDialog, null),
|
|
22233
21431
|
ChangePayment: /*#__PURE__*/React.createElement(ChangePaymentDialog, null),
|
|
22234
|
-
|
|
21432
|
+
PaymentFailed: /*#__PURE__*/React.createElement(PaymentFailedDialog, null),
|
|
22235
21433
|
WrongNetwork: /*#__PURE__*/React.createElement(WrongNetworkDialog, null),
|
|
22236
21434
|
TrackingFailed: /*#__PURE__*/React.createElement(TrackingFailedDialog, null)
|
|
22237
21435
|
}
|
|
@@ -22246,37 +21444,29 @@ var preflight$1 = /*#__PURE__*/function () {
|
|
|
22246
21444
|
switch (_context.prev = _context.next) {
|
|
22247
21445
|
case 0:
|
|
22248
21446
|
accept = _ref.accept, recover = _ref.recover;
|
|
22249
|
-
|
|
22250
21447
|
if (!recover) {
|
|
22251
21448
|
_context.next = 3;
|
|
22252
21449
|
break;
|
|
22253
21450
|
}
|
|
22254
|
-
|
|
22255
21451
|
return _context.abrupt("return");
|
|
22256
|
-
|
|
22257
21452
|
case 3:
|
|
22258
21453
|
accept.forEach(function (configuration) {
|
|
22259
21454
|
if (typeof configuration.blockchain === 'undefined') {
|
|
22260
21455
|
throw 'You need to set the blockchain your want to receive the payment on!';
|
|
22261
21456
|
}
|
|
22262
|
-
|
|
22263
21457
|
if (!['ethereum', 'bsc', 'polygon'].includes(configuration.blockchain)) {
|
|
22264
21458
|
throw 'You need to set a supported blockchain!';
|
|
22265
21459
|
}
|
|
22266
|
-
|
|
22267
21460
|
if (typeof configuration.token === 'undefined' && typeof configuration.fromToken === 'undefined' && typeof configuration.fromAmount === 'undefined' && typeof configuration.toToken === 'undefined') {
|
|
22268
21461
|
throw 'You need to set the token you want to receive as payment!';
|
|
22269
21462
|
}
|
|
22270
|
-
|
|
22271
21463
|
if (typeof configuration.token === 'undefined' && typeof configuration.fromToken !== 'undefined' && typeof configuration.fromAmount === 'undefined' && typeof configuration.toToken === 'undefined') {
|
|
22272
21464
|
throw 'You need to set the fromToken, fromAmount and toToken!';
|
|
22273
21465
|
}
|
|
22274
|
-
|
|
22275
21466
|
if (typeof configuration.receiver === 'undefined') {
|
|
22276
21467
|
throw 'You need to set the receiver address that you want to receive the payment!';
|
|
22277
21468
|
}
|
|
22278
21469
|
});
|
|
22279
|
-
|
|
22280
21470
|
case 4:
|
|
22281
21471
|
case "end":
|
|
22282
21472
|
return _context.stop();
|
|
@@ -22284,20 +21474,18 @@ var preflight$1 = /*#__PURE__*/function () {
|
|
|
22284
21474
|
}
|
|
22285
21475
|
}, _callee);
|
|
22286
21476
|
}));
|
|
22287
|
-
|
|
22288
21477
|
return function preflight(_x) {
|
|
22289
21478
|
return _ref2.apply(this, arguments);
|
|
22290
21479
|
};
|
|
22291
21480
|
}();
|
|
22292
|
-
|
|
22293
21481
|
var Payment = /*#__PURE__*/function () {
|
|
22294
21482
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(_ref3) {
|
|
22295
|
-
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;
|
|
22296
21484
|
return regenerator.wrap(function _callee2$(_context2) {
|
|
22297
21485
|
while (1) {
|
|
22298
21486
|
switch (_context2.prev = _context2.next) {
|
|
22299
21487
|
case 0:
|
|
22300
|
-
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;
|
|
22301
21489
|
requireReactVersion();
|
|
22302
21490
|
_context2.prev = 2;
|
|
22303
21491
|
_context2.next = 5;
|
|
@@ -22305,7 +21493,6 @@ var Payment = /*#__PURE__*/function () {
|
|
|
22305
21493
|
accept: accept,
|
|
22306
21494
|
recover: recover
|
|
22307
21495
|
});
|
|
22308
|
-
|
|
22309
21496
|
case 5:
|
|
22310
21497
|
unmount = mount({
|
|
22311
21498
|
style: style,
|
|
@@ -22327,7 +21514,7 @@ var Payment = /*#__PURE__*/function () {
|
|
|
22327
21514
|
currency: currency,
|
|
22328
21515
|
event: event,
|
|
22329
21516
|
sent: sent,
|
|
22330
|
-
|
|
21517
|
+
succeeded: succeeded,
|
|
22331
21518
|
validated: validated,
|
|
22332
21519
|
failed: failed,
|
|
22333
21520
|
whitelist: whitelist,
|
|
@@ -22369,16 +21556,13 @@ var Payment = /*#__PURE__*/function () {
|
|
|
22369
21556
|
return _context2.abrupt("return", {
|
|
22370
21557
|
unmount: unmount
|
|
22371
21558
|
});
|
|
22372
|
-
|
|
22373
21559
|
case 9:
|
|
22374
21560
|
_context2.prev = 9;
|
|
22375
21561
|
_context2.t0 = _context2["catch"](2);
|
|
22376
21562
|
console.log('critical error', _context2.t0);
|
|
22377
|
-
|
|
22378
21563
|
if (critical != undefined) {
|
|
22379
21564
|
critical(_context2.t0);
|
|
22380
21565
|
}
|
|
22381
|
-
|
|
22382
21566
|
case 13:
|
|
22383
21567
|
case "end":
|
|
22384
21568
|
return _context2.stop();
|
|
@@ -22386,19 +21570,17 @@ var Payment = /*#__PURE__*/function () {
|
|
|
22386
21570
|
}
|
|
22387
21571
|
}, _callee2, null, [[2, 9]]);
|
|
22388
21572
|
}));
|
|
22389
|
-
|
|
22390
21573
|
return function Payment(_x2) {
|
|
22391
21574
|
return _ref4.apply(this, arguments);
|
|
22392
21575
|
};
|
|
22393
21576
|
}();
|
|
22394
|
-
|
|
22395
21577
|
Payment.preload = function (_ref5) {
|
|
22396
21578
|
var account = _ref5.account,
|
|
22397
|
-
|
|
22398
|
-
|
|
22399
|
-
|
|
22400
|
-
|
|
22401
|
-
|
|
21579
|
+
accept = _ref5.accept,
|
|
21580
|
+
whitelist = _ref5.whitelist,
|
|
21581
|
+
blacklist = _ref5.blacklist,
|
|
21582
|
+
event = _ref5.event,
|
|
21583
|
+
fee = _ref5.fee;
|
|
22402
21584
|
routePayments({
|
|
22403
21585
|
account: account,
|
|
22404
21586
|
accept: accept,
|
|
@@ -22415,25 +21597,21 @@ var ToTokenContext = /*#__PURE__*/React.createContext();
|
|
|
22415
21597
|
|
|
22416
21598
|
var ToTokenProvider = (function (props) {
|
|
22417
21599
|
var _useContext = useContext(PaymentContext),
|
|
22418
|
-
|
|
22419
|
-
|
|
21600
|
+
payment = _useContext.payment;
|
|
22420
21601
|
var _useState = useState(),
|
|
22421
|
-
|
|
22422
|
-
|
|
22423
|
-
|
|
22424
|
-
|
|
21602
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
21603
|
+
toToken = _useState2[0],
|
|
21604
|
+
setToToken = _useState2[1];
|
|
22425
21605
|
var _useState3 = useState(),
|
|
22426
|
-
|
|
22427
|
-
|
|
22428
|
-
|
|
22429
|
-
|
|
21606
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
21607
|
+
toTokenReadableAmount = _useState4[0],
|
|
21608
|
+
setToTokenReadableAmount = _useState4[1];
|
|
22430
21609
|
useEffect(function () {
|
|
22431
21610
|
if (payment) {
|
|
22432
21611
|
Promise.all([payment.route.toToken.symbol(), payment.route.toToken.readable(payment.route.toAmount)]).then(function (_ref) {
|
|
22433
21612
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
22434
|
-
|
|
22435
|
-
|
|
22436
|
-
|
|
21613
|
+
symbol = _ref2[0],
|
|
21614
|
+
readableAmount = _ref2[1];
|
|
22437
21615
|
setToToken({
|
|
22438
21616
|
address: payment.route.toToken.address,
|
|
22439
21617
|
symbol: symbol
|
|
@@ -22452,29 +21630,23 @@ var ToTokenProvider = (function (props) {
|
|
|
22452
21630
|
|
|
22453
21631
|
var SaleRoutingProvider = (function (props) {
|
|
22454
21632
|
var _useContext = useContext(ChangableAmountContext),
|
|
22455
|
-
|
|
22456
|
-
|
|
22457
|
-
|
|
21633
|
+
acceptWithAmount = _useContext.acceptWithAmount,
|
|
21634
|
+
setMaxRoute = _useContext.setMaxRoute;
|
|
22458
21635
|
var _useContext2 = useContext(ConfigurationContext),
|
|
22459
|
-
|
|
22460
|
-
|
|
21636
|
+
sell = _useContext2.sell;
|
|
22461
21637
|
var _useContext3 = useContext(ConfigurationContext),
|
|
22462
|
-
|
|
22463
|
-
|
|
21638
|
+
blacklist = _useContext3.blacklist;
|
|
22464
21639
|
if (blacklist == undefined) {
|
|
22465
21640
|
blacklist = {};
|
|
22466
21641
|
}
|
|
22467
|
-
|
|
22468
21642
|
for (var blockchain in sell) {
|
|
22469
21643
|
var token = sell[blockchain];
|
|
22470
|
-
|
|
22471
21644
|
if (blacklist[blockchain] instanceof Array) {
|
|
22472
21645
|
blacklist[blockchain].push(token);
|
|
22473
21646
|
} else {
|
|
22474
21647
|
blacklist[blockchain] = [token];
|
|
22475
21648
|
}
|
|
22476
21649
|
}
|
|
22477
|
-
|
|
22478
21650
|
return /*#__PURE__*/React.createElement(SaleRoutingContext.Provider, {
|
|
22479
21651
|
value: {}
|
|
22480
21652
|
}, /*#__PURE__*/React.createElement(PaymentRoutingProvider, {
|
|
@@ -22522,31 +21694,24 @@ var SaleOverviewSkeleton = (function (props) {
|
|
|
22522
21694
|
|
|
22523
21695
|
var SaleOverviewDialog = (function (props) {
|
|
22524
21696
|
var _useContext = useContext(ChangableAmountContext);
|
|
22525
|
-
|
|
22526
|
-
|
|
21697
|
+
_useContext.amount;
|
|
22527
21698
|
var _useContext2 = useContext(ConfigurationContext),
|
|
22528
|
-
|
|
22529
|
-
|
|
22530
|
-
|
|
21699
|
+
tokenImage = _useContext2.tokenImage,
|
|
21700
|
+
amountConfiguration = _useContext2.amount;
|
|
22531
21701
|
var _useContext3 = useContext(PaymentValueContext),
|
|
22532
|
-
|
|
22533
|
-
|
|
21702
|
+
paymentValue = _useContext3.paymentValue;
|
|
22534
21703
|
var _useContext4 = useContext(PaymentContext),
|
|
22535
|
-
|
|
22536
|
-
|
|
22537
|
-
|
|
21704
|
+
payment = _useContext4.payment,
|
|
21705
|
+
paymentState = _useContext4.paymentState;
|
|
22538
21706
|
var _useContext5 = useContext(NavigateStackContext),
|
|
22539
|
-
|
|
22540
|
-
|
|
21707
|
+
navigate = _useContext5.navigate;
|
|
22541
21708
|
var _useContext6 = useContext(ToTokenContext),
|
|
22542
|
-
|
|
22543
|
-
|
|
22544
|
-
|
|
21709
|
+
toToken = _useContext6.toToken,
|
|
21710
|
+
toTokenReadableAmount = _useContext6.toTokenReadableAmount;
|
|
22545
21711
|
var _useState = useState(),
|
|
22546
|
-
|
|
22547
|
-
|
|
22548
|
-
|
|
22549
|
-
|
|
21712
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
21713
|
+
salePerTokenValue = _useState2[0],
|
|
21714
|
+
setSalePerTokenValue = _useState2[1];
|
|
22550
21715
|
useEffect(function () {
|
|
22551
21716
|
if (paymentValue && (amountConfiguration == undefined || amountConfiguration.token != true) && toTokenReadableAmount) {
|
|
22552
21717
|
var UsdAmountPerToken = paymentValue.amount / parseFloat(toTokenReadableAmount);
|
|
@@ -22558,19 +21723,15 @@ var SaleOverviewDialog = (function (props) {
|
|
|
22558
21723
|
amount: 0,
|
|
22559
21724
|
code: paymentValue.code
|
|
22560
21725
|
}).toString();
|
|
22561
|
-
|
|
22562
21726
|
if (readableLocalizedAmountPerToken != zero) {
|
|
22563
21727
|
setSalePerTokenValue(readableLocalizedAmountPerToken);
|
|
22564
21728
|
}
|
|
22565
21729
|
}
|
|
22566
21730
|
}, [paymentValue, toTokenReadableAmount]);
|
|
22567
|
-
|
|
22568
21731
|
if (toToken == undefined || toTokenReadableAmount == undefined || payment == undefined || paymentValue == undefined) {
|
|
22569
21732
|
return /*#__PURE__*/React.createElement(SaleOverviewSkeleton, null);
|
|
22570
21733
|
}
|
|
22571
|
-
|
|
22572
21734
|
var tokenImageElement;
|
|
22573
|
-
|
|
22574
21735
|
if (tokenImage) {
|
|
22575
21736
|
tokenImageElement = /*#__PURE__*/React.createElement("img", {
|
|
22576
21737
|
src: tokenImage
|
|
@@ -22581,7 +21742,6 @@ var SaleOverviewDialog = (function (props) {
|
|
|
22581
21742
|
address: toToken.address
|
|
22582
21743
|
});
|
|
22583
21744
|
}
|
|
22584
|
-
|
|
22585
21745
|
var blockchain = Blockchain.findByName(payment.blockchain);
|
|
22586
21746
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
22587
21747
|
header: /*#__PURE__*/React.createElement("div", {
|
|
@@ -22598,7 +21758,6 @@ var SaleOverviewDialog = (function (props) {
|
|
|
22598
21758
|
if (paymentState != 'initialized') {
|
|
22599
21759
|
return;
|
|
22600
21760
|
}
|
|
22601
|
-
|
|
22602
21761
|
navigate('ChangeAmount');
|
|
22603
21762
|
}
|
|
22604
21763
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -22634,7 +21793,6 @@ var SaleOverviewDialog = (function (props) {
|
|
|
22634
21793
|
if (paymentState != 'initialized') {
|
|
22635
21794
|
return;
|
|
22636
21795
|
}
|
|
22637
|
-
|
|
22638
21796
|
navigate('ChangePayment');
|
|
22639
21797
|
}
|
|
22640
21798
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -22668,12 +21826,10 @@ var SaleOverviewDialog = (function (props) {
|
|
|
22668
21826
|
|
|
22669
21827
|
var SaleStack = (function (props) {
|
|
22670
21828
|
var _useContext = useContext(ClosableContext),
|
|
22671
|
-
|
|
22672
|
-
|
|
22673
|
-
|
|
21829
|
+
open = _useContext.open,
|
|
21830
|
+
close = _useContext.close;
|
|
22674
21831
|
var _useContext2 = useContext(NavigateContext),
|
|
22675
|
-
|
|
22676
|
-
|
|
21832
|
+
setNavigator = _useContext2.setNavigator;
|
|
22677
21833
|
return /*#__PURE__*/React.createElement(ReactDialogStack, {
|
|
22678
21834
|
setNavigator: setNavigator,
|
|
22679
21835
|
open: open,
|
|
@@ -22686,7 +21842,7 @@ var SaleStack = (function (props) {
|
|
|
22686
21842
|
ChangeAmount: /*#__PURE__*/React.createElement(ChangeAmountDialog, null),
|
|
22687
21843
|
ChangePayment: /*#__PURE__*/React.createElement(ChangePaymentDialog, null),
|
|
22688
21844
|
NoPaymentMethodFound: /*#__PURE__*/React.createElement(NoPaymentMethodFoundDialog, null),
|
|
22689
|
-
|
|
21845
|
+
PaymentFailed: /*#__PURE__*/React.createElement(PaymentFailedDialog, null),
|
|
22690
21846
|
WrongNetwork: /*#__PURE__*/React.createElement(WrongNetworkDialog, null)
|
|
22691
21847
|
}
|
|
22692
21848
|
});
|
|
@@ -22700,30 +21856,23 @@ var preflight = /*#__PURE__*/function () {
|
|
|
22700
21856
|
switch (_context.prev = _context.next) {
|
|
22701
21857
|
case 0:
|
|
22702
21858
|
sell = _ref.sell;
|
|
22703
|
-
|
|
22704
21859
|
if (!(_typeof(sell) != 'object')) {
|
|
22705
21860
|
_context.next = 3;
|
|
22706
21861
|
break;
|
|
22707
21862
|
}
|
|
22708
|
-
|
|
22709
21863
|
throw 'You need to configure at least 1 "blockchain": "token"';
|
|
22710
|
-
|
|
22711
21864
|
case 3:
|
|
22712
21865
|
if (!(Object.keys(sell).length == 0)) {
|
|
22713
21866
|
_context.next = 5;
|
|
22714
21867
|
break;
|
|
22715
21868
|
}
|
|
22716
|
-
|
|
22717
21869
|
throw 'You need to configure at least 1 "blockchain": "token"';
|
|
22718
|
-
|
|
22719
21870
|
case 5:
|
|
22720
21871
|
if (!(Object.values(sell).length == 0)) {
|
|
22721
21872
|
_context.next = 7;
|
|
22722
21873
|
break;
|
|
22723
21874
|
}
|
|
22724
|
-
|
|
22725
21875
|
throw 'You need to configure at least 1 "blockchain": "token"';
|
|
22726
|
-
|
|
22727
21876
|
case 7:
|
|
22728
21877
|
case "end":
|
|
22729
21878
|
return _context.stop();
|
|
@@ -22731,27 +21880,24 @@ var preflight = /*#__PURE__*/function () {
|
|
|
22731
21880
|
}
|
|
22732
21881
|
}, _callee);
|
|
22733
21882
|
}));
|
|
22734
|
-
|
|
22735
21883
|
return function preflight(_x) {
|
|
22736
21884
|
return _ref2.apply(this, arguments);
|
|
22737
21885
|
};
|
|
22738
21886
|
}();
|
|
22739
|
-
|
|
22740
21887
|
var Sale = /*#__PURE__*/function () {
|
|
22741
21888
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(_ref3) {
|
|
22742
|
-
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;
|
|
22743
21890
|
return regenerator.wrap(function _callee2$(_context2) {
|
|
22744
21891
|
while (1) {
|
|
22745
21892
|
switch (_context2.prev = _context2.next) {
|
|
22746
21893
|
case 0:
|
|
22747
|
-
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;
|
|
22748
21895
|
requireReactVersion();
|
|
22749
21896
|
_context2.prev = 2;
|
|
22750
21897
|
_context2.next = 5;
|
|
22751
21898
|
return preflight({
|
|
22752
21899
|
sell: sell
|
|
22753
21900
|
});
|
|
22754
|
-
|
|
22755
21901
|
case 5:
|
|
22756
21902
|
accept = Object.keys(sell).map(function (key) {
|
|
22757
21903
|
return {
|
|
@@ -22777,7 +21923,7 @@ var Sale = /*#__PURE__*/function () {
|
|
|
22777
21923
|
sell: sell,
|
|
22778
21924
|
currency: currency,
|
|
22779
21925
|
sent: sent,
|
|
22780
|
-
|
|
21926
|
+
succeeded: succeeded,
|
|
22781
21927
|
failed: failed,
|
|
22782
21928
|
blacklist: blacklist,
|
|
22783
21929
|
providers: providers,
|
|
@@ -22806,16 +21952,13 @@ var Sale = /*#__PURE__*/function () {
|
|
|
22806
21952
|
return _context2.abrupt("return", {
|
|
22807
21953
|
unmount: unmount
|
|
22808
21954
|
});
|
|
22809
|
-
|
|
22810
21955
|
case 10:
|
|
22811
21956
|
_context2.prev = 10;
|
|
22812
21957
|
_context2.t0 = _context2["catch"](2);
|
|
22813
21958
|
console.log('critical error', _context2.t0);
|
|
22814
|
-
|
|
22815
21959
|
if (critical != undefined) {
|
|
22816
21960
|
critical(_context2.t0);
|
|
22817
21961
|
}
|
|
22818
|
-
|
|
22819
21962
|
case 14:
|
|
22820
21963
|
case "end":
|
|
22821
21964
|
return _context2.stop();
|
|
@@ -22823,7 +21966,6 @@ var Sale = /*#__PURE__*/function () {
|
|
|
22823
21966
|
}
|
|
22824
21967
|
}, _callee2, null, [[2, 10]]);
|
|
22825
21968
|
}));
|
|
22826
|
-
|
|
22827
21969
|
return function Sale(_x2) {
|
|
22828
21970
|
return _ref4.apply(this, arguments);
|
|
22829
21971
|
};
|
|
@@ -22833,10 +21975,9 @@ var SelectionContext = /*#__PURE__*/React.createContext();
|
|
|
22833
21975
|
|
|
22834
21976
|
var SelectionProvider = (function (props) {
|
|
22835
21977
|
var _useState = useState({}),
|
|
22836
|
-
|
|
22837
|
-
|
|
22838
|
-
|
|
22839
|
-
|
|
21978
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
21979
|
+
selection = _useState2[0],
|
|
21980
|
+
setSelection = _useState2[1];
|
|
22840
21981
|
return /*#__PURE__*/React.createElement(SelectionContext.Provider, {
|
|
22841
21982
|
value: {
|
|
22842
21983
|
selection: selection,
|
|
@@ -22870,25 +22011,20 @@ var msToTime = (function (ms) {
|
|
|
22870
22011
|
|
|
22871
22012
|
var ConfirmTokenSelectionDialog = (function (props) {
|
|
22872
22013
|
var _useContext = useContext(SelectionContext),
|
|
22873
|
-
|
|
22874
|
-
|
|
22014
|
+
selection = _useContext.selection;
|
|
22875
22015
|
var _useContext2 = useContext(ClosableContext),
|
|
22876
|
-
|
|
22877
|
-
|
|
22016
|
+
setOpen = _useContext2.setOpen;
|
|
22878
22017
|
var token = selection.token;
|
|
22879
22018
|
var address = token.address || token.external_id;
|
|
22880
22019
|
var logo = token.logo || token.image;
|
|
22881
22020
|
var blockchain = Blockchain.findByName(token.blockchain);
|
|
22882
22021
|
var age = token.first_transfer ? msToTime(new Date() - new Date(token.first_transfer)) : undefined;
|
|
22883
|
-
|
|
22884
22022
|
if (age) {
|
|
22885
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) {
|
|
22886
22024
|
return n;
|
|
22887
22025
|
}).join(' ');
|
|
22888
22026
|
}
|
|
22889
|
-
|
|
22890
22027
|
var holders = token.unique_senders ? token.unique_senders : undefined;
|
|
22891
|
-
|
|
22892
22028
|
if (holders) {
|
|
22893
22029
|
if (holders > 1000000) {
|
|
22894
22030
|
holders = "Millions";
|
|
@@ -22902,7 +22038,6 @@ var ConfirmTokenSelectionDialog = (function (props) {
|
|
|
22902
22038
|
holders = "Only a Few!!!";
|
|
22903
22039
|
}
|
|
22904
22040
|
}
|
|
22905
|
-
|
|
22906
22041
|
var onClickConfirm = function onClickConfirm() {
|
|
22907
22042
|
setOpen(false);
|
|
22908
22043
|
props.resolve({
|
|
@@ -22915,7 +22050,6 @@ var ConfirmTokenSelectionDialog = (function (props) {
|
|
|
22915
22050
|
});
|
|
22916
22051
|
setTimeout(props.unmount, 300);
|
|
22917
22052
|
};
|
|
22918
|
-
|
|
22919
22053
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
22920
22054
|
header: /*#__PURE__*/React.createElement("div", {
|
|
22921
22055
|
className: "PaddingTopS PaddingLeftM PaddingRightM TextLeft"
|
|
@@ -22973,26 +22107,21 @@ var ConfirmTokenSelectionDialog = (function (props) {
|
|
|
22973
22107
|
|
|
22974
22108
|
var SelectBlockchainDialog = (function (props) {
|
|
22975
22109
|
var _useContext = useContext(SelectionContext),
|
|
22976
|
-
|
|
22977
|
-
|
|
22110
|
+
setSelection = _useContext.setSelection;
|
|
22978
22111
|
var _useContext2 = useContext(NavigateStackContext),
|
|
22979
|
-
|
|
22980
|
-
|
|
22112
|
+
navigate = _useContext2.navigate;
|
|
22981
22113
|
var stacked = Object.keys(props.selection).length > 1;
|
|
22982
22114
|
var blockchains = [Blockchain.findByName('ethereum'), Blockchain.findByName('bsc'), Blockchain.findByName('polygon')];
|
|
22983
|
-
|
|
22984
22115
|
var selectBlockchain = function selectBlockchain(blockchain) {
|
|
22985
22116
|
setSelection(Object.assign(props.selection, {
|
|
22986
22117
|
blockchain: blockchain
|
|
22987
22118
|
}));
|
|
22988
|
-
|
|
22989
22119
|
if (stacked) {
|
|
22990
22120
|
navigate('back');
|
|
22991
22121
|
} else {
|
|
22992
22122
|
props.resolve(blockchain);
|
|
22993
22123
|
}
|
|
22994
22124
|
};
|
|
22995
|
-
|
|
22996
22125
|
var elements = blockchains.map(function (blockchain, index) {
|
|
22997
22126
|
return /*#__PURE__*/React.createElement("div", {
|
|
22998
22127
|
key: index,
|
|
@@ -23030,42 +22159,33 @@ var SelectBlockchainDialog = (function (props) {
|
|
|
23030
22159
|
|
|
23031
22160
|
var SelectTokenDialog = (function (props) {
|
|
23032
22161
|
var _useContext = useContext(NavigateStackContext),
|
|
23033
|
-
|
|
23034
|
-
|
|
22162
|
+
navigate = _useContext.navigate;
|
|
23035
22163
|
var _useContext2 = useContext(ClosableContext),
|
|
23036
|
-
|
|
23037
|
-
|
|
22164
|
+
setOpen = _useContext2.setOpen;
|
|
23038
22165
|
var _useContext3 = useContext(SelectionContext),
|
|
23039
|
-
|
|
23040
|
-
|
|
22166
|
+
setSelection = _useContext3.setSelection;
|
|
23041
22167
|
var _useState = useState(''),
|
|
23042
|
-
|
|
23043
|
-
|
|
23044
|
-
|
|
23045
|
-
|
|
22168
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
22169
|
+
searchTerm = _useState2[0],
|
|
22170
|
+
setSearchTerm = _useState2[1];
|
|
23046
22171
|
var _useState3 = useState(),
|
|
23047
|
-
|
|
23048
|
-
|
|
23049
|
-
|
|
23050
|
-
|
|
22172
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
22173
|
+
blockchain = _useState4[0],
|
|
22174
|
+
setBlockchain = _useState4[1];
|
|
23051
22175
|
var _useState5 = useState(false),
|
|
23052
|
-
|
|
23053
|
-
|
|
23054
|
-
|
|
23055
|
-
|
|
22176
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
22177
|
+
showAddToken = _useState6[0],
|
|
22178
|
+
setShowAddToken = _useState6[1];
|
|
23056
22179
|
var _useState7 = useState([]),
|
|
23057
|
-
|
|
23058
|
-
|
|
23059
|
-
|
|
23060
|
-
|
|
22180
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
22181
|
+
tokens = _useState8[0],
|
|
22182
|
+
setTokens = _useState8[1];
|
|
23061
22183
|
var _useState9 = useState(),
|
|
23062
|
-
|
|
23063
|
-
|
|
23064
|
-
|
|
23065
|
-
|
|
22184
|
+
_useState10 = _slicedToArray(_useState9, 2);
|
|
22185
|
+
_useState10[0];
|
|
22186
|
+
_useState10[1];
|
|
23066
22187
|
var searchElement = useRef();
|
|
23067
|
-
var wallet =
|
|
23068
|
-
|
|
22188
|
+
var wallet = getWallets()[0];
|
|
23069
22189
|
var startWithBlockchain = function startWithBlockchain(name) {
|
|
23070
22190
|
var blockchain = Blockchain.findByName(name);
|
|
23071
22191
|
setBlockchain(blockchain);
|
|
@@ -23075,12 +22195,10 @@ var SelectTokenDialog = (function (props) {
|
|
|
23075
22195
|
}));
|
|
23076
22196
|
setTokens(blockchain.tokens);
|
|
23077
22197
|
};
|
|
23078
|
-
|
|
23079
22198
|
useEffect(function () {
|
|
23080
22199
|
if (wallet) {
|
|
23081
22200
|
wallet.connectedTo().then(function (name) {
|
|
23082
22201
|
var blockchain = Blockchain.findByName(name);
|
|
23083
|
-
|
|
23084
22202
|
if (name && name.length && blockchain && blockchain.tokens && blockchain.tokens.length) {
|
|
23085
22203
|
startWithBlockchain(name);
|
|
23086
22204
|
} else {
|
|
@@ -23095,27 +22213,22 @@ var SelectTokenDialog = (function (props) {
|
|
|
23095
22213
|
if (props.selection.blockchain) {
|
|
23096
22214
|
setBlockchain(props.selection.blockchain);
|
|
23097
22215
|
setTokens(props.selection.blockchain.tokens);
|
|
23098
|
-
|
|
23099
22216
|
if (searchElement.current) {
|
|
23100
22217
|
searchElement.current.value = '';
|
|
23101
22218
|
searchElement.current.focus();
|
|
23102
22219
|
}
|
|
23103
22220
|
}
|
|
23104
22221
|
}, [props.selection, props.selection.blockchain]);
|
|
23105
|
-
|
|
23106
22222
|
var onClickChangeBlockchain = function onClickChangeBlockchain() {
|
|
23107
22223
|
navigate('SelectBlockchain');
|
|
23108
22224
|
};
|
|
23109
|
-
|
|
23110
22225
|
var onClickAddToken = function onClickAddToken() {
|
|
23111
22226
|
setShowAddToken(true);
|
|
23112
|
-
|
|
23113
22227
|
if (searchElement.current) {
|
|
23114
22228
|
searchElement.current.value = '';
|
|
23115
22229
|
searchElement.current.focus();
|
|
23116
22230
|
}
|
|
23117
22231
|
};
|
|
23118
|
-
|
|
23119
22232
|
var searchTokens = useCallback(lodash.debounce(function (term, blockchainName) {
|
|
23120
22233
|
fetch("https://public.depay.com/tokens/search?blockchain=".concat(blockchainName, "&term=").concat(term)).then(function (response) {
|
|
23121
22234
|
if (response.status == 200) {
|
|
@@ -23131,32 +22244,26 @@ var SelectTokenDialog = (function (props) {
|
|
|
23131
22244
|
return reject;
|
|
23132
22245
|
});
|
|
23133
22246
|
}, 300), []);
|
|
23134
|
-
|
|
23135
22247
|
var onChangeSearch = function onChangeSearch(event) {
|
|
23136
22248
|
var term = event.target.value;
|
|
23137
22249
|
setSearchTerm(term);
|
|
23138
|
-
|
|
23139
22250
|
if (term.match(/^0x/)) {
|
|
23140
22251
|
setTokens([]);
|
|
23141
22252
|
var token;
|
|
23142
|
-
|
|
23143
22253
|
try {
|
|
23144
22254
|
token = new Token({
|
|
23145
22255
|
blockchain: blockchain.name,
|
|
23146
22256
|
address: term
|
|
23147
22257
|
});
|
|
23148
22258
|
} catch (_unused) {}
|
|
23149
|
-
|
|
23150
22259
|
if (token == undefined) {
|
|
23151
22260
|
return;
|
|
23152
22261
|
}
|
|
23153
|
-
|
|
23154
22262
|
Promise.all([token.name(), token.symbol(), token.decimals()]).then(function (_ref) {
|
|
23155
22263
|
var _ref2 = _slicedToArray(_ref, 3),
|
|
23156
|
-
|
|
23157
|
-
|
|
23158
|
-
|
|
23159
|
-
|
|
22264
|
+
name = _ref2[0],
|
|
22265
|
+
symbol = _ref2[1],
|
|
22266
|
+
decimals = _ref2[2];
|
|
23160
22267
|
setTokens([{
|
|
23161
22268
|
name: name,
|
|
23162
22269
|
symbol: symbol,
|
|
@@ -23172,7 +22279,6 @@ var SelectTokenDialog = (function (props) {
|
|
|
23172
22279
|
setTokens(blockchain.tokens);
|
|
23173
22280
|
}
|
|
23174
22281
|
};
|
|
23175
|
-
|
|
23176
22282
|
var select = function select(token) {
|
|
23177
22283
|
if (blockchain.tokens.find(function (majorToken) {
|
|
23178
22284
|
return majorToken.address.toLowerCase() == (token.address || token.external_id).toLowerCase();
|
|
@@ -23194,7 +22300,6 @@ var SelectTokenDialog = (function (props) {
|
|
|
23194
22300
|
navigate('ConfirmTokenSelection');
|
|
23195
22301
|
}
|
|
23196
22302
|
};
|
|
23197
|
-
|
|
23198
22303
|
var elements = tokens.map(function (token, index) {
|
|
23199
22304
|
return /*#__PURE__*/React.createElement("div", {
|
|
23200
22305
|
key: "".concat(index, "-").concat(token.address),
|
|
@@ -23225,11 +22330,9 @@ var SelectTokenDialog = (function (props) {
|
|
|
23225
22330
|
className: "CardText"
|
|
23226
22331
|
}, token.name))));
|
|
23227
22332
|
});
|
|
23228
|
-
|
|
23229
22333
|
if (blockchain == undefined) {
|
|
23230
22334
|
return null;
|
|
23231
22335
|
}
|
|
23232
|
-
|
|
23233
22336
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
23234
22337
|
header: /*#__PURE__*/React.createElement("div", {
|
|
23235
22338
|
className: "PaddingTopS PaddingLeftM PaddingRightM TextLeft"
|
|
@@ -23282,22 +22385,17 @@ var SelectTokenDialog = (function (props) {
|
|
|
23282
22385
|
|
|
23283
22386
|
var SelectStack = (function (props) {
|
|
23284
22387
|
var _useContext = useContext(ConfigurationContext),
|
|
23285
|
-
|
|
23286
|
-
|
|
22388
|
+
what = _useContext.what;
|
|
23287
22389
|
var _useContext2 = useContext(ClosableContext),
|
|
23288
|
-
|
|
23289
|
-
|
|
23290
|
-
|
|
22390
|
+
open = _useContext2.open,
|
|
22391
|
+
close = _useContext2.close;
|
|
23291
22392
|
var _useContext3 = useContext(SelectionContext),
|
|
23292
|
-
|
|
23293
|
-
|
|
22393
|
+
selection = _useContext3.selection;
|
|
23294
22394
|
var start;
|
|
23295
|
-
|
|
23296
22395
|
switch (what) {
|
|
23297
22396
|
default:
|
|
23298
22397
|
start = 'SelectToken';
|
|
23299
22398
|
}
|
|
23300
|
-
|
|
23301
22399
|
return /*#__PURE__*/React.createElement(ReactDialogStack, {
|
|
23302
22400
|
open: open,
|
|
23303
22401
|
close: close,
|
|
@@ -23326,22 +22424,18 @@ var SelectStack = (function (props) {
|
|
|
23326
22424
|
var Select = function Select(options) {
|
|
23327
22425
|
requireReactVersion();
|
|
23328
22426
|
var style, error, document, what;
|
|
23329
|
-
|
|
23330
22427
|
if (_typeof(options) == 'object') {
|
|
23331
22428
|
style = options.style;
|
|
23332
22429
|
error = options.error;
|
|
23333
22430
|
document = options.document;
|
|
23334
22431
|
what = options.what;
|
|
23335
22432
|
}
|
|
23336
|
-
|
|
23337
22433
|
var startupError;
|
|
23338
|
-
|
|
23339
22434
|
if (what == undefined) {
|
|
23340
22435
|
startupError = '"what" needs to be configured!';
|
|
23341
22436
|
} else if (['token'].indexOf(what) < 0) {
|
|
23342
22437
|
startupError = "Unknown \"what\" configured: ".concat(what, "!");
|
|
23343
22438
|
}
|
|
23344
|
-
|
|
23345
22439
|
return new Promise( /*#__PURE__*/function () {
|
|
23346
22440
|
var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(resolve, reject) {
|
|
23347
22441
|
return regenerator.wrap(function _callee$(_context) {
|
|
@@ -23356,7 +22450,6 @@ var Select = function Select(options) {
|
|
|
23356
22450
|
reject('USER_CLOSED_DIALOG');
|
|
23357
22451
|
unmount();
|
|
23358
22452
|
};
|
|
23359
|
-
|
|
23360
22453
|
return function (container) {
|
|
23361
22454
|
return /*#__PURE__*/React.createElement(ErrorProvider, {
|
|
23362
22455
|
error: startupError,
|
|
@@ -23377,7 +22470,6 @@ var Select = function Select(options) {
|
|
|
23377
22470
|
})), /*#__PURE__*/React.createElement(PoweredBy, null)))));
|
|
23378
22471
|
};
|
|
23379
22472
|
});
|
|
23380
|
-
|
|
23381
22473
|
case 1:
|
|
23382
22474
|
case "end":
|
|
23383
22475
|
return _context.stop();
|
|
@@ -23385,7 +22477,6 @@ var Select = function Select(options) {
|
|
|
23385
22477
|
}
|
|
23386
22478
|
}, _callee);
|
|
23387
22479
|
}));
|
|
23388
|
-
|
|
23389
22480
|
return function (_x, _x2) {
|
|
23390
22481
|
return _ref.apply(this, arguments);
|
|
23391
22482
|
};
|
|
@@ -23398,8 +22489,7 @@ var DePayWidgets = {
|
|
|
23398
22489
|
Login: Login,
|
|
23399
22490
|
Payment: Payment,
|
|
23400
22491
|
Sale: Sale,
|
|
23401
|
-
Select: Select
|
|
23402
|
-
provider: provider
|
|
22492
|
+
Select: Select
|
|
23403
22493
|
};
|
|
23404
22494
|
|
|
23405
22495
|
export { DePayWidgets as default };
|