@depay/widgets 4.2.0 → 4.4.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 +14 -0
- package/dist/cjs/index.bundle.js +15072 -6937
- package/dist/cjs/index.js +103 -85
- package/dist/es/index.bundle.js +15072 -6937
- package/dist/es/index.js +54 -36
- package/dist/umd/index.bundle.js +15072 -6937
- package/dist/umd/index.js +95 -78
- package/package.json +15 -14
package/dist/es/index.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import React, { useState, useContext, useEffect } from 'react';
|
|
2
|
-
import { NavigateStackContext, ReactDialogStack } from 'depay
|
|
3
|
-
import { getWallet, wallets } from 'depay
|
|
2
|
+
import { NavigateStackContext, ReactDialogStack } from '@depay/react-dialog-stack';
|
|
3
|
+
import { getWallet, wallets } from '@depay/web3-wallets';
|
|
4
4
|
import ReactDOM from 'react-dom';
|
|
5
|
-
import { ReactShadowDOM } from 'depay
|
|
5
|
+
import { ReactShadowDOM } from '@depay/react-shadow-dom';
|
|
6
6
|
import { ethers } from 'ethers';
|
|
7
|
-
import { CONSTANTS } from 'depay
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
7
|
+
import { CONSTANTS } from '@depay/web3-constants';
|
|
8
|
+
import { Decimal } from 'decimal.js';
|
|
9
|
+
import { route } from '@depay/web3-exchanges';
|
|
10
|
+
import { Token } from '@depay/web3-tokens';
|
|
11
|
+
import { Currency } from '@depay/local-currency';
|
|
12
|
+
import { setProviderEndpoints, provider } from '@depay/web3-client';
|
|
13
|
+
import { route as route$1 } from '@depay/web3-payments';
|
|
13
14
|
import Slider from 'react-rangeslider';
|
|
14
|
-
import { TokenImage } from 'depay
|
|
15
|
-
import { Blockchain } from 'depay
|
|
15
|
+
import { TokenImage } from '@depay/react-token-image';
|
|
16
|
+
import { Blockchain } from '@depay/web3-blockchains';
|
|
16
17
|
|
|
17
18
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
18
19
|
try {
|
|
@@ -1376,8 +1377,7 @@ function ReactDialogStyle (styles) {
|
|
|
1376
1377
|
let background =
|
|
1377
1378
|
typeof styles === 'object' && styles.background ? styles.background : 'rgba(0,0,0,0.4)';
|
|
1378
1379
|
|
|
1379
|
-
return
|
|
1380
|
-
`
|
|
1380
|
+
return `
|
|
1381
1381
|
.ReactDialog {
|
|
1382
1382
|
bottom: 0;
|
|
1383
1383
|
display: table;
|
|
@@ -1436,12 +1436,9 @@ function ReactDialogStyle (styles) {
|
|
|
1436
1436
|
top: -5vh;
|
|
1437
1437
|
}
|
|
1438
1438
|
`
|
|
1439
|
-
)
|
|
1440
1439
|
}
|
|
1441
1440
|
|
|
1442
|
-
const _jsxFileName = "/
|
|
1443
|
-
|
|
1444
|
-
|
|
1441
|
+
const _jsxFileName = "/home/runner/work/react-dialog/react-dialog/src/components/Dialog.jsx";
|
|
1445
1442
|
class Dialog extends React__default['default'].Component {
|
|
1446
1443
|
constructor(props) {
|
|
1447
1444
|
super(props);
|
|
@@ -1503,7 +1500,7 @@ class Dialog extends React__default['default'].Component {
|
|
|
1503
1500
|
}
|
|
1504
1501
|
}
|
|
1505
1502
|
|
|
1506
|
-
const _jsxFileName$1 = "/
|
|
1503
|
+
const _jsxFileName$1 = "/home/runner/work/react-dialog/react-dialog/src/index.jsx";
|
|
1507
1504
|
class ReactDialog extends React__default['default'].Component {
|
|
1508
1505
|
constructor(props) {
|
|
1509
1506
|
super(props);
|
|
@@ -2038,7 +2035,9 @@ var ChangableAmountProvider = (function (props) {
|
|
|
2038
2035
|
if (amountsMissing && maxRoute) {
|
|
2039
2036
|
maxRoute.fromToken.readable(maxRoute.fromBalance).then(function (readableMaxAmount) {
|
|
2040
2037
|
if (maxRoute.fromToken.address == CONSTANTS[maxRoute.blockchain].USD) {
|
|
2041
|
-
|
|
2038
|
+
var _maxAmount = parseFloat(new Decimal(readableMaxAmount).mul(conversionRate).toString());
|
|
2039
|
+
|
|
2040
|
+
setMaxAmount(_maxAmount > 10 ? Math.round(_maxAmount) : _maxAmount);
|
|
2042
2041
|
} else {
|
|
2043
2042
|
route({
|
|
2044
2043
|
blockchain: maxRoute.blockchain,
|
|
@@ -2054,7 +2053,8 @@ var ChangableAmountProvider = (function (props) {
|
|
|
2054
2053
|
address: CONSTANTS[maxRoute.blockchain].USD
|
|
2055
2054
|
}).then(function (readableMaxAmount) {
|
|
2056
2055
|
var slippage = 1.01;
|
|
2057
|
-
|
|
2056
|
+
var maxAmount = parseFloat(new Decimal(readableMaxAmount).div(slippage).mul(conversionRate).toString());
|
|
2057
|
+
setMaxAmount(maxAmount > 10 ? Math.round(maxAmount) : round(maxAmount));
|
|
2058
2058
|
})["catch"](setError);
|
|
2059
2059
|
})["catch"](setError);
|
|
2060
2060
|
}
|
|
@@ -2082,7 +2082,7 @@ var ConfigurationProvider = (function (props) {
|
|
|
2082
2082
|
useEffect(function () {
|
|
2083
2083
|
if (props.configuration.providers != undefined) {
|
|
2084
2084
|
Object.entries(props.configuration.providers).forEach(function (entry) {
|
|
2085
|
-
|
|
2085
|
+
setProviderEndpoints(entry[0], entry[1]);
|
|
2086
2086
|
});
|
|
2087
2087
|
}
|
|
2088
2088
|
}, [props.configuration]);
|
|
@@ -2689,16 +2689,22 @@ var ChangeAmountDialog = (function (props) {
|
|
|
2689
2689
|
setInputAmount(value);
|
|
2690
2690
|
};
|
|
2691
2691
|
|
|
2692
|
-
var
|
|
2692
|
+
var toValidStep = function toValidStep(value) {
|
|
2693
2693
|
if (step) {
|
|
2694
|
-
value = Math.
|
|
2694
|
+
value = parseFloat(new Decimal(Math.floor(new Decimal(value).div(step))).mul(step).toString());
|
|
2695
2695
|
}
|
|
2696
2696
|
|
|
2697
|
+
return value;
|
|
2698
|
+
};
|
|
2699
|
+
|
|
2700
|
+
var toValidValue = function toValidValue(value) {
|
|
2701
|
+
value = toValidStep(value);
|
|
2697
2702
|
value = Math.max(min, Math.min(value, maxAmount));
|
|
2703
|
+
value = toValidStep(value);
|
|
2698
2704
|
return value;
|
|
2699
2705
|
};
|
|
2700
2706
|
|
|
2701
|
-
var
|
|
2707
|
+
var setValidValue = function setValidValue(value) {
|
|
2702
2708
|
setInputAmount(toValidValue(value));
|
|
2703
2709
|
};
|
|
2704
2710
|
|
|
@@ -2731,7 +2737,7 @@ var ChangeAmountDialog = (function (props) {
|
|
|
2731
2737
|
changeAmount(event.target.value);
|
|
2732
2738
|
},
|
|
2733
2739
|
onBlur: function onBlur(event) {
|
|
2734
|
-
|
|
2740
|
+
setValidValue(event.target.value);
|
|
2735
2741
|
}
|
|
2736
2742
|
})), /*#__PURE__*/React.createElement(Slider, {
|
|
2737
2743
|
max: parseFloat(maxAmount),
|
|
@@ -2739,19 +2745,19 @@ var ChangeAmountDialog = (function (props) {
|
|
|
2739
2745
|
step: step,
|
|
2740
2746
|
value: parseFloat(inputAmount),
|
|
2741
2747
|
onChange: function onChange(value) {
|
|
2742
|
-
changeAmount(value);
|
|
2748
|
+
changeAmount(toValidStep(value));
|
|
2743
2749
|
},
|
|
2744
2750
|
onChangeComplete: function onChangeComplete() {
|
|
2745
|
-
|
|
2751
|
+
setValidValue(inputAmount);
|
|
2746
2752
|
}
|
|
2747
2753
|
}), /*#__PURE__*/React.createElement("div", {
|
|
2748
2754
|
style: {
|
|
2749
2755
|
height: '40px'
|
|
2750
2756
|
}
|
|
2751
|
-
}, /*#__PURE__*/React.createElement("div", null, format(maxAmount), /*#__PURE__*/React.createElement("button", {
|
|
2757
|
+
}, /*#__PURE__*/React.createElement("div", null, format(toValidStep(maxAmount)), /*#__PURE__*/React.createElement("button", {
|
|
2752
2758
|
className: "TextButton",
|
|
2753
2759
|
onClick: function onClick() {
|
|
2754
|
-
changeAmount(maxAmount);
|
|
2760
|
+
changeAmount(toValidValue(maxAmount));
|
|
2755
2761
|
}
|
|
2756
2762
|
}, "(Max)")))))),
|
|
2757
2763
|
footer: /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("button", {
|
|
@@ -3898,7 +3904,8 @@ var SaleOverviewDialog = (function (props) {
|
|
|
3898
3904
|
amount = _useContext.amount;
|
|
3899
3905
|
|
|
3900
3906
|
var _useContext2 = useContext(ConfigurationContext),
|
|
3901
|
-
currencyCode = _useContext2.currencyCode
|
|
3907
|
+
currencyCode = _useContext2.currencyCode,
|
|
3908
|
+
tokenImage = _useContext2.tokenImage;
|
|
3902
3909
|
|
|
3903
3910
|
var _useContext3 = useContext(PaymentValueContext),
|
|
3904
3911
|
paymentValue = _useContext3.paymentValue;
|
|
@@ -3999,6 +4006,19 @@ var SaleOverviewDialog = (function (props) {
|
|
|
3999
4006
|
return /*#__PURE__*/React.createElement(SaleOverviewSkeleton, null);
|
|
4000
4007
|
}
|
|
4001
4008
|
|
|
4009
|
+
var tokenImageElement;
|
|
4010
|
+
|
|
4011
|
+
if (tokenImage) {
|
|
4012
|
+
tokenImageElement = /*#__PURE__*/React.createElement("img", {
|
|
4013
|
+
src: tokenImage
|
|
4014
|
+
});
|
|
4015
|
+
} else {
|
|
4016
|
+
tokenImageElement = /*#__PURE__*/React.createElement(TokenImage, {
|
|
4017
|
+
blockchain: payment.route.blockchain,
|
|
4018
|
+
address: toToken.address
|
|
4019
|
+
});
|
|
4020
|
+
}
|
|
4021
|
+
|
|
4002
4022
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
4003
4023
|
header: /*#__PURE__*/React.createElement("div", {
|
|
4004
4024
|
className: "PaddingTopS PaddingLeftM PaddingRightM"
|
|
@@ -4020,10 +4040,7 @@ var SaleOverviewDialog = (function (props) {
|
|
|
4020
4040
|
}, /*#__PURE__*/React.createElement("div", {
|
|
4021
4041
|
className: "CardImage",
|
|
4022
4042
|
title: payment.name
|
|
4023
|
-
}, /*#__PURE__*/React.createElement(
|
|
4024
|
-
blockchain: payment.route.blockchain,
|
|
4025
|
-
address: toToken.address
|
|
4026
|
-
})), /*#__PURE__*/React.createElement("div", {
|
|
4043
|
+
}, tokenImageElement), /*#__PURE__*/React.createElement("div", {
|
|
4027
4044
|
className: "CardBody"
|
|
4028
4045
|
}, /*#__PURE__*/React.createElement("div", {
|
|
4029
4046
|
className: "CardBodyWrapper"
|
|
@@ -4149,12 +4166,12 @@ var preflight = /*#__PURE__*/function () {
|
|
|
4149
4166
|
|
|
4150
4167
|
var Sale = /*#__PURE__*/function () {
|
|
4151
4168
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(_ref3) {
|
|
4152
|
-
var amount, sell, sent, confirmed, ensured, failed, error, critical, style, blacklist, providers, currency, connected, closed, document, accept, unmount;
|
|
4169
|
+
var amount, sell, sent, confirmed, ensured, failed, error, critical, style, blacklist, providers, currency, connected, closed, tokenImage, document, accept, unmount;
|
|
4153
4170
|
return regenerator.wrap(function _callee2$(_context2) {
|
|
4154
4171
|
while (1) {
|
|
4155
4172
|
switch (_context2.prev = _context2.next) {
|
|
4156
4173
|
case 0:
|
|
4157
|
-
amount = _ref3.amount, sell = _ref3.sell, sent = _ref3.sent, confirmed = _ref3.confirmed, ensured = _ref3.ensured, 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, document = _ref3.document;
|
|
4174
|
+
amount = _ref3.amount, sell = _ref3.sell, sent = _ref3.sent, confirmed = _ref3.confirmed, ensured = _ref3.ensured, 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, tokenImage = _ref3.tokenImage, document = _ref3.document;
|
|
4158
4175
|
_context2.prev = 1;
|
|
4159
4176
|
_context2.next = 4;
|
|
4160
4177
|
return preflight({
|
|
@@ -4180,6 +4197,7 @@ var Sale = /*#__PURE__*/function () {
|
|
|
4180
4197
|
unmount: unmount
|
|
4181
4198
|
}, /*#__PURE__*/React.createElement(ConfigurationProvider, {
|
|
4182
4199
|
configuration: {
|
|
4200
|
+
tokenImage: tokenImage,
|
|
4183
4201
|
amount: amount,
|
|
4184
4202
|
sell: sell,
|
|
4185
4203
|
currency: currency,
|