@depay/widgets 8.0.7 → 8.1.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 +26 -0
- package/dist/esm/index.bundle.js +10 -10
- package/dist/esm/index.js +118 -62
- package/dist/umd/index.bundle.js +6 -6
- package/dist/umd/index.js +118 -62
- package/package.json +2 -2
package/dist/esm/index.js
CHANGED
|
@@ -212,14 +212,9 @@ function _regeneratorRuntime() {
|
|
|
212
212
|
};
|
|
213
213
|
}
|
|
214
214
|
function maybeInvokeDelegate(delegate, context) {
|
|
215
|
-
var
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
|
219
|
-
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
220
|
-
}
|
|
221
|
-
return ContinueSentinel;
|
|
222
|
-
}
|
|
215
|
+
var methodName = context.method,
|
|
216
|
+
method = delegate.iterator[methodName];
|
|
217
|
+
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
|
|
223
218
|
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
224
219
|
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
225
220
|
var info = record.arg;
|
|
@@ -413,28 +408,33 @@ function _arrayWithHoles(arr) {
|
|
|
413
408
|
}
|
|
414
409
|
|
|
415
410
|
function _iterableToArrayLimit(arr, i) {
|
|
416
|
-
var _i =
|
|
417
|
-
if (
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
if (i && _arr.length === i) break;
|
|
426
|
-
}
|
|
427
|
-
} catch (err) {
|
|
428
|
-
_d = true;
|
|
429
|
-
_e = err;
|
|
430
|
-
} finally {
|
|
411
|
+
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
|
|
412
|
+
if (null != _i) {
|
|
413
|
+
var _s,
|
|
414
|
+
_e,
|
|
415
|
+
_x,
|
|
416
|
+
_r,
|
|
417
|
+
_arr = [],
|
|
418
|
+
_n = !0,
|
|
419
|
+
_d = !1;
|
|
431
420
|
try {
|
|
432
|
-
if (
|
|
421
|
+
if (_x = (_i = _i.call(arr)).next, 0 === i) {
|
|
422
|
+
if (Object(_i) !== _i) return;
|
|
423
|
+
_n = !1;
|
|
424
|
+
} else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0) {
|
|
425
|
+
;
|
|
426
|
+
}
|
|
427
|
+
} catch (err) {
|
|
428
|
+
_d = !0, _e = err;
|
|
433
429
|
} finally {
|
|
434
|
-
|
|
430
|
+
try {
|
|
431
|
+
if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return;
|
|
432
|
+
} finally {
|
|
433
|
+
if (_d) throw _e;
|
|
434
|
+
}
|
|
435
435
|
}
|
|
436
|
+
return _arr;
|
|
436
437
|
}
|
|
437
|
-
return _arr;
|
|
438
438
|
}
|
|
439
439
|
|
|
440
440
|
function _arrayLikeToArray(arr, len) {
|
|
@@ -868,13 +868,29 @@ function _classCallCheck(instance, Constructor) {
|
|
|
868
868
|
}
|
|
869
869
|
}
|
|
870
870
|
|
|
871
|
+
function _toPrimitive(input, hint) {
|
|
872
|
+
if (_typeof(input) !== "object" || input === null) return input;
|
|
873
|
+
var prim = input[Symbol.toPrimitive];
|
|
874
|
+
if (prim !== undefined) {
|
|
875
|
+
var res = prim.call(input, hint || "default");
|
|
876
|
+
if (_typeof(res) !== "object") return res;
|
|
877
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
878
|
+
}
|
|
879
|
+
return (hint === "string" ? String : Number)(input);
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
function _toPropertyKey(arg) {
|
|
883
|
+
var key = _toPrimitive(arg, "string");
|
|
884
|
+
return _typeof(key) === "symbol" ? key : String(key);
|
|
885
|
+
}
|
|
886
|
+
|
|
871
887
|
function _defineProperties(target, props) {
|
|
872
888
|
for (var i = 0; i < props.length; i++) {
|
|
873
889
|
var descriptor = props[i];
|
|
874
890
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
875
891
|
descriptor.configurable = true;
|
|
876
892
|
if ("value" in descriptor) descriptor.writable = true;
|
|
877
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
893
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
878
894
|
}
|
|
879
895
|
}
|
|
880
896
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
@@ -19093,7 +19109,9 @@ var PaymentProvider = (function (props) {
|
|
|
19093
19109
|
wallet = _useContext8.wallet;
|
|
19094
19110
|
var _useContext9 = useContext(PaymentTrackingContext),
|
|
19095
19111
|
release = _useContext9.release,
|
|
19096
|
-
|
|
19112
|
+
synchronousTracking = _useContext9.synchronousTracking,
|
|
19113
|
+
asynchronousTracking = _useContext9.asynchronousTracking,
|
|
19114
|
+
trackingInitialized = _useContext9.trackingInitialized,
|
|
19097
19115
|
initializePaymentTracking = _useContext9.initializeTracking;
|
|
19098
19116
|
var _useContext10 = useContext(TransactionTrackingContext),
|
|
19099
19117
|
foundTransaction = _useContext10.foundTransaction,
|
|
@@ -19115,7 +19133,7 @@ var PaymentProvider = (function (props) {
|
|
|
19115
19133
|
paymentState = _useState8[0],
|
|
19116
19134
|
setPaymentState = _useState8[1];
|
|
19117
19135
|
var paymentSucceeded = function paymentSucceeded(transaction) {
|
|
19118
|
-
if (
|
|
19136
|
+
if (synchronousTracking == false && (asynchronousTracking == false || trackingInitialized == true)) {
|
|
19119
19137
|
setClosable(true);
|
|
19120
19138
|
}
|
|
19121
19139
|
setPaymentState('success');
|
|
@@ -19124,11 +19142,14 @@ var PaymentProvider = (function (props) {
|
|
|
19124
19142
|
}
|
|
19125
19143
|
};
|
|
19126
19144
|
var paymentFailed = function paymentFailed(transaction, error) {
|
|
19145
|
+
if (asynchronousTracking == false || trackingInitialized == true) {
|
|
19146
|
+
setClosable(true);
|
|
19147
|
+
}
|
|
19148
|
+
set(['PaymentFailed']);
|
|
19149
|
+
setPaymentState('failed');
|
|
19127
19150
|
if (failed) {
|
|
19128
19151
|
failed(transaction, error);
|
|
19129
19152
|
}
|
|
19130
|
-
setClosable(true);
|
|
19131
|
-
set(['PaymentFailed']);
|
|
19132
19153
|
};
|
|
19133
19154
|
var pay = /*#__PURE__*/function () {
|
|
19134
19155
|
var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
|
|
@@ -19216,6 +19237,11 @@ var PaymentProvider = (function (props) {
|
|
|
19216
19237
|
setPaymentState('success');
|
|
19217
19238
|
}
|
|
19218
19239
|
}, [release]);
|
|
19240
|
+
useEffect(function () {
|
|
19241
|
+
if (asynchronousTracking && trackingInitialized && (paymentState == 'success' || paymentState == 'failed')) {
|
|
19242
|
+
setClosable(true);
|
|
19243
|
+
}
|
|
19244
|
+
}, [trackingInitialized, paymentState]);
|
|
19219
19245
|
useEffect(function () {
|
|
19220
19246
|
if (recover) {
|
|
19221
19247
|
setClosable(false);
|
|
@@ -19321,6 +19347,7 @@ var PaymentProvider = (function (props) {
|
|
|
19321
19347
|
});
|
|
19322
19348
|
|
|
19323
19349
|
function _defineProperty(obj, key, value) {
|
|
19350
|
+
key = _toPropertyKey(key);
|
|
19324
19351
|
if (key in obj) {
|
|
19325
19352
|
Object.defineProperty(obj, key, {
|
|
19326
19353
|
value: value,
|
|
@@ -20092,7 +20119,9 @@ var Footer = (function () {
|
|
|
20092
20119
|
_useContext.amount;
|
|
20093
20120
|
_useContext.amountsMissing;
|
|
20094
20121
|
var _useContext2 = useContext(PaymentTrackingContext),
|
|
20095
|
-
|
|
20122
|
+
synchronousTracking = _useContext2.synchronousTracking,
|
|
20123
|
+
asynchronousTracking = _useContext2.asynchronousTracking,
|
|
20124
|
+
trackingInitialized = _useContext2.trackingInitialized,
|
|
20096
20125
|
release = _useContext2.release,
|
|
20097
20126
|
forwardTo = _useContext2.forwardTo;
|
|
20098
20127
|
var _useContext3 = useContext(PaymentContext),
|
|
@@ -20114,10 +20143,25 @@ var Footer = (function () {
|
|
|
20114
20143
|
var _useContext7 = useContext(ClosableContext),
|
|
20115
20144
|
close = _useContext7.close;
|
|
20116
20145
|
var trackingInfo = function trackingInfo() {
|
|
20117
|
-
if (
|
|
20146
|
+
if (synchronousTracking == false && asynchronousTracking == false || asynchronousTracking && trackingInitialized) {
|
|
20118
20147
|
return null;
|
|
20119
|
-
}
|
|
20120
|
-
|
|
20148
|
+
} else if (asynchronousTracking && trackingInitialized == false) {
|
|
20149
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
20150
|
+
className: "Card transparent small disabled"
|
|
20151
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
20152
|
+
className: "CardImage"
|
|
20153
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
20154
|
+
className: "TextCenter"
|
|
20155
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
20156
|
+
className: "Loading Icon"
|
|
20157
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
20158
|
+
className: "CardBody"
|
|
20159
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
20160
|
+
className: "CardBodyWrapper"
|
|
20161
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
20162
|
+
className: "Opacity05"
|
|
20163
|
+
}, "Initializing tracking")))));
|
|
20164
|
+
} else if (release) {
|
|
20121
20165
|
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
20122
20166
|
className: "Card transparent small disabled"
|
|
20123
20167
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -20175,7 +20219,7 @@ var Footer = (function () {
|
|
|
20175
20219
|
className: "PaddingBottomS"
|
|
20176
20220
|
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("a", {
|
|
20177
20221
|
className: "Card transparent small",
|
|
20178
|
-
title: "
|
|
20222
|
+
title: "Transaction has been confirmed by the network",
|
|
20179
20223
|
href: transaction === null || transaction === void 0 ? void 0 : transaction.url,
|
|
20180
20224
|
target: "_blank",
|
|
20181
20225
|
rel: "noopener noreferrer"
|
|
@@ -20191,7 +20235,7 @@ var Footer = (function () {
|
|
|
20191
20235
|
className: "CardBodyWrapper"
|
|
20192
20236
|
}, /*#__PURE__*/React.createElement("div", {
|
|
20193
20237
|
className: "Opacity05"
|
|
20194
|
-
}, "
|
|
20238
|
+
}, "Transaction confirmed"))))), trackingInfo());
|
|
20195
20239
|
}
|
|
20196
20240
|
};
|
|
20197
20241
|
var approvalButton = function approvalButton() {
|
|
@@ -20257,7 +20301,7 @@ var Footer = (function () {
|
|
|
20257
20301
|
rel: "noopener noreferrer"
|
|
20258
20302
|
}, /*#__PURE__*/React.createElement(LoadingText, null, "Paying"));
|
|
20259
20303
|
} else if (paymentState == 'success') {
|
|
20260
|
-
if (
|
|
20304
|
+
if (synchronousTracking == true) {
|
|
20261
20305
|
if (release) {
|
|
20262
20306
|
if (forwardTo) {
|
|
20263
20307
|
return /*#__PURE__*/React.createElement("a", {
|
|
@@ -20277,6 +20321,11 @@ var Footer = (function () {
|
|
|
20277
20321
|
onClick: function onClick() {}
|
|
20278
20322
|
}, "Continue");
|
|
20279
20323
|
}
|
|
20324
|
+
} else if (asynchronousTracking == true && trackingInitialized == false) {
|
|
20325
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
20326
|
+
className: "ButtonPrimary disabled",
|
|
20327
|
+
onClick: function onClick() {}
|
|
20328
|
+
}, "Close");
|
|
20280
20329
|
} else {
|
|
20281
20330
|
return /*#__PURE__*/React.createElement("button", {
|
|
20282
20331
|
className: "ButtonPrimary",
|
|
@@ -20400,7 +20449,7 @@ var PaymentFailedDialog = (function () {
|
|
|
20400
20449
|
className: "Text PaddingTopS PaddingBottomS PaddingLeftS PaddingRightS"
|
|
20401
20450
|
}, /*#__PURE__*/React.createElement("strong", {
|
|
20402
20451
|
className: "FontSizeM"
|
|
20403
|
-
}, "Unfortunately executing your payment failed
|
|
20452
|
+
}, "Unfortunately executing your payment failed, but you can try again."), transaction && /*#__PURE__*/React.createElement("div", {
|
|
20404
20453
|
className: "PaddingTopS"
|
|
20405
20454
|
}, /*#__PURE__*/React.createElement("a", {
|
|
20406
20455
|
className: "Link",
|
|
@@ -20528,20 +20577,27 @@ var PaymentTrackingProvider = (function (props) {
|
|
|
20528
20577
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
20529
20578
|
paymentRoute = _useState6[0],
|
|
20530
20579
|
setPaymentRoute = _useState6[1];
|
|
20531
|
-
var _useState7 = useState(
|
|
20532
|
-
_useState8 = _slicedToArray(_useState7,
|
|
20533
|
-
|
|
20534
|
-
|
|
20580
|
+
var _useState7 = useState(false),
|
|
20581
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
20582
|
+
trackingInitialized = _useState8[0],
|
|
20583
|
+
setTrackingInitialized = _useState8[1];
|
|
20584
|
+
var _useState9 = useState(!!(track && (track.endpoint || typeof track.method == 'function') && track.async != true)),
|
|
20535
20585
|
_useState10 = _slicedToArray(_useState9, 1),
|
|
20536
|
-
|
|
20537
|
-
var _useState11 = useState(
|
|
20538
|
-
_useState12 = _slicedToArray(_useState11,
|
|
20539
|
-
|
|
20540
|
-
|
|
20541
|
-
|
|
20542
|
-
|
|
20543
|
-
|
|
20544
|
-
|
|
20586
|
+
synchronousTracking = _useState10[0];
|
|
20587
|
+
var _useState11 = useState(!!(track && track.async == true)),
|
|
20588
|
+
_useState12 = _slicedToArray(_useState11, 1),
|
|
20589
|
+
asynchronousTracking = _useState12[0];
|
|
20590
|
+
var _useState13 = useState(!!(track && track.poll && (track.poll.endpoint || typeof track.poll.method == 'function') && track.async != true)),
|
|
20591
|
+
_useState14 = _slicedToArray(_useState13, 1),
|
|
20592
|
+
polling = _useState14[0];
|
|
20593
|
+
var _useState15 = useState(false),
|
|
20594
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
20595
|
+
release = _useState16[0],
|
|
20596
|
+
setRelease = _useState16[1];
|
|
20597
|
+
var _useState17 = useState(),
|
|
20598
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
|
20599
|
+
forwardTo = _useState18[0],
|
|
20600
|
+
setForwardTo = _useState18[1];
|
|
20545
20601
|
var _useContext3 = useContext(ClosableContext),
|
|
20546
20602
|
setClosable = _useContext3.setClosable;
|
|
20547
20603
|
var _useContext4 = useContext(NavigateContext),
|
|
@@ -20636,6 +20692,7 @@ var PaymentTrackingProvider = (function (props) {
|
|
|
20636
20692
|
to_decimals: paymentRoute.toDecimals,
|
|
20637
20693
|
fee_amount: paymentRoute === null || paymentRoute === void 0 ? void 0 : (_paymentRoute$feeAmou = paymentRoute.feeAmount) === null || _paymentRoute$feeAmou === void 0 ? void 0 : _paymentRoute$feeAmou.toString()
|
|
20638
20694
|
}).then(function (response) {
|
|
20695
|
+
setTrackingInitialized(true);
|
|
20639
20696
|
console.log('PAYMENT TRACKING INITIALIZED');
|
|
20640
20697
|
})["catch"](function (error) {
|
|
20641
20698
|
console.log('PAYMENT TRACKING FAILED', error);
|
|
@@ -20692,7 +20749,7 @@ var PaymentTrackingProvider = (function (props) {
|
|
|
20692
20749
|
if (!polling) {
|
|
20693
20750
|
return;
|
|
20694
20751
|
}
|
|
20695
|
-
if (!
|
|
20752
|
+
if (!synchronousTracking) {
|
|
20696
20753
|
return;
|
|
20697
20754
|
}
|
|
20698
20755
|
var pollingInterval = setInterval(function () {
|
|
@@ -20744,10 +20801,10 @@ var PaymentTrackingProvider = (function (props) {
|
|
|
20744
20801
|
};
|
|
20745
20802
|
var initializeTracking = function initializeTracking(transaction, afterBlock, paymentRoute) {
|
|
20746
20803
|
storePayment(transaction, afterBlock, paymentRoute);
|
|
20747
|
-
if (
|
|
20804
|
+
if (synchronousTracking || track && track.async == true) {
|
|
20748
20805
|
startTracking(transaction, afterBlock, paymentRoute);
|
|
20749
20806
|
}
|
|
20750
|
-
if (
|
|
20807
|
+
if (synchronousTracking == false) {
|
|
20751
20808
|
return;
|
|
20752
20809
|
}
|
|
20753
20810
|
setTransaction(transaction);
|
|
@@ -20757,8 +20814,10 @@ var PaymentTrackingProvider = (function (props) {
|
|
|
20757
20814
|
};
|
|
20758
20815
|
return /*#__PURE__*/React.createElement(PaymentTrackingContext.Provider, {
|
|
20759
20816
|
value: {
|
|
20760
|
-
|
|
20817
|
+
synchronousTracking: synchronousTracking,
|
|
20818
|
+
asynchronousTracking: asynchronousTracking,
|
|
20761
20819
|
initializeTracking: initializeTracking,
|
|
20820
|
+
trackingInitialized: trackingInitialized,
|
|
20762
20821
|
continueTryTracking: continueTryTracking,
|
|
20763
20822
|
release: release,
|
|
20764
20823
|
forwardTo: forwardTo
|
|
@@ -21394,8 +21453,8 @@ var PaymentOverviewDialog = (function (props) {
|
|
|
21394
21453
|
var TrackingFailedDialog = (function () {
|
|
21395
21454
|
var _useContext = useContext(PaymentTrackingContext),
|
|
21396
21455
|
continueTryTracking = _useContext.continueTryTracking;
|
|
21397
|
-
var _useContext2 = useContext(PaymentContext)
|
|
21398
|
-
|
|
21456
|
+
var _useContext2 = useContext(PaymentContext);
|
|
21457
|
+
_useContext2.transaction;
|
|
21399
21458
|
var _useContext3 = useContext(NavigateStackContext),
|
|
21400
21459
|
navigate = _useContext3.navigate;
|
|
21401
21460
|
var tryAgain = function tryAgain() {
|
|
@@ -21422,10 +21481,7 @@ var TrackingFailedDialog = (function () {
|
|
|
21422
21481
|
className: "FontSizeM"
|
|
21423
21482
|
}, "Please ensure you are connected to the internet, then click \"Try again\"."), /*#__PURE__*/React.createElement("div", {
|
|
21424
21483
|
className: "PaddingTopS"
|
|
21425
|
-
}, /*#__PURE__*/React.createElement("span", null, "If this keeps happening,
|
|
21426
|
-
className: "Link",
|
|
21427
|
-
href: "mailto:support@depay.com?subject=Payment%20tracking%20failed&body=Tracking%20my%20payment%20failed%0A%0ATransaction:%20".concat(transaction.url)
|
|
21428
|
-
}, "please report it"), "."))),
|
|
21484
|
+
}, /*#__PURE__*/React.createElement("span", null, "If this keeps happening, please report it.")))),
|
|
21429
21485
|
footer: /*#__PURE__*/React.createElement("div", {
|
|
21430
21486
|
className: "PaddingTopXS PaddingRightM PaddingLeftM PaddingBottomM"
|
|
21431
21487
|
}, /*#__PURE__*/React.createElement("button", {
|