@depay/widgets 6.0.2 → 6.2.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/README.md +77 -0
- package/dist/esm/index.bundle.js +1444 -4359
- package/dist/esm/index.js +204 -10
- package/dist/umd/index.bundle.js +1444 -4359
- package/dist/umd/index.js +204 -10
- package/package.json +3 -3
package/dist/umd/index.js
CHANGED
|
@@ -991,12 +991,25 @@
|
|
|
991
991
|
});
|
|
992
992
|
|
|
993
993
|
var ConnectingWalletDialog = (function (props) {
|
|
994
|
+
var _useState = React.useState(false),
|
|
995
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
996
|
+
showConnectButton = _useState2[0],
|
|
997
|
+
setShowConnectButton = _useState2[1];
|
|
998
|
+
|
|
994
999
|
var _useContext = React.useContext(reactDialogStack.NavigateStackContext),
|
|
995
1000
|
navigate = _useContext.navigate;
|
|
996
1001
|
|
|
997
1002
|
var wallet = props.wallet;
|
|
998
1003
|
wallet !== null && wallet !== void 0 && wallet.name ? wallet.name : 'wallet';
|
|
999
1004
|
var walletLogo = wallet !== null && wallet !== void 0 && wallet.logo ? wallet.logo : undefined;
|
|
1005
|
+
React.useEffect(function () {
|
|
1006
|
+
var timeout = setTimeout(function () {
|
|
1007
|
+
return setShowConnectButton(true);
|
|
1008
|
+
}, 10000);
|
|
1009
|
+
return function () {
|
|
1010
|
+
return clearTimeout(timeout);
|
|
1011
|
+
};
|
|
1012
|
+
}, []);
|
|
1000
1013
|
|
|
1001
1014
|
if (props.pending) {
|
|
1002
1015
|
return /*#__PURE__*/React__default$1["default"].createElement(Dialog$1, {
|
|
@@ -1036,7 +1049,7 @@
|
|
|
1036
1049
|
},
|
|
1037
1050
|
className: "TextButton"
|
|
1038
1051
|
}, "Connect with another wallet")))),
|
|
1039
|
-
footer: /*#__PURE__*/React__default$1["default"].createElement("div", {
|
|
1052
|
+
footer: showConnectButton && /*#__PURE__*/React__default$1["default"].createElement("div", {
|
|
1040
1053
|
className: "PaddingTopXS PaddingRightM PaddingLeftM PaddingBottomM"
|
|
1041
1054
|
}, /*#__PURE__*/React__default$1["default"].createElement("button", {
|
|
1042
1055
|
className: "ButtonPrimary",
|
|
@@ -1326,14 +1339,14 @@
|
|
|
1326
1339
|
throw new TypeError("Super expression must either be null or a function");
|
|
1327
1340
|
}
|
|
1328
1341
|
|
|
1342
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
1343
|
+
constructor: {
|
|
1344
|
+
value: subClass,
|
|
1345
|
+
writable: true,
|
|
1346
|
+
configurable: true
|
|
1347
|
+
}
|
|
1348
|
+
});
|
|
1329
1349
|
Object.defineProperty(subClass, "prototype", {
|
|
1330
|
-
value: Object.create(superClass && superClass.prototype, {
|
|
1331
|
-
constructor: {
|
|
1332
|
-
value: subClass,
|
|
1333
|
-
writable: true,
|
|
1334
|
-
configurable: true
|
|
1335
|
-
}
|
|
1336
|
-
}),
|
|
1337
1350
|
writable: false
|
|
1338
1351
|
});
|
|
1339
1352
|
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
@@ -1665,7 +1678,7 @@
|
|
|
1665
1678
|
});
|
|
1666
1679
|
|
|
1667
1680
|
var DialogStyle = (function (style) {
|
|
1668
|
-
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 }\n\n @media screen and (max-width: 450px) {\n \n .Dialog, .ReactDialogAnimation {\n width: 100%;\n }\n\n }\n\n @media (orientation: portrait) and (max-width: 900px) {\n\n .Dialog {\n align-content: stretch;\n display: flex;\n flex-direction: column;\n height: 100%;\n }\n\n .DialogBody {\n flex: 1;\n align-items: flex-end;\n max-height:
|
|
1681
|
+
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 }\n\n @media screen and (max-width: 450px) {\n \n .Dialog, .ReactDialogAnimation {\n width: 100%;\n }\n\n }\n\n @media (orientation: portrait) and (max-width: 900px) {\n\n .Dialog {\n align-content: stretch;\n display: flex;\n flex-direction: column;\n height: 100%;\n }\n\n .DialogBody {\n flex: 1;\n align-items: flex-end;\n max-height: 60vh !important;\n }\n\n .DialogFooter {\n padding-bottom: 20px;\n }\n\n .ReactDialogStackCell {\n vertical-align: bottom;\n }\n\n .ReactDialogAnimation {\n bottom: -100px !important;\n max-height: 66vh !important;\n top: inherit !important;\n transition: opacity 0.4s ease, bottom 0.4s ease;\n }\n\n .ReactDialog.ReactDialogOpen .ReactDialogAnimation {\n bottom: 0px !important;\n }\n\n .DialogFooter {\n border-bottom-left-radius: 0 !important;\n border-bottom-right-radius: 0 !important;\n }\n }\n\n .DialogBody {\n background: rgb(248,248,248);\n overflow-x: hidden;\n overflow-y: auto;\n }\n\n .DialogBody.HeightAuto {\n height: auto;\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 display: flex;\n flex-direction: row;\n position: relative;\n }\n\n .DialogHeaderTitle {\n flex-basis: auto;\n flex-grow: 1;\n }\n \n .DialogHeaderAction {\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 .ReactShadowDOMInsideContainer > .ReactDialog {\n display: table;\n }\n\n ";
|
|
1669
1682
|
});
|
|
1670
1683
|
|
|
1671
1684
|
var FontStyle = (function (style) {
|
|
@@ -3768,6 +3781,186 @@
|
|
|
3768
3781
|
};
|
|
3769
3782
|
}();
|
|
3770
3783
|
|
|
3784
|
+
var SignLoginDialog = (function (props) {
|
|
3785
|
+
var _useContext = React.useContext(ErrorContext),
|
|
3786
|
+
setError = _useContext.setError;
|
|
3787
|
+
|
|
3788
|
+
var _useState = React.useState(false),
|
|
3789
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
3790
|
+
showSignButton = _useState2[0],
|
|
3791
|
+
setShowSignButton = _useState2[1];
|
|
3792
|
+
|
|
3793
|
+
var _useContext2 = React.useContext(ConfigurationContext),
|
|
3794
|
+
message = _useContext2.message,
|
|
3795
|
+
endpoint = _useContext2.endpoint;
|
|
3796
|
+
|
|
3797
|
+
var _useContext3 = React.useContext(ConfigurationContext),
|
|
3798
|
+
recover = _useContext3.recover;
|
|
3799
|
+
|
|
3800
|
+
var wallet = web3Wallets.getWallet();
|
|
3801
|
+
wallet !== null && wallet !== void 0 && wallet.name ? wallet.name : 'wallet';
|
|
3802
|
+
var walletLogo = wallet !== null && wallet !== void 0 && wallet.logo ? wallet.logo : undefined;
|
|
3803
|
+
|
|
3804
|
+
if (typeof recover != 'function') {
|
|
3805
|
+
recover = function recover(_ref) {
|
|
3806
|
+
var message = _ref.message,
|
|
3807
|
+
signature = _ref.signature;
|
|
3808
|
+
return new Promise(function (resolve, reject) {
|
|
3809
|
+
fetch(endpoint, {
|
|
3810
|
+
method: 'POST',
|
|
3811
|
+
body: JSON.stringify({
|
|
3812
|
+
message: message,
|
|
3813
|
+
signature: signature
|
|
3814
|
+
})
|
|
3815
|
+
}).then(function (response) {
|
|
3816
|
+
if (response.status == 200) {
|
|
3817
|
+
response.text().then(function (account) {
|
|
3818
|
+
resolve(account);
|
|
3819
|
+
})["catch"](setError);
|
|
3820
|
+
} else {
|
|
3821
|
+
response.text().then(function (text) {
|
|
3822
|
+
setError(text || 'Recovering login signature failed!');
|
|
3823
|
+
});
|
|
3824
|
+
}
|
|
3825
|
+
});
|
|
3826
|
+
});
|
|
3827
|
+
};
|
|
3828
|
+
}
|
|
3829
|
+
|
|
3830
|
+
var login = function login() {
|
|
3831
|
+
wallet.sign(message).then(function (signature) {
|
|
3832
|
+
recover({
|
|
3833
|
+
message: message,
|
|
3834
|
+
signature: signature
|
|
3835
|
+
}).then(props.resolve)["catch"](setError);
|
|
3836
|
+
})["catch"](setError);
|
|
3837
|
+
};
|
|
3838
|
+
|
|
3839
|
+
React.useEffect(function () {
|
|
3840
|
+
return setTimeout(login, 1000);
|
|
3841
|
+
}, []);
|
|
3842
|
+
React.useEffect(function () {
|
|
3843
|
+
var timeout = setTimeout(function () {
|
|
3844
|
+
return setShowSignButton(true);
|
|
3845
|
+
}, 10000);
|
|
3846
|
+
return function () {
|
|
3847
|
+
return clearTimeout(timeout);
|
|
3848
|
+
};
|
|
3849
|
+
}, []);
|
|
3850
|
+
return /*#__PURE__*/React__default$1["default"].createElement(Dialog$1, {
|
|
3851
|
+
body: /*#__PURE__*/React__default$1["default"].createElement("div", null, walletLogo && /*#__PURE__*/React__default$1["default"].createElement("div", {
|
|
3852
|
+
className: "GraphicWrapper PaddingTopS PaddingBottomS"
|
|
3853
|
+
}, /*#__PURE__*/React__default$1["default"].createElement("img", {
|
|
3854
|
+
className: "Graphic",
|
|
3855
|
+
src: walletLogo
|
|
3856
|
+
})), /*#__PURE__*/React__default$1["default"].createElement("h1", {
|
|
3857
|
+
className: "LineHeightL Text FontSizeL FontWeightBold PaddingTopS"
|
|
3858
|
+
}, "Wallet Login"), /*#__PURE__*/React__default$1["default"].createElement("div", {
|
|
3859
|
+
className: "Text PaddingTopS PaddingBottomS PaddingLeftS PaddingRightS"
|
|
3860
|
+
}, /*#__PURE__*/React__default$1["default"].createElement("p", {
|
|
3861
|
+
className: "FontSizeM PaddingLeftM PaddingRightM"
|
|
3862
|
+
}, "Please sign the login message with your connected wallet."))),
|
|
3863
|
+
footer: showSignButton && /*#__PURE__*/React__default$1["default"].createElement("div", {
|
|
3864
|
+
className: "PaddingTopXS PaddingRightM PaddingLeftM PaddingBottomM"
|
|
3865
|
+
}, /*#__PURE__*/React__default$1["default"].createElement("button", {
|
|
3866
|
+
className: "ButtonPrimary",
|
|
3867
|
+
onClick: login
|
|
3868
|
+
}, "Log in"))
|
|
3869
|
+
});
|
|
3870
|
+
});
|
|
3871
|
+
|
|
3872
|
+
var LoginStack = (function (props) {
|
|
3873
|
+
var _useContext = React.useContext(ClosableContext),
|
|
3874
|
+
open = _useContext.open,
|
|
3875
|
+
close = _useContext.close;
|
|
3876
|
+
|
|
3877
|
+
var _useState = React.useState(true),
|
|
3878
|
+
_useState2 = _slicedToArray(_useState, 2);
|
|
3879
|
+
_useState2[0];
|
|
3880
|
+
_useState2[1];
|
|
3881
|
+
|
|
3882
|
+
return /*#__PURE__*/React__default$1["default"].createElement(reactDialogStack.ReactDialogStack, {
|
|
3883
|
+
open: open,
|
|
3884
|
+
close: close,
|
|
3885
|
+
start: "SignLogin",
|
|
3886
|
+
container: props.container,
|
|
3887
|
+
document: props.document,
|
|
3888
|
+
dialogs: {
|
|
3889
|
+
SignLogin: /*#__PURE__*/React__default$1["default"].createElement(SignLoginDialog, {
|
|
3890
|
+
resolve: props.resolve
|
|
3891
|
+
})
|
|
3892
|
+
}
|
|
3893
|
+
});
|
|
3894
|
+
});
|
|
3895
|
+
|
|
3896
|
+
var Login = function Login(options) {
|
|
3897
|
+
var style, error, document, message, endpoint, recover;
|
|
3898
|
+
|
|
3899
|
+
if (_typeof(options) == 'object') {
|
|
3900
|
+
style = options.style;
|
|
3901
|
+
error = options.error;
|
|
3902
|
+
document = options.document;
|
|
3903
|
+
message = options.message;
|
|
3904
|
+
endpoint = options.endpoint;
|
|
3905
|
+
recover = options.recover;
|
|
3906
|
+
}
|
|
3907
|
+
|
|
3908
|
+
return new Promise( /*#__PURE__*/function () {
|
|
3909
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(_resolve, reject) {
|
|
3910
|
+
return regenerator.wrap(function _callee$(_context) {
|
|
3911
|
+
while (1) {
|
|
3912
|
+
switch (_context.prev = _context.next) {
|
|
3913
|
+
case 0:
|
|
3914
|
+
Connect().then(function () {
|
|
3915
|
+
mount({
|
|
3916
|
+
style: style,
|
|
3917
|
+
document: ensureDocument(document)
|
|
3918
|
+
}, function (unmount) {
|
|
3919
|
+
var rejectBeforeUnmount = function rejectBeforeUnmount() {
|
|
3920
|
+
reject('USER_CLOSED_DIALOG');
|
|
3921
|
+
unmount();
|
|
3922
|
+
};
|
|
3923
|
+
|
|
3924
|
+
return function (container) {
|
|
3925
|
+
return /*#__PURE__*/React__default$1["default"].createElement(ErrorProvider, {
|
|
3926
|
+
error: error,
|
|
3927
|
+
container: container,
|
|
3928
|
+
unmount: unmount
|
|
3929
|
+
}, /*#__PURE__*/React__default$1["default"].createElement(ConfigurationProvider, {
|
|
3930
|
+
configuration: {
|
|
3931
|
+
message: message,
|
|
3932
|
+
endpoint: endpoint || '/login',
|
|
3933
|
+
recover: recover
|
|
3934
|
+
}
|
|
3935
|
+
}, /*#__PURE__*/React__default$1["default"].createElement(UpdatableProvider, null, /*#__PURE__*/React__default$1["default"].createElement(ClosableProvider, {
|
|
3936
|
+
unmount: rejectBeforeUnmount
|
|
3937
|
+
}, /*#__PURE__*/React__default$1["default"].createElement(LoginStack, {
|
|
3938
|
+
document: document,
|
|
3939
|
+
container: container,
|
|
3940
|
+
resolve: function resolve(account) {
|
|
3941
|
+
unmount();
|
|
3942
|
+
|
|
3943
|
+
_resolve(account);
|
|
3944
|
+
}
|
|
3945
|
+
}), /*#__PURE__*/React__default$1["default"].createElement(PoweredBy, null)))));
|
|
3946
|
+
};
|
|
3947
|
+
});
|
|
3948
|
+
})["catch"](reject);
|
|
3949
|
+
|
|
3950
|
+
case 1:
|
|
3951
|
+
case "end":
|
|
3952
|
+
return _context.stop();
|
|
3953
|
+
}
|
|
3954
|
+
}
|
|
3955
|
+
}, _callee);
|
|
3956
|
+
}));
|
|
3957
|
+
|
|
3958
|
+
return function (_x, _x2) {
|
|
3959
|
+
return _ref.apply(this, arguments);
|
|
3960
|
+
};
|
|
3961
|
+
}());
|
|
3962
|
+
};
|
|
3963
|
+
|
|
3771
3964
|
var PaymentAmountRoutingContext = /*#__PURE__*/React__default$1["default"].createContext();
|
|
3772
3965
|
|
|
3773
3966
|
var PaymentAmountRoutingProvider = (function (props) {
|
|
@@ -4476,9 +4669,10 @@
|
|
|
4476
4669
|
|
|
4477
4670
|
var DePayWidgets = {
|
|
4478
4671
|
Connect: Connect,
|
|
4672
|
+
Donation: Donation,
|
|
4673
|
+
Login: Login,
|
|
4479
4674
|
Payment: Payment,
|
|
4480
4675
|
Sale: Sale,
|
|
4481
|
-
Donation: Donation,
|
|
4482
4676
|
provider: web3Client.provider
|
|
4483
4677
|
};
|
|
4484
4678
|
|
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.2.2",
|
|
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",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@depay/web3-exchanges": "^8.0.0",
|
|
46
46
|
"@depay/web3-payments": "^9.0.2",
|
|
47
47
|
"@depay/web3-tokens": "^7.2.0",
|
|
48
|
-
"@depay/web3-wallets": "^7.
|
|
48
|
+
"@depay/web3-wallets": "^7.2.1",
|
|
49
49
|
"decimal.js": "^10.3.1",
|
|
50
50
|
"react-rangeslider": "^2.2.0"
|
|
51
51
|
},
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@babel/preset-env": "^7.12.7",
|
|
61
61
|
"@babel/preset-react": "^7.12.7",
|
|
62
62
|
"@cypress/react": "^5.9.1",
|
|
63
|
-
"@depay/web3-mock": "^9.
|
|
63
|
+
"@depay/web3-mock": "^9.6.0",
|
|
64
64
|
"@rollup/plugin-babel": "^5.3.0",
|
|
65
65
|
"@rollup/plugin-commonjs": "^17.1.0",
|
|
66
66
|
"@rollup/plugin-node-resolve": "^11.1.1",
|