@depay/widgets 6.23.0 → 6.25.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 +127 -78
- package/dist/esm/index.bundle.js +17820 -418
- package/dist/esm/index.js +121 -45
- package/dist/umd/index.bundle.js +17820 -418
- package/dist/umd/index.js +121 -45
- package/package.json +6 -5
package/dist/umd/index.js
CHANGED
|
@@ -1689,7 +1689,7 @@
|
|
|
1689
1689
|
});
|
|
1690
1690
|
|
|
1691
1691
|
var DialogStyle = (function (style) {
|
|
1692
|
-
return "\n\n .ReactDialogBackground {\n backdrop-filter: blur(5px);\n background: rgba(0,0,0,0.7);\n }\n\n .Dialog {\n margin: 0 auto;\n position: relative;\n width: 420px;\n box-shadow: 0 0 20px rgba(0,0,0,0.1);\n border-radius: 0.8rem;\n background: rgb(248,248,248);\n }\n\n @media (max-width: 450px) {\n\n .Dialog {\n border-radius: 0;\n width: 100%;\n }\n
|
|
1692
|
+
return "\n\n .ReactDialogBackground {\n backdrop-filter: blur(5px);\n background: rgba(0,0,0,0.7);\n }\n\n .Dialog {\n margin: 0 auto;\n position: relative;\n width: 420px;\n box-shadow: 0 0 20px rgba(0,0,0,0.1);\n border-radius: 0.8rem;\n background: rgb(248,248,248);\n }\n\n @media (max-width: 450px) {\n\n .Dialog {\n border-radius: 0;\n width: 100%;\n }\n }\n\n @media (orientation: portrait) and (max-width: 800px) {\n\n .ReactDialogAnimation {\n width: 100%;\n }\n\n .ReactDialog {\n height: 100%;\n min-height: 100%;\n }\n\n .ReactDialogStack {\n align-items: flex-end;\n }\n\n .Dialog {\n align-content: stretch;\n border-radius: 0.8rem;\n border-top-radius: 0.8rem;\n display: flex;\n flex-direction: column;\n }\n\n .DialogBody {\n flex: 1;\n align-items: flex-end;\n }\n\n .DialogFooter {\n padding-bottom: 20px;\n }\n\n .ReactDialogAnimation {\n margin-bottom: -100px !important;\n top: inherit !important;\n position: relative;\n transition: opacity 0.4s ease, margin-bottom 0.4s ease;\n }\n\n .ReactDialog.ReactDialogOpen .ReactDialogAnimation {\n margin-bottom: 0px !important;\n }\n\n .DialogFooter {\n border-bottom-left-radius: 0 !important;\n border-bottom-right-radius: 0 !important;\n }\n\n .ReactShadowDOMInsideContainer > .ReactDialog {\n align-items: flex-end;\n }\n }\n\n .DialogBody {\n background: rgb(248,248,248);\n overflow-x: hidden;\n overflow-y: auto;\n }\n\n .DialogBody.ScrollHeight {\n height: 30vh !important;\n max-height: 30vh !important;\n }\n\n .DialogHeader {\n background: rgb(248,248,248);\n border-top-left-radius: 0.8rem;\n border-top-right-radius: 0.8rem;\n min-height: 3.4rem;\n position: relative;\n width: 100%;\n }\n\n .DialogHeaderActionRight {\n position: absolute;\n top: 0;\n right: 0;\n height: 3rem;\n }\n\n .DialogHeaderActionLeft {\n position: absolute;\n top: 0;\n left: 0;\n height: 3rem;\n }\n\n .DialogFooter {\n background: rgb(248,248,248);\n border-bottom-left-radius: 0.8rem;\n border-bottom-right-radius: 0.8rem;\n line-height: 1.5rem;\n min-height: 2rem;\n position: relative;\n text-align: center;\n }\n\n ";
|
|
1693
1693
|
});
|
|
1694
1694
|
|
|
1695
1695
|
var FontStyle = (function (style) {
|
|
@@ -2593,6 +2593,41 @@
|
|
|
2593
2593
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2594
2594
|
|
|
2595
2595
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
2596
|
+
|
|
2597
|
+
var prepareAcceptedPayments = function prepareAcceptedPayments(accept) {
|
|
2598
|
+
var toAddress = _typeof(accept.receiver) == 'object' ? accept.receiver.address : accept.receiver;
|
|
2599
|
+
var toContract = _typeof(accept.receiver) == 'object' ? accept.receiver : undefined;
|
|
2600
|
+
return _objectSpread(_objectSpread({}, accept), {}, {
|
|
2601
|
+
toAddress: toAddress,
|
|
2602
|
+
toContract: toContract
|
|
2603
|
+
});
|
|
2604
|
+
};
|
|
2605
|
+
|
|
2606
|
+
var mergeFromAccounts = function mergeFromAccounts(accept, account) {
|
|
2607
|
+
var from = {};
|
|
2608
|
+
accept.forEach(function (accept) {
|
|
2609
|
+
from[accept.blockchain] = account;
|
|
2610
|
+
});
|
|
2611
|
+
return from;
|
|
2612
|
+
};
|
|
2613
|
+
|
|
2614
|
+
var routePayments = (function (_ref) {
|
|
2615
|
+
var accept = _ref.accept,
|
|
2616
|
+
account = _ref.account,
|
|
2617
|
+
whitelist = _ref.whitelist,
|
|
2618
|
+
blacklist = _ref.blacklist,
|
|
2619
|
+
event = _ref.event,
|
|
2620
|
+
fee = _ref.fee;
|
|
2621
|
+
return web3Payments.route({
|
|
2622
|
+
accept: accept.map(prepareAcceptedPayments),
|
|
2623
|
+
from: mergeFromAccounts(accept, account),
|
|
2624
|
+
whitelist: whitelist,
|
|
2625
|
+
blacklist: blacklist,
|
|
2626
|
+
event: event,
|
|
2627
|
+
fee: fee
|
|
2628
|
+
});
|
|
2629
|
+
});
|
|
2630
|
+
|
|
2596
2631
|
var PaymentRoutingProvider = (function (props) {
|
|
2597
2632
|
var _useState = React.useState(),
|
|
2598
2633
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -2604,10 +2639,15 @@
|
|
|
2604
2639
|
selectedRoute = _useState4[0],
|
|
2605
2640
|
setSelectedRoute = _useState4[1];
|
|
2606
2641
|
|
|
2607
|
-
var _useState5 = React.useState(
|
|
2642
|
+
var _useState5 = React.useState(false),
|
|
2608
2643
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
2609
|
-
|
|
2610
|
-
|
|
2644
|
+
slowRouting = _useState6[0],
|
|
2645
|
+
setSlowRouting = _useState6[1];
|
|
2646
|
+
|
|
2647
|
+
var _useState7 = React.useState(0),
|
|
2648
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
2649
|
+
reloadCount = _useState8[0],
|
|
2650
|
+
setReloadCount = _useState8[1];
|
|
2611
2651
|
|
|
2612
2652
|
var _useContext = React.useContext(WalletContext),
|
|
2613
2653
|
account = _useContext.account;
|
|
@@ -2618,49 +2658,54 @@
|
|
|
2618
2658
|
var _useContext3 = React.useContext(ConfigurationContext),
|
|
2619
2659
|
recover = _useContext3.recover;
|
|
2620
2660
|
|
|
2621
|
-
var
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
}
|
|
2661
|
+
var onRoutesUpdate = function onRoutesUpdate(routes) {
|
|
2662
|
+
if (routes.length == 0) {
|
|
2663
|
+
setAllRoutes([]);
|
|
2664
|
+
|
|
2665
|
+
if (props.setMaxRoute) {
|
|
2666
|
+
props.setMaxRoute(null);
|
|
2667
|
+
}
|
|
2668
|
+
} else {
|
|
2669
|
+
roundAmounts(routes).then(function (roundedRoutes) {
|
|
2670
|
+
var selected;
|
|
2671
|
+
|
|
2672
|
+
if (selectedRoute) {
|
|
2673
|
+
selected = roundedRoutes[allRoutes.findIndex(function (route) {
|
|
2674
|
+
return route.fromToken == selectedRoute.fromToken && route.blockchain == selectedRoute.blockchain;
|
|
2675
|
+
})];
|
|
2676
|
+
}
|
|
2677
|
+
|
|
2678
|
+
if (selected == undefined) {
|
|
2679
|
+
selected = roundedRoutes[0];
|
|
2680
|
+
}
|
|
2681
|
+
|
|
2682
|
+
setSelectedRoute(selected);
|
|
2683
|
+
setAllRoutes(roundedRoutes);
|
|
2684
|
+
|
|
2685
|
+
if (props.setMaxRoute) {
|
|
2686
|
+
props.setMaxRoute(findMaxRoute(roundedRoutes));
|
|
2687
|
+
}
|
|
2688
|
+
});
|
|
2689
|
+
}
|
|
2629
2690
|
};
|
|
2630
2691
|
|
|
2631
2692
|
var getPaymentRoutes = function getPaymentRoutes(_ref) {
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
updatable = _ref.updatable;
|
|
2693
|
+
_ref.allRoutes;
|
|
2694
|
+
_ref.selectedRoute;
|
|
2695
|
+
var updatable = _ref.updatable;
|
|
2635
2696
|
|
|
2636
2697
|
if (updatable == false || !props.accept || !account) {
|
|
2637
2698
|
return;
|
|
2638
2699
|
}
|
|
2639
2700
|
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
setAllRoutes([]);
|
|
2649
|
-
|
|
2650
|
-
if (props.setMaxRoute) {
|
|
2651
|
-
props.setMaxRoute(null);
|
|
2652
|
-
}
|
|
2653
|
-
} else {
|
|
2654
|
-
roundAmounts(routes).then(function (roundedRoutes) {
|
|
2655
|
-
var selected = selectedRoute ? roundedRoutes[allRoutes.indexOf(selectedRoute)] || roundedRoutes[0] : roundedRoutes[0];
|
|
2656
|
-
setSelectedRoute(selected);
|
|
2657
|
-
setAllRoutes(roundedRoutes);
|
|
2658
|
-
|
|
2659
|
-
if (props.setMaxRoute) {
|
|
2660
|
-
props.setMaxRoute(findMaxRoute(roundedRoutes));
|
|
2661
|
-
}
|
|
2662
|
-
});
|
|
2663
|
-
}
|
|
2701
|
+
var slowRoutingTimeout = setTimeout(function () {
|
|
2702
|
+
setSlowRouting(true);
|
|
2703
|
+
}, 4000);
|
|
2704
|
+
routePayments(Object.assign({}, props, {
|
|
2705
|
+
account: account
|
|
2706
|
+
})).then(function (routes) {
|
|
2707
|
+
clearInterval(slowRoutingTimeout);
|
|
2708
|
+
onRoutesUpdate(routes);
|
|
2664
2709
|
});
|
|
2665
2710
|
};
|
|
2666
2711
|
|
|
@@ -2759,7 +2804,8 @@
|
|
|
2759
2804
|
setSelectedRoute: setSelectedRoute,
|
|
2760
2805
|
getPaymentRoutes: getPaymentRoutes,
|
|
2761
2806
|
allRoutes: allRoutes,
|
|
2762
|
-
setAllRoutes: setAllRoutes
|
|
2807
|
+
setAllRoutes: setAllRoutes,
|
|
2808
|
+
slowRouting: slowRouting
|
|
2763
2809
|
}
|
|
2764
2810
|
}, props.children);
|
|
2765
2811
|
});
|
|
@@ -3776,11 +3822,11 @@
|
|
|
3776
3822
|
paymentRoute = _useState6[0],
|
|
3777
3823
|
setPaymentRoute = _useState6[1];
|
|
3778
3824
|
|
|
3779
|
-
var _useState7 = React.useState(!!(track && (track.endpoint || typeof track.method == 'function'))),
|
|
3825
|
+
var _useState7 = React.useState(!!(track && (track.endpoint || typeof track.method == 'function') && track.async != true)),
|
|
3780
3826
|
_useState8 = _slicedToArray(_useState7, 1),
|
|
3781
3827
|
tracking = _useState8[0];
|
|
3782
3828
|
|
|
3783
|
-
var _useState9 = React.useState(!!(track && track.poll && (track.poll.endpoint || typeof track.poll.method == 'function'))),
|
|
3829
|
+
var _useState9 = React.useState(!!(track && track.poll && (track.poll.endpoint || typeof track.poll.method == 'function') && track.async != true)),
|
|
3784
3830
|
_useState10 = _slicedToArray(_useState9, 1),
|
|
3785
3831
|
polling = _useState10[0];
|
|
3786
3832
|
|
|
@@ -3946,6 +3992,10 @@
|
|
|
3946
3992
|
return;
|
|
3947
3993
|
}
|
|
3948
3994
|
|
|
3995
|
+
if (!tracking) {
|
|
3996
|
+
return;
|
|
3997
|
+
}
|
|
3998
|
+
|
|
3949
3999
|
var pollingInterval = setInterval(function () {
|
|
3950
4000
|
return pollStatus(polling, transaction, afterBlock, paymentRoute, pollingInterval);
|
|
3951
4001
|
}, 5000);
|
|
@@ -4001,6 +4051,10 @@
|
|
|
4001
4051
|
var initializeTracking = function initializeTracking(transaction, afterBlock, paymentRoute) {
|
|
4002
4052
|
storePayment(transaction, afterBlock, paymentRoute, 1);
|
|
4003
4053
|
|
|
4054
|
+
if (tracking || track && track.async == true) {
|
|
4055
|
+
startTracking(transaction, afterBlock, paymentRoute);
|
|
4056
|
+
}
|
|
4057
|
+
|
|
4004
4058
|
if (tracking == false) {
|
|
4005
4059
|
return;
|
|
4006
4060
|
}
|
|
@@ -4009,7 +4063,6 @@
|
|
|
4009
4063
|
setAfterBlock(afterBlock);
|
|
4010
4064
|
setPaymentRoute(paymentRoute);
|
|
4011
4065
|
openSocket(transaction);
|
|
4012
|
-
startTracking(transaction, afterBlock, paymentRoute);
|
|
4013
4066
|
};
|
|
4014
4067
|
|
|
4015
4068
|
return /*#__PURE__*/React__default["default"].createElement(PaymentTrackingContext.Provider, {
|
|
@@ -4200,7 +4253,7 @@
|
|
|
4200
4253
|
setWalletState('connected');
|
|
4201
4254
|
|
|
4202
4255
|
if (props.connected) {
|
|
4203
|
-
props.connected(
|
|
4256
|
+
props.connected(account);
|
|
4204
4257
|
}
|
|
4205
4258
|
};
|
|
4206
4259
|
|
|
@@ -4568,6 +4621,10 @@
|
|
|
4568
4621
|
var _useContext = React.useContext(ChangableAmountContext),
|
|
4569
4622
|
amountsMissing = _useContext.amountsMissing;
|
|
4570
4623
|
|
|
4624
|
+
var _useContext2 = React.useContext(PaymentRoutingContext),
|
|
4625
|
+
slowRouting = _useContext2.slowRouting,
|
|
4626
|
+
selectedRoute = _useContext2.selectedRoute;
|
|
4627
|
+
|
|
4571
4628
|
return /*#__PURE__*/React__default["default"].createElement(Dialog$1, {
|
|
4572
4629
|
header: /*#__PURE__*/React__default["default"].createElement("div", {
|
|
4573
4630
|
className: "PaddingTopS PaddingLeftM PaddingRightM TextLeft"
|
|
@@ -4593,7 +4650,9 @@
|
|
|
4593
4650
|
className: "ButtonPrimary Skeleton"
|
|
4594
4651
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
4595
4652
|
className: "SkeletonBackground"
|
|
4596
|
-
})))
|
|
4653
|
+
}))), selectedRoute == undefined && slowRouting && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
4654
|
+
className: "TextCenter Opacity05 PaddingTopS"
|
|
4655
|
+
}, /*#__PURE__*/React__default["default"].createElement("strong", null, "Still loading your wallet balances...")))
|
|
4597
4656
|
});
|
|
4598
4657
|
});
|
|
4599
4658
|
|
|
@@ -4867,6 +4926,23 @@
|
|
|
4867
4926
|
};
|
|
4868
4927
|
}();
|
|
4869
4928
|
|
|
4929
|
+
Payment.preload = function (_ref5) {
|
|
4930
|
+
var account = _ref5.account,
|
|
4931
|
+
accept = _ref5.accept,
|
|
4932
|
+
whitelist = _ref5.whitelist,
|
|
4933
|
+
blacklist = _ref5.blacklist,
|
|
4934
|
+
event = _ref5.event,
|
|
4935
|
+
fee = _ref5.fee;
|
|
4936
|
+
routePayments({
|
|
4937
|
+
account: account,
|
|
4938
|
+
accept: accept,
|
|
4939
|
+
whitelist: whitelist,
|
|
4940
|
+
blacklist: blacklist,
|
|
4941
|
+
event: event,
|
|
4942
|
+
fee: fee
|
|
4943
|
+
});
|
|
4944
|
+
};
|
|
4945
|
+
|
|
4870
4946
|
var SaleRoutingContext = /*#__PURE__*/React__default["default"].createContext();
|
|
4871
4947
|
|
|
4872
4948
|
var ToTokenContext = /*#__PURE__*/React__default["default"].createContext();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@depay/widgets",
|
|
3
3
|
"moduleName": "DePayWidgets",
|
|
4
|
-
"version": "6.
|
|
4
|
+
"version": "6.25.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",
|
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
"@depay/react-shadow-dom": "^4.0.0",
|
|
40
40
|
"@depay/react-token-image": "^3.0.0",
|
|
41
41
|
"@depay/walletconnect-v1": "^1.1.0",
|
|
42
|
-
"@depay/web3-assets": "^
|
|
43
|
-
"@depay/web3-blockchains": "^4.
|
|
42
|
+
"@depay/web3-assets": "^6.2.1",
|
|
43
|
+
"@depay/web3-blockchains": "^4.3.0",
|
|
44
44
|
"@depay/web3-client": "^8.0.0",
|
|
45
45
|
"@depay/web3-constants": "^5.0.0",
|
|
46
|
-
"@depay/web3-exchanges": "^8.2.
|
|
47
|
-
"@depay/web3-payments": "^
|
|
46
|
+
"@depay/web3-exchanges": "^8.2.1",
|
|
47
|
+
"@depay/web3-payments": "^10.1.1",
|
|
48
48
|
"@depay/web3-tokens": "^8.0.1",
|
|
49
49
|
"@depay/web3-wallets": "^10.0.3",
|
|
50
50
|
"decimal.js": "^10.3.1",
|
|
@@ -86,6 +86,7 @@
|
|
|
86
86
|
"regenerator-runtime": "^0.13.7",
|
|
87
87
|
"rollup": "^2.34.2",
|
|
88
88
|
"rollup-plugin-delete": "^2.0.0",
|
|
89
|
+
"rollup-plugin-dev": "^2.0.3",
|
|
89
90
|
"rollup-plugin-livereload": "^2.0.0",
|
|
90
91
|
"rollup-plugin-polyfill-node": "^0.7.0",
|
|
91
92
|
"rollup-plugin-serve": "^1.1.0",
|