@depay/widgets 7.12.0 → 7.13.2
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 +3 -3
- package/dist/esm/index.js +91 -34
- package/dist/umd/index.bundle.js +3 -3
- package/dist/umd/index.js +91 -34
- package/package.json +4 -3
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,
|
|
@@ -19247,7 +19247,8 @@ var PaymentProvider = (function (props) {
|
|
|
19247
19247
|
setUpdatable = _useContext6.setUpdatable;
|
|
19248
19248
|
|
|
19249
19249
|
var _useContext7 = useContext(NavigateContext),
|
|
19250
|
-
navigate = _useContext7.navigate
|
|
19250
|
+
navigate = _useContext7.navigate,
|
|
19251
|
+
set = _useContext7.set;
|
|
19251
19252
|
|
|
19252
19253
|
var _useContext8 = useContext(WalletContext),
|
|
19253
19254
|
wallet = _useContext8.wallet;
|
|
@@ -19298,11 +19299,8 @@ var PaymentProvider = (function (props) {
|
|
|
19298
19299
|
failed(transaction, error);
|
|
19299
19300
|
}
|
|
19300
19301
|
|
|
19301
|
-
setPaymentState('initialized');
|
|
19302
19302
|
setClosable(true);
|
|
19303
|
-
|
|
19304
|
-
getPaymentRoutes({});
|
|
19305
|
-
navigate('PaymentError');
|
|
19303
|
+
set(['PaymentError']);
|
|
19306
19304
|
};
|
|
19307
19305
|
|
|
19308
19306
|
var pay = /*#__PURE__*/function () {
|
|
@@ -19601,7 +19599,8 @@ var PaymentRoutingProvider = (function (props) {
|
|
|
19601
19599
|
|
|
19602
19600
|
var calculateAmountInWithSlippage = /*#__PURE__*/function () {
|
|
19603
19601
|
var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(route) {
|
|
19604
|
-
var currentBlock, blocks, i, exchangeRoute, lastAmountsIn, difference1, difference2, slippage, newAmountBN, readableAmount, roundedAmountBN;
|
|
19602
|
+
var currentBlock, blocks, i, exchangeRoute, lastAmountsIn, difference1, difference2, slippage, newAmountBN, readableAmount, roundedAmountBN, _difference, _difference2, _slippage, highestAmountBN, _newAmountBN, _readableAmount, _roundedAmountBN;
|
|
19603
|
+
|
|
19605
19604
|
return regenerator.wrap(function _callee2$(_context2) {
|
|
19606
19605
|
while (1) {
|
|
19607
19606
|
switch (_context2.prev = _context2.next) {
|
|
@@ -19682,10 +19681,11 @@ var PaymentRoutingProvider = (function (props) {
|
|
|
19682
19681
|
|
|
19683
19682
|
case 15:
|
|
19684
19683
|
if (!(lastAmountsIn[0].gt(lastAmountsIn[1]) && lastAmountsIn[1].gt(lastAmountsIn[2]))) {
|
|
19685
|
-
_context2.next =
|
|
19684
|
+
_context2.next = 31;
|
|
19686
19685
|
break;
|
|
19687
19686
|
}
|
|
19688
19687
|
|
|
19688
|
+
// directional slippage
|
|
19689
19689
|
difference1 = lastAmountsIn[0].sub(lastAmountsIn[1]);
|
|
19690
19690
|
difference2 = lastAmountsIn[1].sub(lastAmountsIn[2]);
|
|
19691
19691
|
|
|
@@ -19717,7 +19717,53 @@ var PaymentRoutingProvider = (function (props) {
|
|
|
19717
19717
|
case 28:
|
|
19718
19718
|
return _context2.abrupt("return", newAmountBN);
|
|
19719
19719
|
|
|
19720
|
-
case
|
|
19720
|
+
case 31:
|
|
19721
|
+
if (lastAmountsIn[0].eq(lastAmountsIn[1]) && lastAmountsIn[1].eq(lastAmountsIn[2])) {
|
|
19722
|
+
_context2.next = 46;
|
|
19723
|
+
break;
|
|
19724
|
+
}
|
|
19725
|
+
|
|
19726
|
+
// base slippage
|
|
19727
|
+
_difference = lastAmountsIn[0].sub(lastAmountsIn[1]).abs();
|
|
19728
|
+
_difference2 = lastAmountsIn[1].sub(lastAmountsIn[2]).abs();
|
|
19729
|
+
|
|
19730
|
+
if (_difference.lt(_difference2)) {
|
|
19731
|
+
_slippage = _difference;
|
|
19732
|
+
} else {
|
|
19733
|
+
_slippage = _difference2;
|
|
19734
|
+
}
|
|
19735
|
+
|
|
19736
|
+
if (lastAmountsIn[0].gt(lastAmountsIn[1]) && lastAmountsIn[0].gt(lastAmountsIn[2])) {
|
|
19737
|
+
highestAmountBN = lastAmountsIn[0];
|
|
19738
|
+
} else if (lastAmountsIn[1].gt(lastAmountsIn[2]) && lastAmountsIn[1].gt(lastAmountsIn[0])) {
|
|
19739
|
+
highestAmountBN = lastAmountsIn[1];
|
|
19740
|
+
} else {
|
|
19741
|
+
highestAmountBN = lastAmountsIn[2];
|
|
19742
|
+
}
|
|
19743
|
+
|
|
19744
|
+
_newAmountBN = highestAmountBN.add(_slippage);
|
|
19745
|
+
_context2.next = 39;
|
|
19746
|
+
return route.fromToken.readable(_newAmountBN);
|
|
19747
|
+
|
|
19748
|
+
case 39:
|
|
19749
|
+
_readableAmount = _context2.sent;
|
|
19750
|
+
_context2.next = 42;
|
|
19751
|
+
return route.fromToken.BigNumber(round(_readableAmount));
|
|
19752
|
+
|
|
19753
|
+
case 42:
|
|
19754
|
+
_roundedAmountBN = _context2.sent;
|
|
19755
|
+
|
|
19756
|
+
if (!(route.fromAmount == _roundedAmountBN.toString())) {
|
|
19757
|
+
_context2.next = 45;
|
|
19758
|
+
break;
|
|
19759
|
+
}
|
|
19760
|
+
|
|
19761
|
+
return _context2.abrupt("return");
|
|
19762
|
+
|
|
19763
|
+
case 45:
|
|
19764
|
+
return _context2.abrupt("return", _newAmountBN);
|
|
19765
|
+
|
|
19766
|
+
case 46:
|
|
19721
19767
|
case "end":
|
|
19722
19768
|
return _context2.stop();
|
|
19723
19769
|
}
|
|
@@ -20323,7 +20369,6 @@ var ChangeAmountDialog = (function (props) {
|
|
|
20323
20369
|
className: "Input FontSizeXXL TextAlignCenter",
|
|
20324
20370
|
type: "number",
|
|
20325
20371
|
name: "amount",
|
|
20326
|
-
autoFocus: true,
|
|
20327
20372
|
value: parseFloat(inputAmount),
|
|
20328
20373
|
onChange: function onChange(event) {
|
|
20329
20374
|
changeAmount(event.target.value);
|
|
@@ -20946,17 +20991,14 @@ 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;
|
|
20954
20999
|
|
|
20955
|
-
var _useContext3 = useContext(ConfigurationContext),
|
|
20956
|
-
recover = _useContext3.recover;
|
|
20957
|
-
|
|
20958
21000
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
20959
|
-
stacked:
|
|
21001
|
+
stacked: false,
|
|
20960
21002
|
header: /*#__PURE__*/React.createElement("div", {
|
|
20961
21003
|
className: "PaddingTopS PaddingLeftM PaddingRightM"
|
|
20962
21004
|
}),
|
|
@@ -20971,7 +21013,7 @@ var PaymentErrorDialog = (function () {
|
|
|
20971
21013
|
className: "LineHeightL Text FontSizeL PaddingTopS FontWeightBold"
|
|
20972
21014
|
}, "Payment Failed"), /*#__PURE__*/React.createElement("div", {
|
|
20973
21015
|
className: "Text PaddingTopS PaddingBottomS PaddingLeftS PaddingRightS"
|
|
20974
|
-
},
|
|
21016
|
+
}, /*#__PURE__*/React.createElement("strong", {
|
|
20975
21017
|
className: "FontSizeM"
|
|
20976
21018
|
}, "Unfortunately executing your payment failed. You can go back and try again."), transaction && /*#__PURE__*/React.createElement("div", {
|
|
20977
21019
|
className: "PaddingTopS"
|
|
@@ -20984,10 +21026,10 @@ var PaymentErrorDialog = (function () {
|
|
|
20984
21026
|
}, "View on explorer")))),
|
|
20985
21027
|
footer: /*#__PURE__*/React.createElement("div", {
|
|
20986
21028
|
className: "PaddingTopXS PaddingRightM PaddingLeftM PaddingBottomM"
|
|
20987
|
-
},
|
|
21029
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
20988
21030
|
className: "ButtonPrimary",
|
|
20989
21031
|
onClick: function onClick() {
|
|
20990
|
-
return
|
|
21032
|
+
return close();
|
|
20991
21033
|
}
|
|
20992
21034
|
}, "Try again"))
|
|
20993
21035
|
});
|
|
@@ -21041,10 +21083,10 @@ var DonationStack = (function (props) {
|
|
|
21041
21083
|
close = _useContext.close;
|
|
21042
21084
|
|
|
21043
21085
|
var _useContext2 = useContext(NavigateContext),
|
|
21044
|
-
|
|
21086
|
+
setNavigator = _useContext2.setNavigator;
|
|
21045
21087
|
|
|
21046
21088
|
return /*#__PURE__*/React.createElement(ReactDialogStack, {
|
|
21047
|
-
|
|
21089
|
+
setNavigator: setNavigator,
|
|
21048
21090
|
open: open,
|
|
21049
21091
|
close: close,
|
|
21050
21092
|
start: "DonationOverview",
|
|
@@ -21063,20 +21105,27 @@ var DonationStack = (function (props) {
|
|
|
21063
21105
|
var NavigateProvider = (function (props) {
|
|
21064
21106
|
var navigator;
|
|
21065
21107
|
|
|
21066
|
-
var
|
|
21108
|
+
var setNavigator = function setNavigator(_navigator) {
|
|
21067
21109
|
navigator = _navigator;
|
|
21068
21110
|
};
|
|
21069
21111
|
|
|
21070
21112
|
var navigate = function navigate(dialog) {
|
|
21071
21113
|
if (navigator) {
|
|
21072
|
-
navigator(dialog);
|
|
21114
|
+
navigator.navigate(dialog);
|
|
21115
|
+
}
|
|
21116
|
+
};
|
|
21117
|
+
|
|
21118
|
+
var set = function set(dialogs) {
|
|
21119
|
+
if (navigator) {
|
|
21120
|
+
navigator.set(dialogs);
|
|
21073
21121
|
}
|
|
21074
21122
|
};
|
|
21075
21123
|
|
|
21076
21124
|
return /*#__PURE__*/React.createElement(NavigateContext.Provider, {
|
|
21077
21125
|
value: {
|
|
21078
21126
|
navigate: navigate,
|
|
21079
|
-
|
|
21127
|
+
set: set,
|
|
21128
|
+
setNavigator: setNavigator
|
|
21080
21129
|
}
|
|
21081
21130
|
}, props.children);
|
|
21082
21131
|
});
|
|
@@ -21133,6 +21182,9 @@ var PaymentTrackingProvider = (function (props) {
|
|
|
21133
21182
|
var _useContext3 = useContext(ClosableContext),
|
|
21134
21183
|
setClosable = _useContext3.setClosable;
|
|
21135
21184
|
|
|
21185
|
+
var _useContext4 = useContext(NavigateContext),
|
|
21186
|
+
set = _useContext4.set;
|
|
21187
|
+
|
|
21136
21188
|
var openSocket = function openSocket(transaction) {
|
|
21137
21189
|
var socket = new WebSocket('wss://integrate.depay.fi/cable');
|
|
21138
21190
|
|
|
@@ -21154,15 +21206,20 @@ var PaymentTrackingProvider = (function (props) {
|
|
|
21154
21206
|
socket.onmessage = function (event) {
|
|
21155
21207
|
var item = JSON.parse(event.data);
|
|
21156
21208
|
|
|
21157
|
-
if (item.type === "ping") {
|
|
21209
|
+
if (item.type === "ping" || !item.message) {
|
|
21158
21210
|
return;
|
|
21159
21211
|
}
|
|
21160
21212
|
|
|
21161
|
-
if (item.message
|
|
21162
|
-
|
|
21163
|
-
|
|
21164
|
-
|
|
21213
|
+
if (item.message.status == 'failed') {
|
|
21214
|
+
setClosable(true);
|
|
21215
|
+
set(['PaymentError']);
|
|
21216
|
+
}
|
|
21217
|
+
|
|
21218
|
+
if (validated) {
|
|
21219
|
+
validated(item.message.status == 'success');
|
|
21220
|
+
}
|
|
21165
21221
|
|
|
21222
|
+
if (item.message.release) {
|
|
21166
21223
|
setRelease(true);
|
|
21167
21224
|
setClosable(!item.message.forward_to);
|
|
21168
21225
|
setForwardTo(item.message.forward_to);
|
|
@@ -22073,10 +22130,10 @@ var PaymentStack = (function (props) {
|
|
|
22073
22130
|
close = _useContext.close;
|
|
22074
22131
|
|
|
22075
22132
|
var _useContext2 = useContext(NavigateContext),
|
|
22076
|
-
|
|
22133
|
+
setNavigator = _useContext2.setNavigator;
|
|
22077
22134
|
|
|
22078
22135
|
return /*#__PURE__*/React.createElement(ReactDialogStack, {
|
|
22079
|
-
|
|
22136
|
+
setNavigator: setNavigator,
|
|
22080
22137
|
open: open,
|
|
22081
22138
|
close: close,
|
|
22082
22139
|
start: "PaymentOverview",
|
|
@@ -22526,10 +22583,10 @@ var SaleStack = (function (props) {
|
|
|
22526
22583
|
close = _useContext.close;
|
|
22527
22584
|
|
|
22528
22585
|
var _useContext2 = useContext(NavigateContext),
|
|
22529
|
-
|
|
22586
|
+
setNavigator = _useContext2.setNavigator;
|
|
22530
22587
|
|
|
22531
22588
|
return /*#__PURE__*/React.createElement(ReactDialogStack, {
|
|
22532
|
-
|
|
22589
|
+
setNavigator: setNavigator,
|
|
22533
22590
|
open: open,
|
|
22534
22591
|
close: close,
|
|
22535
22592
|
start: "SaleOverview",
|