@fileverse-dev/fortune-react 1.0.87 → 1.0.88-patch-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/es/components/SheetOverlay/FormulaHint/index.d.ts +3 -0
- package/es/components/SheetOverlay/FormulaHint/index.js +112 -7
- package/es/components/SheetOverlay/FormulaSearch/index.js +30 -9
- package/es/components/Toolbar/index.js +1 -2
- package/lib/components/SheetOverlay/FormulaHint/index.d.ts +3 -0
- package/lib/components/SheetOverlay/FormulaHint/index.js +115 -7
- package/lib/components/SheetOverlay/FormulaSearch/index.js +30 -9
- package/lib/components/Toolbar/index.js +1 -2
- package/package.json +2 -2
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import "./index.css";
|
|
3
|
+
export declare function formatExpiryTime(createdAt: number): string;
|
|
4
|
+
export declare function isExpired(createdAt: number): boolean;
|
|
5
|
+
export declare function timeFromNowMessage(expiryStr: string): string;
|
|
3
6
|
declare const FormulaHint: React.FC<React.HTMLAttributes<HTMLDivElement>>;
|
|
4
7
|
export default FormulaHint;
|
|
@@ -13,6 +13,23 @@ import { Button, TextField, LucideIcon } from "@fileverse/ui";
|
|
|
13
13
|
import React, { useContext, useEffect, useRef, useState } from "react";
|
|
14
14
|
import WorkbookContext from "../../../context";
|
|
15
15
|
import "./index.css";
|
|
16
|
+
export function formatExpiryTime(createdAt) {
|
|
17
|
+
var expiry = new Date(createdAt + 60 * 60 * 1000);
|
|
18
|
+
var mm = String(expiry.getMinutes()).padStart(2, "0");
|
|
19
|
+
var ss = String(expiry.getSeconds()).padStart(2, "0");
|
|
20
|
+
return "".concat(mm, ":").concat(ss);
|
|
21
|
+
}
|
|
22
|
+
export function isExpired(createdAt) {
|
|
23
|
+
var expiryTs = createdAt + 60 * 60 * 1000;
|
|
24
|
+
return Date.now() > expiryTs;
|
|
25
|
+
}
|
|
26
|
+
export function timeFromNowMessage(expiryStr) {
|
|
27
|
+
if (!expiryStr) {
|
|
28
|
+
return "0 minute";
|
|
29
|
+
}
|
|
30
|
+
var mm = expiryStr.split(":").map(Number)[0];
|
|
31
|
+
return "".concat(mm, " minute").concat(mm !== 1 ? "s" : "");
|
|
32
|
+
}
|
|
16
33
|
var FormulaHint = function FormulaHint(props) {
|
|
17
34
|
var _a;
|
|
18
35
|
var context = useContext(WorkbookContext).context;
|
|
@@ -28,23 +45,57 @@ var FormulaHint = function FormulaHint(props) {
|
|
|
28
45
|
var _d = useState(!!localStorage.getItem(fn === null || fn === void 0 ? void 0 : fn.API_KEY)),
|
|
29
46
|
isKeyAdded = _d[0],
|
|
30
47
|
setApiKeyAdded = _d[1];
|
|
31
|
-
var _e = useState(
|
|
32
|
-
|
|
33
|
-
|
|
48
|
+
var _e = useState(false),
|
|
49
|
+
hasGnosisPayToken = _e[0],
|
|
50
|
+
setHasGnosisPayToken = _e[1];
|
|
51
|
+
var _f = useState(true),
|
|
52
|
+
showFunctionBody = _f[0],
|
|
53
|
+
setShouldShowFunctionBody = _f[1];
|
|
54
|
+
var _g = useState(""),
|
|
55
|
+
expiryTime = _g[0],
|
|
56
|
+
setExpiryTime = _g[1];
|
|
57
|
+
var isWrongGnosisPayConnector = localStorage.getItem("LOGIN_METHOD") !== "walletAddress";
|
|
58
|
+
var handleGnosisPayToken = function handleGnosisPayToken(onDone) {
|
|
59
|
+
if (localStorage.getItem("GNOSIS_PAY_ACCESS")) {
|
|
60
|
+
var access = JSON.parse(localStorage.getItem("GNOSIS_PAY_ACCESS") || "");
|
|
61
|
+
if (!(access === null || access === void 0 ? void 0 : access.token) || isExpired(access === null || access === void 0 ? void 0 : access.createdAt)) {
|
|
62
|
+
if (hasGnosisPayToken) {
|
|
63
|
+
setHasGnosisPayToken(false);
|
|
64
|
+
}
|
|
65
|
+
if (expiryTime) {
|
|
66
|
+
setExpiryTime("");
|
|
67
|
+
}
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
setHasGnosisPayToken(!!access.token);
|
|
71
|
+
setExpiryTime(formatExpiryTime(access.createdAt));
|
|
72
|
+
onDone === null || onDone === void 0 ? void 0 : onDone();
|
|
73
|
+
} else {
|
|
74
|
+
var urlParams = new URLSearchParams(window.location.search);
|
|
75
|
+
var isRejected = urlParams.has("reject");
|
|
76
|
+
if (isRejected) {
|
|
77
|
+
var url = new URL(window.location.href);
|
|
78
|
+
url.searchParams.delete("reject");
|
|
79
|
+
window.history.replaceState({}, "", url.toString());
|
|
80
|
+
onDone === null || onDone === void 0 ? void 0 : onDone();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
34
84
|
useEffect(function () {
|
|
35
85
|
if (fn) {
|
|
36
86
|
setApiKeyAdded(!!localStorage.getItem(fn === null || fn === void 0 ? void 0 : fn.API_KEY));
|
|
37
87
|
setAPI_KEY(localStorage.getItem(fn === null || fn === void 0 ? void 0 : fn.API_KEY) || "");
|
|
38
88
|
setShowAPInput(!localStorage.getItem(fn === null || fn === void 0 ? void 0 : fn.API_KEY));
|
|
89
|
+
handleGnosisPayToken();
|
|
39
90
|
}
|
|
40
91
|
}, [fn]);
|
|
41
92
|
var apiKeyPlaceholder = {
|
|
42
93
|
ETHERSCAN_API_KEY: "Etherscan API key"
|
|
43
94
|
};
|
|
44
95
|
var hintRef = useRef(null);
|
|
45
|
-
var
|
|
46
|
-
top =
|
|
47
|
-
setTop =
|
|
96
|
+
var _h = useState(0),
|
|
97
|
+
top = _h[0],
|
|
98
|
+
setTop = _h[1];
|
|
48
99
|
var calcuatePopUpPlacement = function calcuatePopUpPlacement() {
|
|
49
100
|
var _a, _b, _c;
|
|
50
101
|
if (!((_a = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.top) === null || _a === void 0 ? void 0 : _a.toString()) || !((_b = firstSelection.height_move) === null || _b === void 0 ? void 0 : _b.toString()) || !hintRef.current) return;
|
|
@@ -93,6 +144,15 @@ var FormulaHint = function FormulaHint(props) {
|
|
|
93
144
|
if (el && handleWheel) el.removeEventListener("wheel", handleWheel);
|
|
94
145
|
};
|
|
95
146
|
}, []);
|
|
147
|
+
var gnosisTokenTokenIntervalRef = useRef(null);
|
|
148
|
+
var _j = useState(false),
|
|
149
|
+
isLoading = _j[0],
|
|
150
|
+
setIsLoading = _j[1];
|
|
151
|
+
useEffect(function () {
|
|
152
|
+
return function () {
|
|
153
|
+
if (gnosisTokenTokenIntervalRef.current) clearInterval(gnosisTokenTokenIntervalRef.current);
|
|
154
|
+
};
|
|
155
|
+
}, [gnosisTokenTokenIntervalRef]);
|
|
96
156
|
if (!fn) return null;
|
|
97
157
|
return /*#__PURE__*/React.createElement("div", __assign({}, props, {
|
|
98
158
|
ref: hintRef,
|
|
@@ -254,7 +314,52 @@ var FormulaHint = function FormulaHint(props) {
|
|
|
254
314
|
},
|
|
255
315
|
disabled: !API_KEY,
|
|
256
316
|
className: "min-w-[80px]"
|
|
257
|
-
}, "Ok"))))))), /*#__PURE__*/React.createElement("div", {
|
|
317
|
+
}, "Ok"))))))), fn.n === "GNOSISPAY" && (/*#__PURE__*/React.createElement("div", {
|
|
318
|
+
style: {
|
|
319
|
+
borderLeft: "4px solid ".concat(hasGnosisPayToken ? "#177E23" : "#fb923c"),
|
|
320
|
+
backgroundColor: "white",
|
|
321
|
+
padding: "16px",
|
|
322
|
+
margin: "4px 4px 0px 4px",
|
|
323
|
+
borderRadius: "4px"
|
|
324
|
+
}
|
|
325
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
326
|
+
style: {
|
|
327
|
+
display: "flex",
|
|
328
|
+
justifyContent: "space-between",
|
|
329
|
+
cursor: "pointer"
|
|
330
|
+
},
|
|
331
|
+
onClick: function onClick() {}
|
|
332
|
+
}, /*#__PURE__*/React.createElement("h3", {
|
|
333
|
+
style: {
|
|
334
|
+
margin: "0 0 8px 0"
|
|
335
|
+
},
|
|
336
|
+
className: "text-heading-xsm color-text-default"
|
|
337
|
+
}, hasGnosisPayToken ? "Access granted" : "Access required")), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("p", {
|
|
338
|
+
style: {
|
|
339
|
+
margin: "0 0 16px 0"
|
|
340
|
+
},
|
|
341
|
+
className: "text-body-sm color-text-default"
|
|
342
|
+
}, !hasGnosisPayToken ? "To access your Gnosis Pay account, please grant permission. Your dSheet account should be created via the same wallet ss your Gnosis Pay. " : " You have ".concat(timeFromNowMessage(expiryTime), " to use your Gnosis Pay account. Then you need to grand access again.")), /*#__PURE__*/React.createElement(Button, {
|
|
343
|
+
onClick: function onClick() {
|
|
344
|
+
var button = document.getElementById("grant-gnosispay-access");
|
|
345
|
+
if (!button) return;
|
|
346
|
+
button.click();
|
|
347
|
+
setIsLoading(true);
|
|
348
|
+
var interval = setInterval(function () {
|
|
349
|
+
handleGnosisPayToken(function () {
|
|
350
|
+
clearInterval(interval);
|
|
351
|
+
setIsLoading(false);
|
|
352
|
+
});
|
|
353
|
+
}, 5000);
|
|
354
|
+
gnosisTokenTokenIntervalRef.current = interval;
|
|
355
|
+
},
|
|
356
|
+
disabled: hasGnosisPayToken || isWrongGnosisPayConnector || isLoading,
|
|
357
|
+
className: "w-full items-center flex gap-1"
|
|
358
|
+
}, isLoading && (/*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(LucideIcon, {
|
|
359
|
+
name: "LoaderCircle",
|
|
360
|
+
className: "animate-spin",
|
|
361
|
+
size: "sm"
|
|
362
|
+
}))), /*#__PURE__*/React.createElement("p", null, "Grant access "), " ", expiryTime && /*#__PURE__*/React.createElement("div", null, expiryTime))))), /*#__PURE__*/React.createElement("div", {
|
|
258
363
|
style: {
|
|
259
364
|
backgroundColor: "white",
|
|
260
365
|
padding: "6px",
|
|
@@ -16,9 +16,9 @@ import WorkbookContext from "../../../context";
|
|
|
16
16
|
import "./index.css";
|
|
17
17
|
var FormulaSearch = function FormulaSearch(props) {
|
|
18
18
|
var _a;
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
var context = useContext(WorkbookContext).context;
|
|
20
|
+
var isAuthorized = true;
|
|
21
|
+
var isWrongGnosisPayConnector = localStorage.getItem("LOGIN_METHOD") !== "walletAddress";
|
|
22
22
|
var authedFunction = ["COINGECKO", "ETHERSCAN", "DEFILLAMA", "GNOSIS", "BASE", "EOA", "PNL", "SAFE", "BLOCKSCOUT", "GNOSIS", "LENS", "FARCASTER", "Ethereum", "SMARTCONTRACT"];
|
|
23
23
|
var filteredDefaultCandidates = context.defaultCandidates.filter(function (item) {
|
|
24
24
|
return !authedFunction.includes(item.n);
|
|
@@ -32,9 +32,9 @@ var FormulaSearch = function FormulaSearch(props) {
|
|
|
32
32
|
});
|
|
33
33
|
var firstSelection = (_a = context.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0];
|
|
34
34
|
var hintRef = useRef(null);
|
|
35
|
-
var
|
|
36
|
-
top =
|
|
37
|
-
setTop =
|
|
35
|
+
var _b = useState(0),
|
|
36
|
+
top = _b[0],
|
|
37
|
+
setTop = _b[1];
|
|
38
38
|
var calcuatePopUpPlacement = function calcuatePopUpPlacement() {
|
|
39
39
|
var _a, _b, _c;
|
|
40
40
|
if (!((_a = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.top) === null || _a === void 0 ? void 0 : _a.toString()) || !((_b = firstSelection.height_move) === null || _b === void 0 ? void 0 : _b.toString()) || !hintRef.current) return;
|
|
@@ -166,8 +166,18 @@ var FormulaSearch = function FormulaSearch(props) {
|
|
|
166
166
|
justifyContent: "space-between"
|
|
167
167
|
}
|
|
168
168
|
}, /*#__PURE__*/React.createElement("div", {
|
|
169
|
+
className: "flex items-center"
|
|
170
|
+
}, v.LOGO && isWrongGnosisPayConnector && v.n === "GNOSISPAY" && (/*#__PURE__*/React.createElement("div", {
|
|
171
|
+
className: "mr-2"
|
|
172
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
173
|
+
src: v.LOGO,
|
|
174
|
+
alt: "Service Logo",
|
|
175
|
+
style: {
|
|
176
|
+
width: "16px"
|
|
177
|
+
}
|
|
178
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
169
179
|
className: "luckysheet-formula-search-func color-text-default text-body-sm"
|
|
170
|
-
}, v.n), /*#__PURE__*/React.createElement("div", {
|
|
180
|
+
}, v.n)), /*#__PURE__*/React.createElement("div", {
|
|
171
181
|
style: {
|
|
172
182
|
display: "flex",
|
|
173
183
|
justifyContent: "end",
|
|
@@ -175,7 +185,18 @@ var FormulaSearch = function FormulaSearch(props) {
|
|
|
175
185
|
alignItems: "center",
|
|
176
186
|
gap: "6px"
|
|
177
187
|
}
|
|
178
|
-
}, v.
|
|
188
|
+
}, isWrongGnosisPayConnector && v.n === "GNOSISPAY" ? (/*#__PURE__*/React.createElement(Tooltip, {
|
|
189
|
+
position: "right",
|
|
190
|
+
text: /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("p", null, "Your dSheet account was created via email/social. Unfortunately you are not able to use Gnosis Pay onchain function."), /*#__PURE__*/React.createElement("p", {
|
|
191
|
+
className: "mt-4"
|
|
192
|
+
}, "To use Gnosis Pay onchain function you need to create a new dSheets account via the same wallet as your Gnosis Pay account."))
|
|
193
|
+
}, /*#__PURE__*/React.createElement(LucideIcon, {
|
|
194
|
+
name: "Info",
|
|
195
|
+
size: "sm",
|
|
196
|
+
style: {
|
|
197
|
+
color: "#F16227"
|
|
198
|
+
}
|
|
199
|
+
}))) : (/*#__PURE__*/React.createElement(React.Fragment, null, v.LOGO && (/*#__PURE__*/React.createElement("img", {
|
|
179
200
|
src: v.LOGO,
|
|
180
201
|
alt: "Service Logo",
|
|
181
202
|
style: {
|
|
@@ -204,7 +225,7 @@ var FormulaSearch = function FormulaSearch(props) {
|
|
|
204
225
|
width: "12px",
|
|
205
226
|
height: "12px"
|
|
206
227
|
}
|
|
207
|
-
})))))), /*#__PURE__*/React.createElement("div", {
|
|
228
|
+
})))))))), /*#__PURE__*/React.createElement("div", {
|
|
208
229
|
className: "luckysheet-formula-search-detail mt-1 text-helper-text-sm color-text-secondary"
|
|
209
230
|
}, v.d));
|
|
210
231
|
}), finalFunctionCandidates.length === 0 && (/*#__PURE__*/React.createElement("span", null, !isAuthorized && (/*#__PURE__*/React.createElement("div", {
|
|
@@ -1476,7 +1476,7 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1476
1476
|
icon: "Minus",
|
|
1477
1477
|
variant: "ghost",
|
|
1478
1478
|
size: "sm",
|
|
1479
|
-
className: "
|
|
1479
|
+
className: "",
|
|
1480
1480
|
disabled: decimals === 1,
|
|
1481
1481
|
onClick: function onClick() {
|
|
1482
1482
|
return handleCurrencyDecimalsChange_1(Math.max(1, decimals - 1));
|
|
@@ -1493,7 +1493,6 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1493
1493
|
icon: "Plus",
|
|
1494
1494
|
variant: "ghost",
|
|
1495
1495
|
size: "sm",
|
|
1496
|
-
className: "!bg-transparent",
|
|
1497
1496
|
disabled: decimals === 18,
|
|
1498
1497
|
onClick: function onClick() {
|
|
1499
1498
|
return handleCurrencyDecimalsChange_1(Math.min(18, decimals + 1));
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import "./index.css";
|
|
3
|
+
export declare function formatExpiryTime(createdAt: number): string;
|
|
4
|
+
export declare function isExpired(createdAt: number): boolean;
|
|
5
|
+
export declare function timeFromNowMessage(expiryStr: string): string;
|
|
3
6
|
declare const FormulaHint: React.FC<React.HTMLAttributes<HTMLDivElement>>;
|
|
4
7
|
export default FormulaHint;
|
|
@@ -5,6 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
+
exports.formatExpiryTime = formatExpiryTime;
|
|
9
|
+
exports.isExpired = isExpired;
|
|
10
|
+
exports.timeFromNowMessage = timeFromNowMessage;
|
|
8
11
|
var _fortuneCore = require("@fileverse-dev/fortune-core");
|
|
9
12
|
var _ui = require("@fileverse/ui");
|
|
10
13
|
var _react = _interopRequireWildcard(require("react"));
|
|
@@ -22,6 +25,23 @@ var __assign = void 0 && (void 0).__assign || function () {
|
|
|
22
25
|
};
|
|
23
26
|
return __assign.apply(this, arguments);
|
|
24
27
|
};
|
|
28
|
+
function formatExpiryTime(createdAt) {
|
|
29
|
+
var expiry = new Date(createdAt + 60 * 60 * 1000);
|
|
30
|
+
var mm = String(expiry.getMinutes()).padStart(2, "0");
|
|
31
|
+
var ss = String(expiry.getSeconds()).padStart(2, "0");
|
|
32
|
+
return "".concat(mm, ":").concat(ss);
|
|
33
|
+
}
|
|
34
|
+
function isExpired(createdAt) {
|
|
35
|
+
var expiryTs = createdAt + 60 * 60 * 1000;
|
|
36
|
+
return Date.now() > expiryTs;
|
|
37
|
+
}
|
|
38
|
+
function timeFromNowMessage(expiryStr) {
|
|
39
|
+
if (!expiryStr) {
|
|
40
|
+
return "0 minute";
|
|
41
|
+
}
|
|
42
|
+
var mm = expiryStr.split(":").map(Number)[0];
|
|
43
|
+
return "".concat(mm, " minute").concat(mm !== 1 ? "s" : "");
|
|
44
|
+
}
|
|
25
45
|
var FormulaHint = function FormulaHint(props) {
|
|
26
46
|
var _a;
|
|
27
47
|
var context = (0, _react.useContext)(_context.default).context;
|
|
@@ -37,23 +57,57 @@ var FormulaHint = function FormulaHint(props) {
|
|
|
37
57
|
var _d = (0, _react.useState)(!!localStorage.getItem(fn === null || fn === void 0 ? void 0 : fn.API_KEY)),
|
|
38
58
|
isKeyAdded = _d[0],
|
|
39
59
|
setApiKeyAdded = _d[1];
|
|
40
|
-
var _e = (0, _react.useState)(
|
|
41
|
-
|
|
42
|
-
|
|
60
|
+
var _e = (0, _react.useState)(false),
|
|
61
|
+
hasGnosisPayToken = _e[0],
|
|
62
|
+
setHasGnosisPayToken = _e[1];
|
|
63
|
+
var _f = (0, _react.useState)(true),
|
|
64
|
+
showFunctionBody = _f[0],
|
|
65
|
+
setShouldShowFunctionBody = _f[1];
|
|
66
|
+
var _g = (0, _react.useState)(""),
|
|
67
|
+
expiryTime = _g[0],
|
|
68
|
+
setExpiryTime = _g[1];
|
|
69
|
+
var isWrongGnosisPayConnector = localStorage.getItem("LOGIN_METHOD") !== "walletAddress";
|
|
70
|
+
var handleGnosisPayToken = function handleGnosisPayToken(onDone) {
|
|
71
|
+
if (localStorage.getItem("GNOSIS_PAY_ACCESS")) {
|
|
72
|
+
var access = JSON.parse(localStorage.getItem("GNOSIS_PAY_ACCESS") || "");
|
|
73
|
+
if (!(access === null || access === void 0 ? void 0 : access.token) || isExpired(access === null || access === void 0 ? void 0 : access.createdAt)) {
|
|
74
|
+
if (hasGnosisPayToken) {
|
|
75
|
+
setHasGnosisPayToken(false);
|
|
76
|
+
}
|
|
77
|
+
if (expiryTime) {
|
|
78
|
+
setExpiryTime("");
|
|
79
|
+
}
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
setHasGnosisPayToken(!!access.token);
|
|
83
|
+
setExpiryTime(formatExpiryTime(access.createdAt));
|
|
84
|
+
onDone === null || onDone === void 0 ? void 0 : onDone();
|
|
85
|
+
} else {
|
|
86
|
+
var urlParams = new URLSearchParams(window.location.search);
|
|
87
|
+
var isRejected = urlParams.has("reject");
|
|
88
|
+
if (isRejected) {
|
|
89
|
+
var url = new URL(window.location.href);
|
|
90
|
+
url.searchParams.delete("reject");
|
|
91
|
+
window.history.replaceState({}, "", url.toString());
|
|
92
|
+
onDone === null || onDone === void 0 ? void 0 : onDone();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
43
96
|
(0, _react.useEffect)(function () {
|
|
44
97
|
if (fn) {
|
|
45
98
|
setApiKeyAdded(!!localStorage.getItem(fn === null || fn === void 0 ? void 0 : fn.API_KEY));
|
|
46
99
|
setAPI_KEY(localStorage.getItem(fn === null || fn === void 0 ? void 0 : fn.API_KEY) || "");
|
|
47
100
|
setShowAPInput(!localStorage.getItem(fn === null || fn === void 0 ? void 0 : fn.API_KEY));
|
|
101
|
+
handleGnosisPayToken();
|
|
48
102
|
}
|
|
49
103
|
}, [fn]);
|
|
50
104
|
var apiKeyPlaceholder = {
|
|
51
105
|
ETHERSCAN_API_KEY: "Etherscan API key"
|
|
52
106
|
};
|
|
53
107
|
var hintRef = (0, _react.useRef)(null);
|
|
54
|
-
var
|
|
55
|
-
top =
|
|
56
|
-
setTop =
|
|
108
|
+
var _h = (0, _react.useState)(0),
|
|
109
|
+
top = _h[0],
|
|
110
|
+
setTop = _h[1];
|
|
57
111
|
var calcuatePopUpPlacement = function calcuatePopUpPlacement() {
|
|
58
112
|
var _a, _b, _c;
|
|
59
113
|
if (!((_a = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.top) === null || _a === void 0 ? void 0 : _a.toString()) || !((_b = firstSelection.height_move) === null || _b === void 0 ? void 0 : _b.toString()) || !hintRef.current) return;
|
|
@@ -102,6 +156,15 @@ var FormulaHint = function FormulaHint(props) {
|
|
|
102
156
|
if (el && handleWheel) el.removeEventListener("wheel", handleWheel);
|
|
103
157
|
};
|
|
104
158
|
}, []);
|
|
159
|
+
var gnosisTokenTokenIntervalRef = (0, _react.useRef)(null);
|
|
160
|
+
var _j = (0, _react.useState)(false),
|
|
161
|
+
isLoading = _j[0],
|
|
162
|
+
setIsLoading = _j[1];
|
|
163
|
+
(0, _react.useEffect)(function () {
|
|
164
|
+
return function () {
|
|
165
|
+
if (gnosisTokenTokenIntervalRef.current) clearInterval(gnosisTokenTokenIntervalRef.current);
|
|
166
|
+
};
|
|
167
|
+
}, [gnosisTokenTokenIntervalRef]);
|
|
105
168
|
if (!fn) return null;
|
|
106
169
|
return /*#__PURE__*/_react.default.createElement("div", __assign({}, props, {
|
|
107
170
|
ref: hintRef,
|
|
@@ -263,7 +326,52 @@ var FormulaHint = function FormulaHint(props) {
|
|
|
263
326
|
},
|
|
264
327
|
disabled: !API_KEY,
|
|
265
328
|
className: "min-w-[80px]"
|
|
266
|
-
}, "Ok"))))))), /*#__PURE__*/_react.default.createElement("div", {
|
|
329
|
+
}, "Ok"))))))), fn.n === "GNOSISPAY" && (/*#__PURE__*/_react.default.createElement("div", {
|
|
330
|
+
style: {
|
|
331
|
+
borderLeft: "4px solid ".concat(hasGnosisPayToken ? "#177E23" : "#fb923c"),
|
|
332
|
+
backgroundColor: "white",
|
|
333
|
+
padding: "16px",
|
|
334
|
+
margin: "4px 4px 0px 4px",
|
|
335
|
+
borderRadius: "4px"
|
|
336
|
+
}
|
|
337
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
338
|
+
style: {
|
|
339
|
+
display: "flex",
|
|
340
|
+
justifyContent: "space-between",
|
|
341
|
+
cursor: "pointer"
|
|
342
|
+
},
|
|
343
|
+
onClick: function onClick() {}
|
|
344
|
+
}, /*#__PURE__*/_react.default.createElement("h3", {
|
|
345
|
+
style: {
|
|
346
|
+
margin: "0 0 8px 0"
|
|
347
|
+
},
|
|
348
|
+
className: "text-heading-xsm color-text-default"
|
|
349
|
+
}, hasGnosisPayToken ? "Access granted" : "Access required")), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("p", {
|
|
350
|
+
style: {
|
|
351
|
+
margin: "0 0 16px 0"
|
|
352
|
+
},
|
|
353
|
+
className: "text-body-sm color-text-default"
|
|
354
|
+
}, !hasGnosisPayToken ? "To access your Gnosis Pay account, please grant permission. Your dSheet account should be created via the same wallet ss your Gnosis Pay. " : " You have ".concat(timeFromNowMessage(expiryTime), " to use your Gnosis Pay account. Then you need to grand access again.")), /*#__PURE__*/_react.default.createElement(_ui.Button, {
|
|
355
|
+
onClick: function onClick() {
|
|
356
|
+
var button = document.getElementById("grant-gnosispay-access");
|
|
357
|
+
if (!button) return;
|
|
358
|
+
button.click();
|
|
359
|
+
setIsLoading(true);
|
|
360
|
+
var interval = setInterval(function () {
|
|
361
|
+
handleGnosisPayToken(function () {
|
|
362
|
+
clearInterval(interval);
|
|
363
|
+
setIsLoading(false);
|
|
364
|
+
});
|
|
365
|
+
}, 5000);
|
|
366
|
+
gnosisTokenTokenIntervalRef.current = interval;
|
|
367
|
+
},
|
|
368
|
+
disabled: hasGnosisPayToken || isWrongGnosisPayConnector || isLoading,
|
|
369
|
+
className: "w-full items-center flex gap-1"
|
|
370
|
+
}, isLoading && (/*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_ui.LucideIcon, {
|
|
371
|
+
name: "LoaderCircle",
|
|
372
|
+
className: "animate-spin",
|
|
373
|
+
size: "sm"
|
|
374
|
+
}))), /*#__PURE__*/_react.default.createElement("p", null, "Grant access "), " ", expiryTime && /*#__PURE__*/_react.default.createElement("div", null, expiryTime))))), /*#__PURE__*/_react.default.createElement("div", {
|
|
267
375
|
style: {
|
|
268
376
|
backgroundColor: "white",
|
|
269
377
|
padding: "6px",
|
|
@@ -25,9 +25,9 @@ var __assign = void 0 && (void 0).__assign || function () {
|
|
|
25
25
|
};
|
|
26
26
|
var FormulaSearch = function FormulaSearch(props) {
|
|
27
27
|
var _a;
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
var context = (0, _react.useContext)(_context.default).context;
|
|
29
|
+
var isAuthorized = true;
|
|
30
|
+
var isWrongGnosisPayConnector = localStorage.getItem("LOGIN_METHOD") !== "walletAddress";
|
|
31
31
|
var authedFunction = ["COINGECKO", "ETHERSCAN", "DEFILLAMA", "GNOSIS", "BASE", "EOA", "PNL", "SAFE", "BLOCKSCOUT", "GNOSIS", "LENS", "FARCASTER", "Ethereum", "SMARTCONTRACT"];
|
|
32
32
|
var filteredDefaultCandidates = context.defaultCandidates.filter(function (item) {
|
|
33
33
|
return !authedFunction.includes(item.n);
|
|
@@ -41,9 +41,9 @@ var FormulaSearch = function FormulaSearch(props) {
|
|
|
41
41
|
});
|
|
42
42
|
var firstSelection = (_a = context.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0];
|
|
43
43
|
var hintRef = (0, _react.useRef)(null);
|
|
44
|
-
var
|
|
45
|
-
top =
|
|
46
|
-
setTop =
|
|
44
|
+
var _b = (0, _react.useState)(0),
|
|
45
|
+
top = _b[0],
|
|
46
|
+
setTop = _b[1];
|
|
47
47
|
var calcuatePopUpPlacement = function calcuatePopUpPlacement() {
|
|
48
48
|
var _a, _b, _c;
|
|
49
49
|
if (!((_a = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.top) === null || _a === void 0 ? void 0 : _a.toString()) || !((_b = firstSelection.height_move) === null || _b === void 0 ? void 0 : _b.toString()) || !hintRef.current) return;
|
|
@@ -175,8 +175,18 @@ var FormulaSearch = function FormulaSearch(props) {
|
|
|
175
175
|
justifyContent: "space-between"
|
|
176
176
|
}
|
|
177
177
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
178
|
+
className: "flex items-center"
|
|
179
|
+
}, v.LOGO && isWrongGnosisPayConnector && v.n === "GNOSISPAY" && (/*#__PURE__*/_react.default.createElement("div", {
|
|
180
|
+
className: "mr-2"
|
|
181
|
+
}, /*#__PURE__*/_react.default.createElement("img", {
|
|
182
|
+
src: v.LOGO,
|
|
183
|
+
alt: "Service Logo",
|
|
184
|
+
style: {
|
|
185
|
+
width: "16px"
|
|
186
|
+
}
|
|
187
|
+
}))), /*#__PURE__*/_react.default.createElement("div", {
|
|
178
188
|
className: "luckysheet-formula-search-func color-text-default text-body-sm"
|
|
179
|
-
}, v.n), /*#__PURE__*/_react.default.createElement("div", {
|
|
189
|
+
}, v.n)), /*#__PURE__*/_react.default.createElement("div", {
|
|
180
190
|
style: {
|
|
181
191
|
display: "flex",
|
|
182
192
|
justifyContent: "end",
|
|
@@ -184,7 +194,18 @@ var FormulaSearch = function FormulaSearch(props) {
|
|
|
184
194
|
alignItems: "center",
|
|
185
195
|
gap: "6px"
|
|
186
196
|
}
|
|
187
|
-
}, v.
|
|
197
|
+
}, isWrongGnosisPayConnector && v.n === "GNOSISPAY" ? (/*#__PURE__*/_react.default.createElement(_ui.Tooltip, {
|
|
198
|
+
position: "right",
|
|
199
|
+
text: /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("p", null, "Your dSheet account was created via email/social. Unfortunately you are not able to use Gnosis Pay onchain function."), /*#__PURE__*/_react.default.createElement("p", {
|
|
200
|
+
className: "mt-4"
|
|
201
|
+
}, "To use Gnosis Pay onchain function you need to create a new dSheets account via the same wallet as your Gnosis Pay account."))
|
|
202
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.LucideIcon, {
|
|
203
|
+
name: "Info",
|
|
204
|
+
size: "sm",
|
|
205
|
+
style: {
|
|
206
|
+
color: "#F16227"
|
|
207
|
+
}
|
|
208
|
+
}))) : (/*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, v.LOGO && (/*#__PURE__*/_react.default.createElement("img", {
|
|
188
209
|
src: v.LOGO,
|
|
189
210
|
alt: "Service Logo",
|
|
190
211
|
style: {
|
|
@@ -213,7 +234,7 @@ var FormulaSearch = function FormulaSearch(props) {
|
|
|
213
234
|
width: "12px",
|
|
214
235
|
height: "12px"
|
|
215
236
|
}
|
|
216
|
-
})))))), /*#__PURE__*/_react.default.createElement("div", {
|
|
237
|
+
})))))))), /*#__PURE__*/_react.default.createElement("div", {
|
|
217
238
|
className: "luckysheet-formula-search-detail mt-1 text-helper-text-sm color-text-secondary"
|
|
218
239
|
}, v.d));
|
|
219
240
|
}), finalFunctionCandidates.length === 0 && (/*#__PURE__*/_react.default.createElement("span", null, !isAuthorized && (/*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -1485,7 +1485,7 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1485
1485
|
icon: "Minus",
|
|
1486
1486
|
variant: "ghost",
|
|
1487
1487
|
size: "sm",
|
|
1488
|
-
className: "
|
|
1488
|
+
className: "",
|
|
1489
1489
|
disabled: decimals === 1,
|
|
1490
1490
|
onClick: function onClick() {
|
|
1491
1491
|
return handleCurrencyDecimalsChange_1(Math.max(1, decimals - 1));
|
|
@@ -1502,7 +1502,6 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1502
1502
|
icon: "Plus",
|
|
1503
1503
|
variant: "ghost",
|
|
1504
1504
|
size: "sm",
|
|
1505
|
-
className: "!bg-transparent",
|
|
1506
1505
|
disabled: decimals === 18,
|
|
1507
1506
|
onClick: function onClick() {
|
|
1508
1507
|
return handleCurrencyDecimalsChange_1(Math.min(18, decimals + 1));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fileverse-dev/fortune-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.88-patch-2",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "lib/index.d.ts",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"tsc": "tsc"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@fileverse-dev/fortune-core": "1.0.
|
|
19
|
+
"@fileverse-dev/fortune-core": "1.0.88-patch-2",
|
|
20
20
|
"@fileverse/ui": "^4.1.7-patch-21",
|
|
21
21
|
"@tippyjs/react": "^4.2.6",
|
|
22
22
|
"@types/regenerator-runtime": "^0.13.6",
|