@depay/widgets 7.12.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/dist/esm/index.bundle.js +3 -3
- package/dist/esm/index.js +70 -17
- package/dist/umd/index.bundle.js +3 -3
- package/dist/umd/index.js +70 -17
- package/package.json +1 -1
package/dist/umd/index.js
CHANGED
|
@@ -19227,8 +19227,8 @@
|
|
|
19227
19227
|
before = _useContext2.before;
|
|
19228
19228
|
|
|
19229
19229
|
var _useContext3 = React.useContext(PaymentRoutingContext),
|
|
19230
|
-
selectedRoute = _useContext3.selectedRoute
|
|
19231
|
-
|
|
19230
|
+
selectedRoute = _useContext3.selectedRoute;
|
|
19231
|
+
_useContext3.getPaymentRoutes;
|
|
19232
19232
|
|
|
19233
19233
|
var _useContext4 = React.useContext(ClosableContext),
|
|
19234
19234
|
open = _useContext4.open,
|
|
@@ -19293,10 +19293,7 @@
|
|
|
19293
19293
|
failed(transaction, error);
|
|
19294
19294
|
}
|
|
19295
19295
|
|
|
19296
|
-
setPaymentState('initialized');
|
|
19297
19296
|
setClosable(true);
|
|
19298
|
-
setUpdatable(true);
|
|
19299
|
-
getPaymentRoutes({});
|
|
19300
19297
|
navigate('PaymentError');
|
|
19301
19298
|
};
|
|
19302
19299
|
|
|
@@ -19596,7 +19593,8 @@
|
|
|
19596
19593
|
|
|
19597
19594
|
var calculateAmountInWithSlippage = /*#__PURE__*/function () {
|
|
19598
19595
|
var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(route) {
|
|
19599
|
-
var currentBlock, blocks, i, exchangeRoute, lastAmountsIn, difference1, difference2, slippage, newAmountBN, readableAmount, roundedAmountBN;
|
|
19596
|
+
var currentBlock, blocks, i, exchangeRoute, lastAmountsIn, difference1, difference2, slippage, newAmountBN, readableAmount, roundedAmountBN, _difference, _difference2, _slippage, highestAmountBN, _newAmountBN, _readableAmount, _roundedAmountBN;
|
|
19597
|
+
|
|
19600
19598
|
return regenerator.wrap(function _callee2$(_context2) {
|
|
19601
19599
|
while (1) {
|
|
19602
19600
|
switch (_context2.prev = _context2.next) {
|
|
@@ -19677,10 +19675,11 @@
|
|
|
19677
19675
|
|
|
19678
19676
|
case 15:
|
|
19679
19677
|
if (!(lastAmountsIn[0].gt(lastAmountsIn[1]) && lastAmountsIn[1].gt(lastAmountsIn[2]))) {
|
|
19680
|
-
_context2.next =
|
|
19678
|
+
_context2.next = 31;
|
|
19681
19679
|
break;
|
|
19682
19680
|
}
|
|
19683
19681
|
|
|
19682
|
+
// directional slippage
|
|
19684
19683
|
difference1 = lastAmountsIn[0].sub(lastAmountsIn[1]);
|
|
19685
19684
|
difference2 = lastAmountsIn[1].sub(lastAmountsIn[2]);
|
|
19686
19685
|
|
|
@@ -19712,7 +19711,53 @@
|
|
|
19712
19711
|
case 28:
|
|
19713
19712
|
return _context2.abrupt("return", newAmountBN);
|
|
19714
19713
|
|
|
19715
|
-
case
|
|
19714
|
+
case 31:
|
|
19715
|
+
if (lastAmountsIn[0].eq(lastAmountsIn[1]) && lastAmountsIn[1].eq(lastAmountsIn[2])) {
|
|
19716
|
+
_context2.next = 46;
|
|
19717
|
+
break;
|
|
19718
|
+
}
|
|
19719
|
+
|
|
19720
|
+
// base slippage
|
|
19721
|
+
_difference = lastAmountsIn[0].sub(lastAmountsIn[1]).abs();
|
|
19722
|
+
_difference2 = lastAmountsIn[1].sub(lastAmountsIn[2]).abs();
|
|
19723
|
+
|
|
19724
|
+
if (_difference.lt(_difference2)) {
|
|
19725
|
+
_slippage = _difference;
|
|
19726
|
+
} else {
|
|
19727
|
+
_slippage = _difference2;
|
|
19728
|
+
}
|
|
19729
|
+
|
|
19730
|
+
if (lastAmountsIn[0].gt(lastAmountsIn[1]) && lastAmountsIn[0].gt(lastAmountsIn[2])) {
|
|
19731
|
+
highestAmountBN = lastAmountsIn[0];
|
|
19732
|
+
} else if (lastAmountsIn[1].gt(lastAmountsIn[2]) && lastAmountsIn[1].gt(lastAmountsIn[0])) {
|
|
19733
|
+
highestAmountBN = lastAmountsIn[1];
|
|
19734
|
+
} else {
|
|
19735
|
+
highestAmountBN = lastAmountsIn[2];
|
|
19736
|
+
}
|
|
19737
|
+
|
|
19738
|
+
_newAmountBN = highestAmountBN.add(_slippage);
|
|
19739
|
+
_context2.next = 39;
|
|
19740
|
+
return route.fromToken.readable(_newAmountBN);
|
|
19741
|
+
|
|
19742
|
+
case 39:
|
|
19743
|
+
_readableAmount = _context2.sent;
|
|
19744
|
+
_context2.next = 42;
|
|
19745
|
+
return route.fromToken.BigNumber(round(_readableAmount));
|
|
19746
|
+
|
|
19747
|
+
case 42:
|
|
19748
|
+
_roundedAmountBN = _context2.sent;
|
|
19749
|
+
|
|
19750
|
+
if (!(route.fromAmount == _roundedAmountBN.toString())) {
|
|
19751
|
+
_context2.next = 45;
|
|
19752
|
+
break;
|
|
19753
|
+
}
|
|
19754
|
+
|
|
19755
|
+
return _context2.abrupt("return");
|
|
19756
|
+
|
|
19757
|
+
case 45:
|
|
19758
|
+
return _context2.abrupt("return", _newAmountBN);
|
|
19759
|
+
|
|
19760
|
+
case 46:
|
|
19716
19761
|
case "end":
|
|
19717
19762
|
return _context2.stop();
|
|
19718
19763
|
}
|
|
@@ -20941,8 +20986,8 @@
|
|
|
20941
20986
|
});
|
|
20942
20987
|
|
|
20943
20988
|
var PaymentErrorDialog = (function () {
|
|
20944
|
-
var _useContext = React.useContext(
|
|
20945
|
-
|
|
20989
|
+
var _useContext = React.useContext(ClosableContext),
|
|
20990
|
+
close = _useContext.close;
|
|
20946
20991
|
|
|
20947
20992
|
var _useContext2 = React.useContext(PaymentContext),
|
|
20948
20993
|
transaction = _useContext2.transaction;
|
|
@@ -20951,7 +20996,7 @@
|
|
|
20951
20996
|
recover = _useContext3.recover;
|
|
20952
20997
|
|
|
20953
20998
|
return /*#__PURE__*/React__default["default"].createElement(Dialog$1, {
|
|
20954
|
-
stacked:
|
|
20999
|
+
stacked: false,
|
|
20955
21000
|
header: /*#__PURE__*/React__default["default"].createElement("div", {
|
|
20956
21001
|
className: "PaddingTopS PaddingLeftM PaddingRightM"
|
|
20957
21002
|
}),
|
|
@@ -20982,7 +21027,7 @@
|
|
|
20982
21027
|
}, recover == undefined && /*#__PURE__*/React__default["default"].createElement("button", {
|
|
20983
21028
|
className: "ButtonPrimary",
|
|
20984
21029
|
onClick: function onClick() {
|
|
20985
|
-
return
|
|
21030
|
+
return close();
|
|
20986
21031
|
}
|
|
20987
21032
|
}, "Try again"))
|
|
20988
21033
|
});
|
|
@@ -21128,6 +21173,9 @@
|
|
|
21128
21173
|
var _useContext3 = React.useContext(ClosableContext),
|
|
21129
21174
|
setClosable = _useContext3.setClosable;
|
|
21130
21175
|
|
|
21176
|
+
var _useContext4 = React.useContext(NavigateContext),
|
|
21177
|
+
navigate = _useContext4.navigate;
|
|
21178
|
+
|
|
21131
21179
|
var openSocket = function openSocket(transaction) {
|
|
21132
21180
|
var socket = new WebSocket('wss://integrate.depay.fi/cable');
|
|
21133
21181
|
|
|
@@ -21149,15 +21197,20 @@
|
|
|
21149
21197
|
socket.onmessage = function (event) {
|
|
21150
21198
|
var item = JSON.parse(event.data);
|
|
21151
21199
|
|
|
21152
|
-
if (item.type === "ping") {
|
|
21200
|
+
if (item.type === "ping" || !item.message) {
|
|
21153
21201
|
return;
|
|
21154
21202
|
}
|
|
21155
21203
|
|
|
21156
|
-
if (item.message
|
|
21157
|
-
|
|
21158
|
-
|
|
21159
|
-
|
|
21204
|
+
if (item.message.status == 'failed') {
|
|
21205
|
+
setClosable(true);
|
|
21206
|
+
navigate('PaymentError');
|
|
21207
|
+
}
|
|
21208
|
+
|
|
21209
|
+
if (validated) {
|
|
21210
|
+
validated(item.message.status == 'success');
|
|
21211
|
+
}
|
|
21160
21212
|
|
|
21213
|
+
if (item.message.release) {
|
|
21161
21214
|
setRelease(true);
|
|
21162
21215
|
setClosable(!item.message.forward_to);
|
|
21163
21216
|
setForwardTo(item.message.forward_to);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@depay/widgets",
|
|
3
3
|
"moduleName": "DePayWidgets",
|
|
4
|
-
"version": "7.
|
|
4
|
+
"version": "7.13.0",
|
|
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",
|