@depay/widgets 10.2.11 → 10.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.bundle.js +1 -1
- package/dist/esm/index.js +118 -69
- package/dist/umd/index.bundle.js +1 -1
- package/dist/umd/index.js +118 -69
- package/package.json +1 -1
package/dist/umd/index.js
CHANGED
|
@@ -4797,14 +4797,24 @@
|
|
|
4797
4797
|
|
|
4798
4798
|
var findMaxRoute = (function (routes) {
|
|
4799
4799
|
var sortedLowToHigh = _toConsumableArray(routes).sort(function (a, b) {
|
|
4800
|
+
if (a.fromBalance == '0' || a.fromAmount == '0') {
|
|
4801
|
+
return -1; // b
|
|
4802
|
+
}
|
|
4803
|
+
|
|
4804
|
+
if (b.fromBalance == '0' || b.fromAmount == '0') {
|
|
4805
|
+
return 1; // a
|
|
4806
|
+
}
|
|
4807
|
+
|
|
4800
4808
|
var aAmountsAvailable = ethers.ethers.BigNumber.from(a.fromBalance).div(ethers.ethers.BigNumber.from(a.fromAmount));
|
|
4801
4809
|
var bAmountsAvailable = ethers.ethers.BigNumber.from(b.fromBalance).div(ethers.ethers.BigNumber.from(b.fromAmount));
|
|
4802
4810
|
if (aAmountsAvailable.lt(bAmountsAvailable)) {
|
|
4803
|
-
return -1;
|
|
4811
|
+
return -1; // b
|
|
4804
4812
|
}
|
|
4813
|
+
|
|
4805
4814
|
if (bAmountsAvailable.lt(aAmountsAvailable)) {
|
|
4806
|
-
return 1;
|
|
4815
|
+
return 1; // a
|
|
4807
4816
|
}
|
|
4817
|
+
|
|
4808
4818
|
return 0; // equal
|
|
4809
4819
|
});
|
|
4810
4820
|
|
|
@@ -22389,8 +22399,8 @@
|
|
|
22389
22399
|
recover = _useContext2.recover,
|
|
22390
22400
|
before = _useContext2.before;
|
|
22391
22401
|
var _useContext3 = React.useContext(PaymentRoutingContext),
|
|
22392
|
-
selectedRoute = _useContext3.selectedRoute
|
|
22393
|
-
_useContext3.
|
|
22402
|
+
selectedRoute = _useContext3.selectedRoute,
|
|
22403
|
+
refreshPaymentRoutes = _useContext3.refreshPaymentRoutes;
|
|
22394
22404
|
var _useContext4 = React.useContext(ClosableContext),
|
|
22395
22405
|
open = _useContext4.open,
|
|
22396
22406
|
close = _useContext4.close,
|
|
@@ -22523,13 +22533,15 @@
|
|
|
22523
22533
|
}();
|
|
22524
22534
|
var approve = function approve() {
|
|
22525
22535
|
setClosable(false);
|
|
22536
|
+
setUpdatable(false);
|
|
22526
22537
|
setPaymentState('approving');
|
|
22527
22538
|
wallet.sendTransaction(Object.assign({}, payment.route.approvalTransaction, {
|
|
22528
22539
|
succeeded: function succeeded() {
|
|
22529
|
-
|
|
22530
|
-
setPayment(payment);
|
|
22540
|
+
setUpdatable(true);
|
|
22531
22541
|
setClosable(true);
|
|
22532
|
-
|
|
22542
|
+
refreshPaymentRoutes().then(function () {
|
|
22543
|
+
setPaymentState('initialized');
|
|
22544
|
+
});
|
|
22533
22545
|
}
|
|
22534
22546
|
})).then(function (sentTransaction) {
|
|
22535
22547
|
setApprovalTransaction(sentTransaction);
|
|
@@ -22731,7 +22743,7 @@
|
|
|
22731
22743
|
} else {
|
|
22732
22744
|
roundAmounts(routes).then( /*#__PURE__*/function () {
|
|
22733
22745
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(roundedRoutes) {
|
|
22734
|
-
var selectRoute,
|
|
22746
|
+
var selectRoute, updatedSelectedRoute;
|
|
22735
22747
|
return regenerator.wrap(function _callee$(_context) {
|
|
22736
22748
|
while (1) switch (_context.prev = _context.next) {
|
|
22737
22749
|
case 0:
|
|
@@ -22739,13 +22751,19 @@
|
|
|
22739
22751
|
selectRoute = roundedRoutes[0];
|
|
22740
22752
|
setSelectedRoute(selectRoute);
|
|
22741
22753
|
} else {
|
|
22742
|
-
|
|
22754
|
+
updatedSelectedRoute = roundedRoutes[roundedRoutes.findIndex(function (route) {
|
|
22743
22755
|
return route.fromToken.address == selectedRoute.fromToken.address && route.blockchain == selectedRoute.blockchain;
|
|
22744
22756
|
})];
|
|
22745
|
-
if (
|
|
22746
|
-
if (selectedRoute.fromAmount !=
|
|
22747
|
-
setUpdatedRouteWithNewPrice(
|
|
22757
|
+
if (updatedSelectedRoute) {
|
|
22758
|
+
if (selectedRoute.fromAmount != updatedSelectedRoute.fromAmount) {
|
|
22759
|
+
setUpdatedRouteWithNewPrice(updatedSelectedRoute);
|
|
22760
|
+
} else if (
|
|
22761
|
+
// other reasons but price to update selected route
|
|
22762
|
+
selectedRoute.approvalRequired != updatedSelectedRoute.approvalRequired) {
|
|
22763
|
+
setSelectedRoute(updatedSelectedRoute);
|
|
22748
22764
|
}
|
|
22765
|
+
} else {
|
|
22766
|
+
setSelectedRoute(roundedRoutes[0]);
|
|
22749
22767
|
}
|
|
22750
22768
|
}
|
|
22751
22769
|
setAllRoutes(roundedRoutes);
|
|
@@ -22773,23 +22791,41 @@
|
|
|
22773
22791
|
return _ref.apply(this, arguments);
|
|
22774
22792
|
};
|
|
22775
22793
|
}();
|
|
22776
|
-
var getPaymentRoutes = function
|
|
22777
|
-
_ref3
|
|
22778
|
-
|
|
22779
|
-
|
|
22780
|
-
|
|
22781
|
-
|
|
22782
|
-
|
|
22783
|
-
|
|
22784
|
-
|
|
22785
|
-
|
|
22786
|
-
|
|
22787
|
-
|
|
22788
|
-
|
|
22789
|
-
|
|
22790
|
-
|
|
22791
|
-
|
|
22792
|
-
|
|
22794
|
+
var getPaymentRoutes = /*#__PURE__*/function () {
|
|
22795
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(_ref3) {
|
|
22796
|
+
var updatable, slowRoutingTimeout;
|
|
22797
|
+
return regenerator.wrap(function _callee3$(_context3) {
|
|
22798
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
22799
|
+
case 0:
|
|
22800
|
+
_ref3.allRoutes, _ref3.selectedRoute, updatable = _ref3.updatable;
|
|
22801
|
+
if (!(updatable == false || !props.accept || !account)) {
|
|
22802
|
+
_context3.next = 3;
|
|
22803
|
+
break;
|
|
22804
|
+
}
|
|
22805
|
+
return _context3.abrupt("return");
|
|
22806
|
+
case 3:
|
|
22807
|
+
slowRoutingTimeout = setTimeout(function () {
|
|
22808
|
+
setSlowRouting(true);
|
|
22809
|
+
}, 4000);
|
|
22810
|
+
_context3.next = 6;
|
|
22811
|
+
return routePayments(Object.assign({}, props, {
|
|
22812
|
+
account: account
|
|
22813
|
+
})).then(function (routes) {
|
|
22814
|
+
clearInterval(slowRoutingTimeout);
|
|
22815
|
+
onRoutesUpdate(routes);
|
|
22816
|
+
});
|
|
22817
|
+
case 6:
|
|
22818
|
+
return _context3.abrupt("return", _context3.sent);
|
|
22819
|
+
case 7:
|
|
22820
|
+
case "end":
|
|
22821
|
+
return _context3.stop();
|
|
22822
|
+
}
|
|
22823
|
+
}, _callee3);
|
|
22824
|
+
}));
|
|
22825
|
+
return function getPaymentRoutes(_x3) {
|
|
22826
|
+
return _ref4.apply(this, arguments);
|
|
22827
|
+
};
|
|
22828
|
+
}();
|
|
22793
22829
|
var updateRouteAmount = function updateRouteAmount(route, amountBN) {
|
|
22794
22830
|
route.fromAmount = amountBN.toString();
|
|
22795
22831
|
route.transaction.params.amounts[0] = amountBN.toString();
|
|
@@ -22798,72 +22834,79 @@
|
|
|
22798
22834
|
}
|
|
22799
22835
|
};
|
|
22800
22836
|
var roundAmount = /*#__PURE__*/function () {
|
|
22801
|
-
var
|
|
22837
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(route, amountBN) {
|
|
22802
22838
|
var readableAmount, roundedAmountBN;
|
|
22803
|
-
return regenerator.wrap(function
|
|
22804
|
-
while (1) switch (
|
|
22839
|
+
return regenerator.wrap(function _callee4$(_context4) {
|
|
22840
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
22805
22841
|
case 0:
|
|
22806
22842
|
if (!route.directTransfer) {
|
|
22807
|
-
|
|
22843
|
+
_context4.next = 2;
|
|
22808
22844
|
break;
|
|
22809
22845
|
}
|
|
22810
|
-
return
|
|
22846
|
+
return _context4.abrupt("return", route);
|
|
22811
22847
|
case 2:
|
|
22812
|
-
|
|
22848
|
+
_context4.next = 4;
|
|
22813
22849
|
return route.fromToken.readable(amountBN || route.transaction.params.amounts[0]);
|
|
22814
22850
|
case 4:
|
|
22815
|
-
readableAmount =
|
|
22816
|
-
|
|
22851
|
+
readableAmount = _context4.sent;
|
|
22852
|
+
_context4.next = 7;
|
|
22817
22853
|
return route.fromToken.BigNumber(round(readableAmount));
|
|
22818
22854
|
case 7:
|
|
22819
|
-
roundedAmountBN =
|
|
22855
|
+
roundedAmountBN = _context4.sent;
|
|
22820
22856
|
updateRouteAmount(route, roundedAmountBN);
|
|
22821
|
-
return
|
|
22857
|
+
return _context4.abrupt("return", route);
|
|
22822
22858
|
case 10:
|
|
22823
22859
|
case "end":
|
|
22824
|
-
return
|
|
22860
|
+
return _context4.stop();
|
|
22825
22861
|
}
|
|
22826
|
-
},
|
|
22862
|
+
}, _callee4);
|
|
22827
22863
|
}));
|
|
22828
|
-
return function roundAmount(
|
|
22829
|
-
return
|
|
22864
|
+
return function roundAmount(_x4, _x5) {
|
|
22865
|
+
return _ref5.apply(this, arguments);
|
|
22830
22866
|
};
|
|
22831
22867
|
}();
|
|
22832
22868
|
var roundAmounts = /*#__PURE__*/function () {
|
|
22833
|
-
var
|
|
22834
|
-
return regenerator.wrap(function
|
|
22835
|
-
while (1) switch (
|
|
22869
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(routes) {
|
|
22870
|
+
return regenerator.wrap(function _callee5$(_context5) {
|
|
22871
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
22836
22872
|
case 0:
|
|
22837
|
-
return
|
|
22873
|
+
return _context5.abrupt("return", Promise.all(routes.map(function (route) {
|
|
22838
22874
|
return roundAmount(route);
|
|
22839
22875
|
})));
|
|
22840
22876
|
case 1:
|
|
22841
22877
|
case "end":
|
|
22842
|
-
return
|
|
22878
|
+
return _context5.stop();
|
|
22843
22879
|
}
|
|
22844
|
-
},
|
|
22880
|
+
}, _callee5);
|
|
22845
22881
|
}));
|
|
22846
|
-
return function roundAmounts(
|
|
22847
|
-
return
|
|
22882
|
+
return function roundAmounts(_x6) {
|
|
22883
|
+
return _ref6.apply(this, arguments);
|
|
22848
22884
|
};
|
|
22849
22885
|
}();
|
|
22850
22886
|
var updateRouteWithNewPrice = /*#__PURE__*/function () {
|
|
22851
|
-
var
|
|
22852
|
-
return regenerator.wrap(function
|
|
22853
|
-
while (1) switch (
|
|
22887
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6() {
|
|
22888
|
+
return regenerator.wrap(function _callee6$(_context6) {
|
|
22889
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
22854
22890
|
case 0:
|
|
22855
22891
|
setSelectedRoute(_objectSpread$2({}, updatedRouteWithNewPrice));
|
|
22856
22892
|
setUpdatedRouteWithNewPrice(null);
|
|
22857
22893
|
case 2:
|
|
22858
22894
|
case "end":
|
|
22859
|
-
return
|
|
22895
|
+
return _context6.stop();
|
|
22860
22896
|
}
|
|
22861
|
-
},
|
|
22897
|
+
}, _callee6);
|
|
22862
22898
|
}));
|
|
22863
22899
|
return function updateRouteWithNewPrice() {
|
|
22864
|
-
return
|
|
22900
|
+
return _ref7.apply(this, arguments);
|
|
22865
22901
|
};
|
|
22866
22902
|
}();
|
|
22903
|
+
var refreshPaymentRoutes = function refreshPaymentRoutes() {
|
|
22904
|
+
return getPaymentRoutes({
|
|
22905
|
+
allRoutes: allRoutes,
|
|
22906
|
+
selectedRoute: selectedRoute,
|
|
22907
|
+
updatable: updatable
|
|
22908
|
+
});
|
|
22909
|
+
};
|
|
22867
22910
|
React.useEffect(function () {
|
|
22868
22911
|
var timeout = setTimeout(function () {
|
|
22869
22912
|
setReloadCount(reloadCount + 1);
|
|
@@ -22886,7 +22929,7 @@
|
|
|
22886
22929
|
value: {
|
|
22887
22930
|
selectedRoute: selectedRoute,
|
|
22888
22931
|
setSelectedRoute: setSelectedRoute,
|
|
22889
|
-
|
|
22932
|
+
refreshPaymentRoutes: refreshPaymentRoutes,
|
|
22890
22933
|
allRoutes: allRoutes,
|
|
22891
22934
|
setAllRoutes: setAllRoutes,
|
|
22892
22935
|
slowRouting: slowRouting,
|
|
@@ -23602,7 +23645,7 @@
|
|
|
23602
23645
|
}
|
|
23603
23646
|
};
|
|
23604
23647
|
var approvalButton = function approvalButton() {
|
|
23605
|
-
if (payment.route == undefined || !payment.route.approvalRequired || payment.route.directTransfer) {
|
|
23648
|
+
if (payment.route == undefined || !payment.route.approvalRequired || payment.route.directTransfer || updatedRouteWithNewPrice) {
|
|
23606
23649
|
return null;
|
|
23607
23650
|
} else if (paymentState == 'initialized') {
|
|
23608
23651
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -24936,6 +24979,8 @@
|
|
|
24936
24979
|
}());
|
|
24937
24980
|
};
|
|
24938
24981
|
|
|
24982
|
+
var SUPPORTED_CURRENCIES = ["all", "xcd", "eur", "bbd", "btn", "bnd", "xaf", "cup", "usd", "fkp", "gip", "huf", "irr", "jmd", "aud", "lak", "lyd", "mkd", "xof", "nzd", "omr", "pgk", "rwf", "wst", "rsd", "sek", "tzs", "amd", "bsd", "bam", "cve", "cny", "crc", "czk", "ern", "gel", "htg", "inr", "jod", "krw", "lbp", "mwk", "mru", "mzn", "ang", "pen", "qar", "std", "sll", "sos", "sdg", "syp", "aoa", "awg", "bhd", "bzd", "bwp", "bif", "kyd", "cop", "dkk", "gtq", "hnl", "idr", "ils", "kzt", "kwd", "lsl", "myr", "mur", "mnt", "mmk", "ngn", "pab", "php", "ron", "sar", "sgd", "zar", "srd", "twd", "top", "vef", "dzd", "ars", "azn", "bob", "bgn", "cad", "clp", "cdf", "dop", "fjd", "gmd", "gyd", "isk", "iqd", "jpy", "kpw", "chf", "mga", "mdl", "mad", "npr", "nio", "pkr", "pyg", "shp", "scr", "sbd", "lkr", "thb", "try", "aed", "vuv", "yer", "afn", "bdt", "brl", "khr", "kmf", "hrk", "djf", "egp", "etb", "xpf", "ghs", "gnf", "hkd", "xdr", "kes", "kgs", "lrd", "mop", "mvr", "mxn", "nad", "nok", "pln", "rub", "szl", "tjs", "ttd", "ugx", "uyu", "vnd", "tnd", "uah", "uzs", "tmt", "gbp", "zmw", "byn", "bmd", "ggp", "clf", "cuc", "imp", "jep", "svc", "xag", "zwl"];
|
|
24983
|
+
|
|
24939
24984
|
var PaymentAmountRoutingContext = /*#__PURE__*/React__default["default"].createContext();
|
|
24940
24985
|
|
|
24941
24986
|
var PaymentAmountRoutingProvider = (function (props) {
|
|
@@ -25011,7 +25056,8 @@
|
|
|
25011
25056
|
var _useContext = React.useContext(ConfigurationContext),
|
|
25012
25057
|
currencyCode = _useContext.currencyCode,
|
|
25013
25058
|
recover = _useContext.recover,
|
|
25014
|
-
amountConfiguration = _useContext.amount
|
|
25059
|
+
amountConfiguration = _useContext.amount,
|
|
25060
|
+
currency = _useContext.currency;
|
|
25015
25061
|
var _useContext2 = React.useContext(PaymentContext),
|
|
25016
25062
|
payment = _useContext2.payment,
|
|
25017
25063
|
paymentState = _useContext2.paymentState;
|
|
@@ -25125,7 +25171,7 @@
|
|
|
25125
25171
|
className: "TokenSymbolCell"
|
|
25126
25172
|
}, payment.symbol), /*#__PURE__*/React__default["default"].createElement("span", null, "\xA0"), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
25127
25173
|
className: "TokenAmountCell"
|
|
25128
|
-
}, format(payment.amount))), displayedPaymentValue != "".concat(payment.symbol, " ").concat(format(payment.amount)) && !(amountsMissing && !fixedCurrency) && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
25174
|
+
}, format(payment.amount))), displayedPaymentValue != "".concat(payment.symbol, " ").concat(format(payment.amount)) && !(amountsMissing && !fixedCurrency) && currency !== false && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
25129
25175
|
className: "TokenAmountRow small grey"
|
|
25130
25176
|
}, /*#__PURE__*/React__default["default"].createElement("span", {
|
|
25131
25177
|
className: "TokenAmountCell"
|
|
@@ -25290,13 +25336,16 @@
|
|
|
25290
25336
|
case 0:
|
|
25291
25337
|
accept = _ref3.accept, amount = _ref3.amount, 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, wallet = _ref3.wallet, document = _ref3.document;
|
|
25292
25338
|
requireReactVersion();
|
|
25293
|
-
|
|
25294
|
-
|
|
25339
|
+
if (currency && !SUPPORTED_CURRENCIES.includes(currency.toLowerCase())) {
|
|
25340
|
+
currency = false;
|
|
25341
|
+
}
|
|
25342
|
+
_context2.prev = 3;
|
|
25343
|
+
_context2.next = 6;
|
|
25295
25344
|
return preflight$1({
|
|
25296
25345
|
accept: accept,
|
|
25297
25346
|
recover: recover
|
|
25298
25347
|
});
|
|
25299
|
-
case
|
|
25348
|
+
case 6:
|
|
25300
25349
|
if (typeof window._depayUnmountLoading == 'function') {
|
|
25301
25350
|
window._depayUnmountLoading();
|
|
25302
25351
|
}
|
|
@@ -25363,18 +25412,18 @@
|
|
|
25363
25412
|
return _context2.abrupt("return", {
|
|
25364
25413
|
unmount: unmount
|
|
25365
25414
|
});
|
|
25366
|
-
case
|
|
25367
|
-
_context2.prev =
|
|
25368
|
-
_context2.t0 = _context2["catch"](
|
|
25415
|
+
case 11:
|
|
25416
|
+
_context2.prev = 11;
|
|
25417
|
+
_context2.t0 = _context2["catch"](3);
|
|
25369
25418
|
console.log('critical error', _context2.t0);
|
|
25370
25419
|
if (critical != undefined) {
|
|
25371
25420
|
critical(_context2.t0);
|
|
25372
25421
|
}
|
|
25373
|
-
case
|
|
25422
|
+
case 15:
|
|
25374
25423
|
case "end":
|
|
25375
25424
|
return _context2.stop();
|
|
25376
25425
|
}
|
|
25377
|
-
}, _callee2, null, [[
|
|
25426
|
+
}, _callee2, null, [[3, 11]]);
|
|
25378
25427
|
}));
|
|
25379
25428
|
return function Payment(_x2) {
|
|
25380
25429
|
return _ref4.apply(this, arguments);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@depay/widgets",
|
|
3
3
|
"moduleName": "DePayWidgets",
|
|
4
|
-
"version": "10.2.
|
|
4
|
+
"version": "10.2.13",
|
|
5
5
|
"description": "Web3 Payments with any token. DePay simplifies and improves Web3 Payments with the power of DeFi. Accept any token with on-the-fly conversion.",
|
|
6
6
|
"main": "./dist/umd/index.js",
|
|
7
7
|
"module": "./dist/esm/index.js",
|