@depay/widgets 7.10.0 → 7.13.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 +34 -2
- package/dist/esm/index.bundle.js +3 -3
- package/dist/esm/index.js +81 -19
- package/dist/umd/index.bundle.js +3 -3
- package/dist/umd/index.js +81 -19
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -19232,8 +19232,8 @@ var PaymentProvider = (function (props) {
|
|
|
19232
19232
|
before = _useContext2.before;
|
|
19233
19233
|
|
|
19234
19234
|
var _useContext3 = useContext(PaymentRoutingContext),
|
|
19235
|
-
selectedRoute = _useContext3.selectedRoute
|
|
19236
|
-
|
|
19235
|
+
selectedRoute = _useContext3.selectedRoute;
|
|
19236
|
+
_useContext3.getPaymentRoutes;
|
|
19237
19237
|
|
|
19238
19238
|
var _useContext4 = useContext(ClosableContext),
|
|
19239
19239
|
open = _useContext4.open,
|
|
@@ -19298,10 +19298,7 @@ var PaymentProvider = (function (props) {
|
|
|
19298
19298
|
failed(transaction, error);
|
|
19299
19299
|
}
|
|
19300
19300
|
|
|
19301
|
-
setPaymentState('initialized');
|
|
19302
19301
|
setClosable(true);
|
|
19303
|
-
setUpdatable(true);
|
|
19304
|
-
getPaymentRoutes({});
|
|
19305
19302
|
navigate('PaymentError');
|
|
19306
19303
|
};
|
|
19307
19304
|
|
|
@@ -19601,7 +19598,8 @@ var PaymentRoutingProvider = (function (props) {
|
|
|
19601
19598
|
|
|
19602
19599
|
var calculateAmountInWithSlippage = /*#__PURE__*/function () {
|
|
19603
19600
|
var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(route) {
|
|
19604
|
-
var currentBlock, blocks, i, exchangeRoute, lastAmountsIn, difference1, difference2, slippage, newAmountBN, readableAmount, roundedAmountBN;
|
|
19601
|
+
var currentBlock, blocks, i, exchangeRoute, lastAmountsIn, difference1, difference2, slippage, newAmountBN, readableAmount, roundedAmountBN, _difference, _difference2, _slippage, highestAmountBN, _newAmountBN, _readableAmount, _roundedAmountBN;
|
|
19602
|
+
|
|
19605
19603
|
return regenerator.wrap(function _callee2$(_context2) {
|
|
19606
19604
|
while (1) {
|
|
19607
19605
|
switch (_context2.prev = _context2.next) {
|
|
@@ -19682,10 +19680,11 @@ var PaymentRoutingProvider = (function (props) {
|
|
|
19682
19680
|
|
|
19683
19681
|
case 15:
|
|
19684
19682
|
if (!(lastAmountsIn[0].gt(lastAmountsIn[1]) && lastAmountsIn[1].gt(lastAmountsIn[2]))) {
|
|
19685
|
-
_context2.next =
|
|
19683
|
+
_context2.next = 31;
|
|
19686
19684
|
break;
|
|
19687
19685
|
}
|
|
19688
19686
|
|
|
19687
|
+
// directional slippage
|
|
19689
19688
|
difference1 = lastAmountsIn[0].sub(lastAmountsIn[1]);
|
|
19690
19689
|
difference2 = lastAmountsIn[1].sub(lastAmountsIn[2]);
|
|
19691
19690
|
|
|
@@ -19717,7 +19716,53 @@ var PaymentRoutingProvider = (function (props) {
|
|
|
19717
19716
|
case 28:
|
|
19718
19717
|
return _context2.abrupt("return", newAmountBN);
|
|
19719
19718
|
|
|
19720
|
-
case
|
|
19719
|
+
case 31:
|
|
19720
|
+
if (lastAmountsIn[0].eq(lastAmountsIn[1]) && lastAmountsIn[1].eq(lastAmountsIn[2])) {
|
|
19721
|
+
_context2.next = 46;
|
|
19722
|
+
break;
|
|
19723
|
+
}
|
|
19724
|
+
|
|
19725
|
+
// base slippage
|
|
19726
|
+
_difference = lastAmountsIn[0].sub(lastAmountsIn[1]).abs();
|
|
19727
|
+
_difference2 = lastAmountsIn[1].sub(lastAmountsIn[2]).abs();
|
|
19728
|
+
|
|
19729
|
+
if (_difference.lt(_difference2)) {
|
|
19730
|
+
_slippage = _difference;
|
|
19731
|
+
} else {
|
|
19732
|
+
_slippage = _difference2;
|
|
19733
|
+
}
|
|
19734
|
+
|
|
19735
|
+
if (lastAmountsIn[0].gt(lastAmountsIn[1]) && lastAmountsIn[0].gt(lastAmountsIn[2])) {
|
|
19736
|
+
highestAmountBN = lastAmountsIn[0];
|
|
19737
|
+
} else if (lastAmountsIn[1].gt(lastAmountsIn[2]) && lastAmountsIn[1].gt(lastAmountsIn[0])) {
|
|
19738
|
+
highestAmountBN = lastAmountsIn[1];
|
|
19739
|
+
} else {
|
|
19740
|
+
highestAmountBN = lastAmountsIn[2];
|
|
19741
|
+
}
|
|
19742
|
+
|
|
19743
|
+
_newAmountBN = highestAmountBN.add(_slippage);
|
|
19744
|
+
_context2.next = 39;
|
|
19745
|
+
return route.fromToken.readable(_newAmountBN);
|
|
19746
|
+
|
|
19747
|
+
case 39:
|
|
19748
|
+
_readableAmount = _context2.sent;
|
|
19749
|
+
_context2.next = 42;
|
|
19750
|
+
return route.fromToken.BigNumber(round(_readableAmount));
|
|
19751
|
+
|
|
19752
|
+
case 42:
|
|
19753
|
+
_roundedAmountBN = _context2.sent;
|
|
19754
|
+
|
|
19755
|
+
if (!(route.fromAmount == _roundedAmountBN.toString())) {
|
|
19756
|
+
_context2.next = 45;
|
|
19757
|
+
break;
|
|
19758
|
+
}
|
|
19759
|
+
|
|
19760
|
+
return _context2.abrupt("return");
|
|
19761
|
+
|
|
19762
|
+
case 45:
|
|
19763
|
+
return _context2.abrupt("return", _newAmountBN);
|
|
19764
|
+
|
|
19765
|
+
case 46:
|
|
19721
19766
|
case "end":
|
|
19722
19767
|
return _context2.stop();
|
|
19723
19768
|
}
|
|
@@ -20946,8 +20991,8 @@ var DonationOverviewDialog = (function (props) {
|
|
|
20946
20991
|
});
|
|
20947
20992
|
|
|
20948
20993
|
var PaymentErrorDialog = (function () {
|
|
20949
|
-
var _useContext = useContext(
|
|
20950
|
-
|
|
20994
|
+
var _useContext = useContext(ClosableContext),
|
|
20995
|
+
close = _useContext.close;
|
|
20951
20996
|
|
|
20952
20997
|
var _useContext2 = useContext(PaymentContext),
|
|
20953
20998
|
transaction = _useContext2.transaction;
|
|
@@ -20956,7 +21001,7 @@ var PaymentErrorDialog = (function () {
|
|
|
20956
21001
|
recover = _useContext3.recover;
|
|
20957
21002
|
|
|
20958
21003
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
20959
|
-
stacked:
|
|
21004
|
+
stacked: false,
|
|
20960
21005
|
header: /*#__PURE__*/React.createElement("div", {
|
|
20961
21006
|
className: "PaddingTopS PaddingLeftM PaddingRightM"
|
|
20962
21007
|
}),
|
|
@@ -20987,7 +21032,7 @@ var PaymentErrorDialog = (function () {
|
|
|
20987
21032
|
}, recover == undefined && /*#__PURE__*/React.createElement("button", {
|
|
20988
21033
|
className: "ButtonPrimary",
|
|
20989
21034
|
onClick: function onClick() {
|
|
20990
|
-
return
|
|
21035
|
+
return close();
|
|
20991
21036
|
}
|
|
20992
21037
|
}, "Try again"))
|
|
20993
21038
|
});
|
|
@@ -21087,6 +21132,7 @@ var PaymentTrackingProvider = (function (props) {
|
|
|
21087
21132
|
|
|
21088
21133
|
var _useContext2 = useContext(ConfigurationContext),
|
|
21089
21134
|
track = _useContext2.track,
|
|
21135
|
+
validated = _useContext2.validated,
|
|
21090
21136
|
integration = _useContext2.integration,
|
|
21091
21137
|
link = _useContext2.link,
|
|
21092
21138
|
type = _useContext2.type;
|
|
@@ -21132,6 +21178,9 @@ var PaymentTrackingProvider = (function (props) {
|
|
|
21132
21178
|
var _useContext3 = useContext(ClosableContext),
|
|
21133
21179
|
setClosable = _useContext3.setClosable;
|
|
21134
21180
|
|
|
21181
|
+
var _useContext4 = useContext(NavigateContext),
|
|
21182
|
+
navigate = _useContext4.navigate;
|
|
21183
|
+
|
|
21135
21184
|
var openSocket = function openSocket(transaction) {
|
|
21136
21185
|
var socket = new WebSocket('wss://integrate.depay.fi/cable');
|
|
21137
21186
|
|
|
@@ -21153,14 +21202,23 @@ var PaymentTrackingProvider = (function (props) {
|
|
|
21153
21202
|
socket.onmessage = function (event) {
|
|
21154
21203
|
var item = JSON.parse(event.data);
|
|
21155
21204
|
|
|
21156
|
-
if (item.type === "ping") {
|
|
21205
|
+
if (item.type === "ping" || !item.message) {
|
|
21157
21206
|
return;
|
|
21158
21207
|
}
|
|
21159
21208
|
|
|
21160
|
-
if (item.message
|
|
21209
|
+
if (item.message.status == 'failed') {
|
|
21210
|
+
setClosable(true);
|
|
21211
|
+
navigate('PaymentError');
|
|
21212
|
+
}
|
|
21213
|
+
|
|
21214
|
+
if (validated) {
|
|
21215
|
+
validated(item.message.status == 'success');
|
|
21216
|
+
}
|
|
21217
|
+
|
|
21218
|
+
if (item.message.release) {
|
|
21219
|
+
setRelease(true);
|
|
21161
21220
|
setClosable(!item.message.forward_to);
|
|
21162
21221
|
setForwardTo(item.message.forward_to);
|
|
21163
|
-
setRelease(item.message.release);
|
|
21164
21222
|
socket.close();
|
|
21165
21223
|
|
|
21166
21224
|
if (!!item.message.forward_to) {
|
|
@@ -21222,8 +21280,10 @@ var PaymentTrackingProvider = (function (props) {
|
|
|
21222
21280
|
after_block: afterBlock,
|
|
21223
21281
|
from_token: paymentRoute.fromToken.address,
|
|
21224
21282
|
from_amount: paymentRoute.fromAmount.toString(),
|
|
21283
|
+
from_decimals: paymentRoute.fromDecimals,
|
|
21225
21284
|
to_token: paymentRoute.toToken.address,
|
|
21226
21285
|
to_amount: paymentRoute.toAmount.toString(),
|
|
21286
|
+
to_decimals: paymentRoute.toDecimals,
|
|
21227
21287
|
fee_amount: paymentRoute === null || paymentRoute === void 0 ? void 0 : (_paymentRoute$feeAmou = paymentRoute.feeAmount) === null || _paymentRoute$feeAmou === void 0 ? void 0 : _paymentRoute$feeAmou.toString()
|
|
21228
21288
|
}).then(function (response) {
|
|
21229
21289
|
if (response.status != 200) {
|
|
@@ -21619,12 +21679,12 @@ var preflight$2 = /*#__PURE__*/function () {
|
|
|
21619
21679
|
|
|
21620
21680
|
var Donation = /*#__PURE__*/function () {
|
|
21621
21681
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(_ref3) {
|
|
21622
|
-
var amount, accept, event, sent, confirmed, failed, error, critical, style, blacklist, providers, currency, connected, closed, track, fee, closable, integration, link, container, document, unmount;
|
|
21682
|
+
var amount, accept, event, sent, confirmed, validated, failed, error, critical, style, blacklist, providers, currency, connected, closed, track, fee, closable, integration, link, container, document, unmount;
|
|
21623
21683
|
return regenerator.wrap(function _callee2$(_context2) {
|
|
21624
21684
|
while (1) {
|
|
21625
21685
|
switch (_context2.prev = _context2.next) {
|
|
21626
21686
|
case 0:
|
|
21627
|
-
amount = _ref3.amount, accept = _ref3.accept, event = _ref3.event, sent = _ref3.sent, confirmed = _ref3.confirmed, failed = _ref3.failed, error = _ref3.error, critical = _ref3.critical, style = _ref3.style, blacklist = _ref3.blacklist, providers = _ref3.providers, currency = _ref3.currency, connected = _ref3.connected, closed = _ref3.closed, track = _ref3.track, fee = _ref3.fee, closable = _ref3.closable, integration = _ref3.integration, link = _ref3.link, container = _ref3.container, document = _ref3.document;
|
|
21687
|
+
amount = _ref3.amount, accept = _ref3.accept, event = _ref3.event, sent = _ref3.sent, confirmed = _ref3.confirmed, validated = _ref3.validated, failed = _ref3.failed, error = _ref3.error, critical = _ref3.critical, style = _ref3.style, 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, document = _ref3.document;
|
|
21628
21688
|
requireReactVersion();
|
|
21629
21689
|
_context2.prev = 2;
|
|
21630
21690
|
_context2.next = 5;
|
|
@@ -21655,6 +21715,7 @@ var Donation = /*#__PURE__*/function () {
|
|
|
21655
21715
|
fee: fee,
|
|
21656
21716
|
sent: sent,
|
|
21657
21717
|
confirmed: confirmed,
|
|
21718
|
+
validated: validated,
|
|
21658
21719
|
failed: failed,
|
|
21659
21720
|
blacklist: blacklist,
|
|
21660
21721
|
providers: providers,
|
|
@@ -22138,12 +22199,12 @@ var preflight$1 = /*#__PURE__*/function () {
|
|
|
22138
22199
|
|
|
22139
22200
|
var Payment = /*#__PURE__*/function () {
|
|
22140
22201
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(_ref3) {
|
|
22141
|
-
var accept, amount, event, sent, confirmed, failed, error, critical, style, whitelist, blacklist, providers, currency, connected, closed, track, fee, recover, closable, integration, link, container, before, document, unmount;
|
|
22202
|
+
var accept, amount, event, sent, confirmed, validated, failed, error, critical, style, whitelist, blacklist, providers, currency, connected, closed, track, fee, recover, closable, integration, link, container, before, document, unmount;
|
|
22142
22203
|
return regenerator.wrap(function _callee2$(_context2) {
|
|
22143
22204
|
while (1) {
|
|
22144
22205
|
switch (_context2.prev = _context2.next) {
|
|
22145
22206
|
case 0:
|
|
22146
|
-
accept = _ref3.accept, amount = _ref3.amount, event = _ref3.event, sent = _ref3.sent, confirmed = _ref3.confirmed, 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;
|
|
22207
|
+
accept = _ref3.accept, amount = _ref3.amount, event = _ref3.event, sent = _ref3.sent, confirmed = _ref3.confirmed, validated = _ref3.validated, failed = _ref3.failed, error = _ref3.error, critical = _ref3.critical, style = _ref3.style, whitelist = _ref3.whitelist, blacklist = _ref3.blacklist, providers = _ref3.providers, currency = _ref3.currency, connected = _ref3.connected, closed = _ref3.closed, track = _ref3.track, fee = _ref3.fee, recover = _ref3.recover, closable = _ref3.closable, integration = _ref3.integration, link = _ref3.link, container = _ref3.container, before = _ref3.before, document = _ref3.document;
|
|
22147
22208
|
requireReactVersion();
|
|
22148
22209
|
_context2.prev = 2;
|
|
22149
22210
|
_context2.next = 5;
|
|
@@ -22174,6 +22235,7 @@ var Payment = /*#__PURE__*/function () {
|
|
|
22174
22235
|
event: event,
|
|
22175
22236
|
sent: sent,
|
|
22176
22237
|
confirmed: confirmed,
|
|
22238
|
+
validated: validated,
|
|
22177
22239
|
failed: failed,
|
|
22178
22240
|
whitelist: whitelist,
|
|
22179
22241
|
blacklist: blacklist,
|