@cofhe/react 0.0.0-beta-20260402091708 → 0.0.0-beta-20260409101226
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/index.cjs +447 -410
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +68 -32
- package/dist/index.d.ts +68 -32
- package/dist/index.js +252 -214
- package/dist/index.js.map +1 -1
- package/package.json +3 -4
package/dist/index.cjs
CHANGED
|
@@ -750,8 +750,6 @@ __export(index_exports, {
|
|
|
750
750
|
actionToString: () => actionToString,
|
|
751
751
|
createCofheClient: () => import_web4.createCofheClient,
|
|
752
752
|
createCofheConfig: () => createCofheConfig,
|
|
753
|
-
encryptedValueToString: () => encryptedValueToString,
|
|
754
|
-
fheTypeToString: () => fheTypeToString,
|
|
755
753
|
formatRelativeTime: () => formatRelativeTime,
|
|
756
754
|
getBlockExplorerAddressUrl: () => getBlockExplorerAddressUrl,
|
|
757
755
|
getBlockExplorerTokenUrl: () => getBlockExplorerTokenUrl,
|
|
@@ -770,6 +768,7 @@ __export(index_exports, {
|
|
|
770
768
|
useCofheClient: () => useCofheClient,
|
|
771
769
|
useCofheConnection: () => useCofheConnection,
|
|
772
770
|
useCofheContext: () => useCofheContext,
|
|
771
|
+
useCofheEnabled: () => useCofheEnabled,
|
|
773
772
|
useCofheEncrypt: () => useCofheEncrypt,
|
|
774
773
|
useCofheEncryptAndWriteContract: () => useCofheEncryptAndWriteContract,
|
|
775
774
|
useCofheNavigateToCreatePermit: () => useCofheNavigateToCreatePermit,
|
|
@@ -801,7 +800,7 @@ __export(index_exports, {
|
|
|
801
800
|
module.exports = __toCommonJS(index_exports);
|
|
802
801
|
|
|
803
802
|
// src/providers/CofheProvider.tsx
|
|
804
|
-
var
|
|
803
|
+
var import_react63 = require("react");
|
|
805
804
|
|
|
806
805
|
// src/providers/QueryProvider.tsx
|
|
807
806
|
var import_react_query = require("@tanstack/react-query");
|
|
@@ -1035,33 +1034,6 @@ function isReactNode(data) {
|
|
|
1035
1034
|
return false;
|
|
1036
1035
|
}
|
|
1037
1036
|
|
|
1038
|
-
// src/utils/logging.ts
|
|
1039
|
-
var fheTypeToString = (fheType) => {
|
|
1040
|
-
switch (fheType) {
|
|
1041
|
-
case "bool":
|
|
1042
|
-
return "ebool";
|
|
1043
|
-
case "uint8":
|
|
1044
|
-
return "euint8";
|
|
1045
|
-
case "uint16":
|
|
1046
|
-
return "euint16";
|
|
1047
|
-
case "uint32":
|
|
1048
|
-
return "euint32";
|
|
1049
|
-
case "uint64":
|
|
1050
|
-
return "euint64";
|
|
1051
|
-
case "uint128":
|
|
1052
|
-
return "euint128";
|
|
1053
|
-
case "address":
|
|
1054
|
-
return "eaddress";
|
|
1055
|
-
default:
|
|
1056
|
-
return "unknown";
|
|
1057
|
-
}
|
|
1058
|
-
};
|
|
1059
|
-
var encryptedValueToString = (fheType, handle) => {
|
|
1060
|
-
const hashStr = handle.toString();
|
|
1061
|
-
const truncated = hashStr.slice(0, 6) + ".." + hashStr.slice(hashStr.length - 6);
|
|
1062
|
-
return `${fheTypeToString(fheType)}(${truncated})`;
|
|
1063
|
-
};
|
|
1064
|
-
|
|
1065
1037
|
// src/utils/debounce.ts
|
|
1066
1038
|
var debounce = (func, wait) => {
|
|
1067
1039
|
let timeoutId = null;
|
|
@@ -1077,6 +1049,22 @@ var debounce = (func, wait) => {
|
|
|
1077
1049
|
|
|
1078
1050
|
// src/utils/waitUntilRpcAwareAndReadContract.ts
|
|
1079
1051
|
var import_viem = require("viem");
|
|
1052
|
+
|
|
1053
|
+
// src/utils/debug.ts
|
|
1054
|
+
var noopCofheReactLoggerMethod = (..._args) => {
|
|
1055
|
+
};
|
|
1056
|
+
var NOOP_LOGGER = {
|
|
1057
|
+
log: noopCofheReactLoggerMethod,
|
|
1058
|
+
warn: noopCofheReactLoggerMethod,
|
|
1059
|
+
debug: noopCofheReactLoggerMethod,
|
|
1060
|
+
error: noopCofheReactLoggerMethod
|
|
1061
|
+
};
|
|
1062
|
+
var cofheLogger = NOOP_LOGGER;
|
|
1063
|
+
function setReactLogger(logger) {
|
|
1064
|
+
cofheLogger = logger ?? NOOP_LOGGER;
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
// src/utils/waitUntilRpcAwareAndReadContract.ts
|
|
1080
1068
|
function abortError(message = "Aborted") {
|
|
1081
1069
|
const err = new Error(message);
|
|
1082
1070
|
err.name = "AbortError";
|
|
@@ -1110,7 +1098,7 @@ async function maybeWaitUntilRpcAwareAndReadContract(publicClient, params, optio
|
|
|
1110
1098
|
args: params.args
|
|
1111
1099
|
});
|
|
1112
1100
|
const pollingInterval = options.pollingInterval ?? 1e3;
|
|
1113
|
-
|
|
1101
|
+
cofheLogger.log(`Waiting until RPC is aware of block ${params.blockHashToBeAwareOf} to read contract...`);
|
|
1114
1102
|
let done = false;
|
|
1115
1103
|
while (!done) {
|
|
1116
1104
|
if (options.signal?.aborted) throw abortError();
|
|
@@ -1206,7 +1194,7 @@ function cofheHumanizeViemError(error) {
|
|
|
1206
1194
|
var import_Close = __toESM(require("@mui/icons-material/Close"), 1);
|
|
1207
1195
|
|
|
1208
1196
|
// src/components/FnxFloatingButton/FnxFloatingButtonContext.tsx
|
|
1209
|
-
var
|
|
1197
|
+
var import_react36 = require("react");
|
|
1210
1198
|
|
|
1211
1199
|
// src/utils/bigintJson.ts
|
|
1212
1200
|
var BIGINT_JSON_MARKER_KEY = "__bigint__";
|
|
@@ -1514,17 +1502,6 @@ var useCofheSelectPermit = ({ onSuccess, onError } = {}) => {
|
|
|
1514
1502
|
|
|
1515
1503
|
// src/hooks/useCofheReadContract.ts
|
|
1516
1504
|
var import_ts_essentials = __toESM(require_dist(), 1);
|
|
1517
|
-
|
|
1518
|
-
// src/hooks/useIsCofheErrorActive.ts
|
|
1519
|
-
var import_sdk2 = require("@cofhe/sdk");
|
|
1520
|
-
var import_react5 = require("react");
|
|
1521
|
-
var import_react_error_boundary = require("react-error-boundary");
|
|
1522
|
-
function useIsCofheErrorActive() {
|
|
1523
|
-
const errorBoundaryContext = (0, import_react5.useContext)(import_react_error_boundary.ErrorBoundaryContext);
|
|
1524
|
-
return errorBoundaryContext?.error instanceof import_sdk2.CofheError;
|
|
1525
|
-
}
|
|
1526
|
-
|
|
1527
|
-
// src/hooks/useCofheReadContract.ts
|
|
1528
1505
|
var import_abi = require("@cofhe/abi");
|
|
1529
1506
|
|
|
1530
1507
|
// src/utils/serializeBigint.ts
|
|
@@ -1576,8 +1553,8 @@ function constructCofheReadContractQueryForInvalidation({
|
|
|
1576
1553
|
return [QUERY_CACHE_PREFIX, cofheChainId, address, functionName];
|
|
1577
1554
|
}
|
|
1578
1555
|
function getEnabledForCofheReadContract(params) {
|
|
1579
|
-
const {
|
|
1580
|
-
return
|
|
1556
|
+
const { publicClient, address, abi, functionName, requiresPermit, hasActivePermit, userEnabled } = params;
|
|
1557
|
+
return !!publicClient && !!address && !!abi && !!functionName && (!requiresPermit || hasActivePermit) && (userEnabled ?? true);
|
|
1581
1558
|
}
|
|
1582
1559
|
function convertReadContractResultToCofheReturnType(value) {
|
|
1583
1560
|
return value;
|
|
@@ -1627,12 +1604,10 @@ function createCofheReadContractQueryOptions(params) {
|
|
|
1627
1604
|
}
|
|
1628
1605
|
function useCofheReadContract(params, queryOptions) {
|
|
1629
1606
|
const { address, abi, functionName, args, requiresPermit = true } = params;
|
|
1630
|
-
const isCofheErrorActive = useIsCofheErrorActive();
|
|
1631
1607
|
const publicClient = useCofhePublicClient();
|
|
1632
1608
|
const cofheChainId = useCofheChainId();
|
|
1633
1609
|
const activePermit = useCofheActivePermit();
|
|
1634
1610
|
const enabled = getEnabledForCofheReadContract({
|
|
1635
|
-
isCofheErrorActive,
|
|
1636
1611
|
publicClient,
|
|
1637
1612
|
address,
|
|
1638
1613
|
abi,
|
|
@@ -1657,7 +1632,7 @@ function useCofheReadContract(params, queryOptions) {
|
|
|
1657
1632
|
);
|
|
1658
1633
|
return {
|
|
1659
1634
|
...result,
|
|
1660
|
-
|
|
1635
|
+
disabledDueToMissingValidPermit: requiresPermit && (!activePermit || !activePermit.isValid)
|
|
1661
1636
|
};
|
|
1662
1637
|
}
|
|
1663
1638
|
|
|
@@ -1906,7 +1881,7 @@ function getTokenContractConfig(confidentialityType) {
|
|
|
1906
1881
|
|
|
1907
1882
|
// src/hooks/useCofheTokenLists.ts
|
|
1908
1883
|
var import_react_query3 = require("@tanstack/react-query");
|
|
1909
|
-
var
|
|
1884
|
+
var import_react5 = require("react");
|
|
1910
1885
|
function useCofheTokenLists({ chainId }, queryOptions) {
|
|
1911
1886
|
const widgetConfig = useCofheContext().client.config.react;
|
|
1912
1887
|
const tokensListsUrls = chainId ? widgetConfig.tokenLists?.[chainId] : [];
|
|
@@ -1933,14 +1908,14 @@ function useCofheTokenLists({ chainId }, queryOptions) {
|
|
|
1933
1908
|
},
|
|
1934
1909
|
...queryOptions
|
|
1935
1910
|
})) || [];
|
|
1936
|
-
const result =
|
|
1911
|
+
const result = useInternalQueries({
|
|
1937
1912
|
queries: queriesOptions
|
|
1938
1913
|
});
|
|
1939
1914
|
return result;
|
|
1940
1915
|
}
|
|
1941
1916
|
function useCofheTokens(chainId) {
|
|
1942
1917
|
const tokenLists = useCofheTokenLists({ chainId });
|
|
1943
|
-
const tokens = (0,
|
|
1918
|
+
const tokens = (0, import_react5.useMemo)(() => {
|
|
1944
1919
|
const map = /* @__PURE__ */ new Map();
|
|
1945
1920
|
tokenLists.forEach((result) => {
|
|
1946
1921
|
if (!result.data) return;
|
|
@@ -1958,7 +1933,7 @@ function useCofheToken({ chainId: _chainId, address }, metdataQueryOptions) {
|
|
|
1958
1933
|
const cofheChainId = useCofheChainId();
|
|
1959
1934
|
const chainId = _chainId ?? cofheChainId;
|
|
1960
1935
|
const tokens = useCofheTokens(chainId);
|
|
1961
|
-
const tokenFromList = (0,
|
|
1936
|
+
const tokenFromList = (0, import_react5.useMemo)(() => {
|
|
1962
1937
|
if (!address || !chainId) return;
|
|
1963
1938
|
return tokens.find((t) => t.chainId === chainId && t.address.toLowerCase() === address.toLowerCase());
|
|
1964
1939
|
}, [address, chainId, tokens]);
|
|
@@ -2198,7 +2173,7 @@ function decryptionAwareReadContract({
|
|
|
2198
2173
|
}) {
|
|
2199
2174
|
const decryptionWatchersState = useDecryptionWatchersStore.getState();
|
|
2200
2175
|
const blockHashToBeAwareOf = decryptionWatchersState.findObservedDecryption(queryKey)?.decryptionObservedAt?.blockHash;
|
|
2201
|
-
|
|
2176
|
+
cofheLogger.log("Tracked decryption block for unshield claims:", blockHashToBeAwareOf);
|
|
2202
2177
|
const rpcAwarenessOptions = {
|
|
2203
2178
|
signal,
|
|
2204
2179
|
pollingInterval: BLOCK_AWARENESS_POLLING_INTERVAL,
|
|
@@ -2217,19 +2192,19 @@ function decryptionAwareReadContract({
|
|
|
2217
2192
|
}
|
|
2218
2193
|
|
|
2219
2194
|
// src/hooks/useIsWaitingForDecryptionToInvalidate.ts
|
|
2220
|
-
var
|
|
2195
|
+
var import_react6 = require("react");
|
|
2221
2196
|
function useAwaitingDecryptionQueryKeySet() {
|
|
2222
2197
|
const { byKey } = useDecryptionWatchersStore();
|
|
2223
|
-
const cacheKeysAwaitingDecryption = (0,
|
|
2224
|
-
return (0,
|
|
2198
|
+
const cacheKeysAwaitingDecryption = (0, import_react6.useMemo)(() => Object.values(byKey).flatMap((item) => item.queryKeys), [byKey]);
|
|
2199
|
+
return (0, import_react6.useMemo)(
|
|
2225
2200
|
() => new Set(cacheKeysAwaitingDecryption.map((key) => JSON.stringify(key))),
|
|
2226
2201
|
[cacheKeysAwaitingDecryption]
|
|
2227
2202
|
);
|
|
2228
2203
|
}
|
|
2229
2204
|
function useIsWaitingForDecryptionToInvalidate(queryKey) {
|
|
2230
2205
|
const cacheKeySet = useAwaitingDecryptionQueryKeySet();
|
|
2231
|
-
const result = (0,
|
|
2232
|
-
|
|
2206
|
+
const result = (0, import_react6.useMemo)(() => cacheKeySet.has(JSON.stringify(queryKey)), [cacheKeySet, queryKey]);
|
|
2207
|
+
cofheLogger.log(`isWaitingForDecryption for queryKey ${JSON.stringify(queryKey)}:`, result);
|
|
2233
2208
|
return result;
|
|
2234
2209
|
}
|
|
2235
2210
|
|
|
@@ -2248,7 +2223,7 @@ function invalidateClaimableQueries({
|
|
|
2248
2223
|
accountAddress,
|
|
2249
2224
|
queryClient
|
|
2250
2225
|
}) {
|
|
2251
|
-
|
|
2226
|
+
cofheLogger.log("Invalidating unshield claims queries for token:", token);
|
|
2252
2227
|
queryClient.invalidateQueries({
|
|
2253
2228
|
queryKey: constructUnshieldClaimsQueryKeyForInvalidation({
|
|
2254
2229
|
chainId: token.chainId,
|
|
@@ -2460,7 +2435,7 @@ function useTokenAllowance({ tokenAddress, ownerAddress, spenderAddress }, optio
|
|
|
2460
2435
|
}
|
|
2461
2436
|
|
|
2462
2437
|
// src/hooks/useStoredTransactions.ts
|
|
2463
|
-
var
|
|
2438
|
+
var import_react7 = require("react");
|
|
2464
2439
|
var import_ts_essentials5 = __toESM(require_dist());
|
|
2465
2440
|
function useStoredTransactions({
|
|
2466
2441
|
chainId,
|
|
@@ -2469,7 +2444,7 @@ function useStoredTransactions({
|
|
|
2469
2444
|
reducer
|
|
2470
2445
|
}) {
|
|
2471
2446
|
const transactions = useTransactionStore((state) => state.transactions);
|
|
2472
|
-
const transactionsAsArray = (0,
|
|
2447
|
+
const transactionsAsArray = (0, import_react7.useMemo)(
|
|
2473
2448
|
() => Object.values(
|
|
2474
2449
|
chainId ? (
|
|
2475
2450
|
// if chainId provided -- will filter on chain's txs first
|
|
@@ -2481,7 +2456,7 @@ function useStoredTransactions({
|
|
|
2481
2456
|
),
|
|
2482
2457
|
[transactions, chainId]
|
|
2483
2458
|
);
|
|
2484
|
-
const filtered = (0,
|
|
2459
|
+
const filtered = (0, import_react7.useMemo)(
|
|
2485
2460
|
() => transactionsAsArray.filter((tx) => {
|
|
2486
2461
|
if (account && tx.account.toLowerCase() !== account.toLowerCase()) return false;
|
|
2487
2462
|
if (filter3 && !filter3(tx)) return false;
|
|
@@ -2489,7 +2464,7 @@ function useStoredTransactions({
|
|
|
2489
2464
|
}),
|
|
2490
2465
|
[transactionsAsArray, filter3, account]
|
|
2491
2466
|
);
|
|
2492
|
-
const reduced = (0,
|
|
2467
|
+
const reduced = (0, import_react7.useMemo)(() => {
|
|
2493
2468
|
return reducer?.(filtered);
|
|
2494
2469
|
}, [filtered, reducer]);
|
|
2495
2470
|
const uniqueHashes = new Set(filtered.map((tx) => tx.hash));
|
|
@@ -2497,7 +2472,7 @@ function useStoredTransactions({
|
|
|
2497
2472
|
uniqueHashes.size === filtered.length,
|
|
2498
2473
|
"There should be no duplicate transactions with the same hash in the result"
|
|
2499
2474
|
);
|
|
2500
|
-
const filteredTxsByHash = (0,
|
|
2475
|
+
const filteredTxsByHash = (0, import_react7.useMemo)(
|
|
2501
2476
|
() => filtered.reduce((acc, tx) => {
|
|
2502
2477
|
return {
|
|
2503
2478
|
...acc,
|
|
@@ -2546,7 +2521,7 @@ var usePortalModals = (0, import_zustand3.create)()((set, get) => ({
|
|
|
2546
2521
|
}));
|
|
2547
2522
|
|
|
2548
2523
|
// src/stores/portalUIStore.tsx
|
|
2549
|
-
var
|
|
2524
|
+
var import_react8 = require("react");
|
|
2550
2525
|
var import_zustand5 = require("zustand");
|
|
2551
2526
|
|
|
2552
2527
|
// src/stores/portalStatuses.tsx
|
|
@@ -2634,7 +2609,7 @@ var usePortalUI = (0, import_zustand5.create)()((set, get) => ({
|
|
|
2634
2609
|
}));
|
|
2635
2610
|
var usePortalUIMaxContentHeight = () => {
|
|
2636
2611
|
const { contentHeights } = usePortalUI();
|
|
2637
|
-
return (0,
|
|
2612
|
+
return (0, import_react8.useMemo)(() => {
|
|
2638
2613
|
return contentHeights.reduce((max, height) => Math.max(max, height.height), 0);
|
|
2639
2614
|
}, [contentHeights]);
|
|
2640
2615
|
};
|
|
@@ -2649,7 +2624,7 @@ var usePortalNavigation = (0, import_zustand6.create)()((set, get) => {
|
|
|
2649
2624
|
const currentPage = get().overridingPage ?? get().pageHistory[get().pageHistory.length - 1];
|
|
2650
2625
|
const onPage = currentPage?.page === page;
|
|
2651
2626
|
if (onPage) {
|
|
2652
|
-
|
|
2627
|
+
cofheLogger.warn(`Attempted to navigate to page ${page} but already on that page`);
|
|
2653
2628
|
}
|
|
2654
2629
|
return onPage;
|
|
2655
2630
|
}
|
|
@@ -2693,10 +2668,10 @@ var usePortalCurrentPage = () => {
|
|
|
2693
2668
|
|
|
2694
2669
|
// src/components/FnxFloatingButton/components/ToastPrimitives.tsx
|
|
2695
2670
|
var import_tb = require("react-icons/tb");
|
|
2696
|
-
var
|
|
2671
|
+
var import_react10 = require("motion/react");
|
|
2697
2672
|
|
|
2698
2673
|
// src/components/FnxFloatingButton/components/HashLink.tsx
|
|
2699
|
-
var
|
|
2674
|
+
var import_react9 = require("react");
|
|
2700
2675
|
var import_lu = require("react-icons/lu");
|
|
2701
2676
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
2702
2677
|
var HashLink = ({
|
|
@@ -2751,7 +2726,7 @@ var HashLink = ({
|
|
|
2751
2726
|
] });
|
|
2752
2727
|
};
|
|
2753
2728
|
var CopyButton = ({ text, size = 14, className }) => {
|
|
2754
|
-
const [copied, setCopied] = (0,
|
|
2729
|
+
const [copied, setCopied] = (0, import_react9.useState)(false);
|
|
2755
2730
|
const handleCopy = async (e) => {
|
|
2756
2731
|
e.stopPropagation();
|
|
2757
2732
|
try {
|
|
@@ -2816,7 +2791,7 @@ var ToastDurationIndicator = ({ duration, remainingMs, paused, variant }) => {
|
|
|
2816
2791
|
const progress = remainingMs / duration;
|
|
2817
2792
|
const progressColor = variantProgressBarColorMap[variant ?? "base"];
|
|
2818
2793
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "absolute bottom-0 left-0 w-full h-1 overflow-hidden", children: paused ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: cn(progressColor, "h-full origin-right"), style: { transform: `scaleX(${progress})` } }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2819
|
-
|
|
2794
|
+
import_react10.motion.div,
|
|
2820
2795
|
{
|
|
2821
2796
|
className: cn("h-full origin-right", progressColor),
|
|
2822
2797
|
initial: { scaleX: progress },
|
|
@@ -2918,7 +2893,7 @@ function useTransactionGlobalToastsLifecycle() {
|
|
|
2918
2893
|
return {
|
|
2919
2894
|
// 1.tx is submitted
|
|
2920
2895
|
onTransactionSubmitted: (transaction) => {
|
|
2921
|
-
|
|
2896
|
+
cofheLogger.log("____ Transaction submitted:", transaction);
|
|
2922
2897
|
addToast(
|
|
2923
2898
|
{
|
|
2924
2899
|
variant: "info",
|
|
@@ -2954,7 +2929,7 @@ function useTransactionGlobalToastsLifecycle() {
|
|
|
2954
2929
|
},
|
|
2955
2930
|
// 2.a. tx is mined (could be success or fail)
|
|
2956
2931
|
onTransactionMined: (transaction, receipt) => {
|
|
2957
|
-
|
|
2932
|
+
cofheLogger.log("____ Transaction mined:", transaction, "with receipt:", receipt);
|
|
2958
2933
|
if (receipt.status === "success") {
|
|
2959
2934
|
const descriptionPostfix = transaction.isPendingDecryption ? " It is pending decryption now." : "";
|
|
2960
2935
|
addToast(
|
|
@@ -3003,7 +2978,7 @@ function useTransactionGlobalToastsLifecycle() {
|
|
|
3003
2978
|
},
|
|
3004
2979
|
// 3. tx is decrypted (if applicable)
|
|
3005
2980
|
onTransactionDecrypted: (decryptionCausingTx, decryptionWatcher) => {
|
|
3006
|
-
|
|
2981
|
+
cofheLogger.log("____ Transaction decrypted:", decryptionCausingTx, "with watcher:", decryptionWatcher);
|
|
3007
2982
|
addToast(
|
|
3008
2983
|
{
|
|
3009
2984
|
variant: "success",
|
|
@@ -3037,14 +3012,14 @@ function useTransactionGlobalLifecycle() {
|
|
|
3037
3012
|
}
|
|
3038
3013
|
|
|
3039
3014
|
// src/hooks/useTrackPendingTransactions.ts
|
|
3040
|
-
var
|
|
3015
|
+
var import_react11 = require("react");
|
|
3041
3016
|
function invalidateConfidentialTokenBalanceQueries(token, queryClient) {
|
|
3042
3017
|
const tokenBalanceQueryKey = constructCofheReadContractQueryForInvalidation({
|
|
3043
3018
|
cofheChainId: token.chainId,
|
|
3044
3019
|
address: token.address,
|
|
3045
3020
|
functionName: getTokenContractConfig(token.extensions.fhenix.confidentialityType).functionName
|
|
3046
3021
|
});
|
|
3047
|
-
|
|
3022
|
+
cofheLogger.log("Invalidating shield/send read contract queries for token:", token);
|
|
3048
3023
|
queryClient.invalidateQueries({
|
|
3049
3024
|
queryKey: tokenBalanceQueryKey,
|
|
3050
3025
|
// TODO: it can potentially invalidate irrelevenat queries who happen to belong to the same contract but different function. Not sure if worth fixing
|
|
@@ -3061,7 +3036,7 @@ function invalidatePublicTokenBalanceQueries({
|
|
|
3061
3036
|
tokenAddress,
|
|
3062
3037
|
accountAddress
|
|
3063
3038
|
});
|
|
3064
|
-
|
|
3039
|
+
cofheLogger.log("Invalidating public token balance read contract queries for token:", tokenBalanceQueryKey);
|
|
3065
3040
|
queryClient.invalidateQueries({
|
|
3066
3041
|
queryKey: tokenBalanceQueryKey
|
|
3067
3042
|
});
|
|
@@ -3123,14 +3098,14 @@ function useTrackPendingTransactionsBase({
|
|
|
3123
3098
|
refetchOnWindowFocus: false,
|
|
3124
3099
|
refetchOnReconnect: true
|
|
3125
3100
|
}));
|
|
3126
|
-
|
|
3101
|
+
useInternalQueries({
|
|
3127
3102
|
queries
|
|
3128
3103
|
});
|
|
3129
3104
|
}
|
|
3130
3105
|
function useHandleInvalidations() {
|
|
3131
3106
|
const queryClient = useInternalQueryClient();
|
|
3132
3107
|
const { upsert: upsertDecryptionWatcher, byKey } = useDecryptionWatchersStore();
|
|
3133
|
-
|
|
3108
|
+
cofheLogger.log("Scheduled invalidations store:", byKey);
|
|
3134
3109
|
const handleInvalidations = (tx) => {
|
|
3135
3110
|
invalidatePublicTokenBalanceQueries(
|
|
3136
3111
|
{
|
|
@@ -3199,8 +3174,8 @@ function useHandleInvalidations() {
|
|
|
3199
3174
|
}
|
|
3200
3175
|
function useOnceTransactionSubmitted(onSubmit) {
|
|
3201
3176
|
const pendingTransactions = usePendingTransactions();
|
|
3202
|
-
const previousPendingTxsRef = (0,
|
|
3203
|
-
(0,
|
|
3177
|
+
const previousPendingTxsRef = (0, import_react11.useRef)([]);
|
|
3178
|
+
(0, import_react11.useEffect)(() => {
|
|
3204
3179
|
const newlySubmittedTxs = pendingTransactions.filter(
|
|
3205
3180
|
(tx) => !previousPendingTxsRef.current.some((prevTx) => prevTx.hash === tx.hash)
|
|
3206
3181
|
);
|
|
@@ -3232,10 +3207,10 @@ function useTrackPendingTransactions() {
|
|
|
3232
3207
|
}
|
|
3233
3208
|
|
|
3234
3209
|
// src/hooks/useTrackDecryptingTransactions.ts
|
|
3235
|
-
var
|
|
3210
|
+
var import_react14 = require("react");
|
|
3236
3211
|
|
|
3237
3212
|
// src/hooks/useTransactionReceiptsByHash.ts
|
|
3238
|
-
var
|
|
3213
|
+
var import_react12 = require("react");
|
|
3239
3214
|
var import_ts_essentials7 = __toESM(require_dist(), 1);
|
|
3240
3215
|
function useTransactionReceiptsByHash({ hashes, chainId: chainIdInput, enabled: enabledInput = true, queryOptions } = {
|
|
3241
3216
|
enabled: true
|
|
@@ -3244,7 +3219,7 @@ function useTransactionReceiptsByHash({ hashes, chainId: chainIdInput, enabled:
|
|
|
3244
3219
|
const cofheChainId = useCofheChainId();
|
|
3245
3220
|
const chainId = chainIdInput ?? cofheChainId;
|
|
3246
3221
|
const enabled = !!publicClient && !!chainId && enabledInput && hashes !== void 0 && hashes?.size > 0;
|
|
3247
|
-
const queries = (0,
|
|
3222
|
+
const queries = (0, import_react12.useMemo)(() => {
|
|
3248
3223
|
if (!hashes) return [];
|
|
3249
3224
|
return Array.from(hashes).map((hash) => {
|
|
3250
3225
|
const queryKey = ["tx-receipt", chainId, hash];
|
|
@@ -3263,11 +3238,11 @@ function useTransactionReceiptsByHash({ hashes, chainId: chainIdInput, enabled:
|
|
|
3263
3238
|
};
|
|
3264
3239
|
});
|
|
3265
3240
|
}, [chainId, enabled, hashes, publicClient, queryOptions]);
|
|
3266
|
-
const queriesResults =
|
|
3241
|
+
const queriesResults = useInternalQueries({
|
|
3267
3242
|
queries
|
|
3268
3243
|
});
|
|
3269
|
-
const receiptsByHash = (0,
|
|
3270
|
-
|
|
3244
|
+
const receiptsByHash = (0, import_react12.useMemo)(() => {
|
|
3245
|
+
cofheLogger.log("useTransactionReceiptsByHash - receiptsByHash recalculated");
|
|
3271
3246
|
if (!hashes) return {};
|
|
3272
3247
|
return Array.from(hashes).reduce((acc, hash, i) => {
|
|
3273
3248
|
if (!queriesResults[i]?.data) return acc;
|
|
@@ -3282,8 +3257,8 @@ function useTransactionReceiptsByHash({ hashes, chainId: chainIdInput, enabled:
|
|
|
3282
3257
|
var import_ts_essentials8 = __toESM(require_dist());
|
|
3283
3258
|
|
|
3284
3259
|
// src/hooks/useCofheReadDecryptionResults.ts
|
|
3285
|
-
var
|
|
3286
|
-
var
|
|
3260
|
+
var import_react13 = require("react");
|
|
3261
|
+
var import_sdk2 = require("@cofhe/sdk");
|
|
3287
3262
|
function abortError2(message = "Aborted") {
|
|
3288
3263
|
const err = new Error(message);
|
|
3289
3264
|
err.name = "AbortError";
|
|
@@ -3338,7 +3313,7 @@ var DECRYPTION_RESULT_POLLING_INTERVAL_MS = 5e3;
|
|
|
3338
3313
|
function useCofheReadDecryptionResults(ciphertexts) {
|
|
3339
3314
|
const publicClient = useCofhePublicClient();
|
|
3340
3315
|
const chainId = useCofheChainId();
|
|
3341
|
-
const queries = (0,
|
|
3316
|
+
const queries = (0, import_react13.useMemo)(() => {
|
|
3342
3317
|
return Array.from(ciphertexts).map((ct) => {
|
|
3343
3318
|
return {
|
|
3344
3319
|
queryKey: ["decryptionResult", chainId, ct],
|
|
@@ -3347,7 +3322,7 @@ function useCofheReadDecryptionResults(ciphertexts) {
|
|
|
3347
3322
|
while (!signal.aborted) {
|
|
3348
3323
|
const [res, block] = await Promise.allSettled([
|
|
3349
3324
|
publicClient.readContract({
|
|
3350
|
-
address:
|
|
3325
|
+
address: import_sdk2.TASK_MANAGER_ADDRESS,
|
|
3351
3326
|
abi: TASK_MANAGER_ABI,
|
|
3352
3327
|
functionName: "getDecryptResultSafe",
|
|
3353
3328
|
args: [BigInt(ct)]
|
|
@@ -3378,8 +3353,8 @@ function useCofheReadDecryptionResults(ciphertexts) {
|
|
|
3378
3353
|
};
|
|
3379
3354
|
});
|
|
3380
3355
|
}, [chainId, ciphertexts, publicClient]);
|
|
3381
|
-
const results =
|
|
3382
|
-
const isDecryptedByCt = (0,
|
|
3356
|
+
const results = useInternalQueries({ queries });
|
|
3357
|
+
const isDecryptedByCt = (0, import_react13.useMemo)(() => {
|
|
3383
3358
|
return results.reduce((record, res, index) => {
|
|
3384
3359
|
const ct = Array.from(ciphertexts)[index];
|
|
3385
3360
|
record[ct] = res.data;
|
|
@@ -3392,11 +3367,11 @@ function useCofheReadDecryptionResults(ciphertexts) {
|
|
|
3392
3367
|
// src/hooks/useTrackDecryptingTransactions.ts
|
|
3393
3368
|
function useHandleInvalidationsAfterDecryption() {
|
|
3394
3369
|
const queryClient = useInternalQueryClient();
|
|
3395
|
-
return (0,
|
|
3396
|
-
async (
|
|
3397
|
-
|
|
3370
|
+
return (0, import_react14.useCallback)(
|
|
3371
|
+
async (_tx, decryptionWatcher) => {
|
|
3372
|
+
cofheLogger.log("Invalidating queries for decryption watcher:", decryptionWatcher);
|
|
3398
3373
|
for (const queryKey of decryptionWatcher.queryKeys) {
|
|
3399
|
-
|
|
3374
|
+
cofheLogger.log("Invalidating query due to observed decryption:", queryKey);
|
|
3400
3375
|
await queryClient.invalidateQueries({ queryKey });
|
|
3401
3376
|
}
|
|
3402
3377
|
},
|
|
@@ -3415,7 +3390,7 @@ function useTrackDecryptingTransactionsBase({ onDecryptionResolve }) {
|
|
|
3415
3390
|
const { receiptsByHash } = useTransactionReceiptsByHash({
|
|
3416
3391
|
hashes
|
|
3417
3392
|
});
|
|
3418
|
-
const minedTxsWithCiphertextsToWatch = (0,
|
|
3393
|
+
const minedTxsWithCiphertextsToWatch = (0, import_react14.useMemo)(() => {
|
|
3419
3394
|
return Object.entries(minedTxsPendingDecryptionByHash).filter(([, tx]) => receiptsByHash[tx.hash] !== void 0).map(([, tx]) => {
|
|
3420
3395
|
const ciphertextToWatch = findDecryptRequestLog(tx.account, receiptsByHash[tx.hash].logs)?.ciphertext;
|
|
3421
3396
|
(0, import_ts_essentials8.assert)(
|
|
@@ -3429,13 +3404,13 @@ function useTrackDecryptingTransactionsBase({ onDecryptionResolve }) {
|
|
|
3429
3404
|
};
|
|
3430
3405
|
});
|
|
3431
3406
|
}, [minedTxsPendingDecryptionByHash, receiptsByHash]);
|
|
3432
|
-
const ciphertextsToWatch = (0,
|
|
3407
|
+
const ciphertextsToWatch = (0, import_react14.useMemo)(() => {
|
|
3433
3408
|
return new Set(minedTxsWithCiphertextsToWatch.map(({ ciphertextToWatch }) => ciphertextToWatch));
|
|
3434
3409
|
}, [minedTxsWithCiphertextsToWatch]);
|
|
3435
3410
|
const decryptionResults = useCofheReadDecryptionResults(ciphertextsToWatch);
|
|
3436
3411
|
const queryClient = useInternalQueryClient();
|
|
3437
3412
|
const { setDecryptionObservedAt } = useDecryptionWatchersStore();
|
|
3438
|
-
(0,
|
|
3413
|
+
(0, import_react14.useEffect)(() => {
|
|
3439
3414
|
const txsWithDecryptionResults = minedTxsWithCiphertextsToWatch.filter(({ ciphertextToWatch }) => decryptionResults[ciphertextToWatch] !== void 0).map((item) => {
|
|
3440
3415
|
const decryptionResult = decryptionResults[item.ciphertextToWatch];
|
|
3441
3416
|
(0, import_ts_essentials8.assert)(decryptionResult, "decryptionResult must be defined here");
|
|
@@ -3451,7 +3426,7 @@ function useTrackDecryptingTransactionsBase({ onDecryptionResolve }) {
|
|
|
3451
3426
|
false
|
|
3452
3427
|
// no longer pending decryption
|
|
3453
3428
|
);
|
|
3454
|
-
|
|
3429
|
+
cofheLogger.log("Decryption completed for tx, invalidating relevant queries", {
|
|
3455
3430
|
tx,
|
|
3456
3431
|
decryptionResult,
|
|
3457
3432
|
receipt,
|
|
@@ -3470,26 +3445,26 @@ function useTrackDecryptingTransactionsBase({ onDecryptionResolve }) {
|
|
|
3470
3445
|
}
|
|
3471
3446
|
function useOnDecryptionCallback({ onDecryptionResolve }) {
|
|
3472
3447
|
const { byKey } = useDecryptionWatchersStore();
|
|
3473
|
-
const watchersWithObservedDecryption = (0,
|
|
3448
|
+
const watchersWithObservedDecryption = (0, import_react14.useMemo)(
|
|
3474
3449
|
() => Object.values(byKey).filter((item) => item.decryptionObservedAt !== void 0),
|
|
3475
3450
|
[byKey]
|
|
3476
3451
|
);
|
|
3477
|
-
|
|
3478
|
-
const handleDecryptionResolve = (0,
|
|
3452
|
+
cofheLogger.log("All observed decryptions:", watchersWithObservedDecryption);
|
|
3453
|
+
const handleDecryptionResolve = (0, import_react14.useCallback)(async () => {
|
|
3479
3454
|
const transactionStore = useTransactionStore.getState().transactions;
|
|
3480
3455
|
for (const sch of watchersWithObservedDecryption) {
|
|
3481
3456
|
const tx = transactionStore[sch.chainId]?.[sch.triggerTxHash];
|
|
3482
3457
|
onDecryptionResolve(tx, sch);
|
|
3483
3458
|
}
|
|
3484
3459
|
}, [watchersWithObservedDecryption, onDecryptionResolve]);
|
|
3485
|
-
const stableHandleDecryptionResolve = (0,
|
|
3460
|
+
const stableHandleDecryptionResolve = (0, import_react14.useRef)(handleDecryptionResolve);
|
|
3486
3461
|
stableHandleDecryptionResolve.current = handleDecryptionResolve;
|
|
3487
|
-
(0,
|
|
3462
|
+
(0, import_react14.useEffect)(() => {
|
|
3488
3463
|
stableHandleDecryptionResolve.current = handleDecryptionResolve;
|
|
3489
3464
|
}, [handleDecryptionResolve]);
|
|
3490
|
-
(0,
|
|
3465
|
+
(0, import_react14.useEffect)(() => {
|
|
3491
3466
|
if (watchersWithObservedDecryption.length > 0) {
|
|
3492
|
-
|
|
3467
|
+
cofheLogger.log("All observed decryption query keys subject to invalidate:", watchersWithObservedDecryption);
|
|
3493
3468
|
stableHandleDecryptionResolve.current();
|
|
3494
3469
|
}
|
|
3495
3470
|
}, [watchersWithObservedDecryption]);
|
|
@@ -3517,13 +3492,42 @@ function useTrackDecryptingTransactions() {
|
|
|
3517
3492
|
const { onTransactionDecrypted } = useTransactionGlobalLifecycle();
|
|
3518
3493
|
useTrackDecryptingTransactionsBase({
|
|
3519
3494
|
onDecryptionResolve: async (decryptionCausingTx, decryptionWatcher) => {
|
|
3520
|
-
|
|
3495
|
+
cofheLogger.log("Decryption resolved for tx:", decryptionCausingTx, "with watcher:", decryptionWatcher);
|
|
3521
3496
|
handleInvalidationsAfterDecryption(decryptionCausingTx, decryptionWatcher);
|
|
3522
3497
|
onTransactionDecrypted(decryptionCausingTx, decryptionWatcher);
|
|
3523
3498
|
}
|
|
3524
3499
|
});
|
|
3525
3500
|
}
|
|
3526
3501
|
|
|
3502
|
+
// src/hooks/useCofheEnabled.ts
|
|
3503
|
+
var import_sdk3 = require("@cofhe/sdk");
|
|
3504
|
+
var TASK_MANAGER_IS_ENABLED_ABI = [
|
|
3505
|
+
{
|
|
3506
|
+
type: "function",
|
|
3507
|
+
name: "isEnabled",
|
|
3508
|
+
inputs: [],
|
|
3509
|
+
outputs: [
|
|
3510
|
+
{
|
|
3511
|
+
name: "enabled",
|
|
3512
|
+
type: "bool",
|
|
3513
|
+
internalType: "bool"
|
|
3514
|
+
}
|
|
3515
|
+
],
|
|
3516
|
+
stateMutability: "view"
|
|
3517
|
+
}
|
|
3518
|
+
];
|
|
3519
|
+
function useCofheEnabled(options) {
|
|
3520
|
+
return useCofheReadContract(
|
|
3521
|
+
{
|
|
3522
|
+
address: import_sdk3.TASK_MANAGER_ADDRESS,
|
|
3523
|
+
abi: TASK_MANAGER_IS_ENABLED_ABI,
|
|
3524
|
+
functionName: "isEnabled",
|
|
3525
|
+
requiresPermit: false
|
|
3526
|
+
},
|
|
3527
|
+
options
|
|
3528
|
+
);
|
|
3529
|
+
}
|
|
3530
|
+
|
|
3527
3531
|
// src/hooks/useCofheClient.ts
|
|
3528
3532
|
var useCofheClient = () => {
|
|
3529
3533
|
return useCofheContext().client;
|
|
@@ -3548,9 +3552,8 @@ function useCofheDecrypt({
|
|
|
3548
3552
|
onPoll: onPoll2
|
|
3549
3553
|
}, queryOptions) {
|
|
3550
3554
|
const { client } = useCofheContext();
|
|
3551
|
-
const isCofheErrorActive = useIsCofheErrorActive();
|
|
3552
3555
|
const { enabled: userEnabled, ...restQueryOptions } = queryOptions || {};
|
|
3553
|
-
const enabled = !!input && BigInt(input.ctHash) > 0n &&
|
|
3556
|
+
const enabled = !!input && BigInt(input.ctHash) > 0n && !!client && (userEnabled ?? true);
|
|
3554
3557
|
return useInternalQuery({
|
|
3555
3558
|
enabled,
|
|
3556
3559
|
queryKey: ["decryptCiphertext", input?.ctHash.toString(), input?.utype],
|
|
@@ -3571,21 +3574,6 @@ function useCofheDecrypt({
|
|
|
3571
3574
|
});
|
|
3572
3575
|
}
|
|
3573
3576
|
|
|
3574
|
-
// src/utils/isProduction.ts
|
|
3575
|
-
var import_meta = {};
|
|
3576
|
-
var isProduction = () => {
|
|
3577
|
-
if (typeof process !== "undefined" && process.env?.NODE_ENV === "development") {
|
|
3578
|
-
return false;
|
|
3579
|
-
}
|
|
3580
|
-
if (typeof import_meta !== "undefined") {
|
|
3581
|
-
const metaEnv = import_meta.env;
|
|
3582
|
-
if (metaEnv && metaEnv.MODE === "development" && metaEnv.DEV === true && metaEnv.PROD === false) {
|
|
3583
|
-
return false;
|
|
3584
|
-
}
|
|
3585
|
-
}
|
|
3586
|
-
return true;
|
|
3587
|
-
};
|
|
3588
|
-
|
|
3589
3577
|
// src/hooks/useCofheReadContractAndDecrypt.ts
|
|
3590
3578
|
function isEncryptedValue(value) {
|
|
3591
3579
|
return typeof value === "object" && value !== null && "ctHash" in value && "utype" in value && Object.values(import_sdk5.FheTypes).includes(value.utype);
|
|
@@ -3596,8 +3584,8 @@ function convertCofheReturnTypeToEncryptedReturnType(value) {
|
|
|
3596
3584
|
"Auto-decryption now only supports a case where the contract function returns a single encrypted value"
|
|
3597
3585
|
);
|
|
3598
3586
|
}
|
|
3599
|
-
var onPoll =
|
|
3600
|
-
|
|
3587
|
+
var onPoll = (context) => {
|
|
3588
|
+
cofheLogger.debug(
|
|
3601
3589
|
`Decryption poll attemptIndex ${context.attemptIndex}. Operation: ${context.operation}. ${context.elapsedMs}ms elapsed. Request ID: ${context.requestId}.`
|
|
3602
3590
|
);
|
|
3603
3591
|
};
|
|
@@ -3619,7 +3607,7 @@ function useCofheReadContractAndDecrypt(params, {
|
|
|
3619
3607
|
return {
|
|
3620
3608
|
encrypted,
|
|
3621
3609
|
decrypted,
|
|
3622
|
-
|
|
3610
|
+
disabledDueToMissingValidPermit: encrypted.disabledDueToMissingValidPermit
|
|
3623
3611
|
};
|
|
3624
3612
|
}
|
|
3625
3613
|
|
|
@@ -3630,7 +3618,7 @@ function useCofheTokenDecryptedBalance({ token, accountAddress, displayDecimals
|
|
|
3630
3618
|
const {
|
|
3631
3619
|
decrypted: { data: decryptedData, isFetching: isDecryptionFetching },
|
|
3632
3620
|
encrypted: { isFetching: isEncryptedFetching, refetch: refetchCiphertext },
|
|
3633
|
-
|
|
3621
|
+
disabledDueToMissingValidPermit
|
|
3634
3622
|
} = useCofheReadContractAndDecrypt(
|
|
3635
3623
|
{
|
|
3636
3624
|
address: token?.address,
|
|
@@ -3658,7 +3646,7 @@ function useCofheTokenDecryptedBalance({ token, accountAddress, displayDecimals
|
|
|
3658
3646
|
}
|
|
3659
3647
|
);
|
|
3660
3648
|
return {
|
|
3661
|
-
|
|
3649
|
+
disabledDueToMissingValidPermit,
|
|
3662
3650
|
data: decryptedData,
|
|
3663
3651
|
isFetching: isDecryptionFetching || isEncryptedFetching,
|
|
3664
3652
|
refetch: refetchCiphertext
|
|
@@ -3678,7 +3666,7 @@ var import_ts_essentials11 = __toESM(require_dist(), 1);
|
|
|
3678
3666
|
|
|
3679
3667
|
// src/hooks/internal/useStepsState.ts
|
|
3680
3668
|
var import_sdk7 = require("@cofhe/sdk");
|
|
3681
|
-
var
|
|
3669
|
+
var import_react15 = require("react");
|
|
3682
3670
|
function validateAndCompactizeSteps(encSteps) {
|
|
3683
3671
|
const result = {};
|
|
3684
3672
|
encSteps.forEach((encStep, index) => {
|
|
@@ -3690,19 +3678,19 @@ function validateAndCompactizeSteps(encSteps) {
|
|
|
3690
3678
|
return result;
|
|
3691
3679
|
}
|
|
3692
3680
|
function useStepsState() {
|
|
3693
|
-
const [steps, setSteps] = (0,
|
|
3694
|
-
const [currentKey, setCurrentKey] = (0,
|
|
3695
|
-
const onStep = (0,
|
|
3681
|
+
const [steps, setSteps] = (0, import_react15.useState)({});
|
|
3682
|
+
const [currentKey, setCurrentKey] = (0, import_react15.useState)(null);
|
|
3683
|
+
const onStep = (0, import_react15.useCallback)((key, step, context) => {
|
|
3696
3684
|
if (step === import_sdk7.EncryptStep.InitTfhe && context?.isStart) {
|
|
3697
3685
|
setSteps((prev) => ({ ...prev, [key]: [{ step, context }] }));
|
|
3698
3686
|
} else {
|
|
3699
3687
|
setSteps((prev) => ({ ...prev, [key]: [...prev[key], { step, context }] }));
|
|
3700
3688
|
}
|
|
3701
3689
|
}, []);
|
|
3702
|
-
const onSetKey = (0,
|
|
3690
|
+
const onSetKey = (0, import_react15.useCallback)((key) => {
|
|
3703
3691
|
setCurrentKey(key);
|
|
3704
3692
|
}, []);
|
|
3705
|
-
const compactSteps = (0,
|
|
3693
|
+
const compactSteps = (0, import_react15.useMemo)(
|
|
3706
3694
|
() => validateAndCompactizeSteps(currentKey ? steps[currentKey] : []),
|
|
3707
3695
|
[steps, currentKey]
|
|
3708
3696
|
);
|
|
@@ -4133,10 +4121,10 @@ var import_viem15 = require("viem");
|
|
|
4133
4121
|
var import_ts_essentials15 = __toESM(require_dist(), 1);
|
|
4134
4122
|
|
|
4135
4123
|
// src/hooks/useStoredTransaction.ts
|
|
4136
|
-
var
|
|
4124
|
+
var import_react16 = require("react");
|
|
4137
4125
|
var import_ts_essentials14 = __toESM(require_dist(), 1);
|
|
4138
4126
|
function useStoredTransaction(txHash) {
|
|
4139
|
-
const filter3 = (0,
|
|
4127
|
+
const filter3 = (0, import_react16.useMemo)(() => {
|
|
4140
4128
|
return (tx) => tx.hash === txHash;
|
|
4141
4129
|
}, [txHash]);
|
|
4142
4130
|
const { filteredTxs } = useStoredTransactions({ filter: filter3 });
|
|
@@ -4145,7 +4133,7 @@ function useStoredTransaction(txHash) {
|
|
|
4145
4133
|
}
|
|
4146
4134
|
|
|
4147
4135
|
// src/hooks/useOnceTransactionMined.ts
|
|
4148
|
-
var
|
|
4136
|
+
var import_react17 = require("react");
|
|
4149
4137
|
function useOnceTransactionMined({
|
|
4150
4138
|
txHash,
|
|
4151
4139
|
onceMined
|
|
@@ -4168,8 +4156,8 @@ function useStoredTransactionStatusEffect({
|
|
|
4168
4156
|
onTransactionStatusChange
|
|
4169
4157
|
}) {
|
|
4170
4158
|
const transaction = useStoredTransaction(txHash);
|
|
4171
|
-
const previousTransactionRef = (0,
|
|
4172
|
-
(0,
|
|
4159
|
+
const previousTransactionRef = (0, import_react17.useRef)(void 0);
|
|
4160
|
+
(0, import_react17.useEffect)(() => {
|
|
4173
4161
|
if (!onTransactionStatusChange) return;
|
|
4174
4162
|
if (previousTransactionRef.current?.status !== transaction?.status && !!transaction) {
|
|
4175
4163
|
onTransactionStatusChange(previousTransactionRef.current?.status, transaction.status, transaction);
|
|
@@ -4182,7 +4170,7 @@ function useStoredTransactionStatusEffect({
|
|
|
4182
4170
|
}
|
|
4183
4171
|
|
|
4184
4172
|
// src/hooks/useOnceDecrypted.ts
|
|
4185
|
-
var
|
|
4173
|
+
var import_react18 = require("react");
|
|
4186
4174
|
function useOnceDecrypted({
|
|
4187
4175
|
txHash,
|
|
4188
4176
|
onceDecrypted
|
|
@@ -4205,8 +4193,8 @@ function useStoredTransactionDecryptionEffect({
|
|
|
4205
4193
|
onDecryptionPendingChange
|
|
4206
4194
|
}) {
|
|
4207
4195
|
const transaction = useStoredTransaction(txHash);
|
|
4208
|
-
const previousTransactionRef = (0,
|
|
4209
|
-
(0,
|
|
4196
|
+
const previousTransactionRef = (0, import_react18.useRef)(void 0);
|
|
4197
|
+
(0, import_react18.useEffect)(() => {
|
|
4210
4198
|
if (!onDecryptionPendingChange) return;
|
|
4211
4199
|
if (previousTransactionRef.current?.isPendingDecryption !== transaction?.isPendingDecryption && !!transaction) {
|
|
4212
4200
|
onDecryptionPendingChange(
|
|
@@ -4445,14 +4433,14 @@ function useCofheTokenClaimUnshielded(options) {
|
|
|
4445
4433
|
|
|
4446
4434
|
// src/hooks/useCofheTokensClaimable.ts
|
|
4447
4435
|
var import_react_query14 = require("@tanstack/react-query");
|
|
4448
|
-
var
|
|
4436
|
+
var import_react21 = require("react");
|
|
4449
4437
|
var import_viem18 = require("viem");
|
|
4450
4438
|
var import_ts_essentials18 = __toESM(require_dist(), 1);
|
|
4451
4439
|
|
|
4452
4440
|
// src/hooks/useNormalizedList.ts
|
|
4453
|
-
var
|
|
4441
|
+
var import_react19 = require("react");
|
|
4454
4442
|
function useNormalizedList(items, options) {
|
|
4455
|
-
return (0,
|
|
4443
|
+
return (0, import_react19.useMemo)(() => {
|
|
4456
4444
|
if (!items || items.length === 0) return [];
|
|
4457
4445
|
const filter3 = options?.filter;
|
|
4458
4446
|
const dedupeKey = options?.dedupeKey;
|
|
@@ -4476,12 +4464,12 @@ function useNormalizedList(items, options) {
|
|
|
4476
4464
|
}
|
|
4477
4465
|
|
|
4478
4466
|
// src/hooks/useIsWaitingForDecryptionByAddress.ts
|
|
4479
|
-
var
|
|
4467
|
+
var import_react20 = require("react");
|
|
4480
4468
|
var import_viem17 = require("viem");
|
|
4481
4469
|
var import_ts_essentials17 = __toESM(require_dist(), 1);
|
|
4482
4470
|
function useIsWaitingForDecryptionByAddress(entries) {
|
|
4483
4471
|
const awaitingDecryptionKeySet = useAwaitingDecryptionQueryKeySet();
|
|
4484
|
-
return (0,
|
|
4472
|
+
return (0, import_react20.useMemo)(() => {
|
|
4485
4473
|
const map = {};
|
|
4486
4474
|
for (const entry of entries) {
|
|
4487
4475
|
(0, import_ts_essentials17.assert)((0, import_viem17.isAddress)(entry.address), "address is valid");
|
|
@@ -4520,7 +4508,7 @@ function useCofheTokensClaimable({ tokens, accountAddress: account }, queryOptio
|
|
|
4520
4508
|
sort: claimableSort
|
|
4521
4509
|
});
|
|
4522
4510
|
const enabledBase = !!publicClient && !!account && normalizedTokens.length > 0;
|
|
4523
|
-
const waitingEntries = (0,
|
|
4511
|
+
const waitingEntries = (0, import_react21.useMemo)(() => {
|
|
4524
4512
|
if (!account) return [];
|
|
4525
4513
|
return normalizedTokens.map((token) => ({
|
|
4526
4514
|
address: token.address,
|
|
@@ -4546,7 +4534,7 @@ function useCofheTokensClaimable({ tokens, accountAddress: account }, queryOptio
|
|
|
4546
4534
|
filter: pendingClaimsFilter,
|
|
4547
4535
|
reducer: asBooleanByTokenAddressLowercase
|
|
4548
4536
|
});
|
|
4549
|
-
const combined =
|
|
4537
|
+
const combined = useInternalQueries({
|
|
4550
4538
|
queries: normalizedTokens.map((token) => {
|
|
4551
4539
|
const confidentialityType = token.extensions.fhenix.confidentialityType;
|
|
4552
4540
|
const queryKey = constructUnshieldClaimsQueryKey({
|
|
@@ -4627,7 +4615,7 @@ function useCofheTokensClaimable({ tokens, accountAddress: account }, queryOptio
|
|
|
4627
4615
|
}
|
|
4628
4616
|
|
|
4629
4617
|
// src/hooks/useCofheTokensWithExistingEncryptedBalances.ts
|
|
4630
|
-
var
|
|
4618
|
+
var import_react22 = require("react");
|
|
4631
4619
|
|
|
4632
4620
|
// src/hooks/useCofheReadContracts.ts
|
|
4633
4621
|
var import_react_query15 = require("@tanstack/react-query");
|
|
@@ -4647,8 +4635,8 @@ function constructCofheReadContractsQueryKey(params) {
|
|
|
4647
4635
|
return [QUERY_CACHE_PREFIX2, cofheChainId, serializedContracts, allowFailure, enabled];
|
|
4648
4636
|
}
|
|
4649
4637
|
function getEnabledForCofheReadContracts(params) {
|
|
4650
|
-
const {
|
|
4651
|
-
return
|
|
4638
|
+
const { publicClient, cofheChainId, contracts, userEnabled } = params;
|
|
4639
|
+
return !!publicClient && !!cofheChainId && !!contracts && contracts.length > 0 && (userEnabled ?? true);
|
|
4652
4640
|
}
|
|
4653
4641
|
function isViemAllowFailureResult(value) {
|
|
4654
4642
|
return !!value && typeof value === "object" && "status" in value;
|
|
@@ -4658,11 +4646,9 @@ function transformResultForContract(contract, value) {
|
|
|
4658
4646
|
}
|
|
4659
4647
|
function useCofheReadContracts(params, queryOptions) {
|
|
4660
4648
|
const { contracts, multicallOptions } = params;
|
|
4661
|
-
const isCofheErrorActive = useIsCofheErrorActive();
|
|
4662
4649
|
const publicClient = useCofhePublicClient();
|
|
4663
4650
|
const cofheChainId = useCofheChainId();
|
|
4664
4651
|
const enabled = getEnabledForCofheReadContracts({
|
|
4665
|
-
isCofheErrorActive,
|
|
4666
4652
|
publicClient,
|
|
4667
4653
|
cofheChainId,
|
|
4668
4654
|
contracts,
|
|
@@ -4674,9 +4660,7 @@ function useCofheReadContracts(params, queryOptions) {
|
|
|
4674
4660
|
queryKey: constructCofheReadContractsQueryKey({
|
|
4675
4661
|
cofheChainId,
|
|
4676
4662
|
contracts,
|
|
4677
|
-
allowFailure: multicallOptions?.allowFailure
|
|
4678
|
-
// Same rationale as in `useCofheReadContract`: guard against a blank screen when CofheError is active.
|
|
4679
|
-
enabled
|
|
4663
|
+
allowFailure: multicallOptions?.allowFailure
|
|
4680
4664
|
}),
|
|
4681
4665
|
queryFn: async () => {
|
|
4682
4666
|
(0, import_ts_essentials19.assert)(publicClient, "PublicClient should be guaranteed by enabled check");
|
|
@@ -4716,7 +4700,7 @@ function useCofheTokensWithExistingEncryptedBalances({ chainId: _chainId, accoun
|
|
|
4716
4700
|
const currentChainId = useCofheChainId();
|
|
4717
4701
|
const chainIdForTokens = _chainId ?? currentChainId;
|
|
4718
4702
|
const tokens = useCofheTokens(chainIdForTokens);
|
|
4719
|
-
const contracts = (0,
|
|
4703
|
+
const contracts = (0, import_react22.useMemo)(() => {
|
|
4720
4704
|
if (!account) return [];
|
|
4721
4705
|
return tokens.map((token) => {
|
|
4722
4706
|
const config = getTokenContractConfig(token.extensions.fhenix.confidentialityType);
|
|
@@ -4741,7 +4725,7 @@ function useCofheTokensWithExistingEncryptedBalances({ chainId: _chainId, accoun
|
|
|
4741
4725
|
enabled: (queryOptions?.enabled ?? true) && !!account && tokens.length > 0
|
|
4742
4726
|
}
|
|
4743
4727
|
);
|
|
4744
|
-
const { tokensWithExistingEncryptedBalance, ctHashByTokenAddress, error } = (0,
|
|
4728
|
+
const { tokensWithExistingEncryptedBalance, ctHashByTokenAddress, error } = (0, import_react22.useMemo)(() => {
|
|
4745
4729
|
const map = {};
|
|
4746
4730
|
const filtered = [];
|
|
4747
4731
|
const items = read.data;
|
|
@@ -4782,7 +4766,7 @@ function useCofheTokensWithExistingEncryptedBalances({ chainId: _chainId, accoun
|
|
|
4782
4766
|
}
|
|
4783
4767
|
|
|
4784
4768
|
// src/hooks/useTokensWithPublicBalances.ts
|
|
4785
|
-
var
|
|
4769
|
+
var import_react23 = require("react");
|
|
4786
4770
|
function useTokensWithPublicBalances({ chainId: _chainId, accountAddress, displayDecimals = 5 } = {}, options) {
|
|
4787
4771
|
const connectedAccount = useCofheAccount();
|
|
4788
4772
|
const account = accountAddress ?? connectedAccount;
|
|
@@ -4790,19 +4774,25 @@ function useTokensWithPublicBalances({ chainId: _chainId, accountAddress, displa
|
|
|
4790
4774
|
const chainIdForTokens = _chainId ?? currentChainId;
|
|
4791
4775
|
const publicClient = useCofhePublicClient();
|
|
4792
4776
|
const tokens = useCofheTokens(chainIdForTokens);
|
|
4793
|
-
const
|
|
4794
|
-
const
|
|
4777
|
+
const sources = (0, import_react23.useMemo)(() => {
|
|
4778
|
+
const bySourceAddress = /* @__PURE__ */ new Map();
|
|
4795
4779
|
for (const token of tokens) {
|
|
4796
4780
|
const source = getPublicTokenBalanceSource(token);
|
|
4797
4781
|
if (!source) continue;
|
|
4798
|
-
|
|
4782
|
+
const key = source.address.toLowerCase();
|
|
4783
|
+
const existing = bySourceAddress.get(key);
|
|
4784
|
+
if (existing) {
|
|
4785
|
+
existing.tokens.push(token);
|
|
4786
|
+
} else {
|
|
4787
|
+
bySourceAddress.set(key, { source, tokens: [token] });
|
|
4788
|
+
}
|
|
4799
4789
|
}
|
|
4800
|
-
return
|
|
4790
|
+
return Array.from(bySourceAddress.values());
|
|
4801
4791
|
}, [tokens]);
|
|
4802
4792
|
const { enabled: userEnabled = true, ...restOptions } = options ?? {};
|
|
4803
|
-
const enabled = userEnabled && !!publicClient && !!account &&
|
|
4804
|
-
const combined =
|
|
4805
|
-
queries:
|
|
4793
|
+
const enabled = userEnabled && !!publicClient && !!account && sources.length > 0;
|
|
4794
|
+
const combined = useInternalQueries({
|
|
4795
|
+
queries: sources.map(
|
|
4806
4796
|
({ source }) => createPublicTokenBalanceQueryOptions({
|
|
4807
4797
|
publicClient,
|
|
4808
4798
|
accountAddress: account,
|
|
@@ -4822,7 +4812,7 @@ function useTokensWithPublicBalances({ chainId: _chainId, accountAddress, displa
|
|
|
4822
4812
|
let error = null;
|
|
4823
4813
|
for (let index = 0; index < results.length; index++) {
|
|
4824
4814
|
const result = results[index];
|
|
4825
|
-
const entry =
|
|
4815
|
+
const entry = sources[index];
|
|
4826
4816
|
if (!result || !entry) continue;
|
|
4827
4817
|
isLoading = isLoading || result.isLoading;
|
|
4828
4818
|
isFetching = isFetching || result.isFetching;
|
|
@@ -4831,8 +4821,11 @@ function useTokensWithPublicBalances({ chainId: _chainId, accountAddress, displa
|
|
|
4831
4821
|
const wei = result.data;
|
|
4832
4822
|
if (typeof wei !== "bigint") continue;
|
|
4833
4823
|
if (wei <= 0n) continue;
|
|
4834
|
-
|
|
4835
|
-
|
|
4824
|
+
const formatted = formatTokenAmount(wei, entry.source.decimals, displayDecimals);
|
|
4825
|
+
for (const token of entry.tokens) {
|
|
4826
|
+
out.push(token);
|
|
4827
|
+
balanceMap[token.address.toLowerCase()] = formatted;
|
|
4828
|
+
}
|
|
4836
4829
|
}
|
|
4837
4830
|
return {
|
|
4838
4831
|
tokensWithPublicBalances: out,
|
|
@@ -4890,10 +4883,9 @@ function useCofheSimulateWriteContract(callArgs, queryOptions) {
|
|
|
4890
4883
|
const walletClient = useCofheWalletClient();
|
|
4891
4884
|
const publicClient = useCofhePublicClient();
|
|
4892
4885
|
const cofheChainId = useCofheChainId();
|
|
4893
|
-
const isCofheErrorActive = useIsCofheErrorActive();
|
|
4894
4886
|
const { enabled: userEnabled, ...restQueryOptions } = queryOptions || {};
|
|
4895
4887
|
const resolvedAccountAddress = getAccountAddress(callArgs?.account ?? walletClient?.account);
|
|
4896
|
-
const enabled =
|
|
4888
|
+
const enabled = !!publicClient && !!walletClient && !!callArgs && !!resolvedAccountAddress && (userEnabled ?? true);
|
|
4897
4889
|
return useInternalQuery({
|
|
4898
4890
|
enabled,
|
|
4899
4891
|
queryKey: constructCofheSimulateWriteContractQueryKey({
|
|
@@ -4923,10 +4915,10 @@ function useCofheSimulateWriteContract(callArgs, queryOptions) {
|
|
|
4923
4915
|
}
|
|
4924
4916
|
|
|
4925
4917
|
// src/hooks/permits/usePermitDuration.ts
|
|
4926
|
-
var
|
|
4918
|
+
var import_react24 = require("react");
|
|
4927
4919
|
function usePermitDuration(options) {
|
|
4928
4920
|
const { onDurationChange, initialSeconds = 7 * 24 * 60 * 60 } = options;
|
|
4929
|
-
const presets = (0,
|
|
4921
|
+
const presets = (0, import_react24.useMemo)(
|
|
4930
4922
|
() => [
|
|
4931
4923
|
{ label: "1 day", seconds: 1 * 24 * 60 * 60 },
|
|
4932
4924
|
{ label: "1 week", seconds: 7 * 24 * 60 * 60 },
|
|
@@ -4934,7 +4926,7 @@ function usePermitDuration(options) {
|
|
|
4934
4926
|
],
|
|
4935
4927
|
[]
|
|
4936
4928
|
);
|
|
4937
|
-
const unitSeconds = (0,
|
|
4929
|
+
const unitSeconds = (0, import_react24.useMemo)(
|
|
4938
4930
|
() => ({
|
|
4939
4931
|
hours: 60 * 60,
|
|
4940
4932
|
days: 24 * 60 * 60,
|
|
@@ -4943,17 +4935,17 @@ function usePermitDuration(options) {
|
|
|
4943
4935
|
}),
|
|
4944
4936
|
[]
|
|
4945
4937
|
);
|
|
4946
|
-
const [durationSeconds, setDurationSecondsState] = (0,
|
|
4947
|
-
const [customCount, setCustomCountState] = (0,
|
|
4948
|
-
const [customUnit, setCustomUnitState] = (0,
|
|
4949
|
-
const selectPreset = (0,
|
|
4938
|
+
const [durationSeconds, setDurationSecondsState] = (0, import_react24.useState)(initialSeconds);
|
|
4939
|
+
const [customCount, setCustomCountState] = (0, import_react24.useState)("");
|
|
4940
|
+
const [customUnit, setCustomUnitState] = (0, import_react24.useState)("days");
|
|
4941
|
+
const selectPreset = (0, import_react24.useCallback)(
|
|
4950
4942
|
(seconds) => {
|
|
4951
4943
|
setDurationSecondsState(seconds);
|
|
4952
4944
|
onDurationChange(seconds);
|
|
4953
4945
|
},
|
|
4954
4946
|
[onDurationChange]
|
|
4955
4947
|
);
|
|
4956
|
-
const applyCustom = (0,
|
|
4948
|
+
const applyCustom = (0, import_react24.useCallback)(
|
|
4957
4949
|
(count, unit) => {
|
|
4958
4950
|
setCustomCountState(count);
|
|
4959
4951
|
setCustomUnitState(unit);
|
|
@@ -4965,8 +4957,8 @@ function usePermitDuration(options) {
|
|
|
4965
4957
|
},
|
|
4966
4958
|
[unitSeconds, onDurationChange]
|
|
4967
4959
|
);
|
|
4968
|
-
const setCustomCount = (0,
|
|
4969
|
-
const setCustomUnit = (0,
|
|
4960
|
+
const setCustomCount = (0, import_react24.useCallback)((value) => applyCustom(value, customUnit), [applyCustom, customUnit]);
|
|
4961
|
+
const setCustomUnit = (0, import_react24.useCallback)((unit) => applyCustom(customCount, unit), [applyCustom, customCount]);
|
|
4970
4962
|
return {
|
|
4971
4963
|
durationSeconds,
|
|
4972
4964
|
customCount,
|
|
@@ -4982,7 +4974,7 @@ function usePermitDuration(options) {
|
|
|
4982
4974
|
}
|
|
4983
4975
|
|
|
4984
4976
|
// src/hooks/permits/usePermitForm.ts
|
|
4985
|
-
var
|
|
4977
|
+
var import_react25 = require("react");
|
|
4986
4978
|
|
|
4987
4979
|
// src/stores/portalPersisted.tsx
|
|
4988
4980
|
var import_zustand8 = require("zustand");
|
|
@@ -5035,33 +5027,33 @@ var useCofheCreatePermitMutation = ({ onSuccess, onError } = {}) => {
|
|
|
5035
5027
|
// src/hooks/permits/usePermitForm.ts
|
|
5036
5028
|
function usePermitForm(options = {}) {
|
|
5037
5029
|
const { onSuccess, onError, isDelegate = false } = options;
|
|
5038
|
-
const [permitName, setPermitName] = (0,
|
|
5039
|
-
const [receiver, setReceiver] = (0,
|
|
5040
|
-
const [error, setError] = (0,
|
|
5041
|
-
const [nameError, setNameError] = (0,
|
|
5042
|
-
const [receiverError, setReceiverError] = (0,
|
|
5043
|
-
const [durationSeconds, setDurationSeconds] = (0,
|
|
5030
|
+
const [permitName, setPermitName] = (0, import_react25.useState)("");
|
|
5031
|
+
const [receiver, setReceiver] = (0, import_react25.useState)("");
|
|
5032
|
+
const [error, setError] = (0, import_react25.useState)(null);
|
|
5033
|
+
const [nameError, setNameError] = (0, import_react25.useState)(null);
|
|
5034
|
+
const [receiverError, setReceiverError] = (0, import_react25.useState)(null);
|
|
5035
|
+
const [durationSeconds, setDurationSeconds] = (0, import_react25.useState)(7 * 24 * 60 * 60);
|
|
5044
5036
|
const { mutateAsync: createPermitMutateAsync, isPending: isPermitCreationPending } = useCofheCreatePermitMutation({
|
|
5045
5037
|
onSuccess,
|
|
5046
5038
|
onError
|
|
5047
5039
|
});
|
|
5048
5040
|
const recipientAddressValid = isDelegate ? isValidAddress(receiver) : true;
|
|
5049
5041
|
const isValid = !!permitName.trim() && recipientAddressValid;
|
|
5050
|
-
const handleNameChange = (0,
|
|
5042
|
+
const handleNameChange = (0, import_react25.useCallback)(
|
|
5051
5043
|
(e) => {
|
|
5052
5044
|
setPermitName(e.target.value);
|
|
5053
5045
|
if (nameError) setNameError(null);
|
|
5054
5046
|
},
|
|
5055
5047
|
[nameError]
|
|
5056
5048
|
);
|
|
5057
|
-
const handleReceiverChange = (0,
|
|
5049
|
+
const handleReceiverChange = (0, import_react25.useCallback)(
|
|
5058
5050
|
(e) => {
|
|
5059
5051
|
setReceiver(e.target.value);
|
|
5060
5052
|
if (receiverError) setReceiverError(null);
|
|
5061
5053
|
},
|
|
5062
5054
|
[receiverError]
|
|
5063
5055
|
);
|
|
5064
|
-
const handleSubmit = (0,
|
|
5056
|
+
const handleSubmit = (0, import_react25.useCallback)(async () => {
|
|
5065
5057
|
if (isPermitCreationPending) return;
|
|
5066
5058
|
const nameToUse = permitName.trim();
|
|
5067
5059
|
if (!nameToUse) {
|
|
@@ -5087,7 +5079,7 @@ function usePermitForm(options = {}) {
|
|
|
5087
5079
|
setError(e?.message ?? "Failed to create permit");
|
|
5088
5080
|
}
|
|
5089
5081
|
}, [isPermitCreationPending, permitName, isDelegate, receiver, durationSeconds, createPermitMutateAsync]);
|
|
5090
|
-
const reset = (0,
|
|
5082
|
+
const reset = (0, import_react25.useCallback)(() => {
|
|
5091
5083
|
setPermitName("");
|
|
5092
5084
|
setReceiver("");
|
|
5093
5085
|
setError(null);
|
|
@@ -5116,15 +5108,15 @@ function isValidAddress(address) {
|
|
|
5116
5108
|
}
|
|
5117
5109
|
|
|
5118
5110
|
// src/hooks/permits/usePermitsList.ts
|
|
5119
|
-
var
|
|
5111
|
+
var import_react27 = require("react");
|
|
5120
5112
|
var import_permits2 = require("@cofhe/sdk/permits");
|
|
5121
5113
|
|
|
5122
5114
|
// src/hooks/permits/useCofheNavigateToCreatePermit.tsx
|
|
5123
|
-
var
|
|
5115
|
+
var import_react26 = require("react");
|
|
5124
5116
|
var useCofheNavigateToCreatePermit = () => {
|
|
5125
5117
|
const { navigateTo, navigateBack } = usePortalNavigation();
|
|
5126
5118
|
const { portalOpen, openPortal } = usePortalUI();
|
|
5127
|
-
return (0,
|
|
5119
|
+
return (0, import_react26.useCallback)(
|
|
5128
5120
|
({ cause } = {}) => {
|
|
5129
5121
|
if (!portalOpen) openPortal();
|
|
5130
5122
|
navigateTo("generatePermit" /* GeneratePermits */, {
|
|
@@ -5142,20 +5134,20 @@ var usePermitsList = () => {
|
|
|
5142
5134
|
const activePermit = useCofheActivePermit();
|
|
5143
5135
|
const { navigateTo } = usePortalNavigation();
|
|
5144
5136
|
const { openModal } = usePortalModals();
|
|
5145
|
-
const activePermitHash = (0,
|
|
5137
|
+
const activePermitHash = (0, import_react27.useMemo)(() => {
|
|
5146
5138
|
return activePermit?.permit.hash;
|
|
5147
5139
|
}, [activePermit?.permit.hash]);
|
|
5148
|
-
const selfPermits = (0,
|
|
5140
|
+
const selfPermits = (0, import_react27.useMemo)(() => {
|
|
5149
5141
|
return allPermits.filter((permit) => permit.type === "self");
|
|
5150
5142
|
}, [allPermits]);
|
|
5151
|
-
const delegatedPermits = (0,
|
|
5143
|
+
const delegatedPermits = (0, import_react27.useMemo)(() => {
|
|
5152
5144
|
return allPermits.filter((permit) => permit.type === "sharing");
|
|
5153
5145
|
}, [allPermits]);
|
|
5154
|
-
const importedPermits = (0,
|
|
5146
|
+
const importedPermits = (0, import_react27.useMemo)(() => {
|
|
5155
5147
|
return allPermits.filter((permit) => permit.type === "recipient");
|
|
5156
5148
|
}, [allPermits]);
|
|
5157
5149
|
const navigateToGeneratePermit = useCofheNavigateToCreatePermit();
|
|
5158
|
-
const handlePermitAction = (0,
|
|
5150
|
+
const handlePermitAction = (0, import_react27.useCallback)(
|
|
5159
5151
|
(actionId) => {
|
|
5160
5152
|
if (actionId === "generate") {
|
|
5161
5153
|
navigateToGeneratePermit();
|
|
@@ -5171,7 +5163,7 @@ var usePermitsList = () => {
|
|
|
5171
5163
|
},
|
|
5172
5164
|
[navigateTo, navigateToGeneratePermit]
|
|
5173
5165
|
);
|
|
5174
|
-
const handleOpenPermit = (0,
|
|
5166
|
+
const handleOpenPermit = (0, import_react27.useCallback)(
|
|
5175
5167
|
(hash) => {
|
|
5176
5168
|
openModal("permitDetails" /* PermitDetails */, { hash });
|
|
5177
5169
|
},
|
|
@@ -5188,17 +5180,17 @@ var usePermitsList = () => {
|
|
|
5188
5180
|
};
|
|
5189
5181
|
|
|
5190
5182
|
// src/hooks/permits/useReceivePermit.ts
|
|
5191
|
-
var
|
|
5183
|
+
var import_react28 = require("react");
|
|
5192
5184
|
var import_permits3 = require("@cofhe/sdk/permits");
|
|
5193
5185
|
function useReceivePermit({ onSuccess, onError } = {}) {
|
|
5194
5186
|
const { client } = useCofheContext();
|
|
5195
|
-
const [importedPermit, setImportedPermit] = (0,
|
|
5196
|
-
const [permitData, setPermitData] = (0,
|
|
5197
|
-
const [permitName, setPermitName] = (0,
|
|
5198
|
-
const [isSubmitting, setIsSubmitting] = (0,
|
|
5199
|
-
const [errorMsg, setErrorMsg] = (0,
|
|
5200
|
-
const [successMsg, setSuccessMsg] = (0,
|
|
5201
|
-
const submit = (0,
|
|
5187
|
+
const [importedPermit, setImportedPermit] = (0, import_react28.useState)(null);
|
|
5188
|
+
const [permitData, setPermitData] = (0, import_react28.useState)("");
|
|
5189
|
+
const [permitName, setPermitName] = (0, import_react28.useState)("");
|
|
5190
|
+
const [isSubmitting, setIsSubmitting] = (0, import_react28.useState)(false);
|
|
5191
|
+
const [errorMsg, setErrorMsg] = (0, import_react28.useState)(null);
|
|
5192
|
+
const [successMsg, setSuccessMsg] = (0, import_react28.useState)(null);
|
|
5193
|
+
const submit = (0, import_react28.useCallback)(async () => {
|
|
5202
5194
|
setErrorMsg(null);
|
|
5203
5195
|
setSuccessMsg(null);
|
|
5204
5196
|
if (!permitData.trim()) {
|
|
@@ -5229,7 +5221,7 @@ function useReceivePermit({ onSuccess, onError } = {}) {
|
|
|
5229
5221
|
setIsSubmitting(false);
|
|
5230
5222
|
}
|
|
5231
5223
|
}, [client, permitData, permitName, onSuccess, onError]);
|
|
5232
|
-
const handleSetPermitData = (0,
|
|
5224
|
+
const handleSetPermitData = (0, import_react28.useCallback)((v) => {
|
|
5233
5225
|
setPermitData(v);
|
|
5234
5226
|
try {
|
|
5235
5227
|
const permit = import_permits3.PermitUtils.importShared(v);
|
|
@@ -5255,17 +5247,17 @@ function useReceivePermit({ onSuccess, onError } = {}) {
|
|
|
5255
5247
|
}
|
|
5256
5248
|
|
|
5257
5249
|
// src/hooks/permits/usePermitDetailsAndActions.ts
|
|
5258
|
-
var
|
|
5250
|
+
var import_react30 = require("react");
|
|
5259
5251
|
var import_viem19 = require("viem");
|
|
5260
5252
|
var import_permits4 = require("@cofhe/sdk/permits");
|
|
5261
5253
|
|
|
5262
5254
|
// src/hooks/useCopyFeedback.ts
|
|
5263
|
-
var
|
|
5255
|
+
var import_react29 = require("react");
|
|
5264
5256
|
function useCopyFeedback(defaultDurationMs = 2e3) {
|
|
5265
|
-
const [copiedKeys, setCopiedKeys] = (0,
|
|
5266
|
-
const timersRef = (0,
|
|
5267
|
-
const isCopied = (0,
|
|
5268
|
-
const clearTimer = (0,
|
|
5257
|
+
const [copiedKeys, setCopiedKeys] = (0, import_react29.useState)(/* @__PURE__ */ new Set());
|
|
5258
|
+
const timersRef = (0, import_react29.useRef)(/* @__PURE__ */ new Map());
|
|
5259
|
+
const isCopied = (0, import_react29.useCallback)((key) => copiedKeys.has(key), [copiedKeys]);
|
|
5260
|
+
const clearTimer = (0, import_react29.useCallback)((key) => {
|
|
5269
5261
|
const timers = timersRef.current;
|
|
5270
5262
|
const existing = timers.get(key);
|
|
5271
5263
|
if (existing) {
|
|
@@ -5273,7 +5265,7 @@ function useCopyFeedback(defaultDurationMs = 2e3) {
|
|
|
5273
5265
|
timers.delete(key);
|
|
5274
5266
|
}
|
|
5275
5267
|
}, []);
|
|
5276
|
-
const copyWithFeedback = (0,
|
|
5268
|
+
const copyWithFeedback = (0, import_react29.useCallback)(
|
|
5277
5269
|
async (key, text, durationMs) => {
|
|
5278
5270
|
try {
|
|
5279
5271
|
await navigator.clipboard.writeText(text);
|
|
@@ -5299,7 +5291,7 @@ function useCopyFeedback(defaultDurationMs = 2e3) {
|
|
|
5299
5291
|
},
|
|
5300
5292
|
[clearTimer, defaultDurationMs]
|
|
5301
5293
|
);
|
|
5302
|
-
(0,
|
|
5294
|
+
(0, import_react29.useEffect)(() => {
|
|
5303
5295
|
return () => {
|
|
5304
5296
|
for (const id of timersRef.current.values()) {
|
|
5305
5297
|
window.clearTimeout(id);
|
|
@@ -5351,21 +5343,21 @@ var usePermitDetailsAndActions = (permitHash) => {
|
|
|
5351
5343
|
const isActivePermit = permit != null && activePermit?.permit.hash === permitHash;
|
|
5352
5344
|
const expirationDate = permit != null ? new Date(permit.expiration * 1e3).toLocaleString() : void 0;
|
|
5353
5345
|
const isShareablePermit = permit?.type === "sharing";
|
|
5354
|
-
const permitLabel = (0,
|
|
5346
|
+
const permitLabel = (0, import_react30.useMemo)(() => {
|
|
5355
5347
|
if (!permit) return void 0;
|
|
5356
5348
|
if (permit.name?.trim()) return permit.name;
|
|
5357
5349
|
const fallbackAddress = permit.recipient && permit.recipient !== import_viem19.zeroAddress ? permit.recipient : permit.issuer || import_viem19.zeroAddress;
|
|
5358
5350
|
return truncateAddress(fallbackAddress, 4, 4) ?? fallbackAddress;
|
|
5359
5351
|
}, [permit]);
|
|
5360
|
-
const expirationInfo = (0,
|
|
5361
|
-
const permitJson = (0,
|
|
5352
|
+
const expirationInfo = (0, import_react30.useMemo)(() => formatExpirationLabel(permit?.expiration), [permit?.expiration]);
|
|
5353
|
+
const permitJson = (0, import_react30.useMemo)(() => {
|
|
5362
5354
|
if (!permit) return void 0;
|
|
5363
5355
|
return import_permits4.PermitUtils.export(permit);
|
|
5364
5356
|
}, [permit]);
|
|
5365
|
-
const handleBack = (0,
|
|
5357
|
+
const handleBack = (0, import_react30.useCallback)(() => {
|
|
5366
5358
|
navigateBack();
|
|
5367
5359
|
}, [navigateBack]);
|
|
5368
|
-
const handleCopySharablePermitData = (0,
|
|
5360
|
+
const handleCopySharablePermitData = (0, import_react30.useCallback)(() => {
|
|
5369
5361
|
if (!permitJson) return;
|
|
5370
5362
|
copyWithFeedback(COPY_KEY, permitJson);
|
|
5371
5363
|
addToast({
|
|
@@ -5374,10 +5366,10 @@ var usePermitDetailsAndActions = (permitHash) => {
|
|
|
5374
5366
|
description: "Share copied data with recipient."
|
|
5375
5367
|
});
|
|
5376
5368
|
}, [copyWithFeedback, permitJson, addToast]);
|
|
5377
|
-
const handleSelectActivePermit = (0,
|
|
5369
|
+
const handleSelectActivePermit = (0, import_react30.useCallback)(() => {
|
|
5378
5370
|
selectActivePermit(permitHash);
|
|
5379
5371
|
}, [selectActivePermit, permitHash]);
|
|
5380
|
-
const handleRemovePermit = (0,
|
|
5372
|
+
const handleRemovePermit = (0, import_react30.useCallback)(() => {
|
|
5381
5373
|
removePermit(permitHash);
|
|
5382
5374
|
}, [removePermit, permitHash]);
|
|
5383
5375
|
return {
|
|
@@ -5398,7 +5390,7 @@ var usePermitDetailsAndActions = (permitHash) => {
|
|
|
5398
5390
|
};
|
|
5399
5391
|
|
|
5400
5392
|
// src/hooks/useCofheAutoConnect.ts
|
|
5401
|
-
var
|
|
5393
|
+
var import_react32 = require("react");
|
|
5402
5394
|
|
|
5403
5395
|
// src/providers/internalQueryHooks.ts
|
|
5404
5396
|
var import_react_query17 = require("@tanstack/react-query");
|
|
@@ -5407,7 +5399,7 @@ var import_react_query17 = require("@tanstack/react-query");
|
|
|
5407
5399
|
var import_react_query16 = require("@tanstack/react-query");
|
|
5408
5400
|
var import_react_query_persist_client = require("@tanstack/react-query-persist-client");
|
|
5409
5401
|
var import_query_async_storage_persister = require("@tanstack/query-async-storage-persister");
|
|
5410
|
-
var
|
|
5402
|
+
var import_react31 = require("react");
|
|
5411
5403
|
var import_web = require("@cofhe/sdk/web");
|
|
5412
5404
|
function isPersistedQuery(options) {
|
|
5413
5405
|
const meta = options.meta;
|
|
@@ -5462,7 +5454,7 @@ function useInternalMutation(options) {
|
|
|
5462
5454
|
const qc = useInternalQueryClient();
|
|
5463
5455
|
return (0, import_react_query17.useMutation)(options, qc);
|
|
5464
5456
|
}
|
|
5465
|
-
var
|
|
5457
|
+
var useInternalQueries = (options, _ignoredQueryClient) => {
|
|
5466
5458
|
const qc = useInternalQueryClient();
|
|
5467
5459
|
if (options && typeof options === "object" && "queries" in options) {
|
|
5468
5460
|
const typedOptions = options;
|
|
@@ -5494,15 +5486,15 @@ var useCofheConnect = (options) => {
|
|
|
5494
5486
|
var useCofheAutoConnect = ({ walletClient, publicClient }) => {
|
|
5495
5487
|
const client = useCofheClient();
|
|
5496
5488
|
const connectMutationFn = useCofheConnect().mutate;
|
|
5497
|
-
const supportedChainIds = (0,
|
|
5489
|
+
const supportedChainIds = (0, import_react32.useMemo)(() => {
|
|
5498
5490
|
return new Set(client.config.supportedChains.map((chain) => chain.id));
|
|
5499
5491
|
}, [client.config.supportedChains]);
|
|
5500
|
-
const disconnectIfConnected = (0,
|
|
5492
|
+
const disconnectIfConnected = (0, import_react32.useCallback)(() => {
|
|
5501
5493
|
if (client.connected || client.connecting) {
|
|
5502
5494
|
client.disconnect();
|
|
5503
5495
|
}
|
|
5504
5496
|
}, [client]);
|
|
5505
|
-
(0,
|
|
5497
|
+
(0, import_react32.useEffect)(() => {
|
|
5506
5498
|
if (!publicClient || !walletClient) {
|
|
5507
5499
|
disconnectIfConnected();
|
|
5508
5500
|
return;
|
|
@@ -5518,10 +5510,10 @@ var useCofheAutoConnect = ({ walletClient, publicClient }) => {
|
|
|
5518
5510
|
};
|
|
5519
5511
|
|
|
5520
5512
|
// src/hooks/useReschedulableTimeout.ts
|
|
5521
|
-
var
|
|
5513
|
+
var import_react33 = require("react");
|
|
5522
5514
|
function useReschedulableTimeout(callback, defaultTimeout) {
|
|
5523
|
-
const timerRef = (0,
|
|
5524
|
-
(0,
|
|
5515
|
+
const timerRef = (0, import_react33.useRef)(null);
|
|
5516
|
+
(0, import_react33.useEffect)(() => {
|
|
5525
5517
|
return () => {
|
|
5526
5518
|
if (timerRef.current) {
|
|
5527
5519
|
clearTimeout(timerRef.current);
|
|
@@ -5735,7 +5727,7 @@ function useCoingeckoContractMarketChartRange({
|
|
|
5735
5727
|
|
|
5736
5728
|
// src/hooks/useWatchPermitStatus.ts
|
|
5737
5729
|
var import_permits5 = require("@cofhe/sdk/permits");
|
|
5738
|
-
var
|
|
5730
|
+
var import_react34 = require("react");
|
|
5739
5731
|
var STATUS_ID_MISSING_PERMIT = "missing-permit";
|
|
5740
5732
|
var STATUS_ID_PERMIT_EXPIRED = "permit-expired";
|
|
5741
5733
|
var STATUS_ID_PERMIT_EXPIRING_SOON = "permit-expiring-soon";
|
|
@@ -5806,10 +5798,10 @@ var hidePermitSharedStatus = () => {
|
|
|
5806
5798
|
usePortalStatuses.getState().removeStatus(STATUS_ID_PERMIT_SHARED);
|
|
5807
5799
|
};
|
|
5808
5800
|
var useWatchPermitStatus = () => {
|
|
5809
|
-
const intervalRef = (0,
|
|
5801
|
+
const intervalRef = (0, import_react34.useRef)(null);
|
|
5810
5802
|
const activePermit = useCofheActivePermit();
|
|
5811
5803
|
const connected = useCofheIsConnected();
|
|
5812
|
-
(0,
|
|
5804
|
+
(0, import_react34.useEffect)(() => {
|
|
5813
5805
|
const updateStatuses = (permit) => {
|
|
5814
5806
|
const hasCreatedFirstPermit = usePortalPersisted.getState().hasCreatedFirstPermit;
|
|
5815
5807
|
const missingPermitStatusShown = usePortalStatuses.getState().hasStatus(STATUS_ID_MISSING_PERMIT);
|
|
@@ -5871,7 +5863,7 @@ var useWatchPermitStatus = () => {
|
|
|
5871
5863
|
};
|
|
5872
5864
|
|
|
5873
5865
|
// src/hooks/useWatchClaimablesStatus.ts
|
|
5874
|
-
var
|
|
5866
|
+
var import_react35 = require("react");
|
|
5875
5867
|
|
|
5876
5868
|
// src/hooks/useCofheClaimableTokens.ts
|
|
5877
5869
|
function useCofheClaimableTokens() {
|
|
@@ -5907,7 +5899,7 @@ var useWatchClaimablesStatus = () => {
|
|
|
5907
5899
|
const { totalTokensClaimable } = useCofheClaimableTokens();
|
|
5908
5900
|
const { navigateTo } = usePortalNavigation();
|
|
5909
5901
|
const { openPortal } = usePortalUI();
|
|
5910
|
-
(0,
|
|
5902
|
+
(0, import_react35.useEffect)(() => {
|
|
5911
5903
|
const claimsAvailableStatusShown = usePortalStatuses.getState().hasStatus(CLAIMS_AVAILABLE_STATUS_ID);
|
|
5912
5904
|
if (totalTokensClaimable > 0 && !claimsAvailableStatusShown) {
|
|
5913
5905
|
showClaimsAvailableStatus({
|
|
@@ -5925,7 +5917,7 @@ var useWatchClaimablesStatus = () => {
|
|
|
5925
5917
|
|
|
5926
5918
|
// src/components/FnxFloatingButton/FnxFloatingButtonContext.tsx
|
|
5927
5919
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
5928
|
-
var FnxFloatingButtonContext = (0,
|
|
5920
|
+
var FnxFloatingButtonContext = (0, import_react36.createContext)(null);
|
|
5929
5921
|
var FnxFloatingButtonProvider = ({ children }) => {
|
|
5930
5922
|
const { state } = useCofheContext();
|
|
5931
5923
|
const theme = state.theme;
|
|
@@ -5950,7 +5942,7 @@ var FnxFloatingButtonProvider = ({ children }) => {
|
|
|
5950
5942
|
);
|
|
5951
5943
|
};
|
|
5952
5944
|
var useFnxFloatingButtonContext = () => {
|
|
5953
|
-
const context = (0,
|
|
5945
|
+
const context = (0, import_react36.useContext)(FnxFloatingButtonContext);
|
|
5954
5946
|
if (!context) {
|
|
5955
5947
|
throw new Error("useFnxFloatingButtonContext must be used within FnxFloatingButtonProvider");
|
|
5956
5948
|
}
|
|
@@ -6008,15 +6000,15 @@ var FloatingButtonComponent = ({ onClick }) => {
|
|
|
6008
6000
|
};
|
|
6009
6001
|
|
|
6010
6002
|
// src/components/FnxFloatingButton/StatusBarSection.tsx
|
|
6011
|
-
var
|
|
6012
|
-
var
|
|
6003
|
+
var import_react37 = require("react");
|
|
6004
|
+
var import_react38 = require("motion/react");
|
|
6013
6005
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
6014
6006
|
var StatusBarSection = ({ children }) => {
|
|
6015
6007
|
const { isLeftSide } = useFnxFloatingButtonContext();
|
|
6016
6008
|
const { statuses } = usePortalStatuses();
|
|
6017
6009
|
const { statusPanelOpen } = usePortalUI();
|
|
6018
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
6019
|
-
|
|
6010
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react38.AnimatePresence, { children: (statusPanelOpen || statuses.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
6011
|
+
import_react38.motion.div,
|
|
6020
6012
|
{
|
|
6021
6013
|
className: "relative flex flex-1 h-12 items-center justify-between",
|
|
6022
6014
|
initial: { opacity: 0, x: isLeftSide ? -10 : 10 },
|
|
@@ -6030,11 +6022,11 @@ var StatusBarSection = ({ children }) => {
|
|
|
6030
6022
|
// src/components/FnxFloatingButton/StatusBarContent.tsx
|
|
6031
6023
|
var import_md = require("react-icons/md");
|
|
6032
6024
|
var import_io = require("react-icons/io");
|
|
6033
|
-
var
|
|
6025
|
+
var import_react41 = require("react");
|
|
6034
6026
|
|
|
6035
6027
|
// src/components/primitives/AnimatedZStack.tsx
|
|
6036
|
-
var
|
|
6037
|
-
var
|
|
6028
|
+
var import_react39 = __toESM(require("react"), 1);
|
|
6029
|
+
var import_react40 = require("motion/react");
|
|
6038
6030
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
6039
6031
|
var AnimatedZStackItem = ({
|
|
6040
6032
|
children,
|
|
@@ -6060,7 +6052,7 @@ var AnimatedZStackItem = ({
|
|
|
6060
6052
|
zIndex: index
|
|
6061
6053
|
};
|
|
6062
6054
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
6063
|
-
|
|
6055
|
+
import_react40.motion.div,
|
|
6064
6056
|
{
|
|
6065
6057
|
className: cn("w-full h-full absolute origin-top", invIndex === 0 && "events-none", className),
|
|
6066
6058
|
initial: entryStyle,
|
|
@@ -6076,8 +6068,8 @@ var AnimatedZStack = ({
|
|
|
6076
6068
|
stackScale = 0.05,
|
|
6077
6069
|
itemClassName
|
|
6078
6070
|
}) => {
|
|
6079
|
-
const filteredChildren =
|
|
6080
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
6071
|
+
const filteredChildren = import_react39.default.Children.toArray(children).filter(Boolean);
|
|
6072
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react40.AnimatePresence, { children: filteredChildren.map((child, index) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
6081
6073
|
AnimatedZStackItem,
|
|
6082
6074
|
{
|
|
6083
6075
|
stackOffset,
|
|
@@ -6181,7 +6173,7 @@ function sortStatuses(a, b) {
|
|
|
6181
6173
|
}
|
|
6182
6174
|
var StatusBarContent = () => {
|
|
6183
6175
|
const { statuses } = usePortalStatuses();
|
|
6184
|
-
const sortedStatuses = (0,
|
|
6176
|
+
const sortedStatuses = (0, import_react41.useMemo)(() => statuses.sort(sortStatuses), [statuses]);
|
|
6185
6177
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(AnimatedZStack, { children: [
|
|
6186
6178
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ConnectionStatus, {}),
|
|
6187
6179
|
sortedStatuses.map((status) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ActiveStatusContent, { status }, status.id))
|
|
@@ -6189,17 +6181,17 @@ var StatusBarContent = () => {
|
|
|
6189
6181
|
};
|
|
6190
6182
|
|
|
6191
6183
|
// src/components/FnxFloatingButton/ContentSection.tsx
|
|
6192
|
-
var
|
|
6184
|
+
var import_react59 = require("react");
|
|
6193
6185
|
|
|
6194
6186
|
// src/components/FnxFloatingButton/pages/MainPage/WalletHeader.tsx
|
|
6195
6187
|
var import_md3 = require("react-icons/md");
|
|
6196
6188
|
|
|
6197
6189
|
// src/components/FnxFloatingButton/components/AddressButton.tsx
|
|
6198
|
-
var
|
|
6190
|
+
var import_react42 = require("react");
|
|
6199
6191
|
var import_md2 = require("react-icons/md");
|
|
6200
6192
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
6201
6193
|
var AddressButton = ({ address, className, icon, showCopyIcon = true }) => {
|
|
6202
|
-
const [copied, setCopied] = (0,
|
|
6194
|
+
const [copied, setCopied] = (0, import_react42.useState)(false);
|
|
6203
6195
|
const handleCopyAddress = async () => {
|
|
6204
6196
|
if (!address) return;
|
|
6205
6197
|
try {
|
|
@@ -6301,7 +6293,7 @@ var WalletHeader = () => {
|
|
|
6301
6293
|
var import_KeyboardArrowRight = __toESM(require("@mui/icons-material/KeyboardArrowRight"), 1);
|
|
6302
6294
|
|
|
6303
6295
|
// src/components/FnxFloatingButton/components/TokenIcon.tsx
|
|
6304
|
-
var
|
|
6296
|
+
var import_react43 = require("react");
|
|
6305
6297
|
|
|
6306
6298
|
// src/assets/default-token.webp
|
|
6307
6299
|
var default_token_default = "data:image/webp;base64,UklGRrADAABXRUJQVlA4WAoAAAAQAAAAPwAAPwAAVlA4TDsDAAAvP8APEAelqJEkpfzLPf4xWCCQtLF/5p0zbtvIEftvdHPeve8xbts2kPYft6/2TrbVtm3DIFtn3gD9/9o+ao+6R92j9ii71C5lh9wmb5ObpCZpjVAhFMC+gWDo6vtrUGSD0C3AIESRYxOGwIuFh6In9xAhS7EhC3xaIYIDUQz/1pyv4S7Scs0Dz9fgkccgQQAYQ5KS9WgnPVrbtm3bNs62bQ9P3X/tmZ5UzQci+j8BwKx6X1xfHW4uyHC5Mgqah1dvvPCpIK/me7jVV+wmw57ige2HPk2O/x9O+7OJNbv//JMqTvu4W+sgdkfjwWdNkP9ys0JCldarARHqi1E3CfdMvNLY/t6sJClrbv9l8m9nk6Q5u0GW73NOkta9/Ivh27SDJHbM/orKP6eQ1I6VYBR/t50kuXvvn7Gb2SR97h1Dz6soButfG/CPUUxOhiJddjPZTUmoTzExpd2I8LGFWO3JaDSFhdq/hNH2iNUWh8YTUjmUozAfG1hscRhtvJ2BWr/oThWWBNQnW4nIkqTDRA7HJQDw9ROnGRExzkrhLTo0M9BQCOBhNku8zkaRLbpEjvwnANvEaUNETCajyYiIdgbaB98Ai0lnM2TTWTmGgi9KWJIRMYGMs5W/ueFhIYspMTmKOK70u6skpx0RMZWDtoYlMSFiPLFONMthQ0Q08XQUSGGLQ8R4O09phgzWOEREK/HmuSSwoN5MzOkSmFFvJu7MDGEm1JuJPa9AlA31VuIvbRYVr7OSwI5hQWZERDOJnFgVlISICSR087pbTDwimoSk33leIgYR0SKk7I23T5xVyFAQtsTZhOwBPMgWIjz3EcCv3lga9APASQwpFwAA3tfFTvNnnbYrIBkRMVXAIYR93xQrbZ/DwQVXbHiuQ0TvSGyMByLB03IusTUvwaB2LVO+nFtg+M+6UzbXzj9j4J1R5HIsBCHar1OKTI7pHxD91xmnPM7578DpXc+UJXvbD7y/r5TJUXHzL3CrT4dd4tyjz1UQ6D2rU8QojRd9IFZ9t1Wt8Ck1ux80EP7/7WFnBk9W1/H7/yCl9uPeWnehy5i7qGfj/k8N5FV/PL602F+d6yJy5VYPLF159lMFZgBQU0FJTgAAADhCSU0D7QAAAAAAEABIAAAAAQACAEgAAAABAAI4QklNBCgAAAAAAAwAAAACP/AAAAAAAAA4QklNBEMAAAAAAA1QYmVXARAABQEAAAAAAA==";
|
|
@@ -6321,8 +6313,8 @@ var TokenIcon = ({
|
|
|
6321
6313
|
className,
|
|
6322
6314
|
imageClassName = "w-full h-full object-cover"
|
|
6323
6315
|
}) => {
|
|
6324
|
-
const [iconError, setIconError] = (0,
|
|
6325
|
-
(0,
|
|
6316
|
+
const [iconError, setIconError] = (0, import_react43.useState)(false);
|
|
6317
|
+
(0, import_react43.useEffect)(() => {
|
|
6326
6318
|
setIconError(false);
|
|
6327
6319
|
}, [logoURI]);
|
|
6328
6320
|
const containerClassName = className || cn(sizeClasses[size], "rounded-full fnx-icon-bg flex items-center justify-center flex-shrink-0 overflow-hidden");
|
|
@@ -6418,7 +6410,7 @@ var CofheTokenConfidentialBalance = ({
|
|
|
6418
6410
|
const {
|
|
6419
6411
|
data: { formatted: confidentialBalanceFormatted } = {},
|
|
6420
6412
|
isFetching: isFetchingConfidential,
|
|
6421
|
-
|
|
6413
|
+
disabledDueToMissingValidPermit
|
|
6422
6414
|
} = useCofheTokenDecryptedBalance({
|
|
6423
6415
|
token,
|
|
6424
6416
|
accountAddress: effectiveAccountAddress,
|
|
@@ -6429,7 +6421,7 @@ var CofheTokenConfidentialBalance = ({
|
|
|
6429
6421
|
{
|
|
6430
6422
|
className,
|
|
6431
6423
|
size,
|
|
6432
|
-
hidden:
|
|
6424
|
+
hidden: disabledDueToMissingValidPermit,
|
|
6433
6425
|
isFetching: isFetchingConfidential,
|
|
6434
6426
|
formattedBalance: confidentialBalanceFormatted,
|
|
6435
6427
|
symbol: showSymbol ? token?.symbol : void 0
|
|
@@ -6702,7 +6694,7 @@ var Button = ({
|
|
|
6702
6694
|
};
|
|
6703
6695
|
|
|
6704
6696
|
// src/components/FnxFloatingButton/components/TokenPriceChart.tsx
|
|
6705
|
-
var
|
|
6697
|
+
var import_react44 = require("react");
|
|
6706
6698
|
var import_recharts = require("recharts");
|
|
6707
6699
|
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
6708
6700
|
var formatTime = (ts) => new Date(ts).toLocaleTimeString(void 0, {
|
|
@@ -6733,8 +6725,8 @@ var themeClasses = {
|
|
|
6733
6725
|
tooltipCursor: "[&_.recharts-tooltip-cursor]:stroke-current [&_.recharts-tooltip-cursor]:stroke-opacity-35 dark:[&_.recharts-tooltip-cursor]:stroke-opacity-45"
|
|
6734
6726
|
};
|
|
6735
6727
|
var TokenPriceChart = ({ points, className, height = 150 }) => {
|
|
6736
|
-
const gradientId = (0,
|
|
6737
|
-
const { start, mid, end } = (0,
|
|
6728
|
+
const gradientId = (0, import_react44.useId)();
|
|
6729
|
+
const { start, mid, end } = (0, import_react44.useMemo)(() => {
|
|
6738
6730
|
if (!points.length) {
|
|
6739
6731
|
const now = Date.now();
|
|
6740
6732
|
return { start: now - 24 * 36e5, mid: now - 12 * 36e5, end: now };
|
|
@@ -6790,7 +6782,7 @@ var TokenPriceChart = ({ points, className, height = 150 }) => {
|
|
|
6790
6782
|
};
|
|
6791
6783
|
|
|
6792
6784
|
// src/components/FnxFloatingButton/components/PageContainer.tsx
|
|
6793
|
-
var
|
|
6785
|
+
var import_react45 = require("react");
|
|
6794
6786
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
6795
6787
|
var PageContainer = ({ isModal, header, content, footer }) => {
|
|
6796
6788
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: cn("flex flex-col max-h-[500px] w-full gap-4", isModal ? "" : "h-full"), children: [
|
|
@@ -6844,6 +6836,21 @@ var TransactionItem = ({ transaction }) => {
|
|
|
6844
6836
|
] }) });
|
|
6845
6837
|
};
|
|
6846
6838
|
|
|
6839
|
+
// src/utils/isProduction.ts
|
|
6840
|
+
var import_meta = {};
|
|
6841
|
+
var isProduction = () => {
|
|
6842
|
+
if (typeof process !== "undefined" && process.env?.NODE_ENV === "development") {
|
|
6843
|
+
return false;
|
|
6844
|
+
}
|
|
6845
|
+
if (typeof import_meta !== "undefined") {
|
|
6846
|
+
const metaEnv = import_meta.env;
|
|
6847
|
+
if (metaEnv && metaEnv.MODE === "development" && metaEnv.DEV === true && metaEnv.PROD === false) {
|
|
6848
|
+
return false;
|
|
6849
|
+
}
|
|
6850
|
+
}
|
|
6851
|
+
return true;
|
|
6852
|
+
};
|
|
6853
|
+
|
|
6847
6854
|
// src/components/FnxFloatingButton/pages/MainPage/BottomNavigation.tsx
|
|
6848
6855
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
6849
6856
|
var iconClassName = "w-4 h-4";
|
|
@@ -7007,22 +7014,22 @@ var SettingsPage = () => {
|
|
|
7007
7014
|
// src/components/FnxFloatingButton/pages/permits/PermitsListPage/index.tsx
|
|
7008
7015
|
var import_ArrowBack2 = __toESM(require("@mui/icons-material/ArrowBack"), 1);
|
|
7009
7016
|
var import_fa2 = require("react-icons/fa");
|
|
7010
|
-
var
|
|
7017
|
+
var import_react49 = require("react");
|
|
7011
7018
|
|
|
7012
7019
|
// src/components/FnxFloatingButton/Accordion.tsx
|
|
7013
|
-
var
|
|
7020
|
+
var import_react46 = require("react");
|
|
7014
7021
|
var import_fa6 = require("react-icons/fa6");
|
|
7015
7022
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
7016
|
-
var AccordionContext = (0,
|
|
7023
|
+
var AccordionContext = (0, import_react46.createContext)(void 0);
|
|
7017
7024
|
var Accordion = ({ children, defaultActiveId = null }) => {
|
|
7018
|
-
const [activeId, setActiveId] = (0,
|
|
7019
|
-
const handleToggle = (0,
|
|
7025
|
+
const [activeId, setActiveId] = (0, import_react46.useState)(defaultActiveId);
|
|
7026
|
+
const handleToggle = (0, import_react46.useCallback)(
|
|
7020
7027
|
(id) => {
|
|
7021
7028
|
setActiveId(activeId === id ? null : id);
|
|
7022
7029
|
},
|
|
7023
7030
|
[activeId]
|
|
7024
7031
|
);
|
|
7025
|
-
const contextValue = (0,
|
|
7032
|
+
const contextValue = (0, import_react46.useMemo)(
|
|
7026
7033
|
() => ({
|
|
7027
7034
|
activeId,
|
|
7028
7035
|
toggle: handleToggle
|
|
@@ -7032,7 +7039,7 @@ var Accordion = ({ children, defaultActiveId = null }) => {
|
|
|
7032
7039
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(AccordionContext.Provider, { value: contextValue, children });
|
|
7033
7040
|
};
|
|
7034
7041
|
var useAccordionContext = () => {
|
|
7035
|
-
const context = (0,
|
|
7042
|
+
const context = (0, import_react46.useContext)(AccordionContext);
|
|
7036
7043
|
if (!context) {
|
|
7037
7044
|
throw new Error("Accordion components must be used within an Accordion");
|
|
7038
7045
|
}
|
|
@@ -7041,6 +7048,7 @@ var useAccordionContext = () => {
|
|
|
7041
7048
|
var AccordionSection = ({
|
|
7042
7049
|
id,
|
|
7043
7050
|
renderHeader,
|
|
7051
|
+
accessory,
|
|
7044
7052
|
children,
|
|
7045
7053
|
sectionClassName,
|
|
7046
7054
|
triggerClassName,
|
|
@@ -7049,20 +7057,23 @@ var AccordionSection = ({
|
|
|
7049
7057
|
const { activeId, toggle } = useAccordionContext();
|
|
7050
7058
|
const isOpen = activeId === id;
|
|
7051
7059
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("section", { className: sectionClassName, children: [
|
|
7052
|
-
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
7053
|
-
|
|
7054
|
-
|
|
7055
|
-
|
|
7056
|
-
|
|
7057
|
-
|
|
7058
|
-
|
|
7059
|
-
|
|
7060
|
-
|
|
7061
|
-
|
|
7062
|
-
|
|
7063
|
-
|
|
7064
|
-
|
|
7065
|
-
|
|
7060
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
7061
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
7062
|
+
Button,
|
|
7063
|
+
{
|
|
7064
|
+
variant: "ghost",
|
|
7065
|
+
className: cn("!justify-start flex-1 text-md py-2", triggerClassName),
|
|
7066
|
+
"aria-expanded": isOpen,
|
|
7067
|
+
onClick: () => toggle(id),
|
|
7068
|
+
children: [
|
|
7069
|
+
renderHeader(isOpen),
|
|
7070
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: "flex flex-1" }),
|
|
7071
|
+
isOpen ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_fa6.FaChevronUp, {}) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_fa6.FaChevronDown, {})
|
|
7072
|
+
]
|
|
7073
|
+
}
|
|
7074
|
+
),
|
|
7075
|
+
accessory ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "shrink-0", children: accessory }) : null
|
|
7076
|
+
] }),
|
|
7066
7077
|
isOpen ? /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: cn("relative", contentClassName), children: [
|
|
7067
7078
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
7068
7079
|
"span",
|
|
@@ -7138,7 +7149,7 @@ var import_viem21 = require("viem");
|
|
|
7138
7149
|
var import_permits7 = require("@cofhe/sdk/permits");
|
|
7139
7150
|
|
|
7140
7151
|
// src/components/StripedBackground.tsx
|
|
7141
|
-
var
|
|
7152
|
+
var import_react47 = require("react");
|
|
7142
7153
|
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
7143
7154
|
function StripedBackground({
|
|
7144
7155
|
stripeColor = "rgba(255,255,255,0.18)",
|
|
@@ -7147,7 +7158,7 @@ function StripedBackground({
|
|
|
7147
7158
|
style,
|
|
7148
7159
|
children
|
|
7149
7160
|
}) {
|
|
7150
|
-
const bgImage = (0,
|
|
7161
|
+
const bgImage = (0, import_react47.useMemo)(() => {
|
|
7151
7162
|
return `repeating-linear-gradient(
|
|
7152
7163
|
45deg,
|
|
7153
7164
|
${stripeColor} 0px,
|
|
@@ -7184,7 +7195,7 @@ var PermitStripedBackground = ({ variant, className, children }) => {
|
|
|
7184
7195
|
};
|
|
7185
7196
|
|
|
7186
7197
|
// src/components/FnxFloatingButton/components/PermitCard.tsx
|
|
7187
|
-
var
|
|
7198
|
+
var import_react48 = require("react");
|
|
7188
7199
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
7189
7200
|
var PermitTypeLabel = {
|
|
7190
7201
|
self: "Self",
|
|
@@ -7202,7 +7213,7 @@ var BasePermitCard = ({
|
|
|
7202
7213
|
}) => {
|
|
7203
7214
|
const activePermitHash = useCofheActivePermitHash();
|
|
7204
7215
|
const expirationInfo = formatExpirationLabel(permit.expiration);
|
|
7205
|
-
const metadataTags = (0,
|
|
7216
|
+
const metadataTags = (0, import_react48.useMemo)(() => {
|
|
7206
7217
|
const isActivePermit = permit.hash === activePermitHash;
|
|
7207
7218
|
const tags = [];
|
|
7208
7219
|
if (expirationInfo.expired) tags.push("expired");
|
|
@@ -7339,19 +7350,21 @@ var PermitsListPage = () => {
|
|
|
7339
7350
|
PageContainer,
|
|
7340
7351
|
{
|
|
7341
7352
|
header: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "flex flex-col gap-3", children: [
|
|
7342
|
-
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
7343
|
-
|
|
7344
|
-
|
|
7345
|
-
|
|
7346
|
-
|
|
7347
|
-
|
|
7348
|
-
|
|
7349
|
-
|
|
7350
|
-
|
|
7351
|
-
|
|
7352
|
-
|
|
7353
|
-
|
|
7354
|
-
|
|
7353
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "flex items-center gap-2 text-base font-semibold tracking-tight text-[#0E2F3F] dark:text-white", children: [
|
|
7354
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
7355
|
+
"button",
|
|
7356
|
+
{
|
|
7357
|
+
className: "inline-flex items-center gap-2 transition-opacity hover:opacity-80",
|
|
7358
|
+
onClick: navigateBack,
|
|
7359
|
+
type: "button",
|
|
7360
|
+
children: [
|
|
7361
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_ArrowBack2.default, { fontSize: "small" }),
|
|
7362
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { children: "Permits" })
|
|
7363
|
+
]
|
|
7364
|
+
}
|
|
7365
|
+
),
|
|
7366
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(InfoModalButton, { onClick: () => openModal("permitInfo" /* PermitInfo */) })
|
|
7367
|
+
] }),
|
|
7355
7368
|
activePermitHash != null && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7356
7369
|
PermitCard,
|
|
7357
7370
|
{
|
|
@@ -7366,15 +7379,12 @@ var PermitsListPage = () => {
|
|
|
7366
7379
|
AccordionSection,
|
|
7367
7380
|
{
|
|
7368
7381
|
id: "self",
|
|
7369
|
-
renderHeader: () => /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
7370
|
-
|
|
7371
|
-
|
|
7372
|
-
|
|
7373
|
-
")"
|
|
7374
|
-
] }),
|
|
7375
|
-
" ",
|
|
7376
|
-
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(InfoModalButton, { onClick: () => openModal("permitTypeInfo" /* PermitTypeInfo */, { type: "self" }) })
|
|
7382
|
+
renderHeader: () => /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("span", { children: [
|
|
7383
|
+
"Self: (",
|
|
7384
|
+
selfPermits.length,
|
|
7385
|
+
")"
|
|
7377
7386
|
] }),
|
|
7387
|
+
accessory: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(InfoModalButton, { onClick: () => openModal("permitTypeInfo" /* PermitTypeInfo */, { type: "self" }) }),
|
|
7378
7388
|
children: selfPermits.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "pl-4 text-xs p-2 px-4 italic", children: "No self permits." }) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { children: selfPermits.map((permit2) => {
|
|
7379
7389
|
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7380
7390
|
PermitItem,
|
|
@@ -7392,15 +7402,12 @@ var PermitsListPage = () => {
|
|
|
7392
7402
|
AccordionSection,
|
|
7393
7403
|
{
|
|
7394
7404
|
id: "delegated",
|
|
7395
|
-
renderHeader: () => /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
7396
|
-
|
|
7397
|
-
|
|
7398
|
-
|
|
7399
|
-
")"
|
|
7400
|
-
] }),
|
|
7401
|
-
" ",
|
|
7402
|
-
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(InfoModalButton, { onClick: () => openModal("permitTypeInfo" /* PermitTypeInfo */, { type: "sharing" }) })
|
|
7405
|
+
renderHeader: () => /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("span", { children: [
|
|
7406
|
+
"Delegated: (",
|
|
7407
|
+
delegatedPermits.length,
|
|
7408
|
+
")"
|
|
7403
7409
|
] }),
|
|
7410
|
+
accessory: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(InfoModalButton, { onClick: () => openModal("permitTypeInfo" /* PermitTypeInfo */, { type: "sharing" }) }),
|
|
7404
7411
|
children: delegatedPermits.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "pl-1 text-xs p-2 px-4 italic", children: "No delegated permits." }) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { children: delegatedPermits.map((permit2) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(PermitItem, { permit: permit2, onClick: () => handleOpenPermit(permit2.hash) }, permit2.hash)) })
|
|
7405
7412
|
}
|
|
7406
7413
|
),
|
|
@@ -7408,15 +7415,12 @@ var PermitsListPage = () => {
|
|
|
7408
7415
|
AccordionSection,
|
|
7409
7416
|
{
|
|
7410
7417
|
id: "received",
|
|
7411
|
-
renderHeader: () => /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
7412
|
-
|
|
7413
|
-
|
|
7414
|
-
|
|
7415
|
-
")"
|
|
7416
|
-
] }),
|
|
7417
|
-
" ",
|
|
7418
|
-
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(InfoModalButton, { onClick: () => openModal("permitTypeInfo" /* PermitTypeInfo */, { type: "recipient" }) })
|
|
7418
|
+
renderHeader: () => /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("span", { children: [
|
|
7419
|
+
"Imported: (",
|
|
7420
|
+
importedPermits.length,
|
|
7421
|
+
")"
|
|
7419
7422
|
] }),
|
|
7423
|
+
accessory: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(InfoModalButton, { onClick: () => openModal("permitTypeInfo" /* PermitTypeInfo */, { type: "recipient" }) }),
|
|
7420
7424
|
children: importedPermits.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "pl-1 text-xs p-2 px-4 italic", children: "No imported permits." }) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { children: importedPermits.map((permit2) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7421
7425
|
PermitItem,
|
|
7422
7426
|
{
|
|
@@ -7818,11 +7822,11 @@ var ImportPermitPage = () => {
|
|
|
7818
7822
|
|
|
7819
7823
|
// src/components/FnxFloatingButton/pages/TokenInfoPage.tsx
|
|
7820
7824
|
var import_chains3 = require("@cofhe/sdk/chains");
|
|
7821
|
-
var
|
|
7825
|
+
var import_react52 = require("react");
|
|
7822
7826
|
var import_ArrowBack6 = __toESM(require("@mui/icons-material/ArrowBack"), 1);
|
|
7823
7827
|
|
|
7824
7828
|
// src/components/FnxFloatingButton/pages/TokenInfoBalanceChart.tsx
|
|
7825
|
-
var
|
|
7829
|
+
var import_react50 = require("react");
|
|
7826
7830
|
var import_Lock = __toESM(require("@mui/icons-material/Lock"), 1);
|
|
7827
7831
|
var import_Public = __toESM(require("@mui/icons-material/Public"), 1);
|
|
7828
7832
|
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
@@ -7840,7 +7844,7 @@ var TokenInfoBalanceChart = ({ token, chartPoints }) => {
|
|
|
7840
7844
|
token
|
|
7841
7845
|
});
|
|
7842
7846
|
const isFetchingBalances = isFetchingConfidentialBalance || isFetchingPublicBalance;
|
|
7843
|
-
const balancePercents = (0,
|
|
7847
|
+
const balancePercents = (0, import_react50.useMemo)(() => {
|
|
7844
7848
|
if (!confidentialBalance && !publicBalance) return;
|
|
7845
7849
|
const confidentialUnit = confidentialBalance?.unit ?? null;
|
|
7846
7850
|
const publicUnit = publicBalance?.unit ?? null;
|
|
@@ -7852,7 +7856,7 @@ var TokenInfoBalanceChart = ({ token, chartPoints }) => {
|
|
|
7852
7856
|
publicPct
|
|
7853
7857
|
};
|
|
7854
7858
|
}, [confidentialBalance, publicBalance]);
|
|
7855
|
-
const price = (0,
|
|
7859
|
+
const price = (0, import_react50.useMemo)(() => {
|
|
7856
7860
|
const lastPoint = chartPoints?.[chartPoints.length - 1];
|
|
7857
7861
|
const firstPoint = chartPoints?.[0];
|
|
7858
7862
|
if (!lastPoint || !firstPoint) return;
|
|
@@ -7927,7 +7931,7 @@ var TokenInfoBalanceChart = ({ token, chartPoints }) => {
|
|
|
7927
7931
|
};
|
|
7928
7932
|
|
|
7929
7933
|
// src/components/FnxFloatingButton/pages/TokenInfoTransactionHistory.tsx
|
|
7930
|
-
var
|
|
7934
|
+
var import_react51 = require("react");
|
|
7931
7935
|
var import_viem22 = require("viem");
|
|
7932
7936
|
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
7933
7937
|
var TokenInfoTransactionHistoryHeader = ({ token }) => {
|
|
@@ -7950,7 +7954,7 @@ var TokenInfoTransactionHistory = ({ token, priceUsd }) => {
|
|
|
7950
7954
|
account,
|
|
7951
7955
|
filter: (tx) => tx.token.address.toLowerCase() === token.address.toLowerCase()
|
|
7952
7956
|
});
|
|
7953
|
-
const activity = (0,
|
|
7957
|
+
const activity = (0, import_react51.useMemo)(() => {
|
|
7954
7958
|
return tokenTxs.slice().sort((a, b) => b.timestamp - a.timestamp).map((tx) => {
|
|
7955
7959
|
const amountToken = parseFloat((0, import_viem22.formatUnits)(tx.tokenAmount, tx.token.decimals));
|
|
7956
7960
|
const amountUsd = typeof priceUsd === "number" && Number.isFinite(amountToken) ? amountToken * priceUsd : void 0;
|
|
@@ -8002,7 +8006,7 @@ var TokenInfoPage = ({ token }) => {
|
|
|
8002
8006
|
},
|
|
8003
8007
|
rangeMs: 24 * 36e5
|
|
8004
8008
|
});
|
|
8005
|
-
const priceUsd = (0,
|
|
8009
|
+
const priceUsd = (0, import_react52.useMemo)(() => {
|
|
8006
8010
|
const lastPoint = chartPoints?.[chartPoints.length - 1];
|
|
8007
8011
|
return lastPoint?.value;
|
|
8008
8012
|
}, [chartPoints]);
|
|
@@ -8056,14 +8060,14 @@ var TokenInfoPage = ({ token }) => {
|
|
|
8056
8060
|
};
|
|
8057
8061
|
|
|
8058
8062
|
// src/components/FnxFloatingButton/pages/SendPage.tsx
|
|
8059
|
-
var
|
|
8063
|
+
var import_react53 = require("react");
|
|
8060
8064
|
var import_ArrowBack7 = __toESM(require("@mui/icons-material/ArrowBack"), 1);
|
|
8061
8065
|
var import_KeyboardArrowRight2 = __toESM(require("@mui/icons-material/KeyboardArrowRight"), 1);
|
|
8062
8066
|
var import_viem23 = require("viem");
|
|
8063
8067
|
var import_ts_essentials22 = __toESM(require_dist(), 1);
|
|
8064
8068
|
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
8065
8069
|
var SendPage = ({ token: _token }) => {
|
|
8066
|
-
const [overriddenToken, setOverriddenToken] = (0,
|
|
8070
|
+
const [overriddenToken, setOverriddenToken] = (0, import_react53.useState)(null);
|
|
8067
8071
|
const token = overriddenToken ?? _token;
|
|
8068
8072
|
const { navigateBack } = usePortalNavigation();
|
|
8069
8073
|
const { openModal } = usePortalModals();
|
|
@@ -8107,11 +8111,11 @@ var SendPage = ({ token: _token }) => {
|
|
|
8107
8111
|
token,
|
|
8108
8112
|
accountAddress: account
|
|
8109
8113
|
});
|
|
8110
|
-
const encryptionProgressLabel = (0,
|
|
8111
|
-
const [amount, setAmount] = (0,
|
|
8112
|
-
const [recipientAddress, setRecipientAddress] = (0,
|
|
8113
|
-
const [error, setError] = (0,
|
|
8114
|
-
const [success, setSuccess] = (0,
|
|
8114
|
+
const encryptionProgressLabel = (0, import_react53.useMemo)(() => lastStep?.step && getStepConfig(lastStep).label, [lastStep]);
|
|
8115
|
+
const [amount, setAmount] = (0, import_react53.useState)("");
|
|
8116
|
+
const [recipientAddress, setRecipientAddress] = (0, import_react53.useState)("");
|
|
8117
|
+
const [error, setError] = (0, import_react53.useState)(null);
|
|
8118
|
+
const [success, setSuccess] = (0, import_react53.useState)(null);
|
|
8115
8119
|
const isValidAddress2 = (0, import_viem23.isAddress)(recipientAddress);
|
|
8116
8120
|
const isValidAmount = (amount.length > 0 && confidentialUnitBalance && confidentialUnitBalance.gte(amount)) ?? false;
|
|
8117
8121
|
const handleSend = async () => {
|
|
@@ -8260,15 +8264,15 @@ var import_ArrowBack8 = __toESM(require("@mui/icons-material/ArrowBack"), 1);
|
|
|
8260
8264
|
var import_KeyboardArrowDown = __toESM(require("@mui/icons-material/KeyboardArrowDown"), 1);
|
|
8261
8265
|
var import_tb4 = require("react-icons/tb");
|
|
8262
8266
|
var import_lu2 = require("react-icons/lu");
|
|
8263
|
-
var
|
|
8267
|
+
var import_react55 = require("react");
|
|
8264
8268
|
var import_viem24 = require("viem");
|
|
8265
8269
|
var import_ts_essentials23 = __toESM(require_dist(), 1);
|
|
8266
8270
|
|
|
8267
8271
|
// src/hooks/useIsUnshieldingMining.ts
|
|
8268
|
-
var
|
|
8272
|
+
var import_react54 = require("react");
|
|
8269
8273
|
function useIsUnshieldingMining(token) {
|
|
8270
8274
|
const account = useCofheAccount();
|
|
8271
|
-
const filter3 = (0,
|
|
8275
|
+
const filter3 = (0, import_react54.useCallback)(
|
|
8272
8276
|
(tx) => {
|
|
8273
8277
|
return tx.token.address === token.address && tx.actionType === "unshield" /* Unshield */ && tx.status === "pending" /* Pending */;
|
|
8274
8278
|
},
|
|
@@ -8287,8 +8291,8 @@ var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
|
8287
8291
|
var AUTOCLEAR_TX_STATUS_TIMEOUT = 5e3;
|
|
8288
8292
|
var DISPLAY_DECIMALS = 5;
|
|
8289
8293
|
function useLifecycleStore() {
|
|
8290
|
-
const [error, setError] = (0,
|
|
8291
|
-
const [status, setStatus] = (0,
|
|
8294
|
+
const [error, setError] = (0, import_react55.useState)(null);
|
|
8295
|
+
const [status, setStatus] = (0, import_react55.useState)(null);
|
|
8292
8296
|
return {
|
|
8293
8297
|
error,
|
|
8294
8298
|
setError,
|
|
@@ -8390,7 +8394,7 @@ function useClaimUnshieldedWithLifecycle() {
|
|
|
8390
8394
|
function useShieldWithLifecycle(token) {
|
|
8391
8395
|
const account = useCofheAccount();
|
|
8392
8396
|
const chainId = useCofheChainId();
|
|
8393
|
-
const [shieldAmount, setShieldAmount] = (0,
|
|
8397
|
+
const [shieldAmount, setShieldAmount] = (0, import_react55.useState)("");
|
|
8394
8398
|
const { setError, setStatus, error, status } = useLifecycleStore();
|
|
8395
8399
|
const { schedule: scheduleStatusClear } = useReschedulableTimeout(() => setStatus(null), AUTOCLEAR_TX_STATUS_TIMEOUT);
|
|
8396
8400
|
const tokenShield = useCofheTokenShield({
|
|
@@ -8471,7 +8475,7 @@ function useShieldWithLifecycle(token) {
|
|
|
8471
8475
|
if (publicBalanceUnit) setShieldAmount(publicBalanceUnit.toFixed());
|
|
8472
8476
|
};
|
|
8473
8477
|
const isValidShieldAmount = (shieldAmount.length > 0 && publicBalanceUnit?.gte(shieldAmount)) ?? false;
|
|
8474
|
-
const shieldAmountWei = (0,
|
|
8478
|
+
const shieldAmountWei = (0, import_react55.useMemo)(() => {
|
|
8475
8479
|
if (!isValidShieldAmount) return void 0;
|
|
8476
8480
|
try {
|
|
8477
8481
|
return unitToWei(shieldAmount, token.decimals);
|
|
@@ -8479,7 +8483,7 @@ function useShieldWithLifecycle(token) {
|
|
|
8479
8483
|
return void 0;
|
|
8480
8484
|
}
|
|
8481
8485
|
}, [isValidShieldAmount, shieldAmount, token.decimals]);
|
|
8482
|
-
const shieldTxCallArgs = (0,
|
|
8486
|
+
const shieldTxCallArgs = (0, import_react55.useMemo)(() => {
|
|
8483
8487
|
if (!account || !shieldAmountWei) return void 0;
|
|
8484
8488
|
return getCofheTokenShieldCallArgs({ token, amount: shieldAmountWei, account });
|
|
8485
8489
|
}, [account, shieldAmountWei, token]);
|
|
@@ -8506,7 +8510,7 @@ function useShieldWithLifecycle(token) {
|
|
|
8506
8510
|
const shieldSimulation = useCofheSimulateWriteContract(shieldCallArgs, {
|
|
8507
8511
|
enabled: !!shieldCallArgs && !shouldApprove
|
|
8508
8512
|
});
|
|
8509
|
-
const simulationError = (0,
|
|
8513
|
+
const simulationError = (0, import_react55.useMemo)(() => {
|
|
8510
8514
|
const relevantError = shouldApprove ? approvalSimulation.error : shieldSimulation.error;
|
|
8511
8515
|
if (!relevantError) return null;
|
|
8512
8516
|
const cofheErrorMessage = cofheHumanizeViemError(relevantError);
|
|
@@ -8539,7 +8543,7 @@ function useUnshieldWithLifecycle(token) {
|
|
|
8539
8543
|
const chainId = useCofheChainId();
|
|
8540
8544
|
const { setError, setStatus, error, status } = useLifecycleStore();
|
|
8541
8545
|
const { schedule: scheduleStatusClear } = useReschedulableTimeout(() => setStatus(null), AUTOCLEAR_TX_STATUS_TIMEOUT);
|
|
8542
|
-
const [unshieldAmount, setUnshieldAmount] = (0,
|
|
8546
|
+
const [unshieldAmount, setUnshieldAmount] = (0, import_react55.useState)("");
|
|
8543
8547
|
const tokenUnshield = useCofheTokenUnshield({
|
|
8544
8548
|
onUserSignatureRequest: (hash) => {
|
|
8545
8549
|
() => {
|
|
@@ -8602,7 +8606,7 @@ function useUnshieldWithLifecycle(token) {
|
|
|
8602
8606
|
if (confidentialBalanceUnit) setUnshieldAmount(confidentialBalanceUnit.toFixed());
|
|
8603
8607
|
};
|
|
8604
8608
|
const isValidUnshieldAmount = (unshieldAmount.length > 0 && confidentialBalanceUnit?.gte(unshieldAmount)) ?? false;
|
|
8605
|
-
const unshieldCallArgs = (0,
|
|
8609
|
+
const unshieldCallArgs = (0, import_react55.useMemo)(() => {
|
|
8606
8610
|
if (!account || !isValidUnshieldAmount) return void 0;
|
|
8607
8611
|
const amountWei = (0, import_viem24.parseUnits)(unshieldAmount, token.decimals);
|
|
8608
8612
|
return getCofheTokenUnshieldCallArgs({ token, amount: amountWei, account });
|
|
@@ -8610,7 +8614,7 @@ function useUnshieldWithLifecycle(token) {
|
|
|
8610
8614
|
const unshieldSimulation = useCofheSimulateWriteContract(unshieldCallArgs, {
|
|
8611
8615
|
enabled: !!unshieldCallArgs
|
|
8612
8616
|
});
|
|
8613
|
-
const simulationError = (0,
|
|
8617
|
+
const simulationError = (0, import_react55.useMemo)(
|
|
8614
8618
|
() => humanizeSimulationError(unshieldSimulation.error, "Failed to simulate unshield transaction"),
|
|
8615
8619
|
[unshieldSimulation.error]
|
|
8616
8620
|
);
|
|
@@ -8634,8 +8638,8 @@ function useUnshieldWithLifecycle(token) {
|
|
|
8634
8638
|
}
|
|
8635
8639
|
var shieldableTypes = /* @__PURE__ */ new Set(["dual", "wrapped"]);
|
|
8636
8640
|
var ShieldPageV2 = ({ token: _token, defaultMode }) => {
|
|
8637
|
-
const [mode, setMode] = (0,
|
|
8638
|
-
const [overriddenToken, setOverriddenToken] = (0,
|
|
8641
|
+
const [mode, setMode] = (0, import_react55.useState)(defaultMode ?? "shield");
|
|
8642
|
+
const [overriddenToken, setOverriddenToken] = (0, import_react55.useState)(null);
|
|
8639
8643
|
const token = overriddenToken ?? _token;
|
|
8640
8644
|
return mode === "shield" ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(ShieldTab, { token, mode, setMode, setToken: setOverriddenToken }) : /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(UnshieldTab, { token, mode, setMode, setToken: setOverriddenToken });
|
|
8641
8645
|
};
|
|
@@ -8682,14 +8686,14 @@ function ClaimingSection({ token }) {
|
|
|
8682
8686
|
});
|
|
8683
8687
|
};
|
|
8684
8688
|
const isUnshieldingMining = useIsUnshieldingMining(token);
|
|
8685
|
-
const claimCallArgs = (0,
|
|
8689
|
+
const claimCallArgs = (0, import_react55.useMemo)(() => {
|
|
8686
8690
|
if (!account || !unshieldedClaims?.hasClaimable) return void 0;
|
|
8687
8691
|
return getCofheTokenClaimUnshieldedCallArgs({ token, account });
|
|
8688
8692
|
}, [account, token, unshieldedClaims?.hasClaimable]);
|
|
8689
8693
|
const claimSimulation = useCofheSimulateWriteContract(claimCallArgs, {
|
|
8690
8694
|
enabled: !!claimCallArgs
|
|
8691
8695
|
});
|
|
8692
|
-
const claimSimulationError = (0,
|
|
8696
|
+
const claimSimulationError = (0, import_react55.useMemo)(
|
|
8693
8697
|
() => humanizeSimulationError(claimSimulation.error, "Failed to simulate claim transaction"),
|
|
8694
8698
|
[claimSimulation.error]
|
|
8695
8699
|
);
|
|
@@ -8967,7 +8971,7 @@ var ActivityPage = () => {
|
|
|
8967
8971
|
|
|
8968
8972
|
// src/components/FnxFloatingButton/pages/DebugPage.tsx
|
|
8969
8973
|
var import_ArrowBack10 = __toESM(require("@mui/icons-material/ArrowBack"), 1);
|
|
8970
|
-
var
|
|
8974
|
+
var import_react56 = require("react");
|
|
8971
8975
|
var import_accounts = require("viem/accounts");
|
|
8972
8976
|
var import_viem25 = require("viem");
|
|
8973
8977
|
var import_jsx_runtime51 = require("react/jsx-runtime");
|
|
@@ -8976,8 +8980,8 @@ var DebugPage = () => {
|
|
|
8976
8980
|
const { statuses, addStatus, removeStatus } = usePortalStatuses();
|
|
8977
8981
|
const { addToast } = usePortalToasts();
|
|
8978
8982
|
const { openModal } = usePortalModals();
|
|
8979
|
-
const [modalSelection, setModalSelection] = (0,
|
|
8980
|
-
const [activeTab, setActiveTab] = (0,
|
|
8983
|
+
const [modalSelection, setModalSelection] = (0, import_react56.useState)(void 0);
|
|
8984
|
+
const [activeTab, setActiveTab] = (0, import_react56.useState)("modal");
|
|
8981
8985
|
return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
8982
8986
|
PageContainer,
|
|
8983
8987
|
{
|
|
@@ -9381,6 +9385,9 @@ var import_KeyboardArrowRight3 = __toESM(require("@mui/icons-material/KeyboardAr
|
|
|
9381
9385
|
var import_chains4 = require("@cofhe/sdk/chains");
|
|
9382
9386
|
var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
9383
9387
|
var TokenRow = ({ token, onClick, topLabel, balanceType }) => {
|
|
9388
|
+
const publicSymbol = token.extensions.fhenix.erc20Pair?.symbol ?? token.symbol;
|
|
9389
|
+
const destinationSymbol = token.symbol;
|
|
9390
|
+
const showDestination = balanceType === "public" /* Public */ && !!publicSymbol && !!destinationSymbol && publicSymbol !== destinationSymbol;
|
|
9384
9391
|
const account = useCofheAccount();
|
|
9385
9392
|
const { data: confidentialBalance } = useCofheTokenDecryptedBalance(
|
|
9386
9393
|
{
|
|
@@ -9416,7 +9423,11 @@ var TokenRow = ({ token, onClick, topLabel, balanceType }) => {
|
|
|
9416
9423
|
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(TokenIcon, { logoURI: token.logoURI, alt: token.name, size: "sm" }),
|
|
9417
9424
|
/* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { className: "min-w-0 flex-1", children: [
|
|
9418
9425
|
topLabel && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: "text-xxxs opacity-70 fnx-text-primary leading-none", children: topLabel }),
|
|
9419
|
-
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: "text-sm font-medium fnx-text-primary truncate leading-tight", children: balanceType === "confidential" /* Confidential */ ? token.symbol :
|
|
9426
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: "text-sm font-medium fnx-text-primary truncate leading-tight", children: balanceType === "confidential" /* Confidential */ ? token.symbol : publicSymbol }),
|
|
9427
|
+
showDestination && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { className: "text-xxxs opacity-70 fnx-text-primary truncate leading-tight", children: [
|
|
9428
|
+
"\u2192 ",
|
|
9429
|
+
destinationSymbol
|
|
9430
|
+
] })
|
|
9420
9431
|
] })
|
|
9421
9432
|
] }),
|
|
9422
9433
|
/* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { className: "flex items-center gap-2 flex-shrink-0", children: [
|
|
@@ -9557,7 +9568,7 @@ var PortfolioPage = () => {
|
|
|
9557
9568
|
|
|
9558
9569
|
// src/components/FnxFloatingButton/pages/ClaimableTokens.tsx
|
|
9559
9570
|
var import_ArrowBack13 = __toESM(require("@mui/icons-material/ArrowBack"), 1);
|
|
9560
|
-
var
|
|
9571
|
+
var import_react57 = require("react");
|
|
9561
9572
|
var import_ts_essentials24 = __toESM(require_dist(), 1);
|
|
9562
9573
|
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
9563
9574
|
function ClaimableTokens() {
|
|
@@ -9570,7 +9581,7 @@ function ClaimableTokens() {
|
|
|
9570
9581
|
const chainId = useCofheChainId();
|
|
9571
9582
|
const allTokens = useCofheTokens(chainId);
|
|
9572
9583
|
const claimMutation = useCofheTokenClaimUnshielded();
|
|
9573
|
-
const rows = (0,
|
|
9584
|
+
const rows = (0, import_react57.useMemo)(() => {
|
|
9574
9585
|
const byLower = new Map(allTokens.map((t) => [t.address.toLowerCase(), t]));
|
|
9575
9586
|
return Object.entries(claimableByTokenAddress).filter(([_t, amount]) => amount > 0n).map(([tokenAddress, claimableAmount]) => {
|
|
9576
9587
|
const token = byLower.get(tokenAddress.toLowerCase());
|
|
@@ -9657,7 +9668,7 @@ var pages = {
|
|
|
9657
9668
|
};
|
|
9658
9669
|
|
|
9659
9670
|
// src/components/FnxFloatingButton/ContentSection.tsx
|
|
9660
|
-
var
|
|
9671
|
+
var import_react60 = require("motion/react");
|
|
9661
9672
|
|
|
9662
9673
|
// src/components/FnxFloatingButton/modals/ExampleSelectionPage.tsx
|
|
9663
9674
|
var import_Close2 = __toESM(require("@mui/icons-material/Close"), 1);
|
|
@@ -9720,7 +9731,7 @@ var ExampleInfoPage = ({ onClose }) => {
|
|
|
9720
9731
|
// src/components/FnxFloatingButton/modals/PermitDetailsModal.tsx
|
|
9721
9732
|
var import_fa64 = require("react-icons/fa6");
|
|
9722
9733
|
var import_Close4 = __toESM(require("@mui/icons-material/Close"), 1);
|
|
9723
|
-
var
|
|
9734
|
+
var import_react58 = require("react");
|
|
9724
9735
|
var import_jsx_runtime58 = require("react/jsx-runtime");
|
|
9725
9736
|
var PermitTypeLabel2 = {
|
|
9726
9737
|
self: "Self",
|
|
@@ -9749,15 +9760,15 @@ var PermitDetailsModal = ({ hash, onClose }) => {
|
|
|
9749
9760
|
isCopyComplete
|
|
9750
9761
|
} = usePermitDetailsAndActions(hash);
|
|
9751
9762
|
const { openModal } = usePortalModals();
|
|
9752
|
-
const [confirmDelete, setConfirmDelete] = (0,
|
|
9753
|
-
const handlePermitSelect = (0,
|
|
9763
|
+
const [confirmDelete, setConfirmDelete] = (0, import_react58.useState)(false);
|
|
9764
|
+
const handlePermitSelect = (0, import_react58.useCallback)(() => {
|
|
9754
9765
|
handleSelectActivePermit();
|
|
9755
9766
|
onClose();
|
|
9756
9767
|
}, [handleSelectActivePermit, onClose]);
|
|
9757
|
-
const handlePermitShare = (0,
|
|
9768
|
+
const handlePermitShare = (0, import_react58.useCallback)(() => {
|
|
9758
9769
|
handleCopySharablePermitData();
|
|
9759
9770
|
}, [handleCopySharablePermitData]);
|
|
9760
|
-
const handlePermitDelete = (0,
|
|
9771
|
+
const handlePermitDelete = (0, import_react58.useCallback)(async () => {
|
|
9761
9772
|
if (!confirmDelete) {
|
|
9762
9773
|
setConfirmDelete(true);
|
|
9763
9774
|
return;
|
|
@@ -9933,8 +9944,8 @@ var modals = {
|
|
|
9933
9944
|
var import_jsx_runtime62 = require("react/jsx-runtime");
|
|
9934
9945
|
var MeasuredContentRenderer = ({ children, id, isModal, onModalOverlayClick }) => {
|
|
9935
9946
|
const { setContentHeight, removeContentHeight } = usePortalUI();
|
|
9936
|
-
const contentRef = (0,
|
|
9937
|
-
(0,
|
|
9947
|
+
const contentRef = (0, import_react59.useRef)(null);
|
|
9948
|
+
(0, import_react59.useEffect)(() => {
|
|
9938
9949
|
if (!contentRef.current) return;
|
|
9939
9950
|
const observer = new ResizeObserver((entries) => {
|
|
9940
9951
|
for (const entry of entries) {
|
|
@@ -9964,7 +9975,7 @@ var MeasuredContentRenderer = ({ children, id, isModal, onModalOverlayClick }) =
|
|
|
9964
9975
|
] });
|
|
9965
9976
|
};
|
|
9966
9977
|
var ContentRenderer = ({ page }) => {
|
|
9967
|
-
const content = (0,
|
|
9978
|
+
const content = (0, import_react59.useMemo)(() => {
|
|
9968
9979
|
const PageComp = pages[page.page];
|
|
9969
9980
|
const props = page.props ?? {};
|
|
9970
9981
|
return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(PageComp, { ...props });
|
|
@@ -9972,7 +9983,7 @@ var ContentRenderer = ({ page }) => {
|
|
|
9972
9983
|
return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(MeasuredContentRenderer, { id: "content", children: content });
|
|
9973
9984
|
};
|
|
9974
9985
|
var ModalRenderer = ({ modal }) => {
|
|
9975
|
-
const content = (0,
|
|
9986
|
+
const content = (0, import_react59.useMemo)(() => {
|
|
9976
9987
|
const ModalComp = modals[modal.modal];
|
|
9977
9988
|
return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(ModalComp, { ...modal });
|
|
9978
9989
|
}, [modal]);
|
|
@@ -9985,8 +9996,8 @@ var ContentSection = ({ overriddingPage }) => {
|
|
|
9985
9996
|
const maxContentHeight = usePortalUIMaxContentHeight();
|
|
9986
9997
|
const currentPage = usePortalCurrentPage();
|
|
9987
9998
|
const pageOrOverridingPage = overriddingPage ?? currentPage;
|
|
9988
|
-
return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
|
|
9989
|
-
|
|
9999
|
+
return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_react60.AnimatePresence, { children: contentPanelOpen && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
|
|
10000
|
+
import_react60.motion.div,
|
|
9990
10001
|
{
|
|
9991
10002
|
className: "relative flex w-full z-50",
|
|
9992
10003
|
initial: { opacity: 0, y: isTopSide ? -10 : 10 },
|
|
@@ -10003,13 +10014,13 @@ var ContentSection = ({ overriddingPage }) => {
|
|
|
10003
10014
|
};
|
|
10004
10015
|
|
|
10005
10016
|
// src/components/FnxFloatingButton/ToastsSection.tsx
|
|
10006
|
-
var
|
|
10007
|
-
var
|
|
10017
|
+
var import_react61 = require("react");
|
|
10018
|
+
var import_react62 = require("motion/react");
|
|
10008
10019
|
var import_jsx_runtime63 = require("react/jsx-runtime");
|
|
10009
10020
|
var ToastClearer = ({ id, paused, remainingMs }) => {
|
|
10010
10021
|
const { removeToast } = usePortalToasts();
|
|
10011
|
-
const timerRef = (0,
|
|
10012
|
-
(0,
|
|
10022
|
+
const timerRef = (0, import_react61.useRef)(null);
|
|
10023
|
+
(0, import_react61.useEffect)(() => {
|
|
10013
10024
|
if (remainingMs <= 0) {
|
|
10014
10025
|
removeToast(id);
|
|
10015
10026
|
return;
|
|
@@ -10038,7 +10049,7 @@ var ToastComponent = ({ id, duration, paused, startMs, remainingMs, content }) =
|
|
|
10038
10049
|
const handleDismiss = () => {
|
|
10039
10050
|
removeToast(id);
|
|
10040
10051
|
};
|
|
10041
|
-
const injectedContent = (0,
|
|
10052
|
+
const injectedContent = (0, import_react61.isValidElement)(content) ? (0, import_react61.cloneElement)(content, {
|
|
10042
10053
|
id,
|
|
10043
10054
|
paused,
|
|
10044
10055
|
startMs,
|
|
@@ -10049,7 +10060,7 @@ var ToastComponent = ({ id, duration, paused, startMs, remainingMs, content }) =
|
|
|
10049
10060
|
...content.props
|
|
10050
10061
|
}) : content;
|
|
10051
10062
|
return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(
|
|
10052
|
-
|
|
10063
|
+
import_react62.motion.div,
|
|
10053
10064
|
{
|
|
10054
10065
|
initial: { opacity: 0, y: isTopSide ? -4 : 4 },
|
|
10055
10066
|
animate: { opacity: 1, y: 0 },
|
|
@@ -10066,7 +10077,7 @@ var ToastComponent = ({ id, duration, paused, startMs, remainingMs, content }) =
|
|
|
10066
10077
|
};
|
|
10067
10078
|
var ToastsSection = () => {
|
|
10068
10079
|
const { toasts } = usePortalToasts();
|
|
10069
|
-
return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { className: "flex flex-col gap-3 w-full max-w-full", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
10080
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { className: "flex flex-col gap-3 w-full max-w-full", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_react62.AnimatePresence, { children: toasts.map((toast) => /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(ToastComponent, { ...toast }, toast.id)) }) });
|
|
10070
10081
|
};
|
|
10071
10082
|
|
|
10072
10083
|
// src/components/FnxFloatingButton/FnxFloatingButtonBase.tsx
|
|
@@ -10140,6 +10151,31 @@ var import_zod = require("zod");
|
|
|
10140
10151
|
var import_sdk10 = require("@cofhe/sdk");
|
|
10141
10152
|
var import_web2 = require("@cofhe/sdk/web");
|
|
10142
10153
|
var import_viem26 = require("viem");
|
|
10154
|
+
var noopCofheReactLoggerMethod2 = (..._args) => {
|
|
10155
|
+
};
|
|
10156
|
+
var NOOP_COFHE_REACT_LOGGER = {
|
|
10157
|
+
log: noopCofheReactLoggerMethod2,
|
|
10158
|
+
warn: noopCofheReactLoggerMethod2,
|
|
10159
|
+
debug: noopCofheReactLoggerMethod2,
|
|
10160
|
+
error: noopCofheReactLoggerMethod2
|
|
10161
|
+
};
|
|
10162
|
+
function resolveLoggerMethod(method) {
|
|
10163
|
+
return typeof method === "function" ? method : noopCofheReactLoggerMethod2;
|
|
10164
|
+
}
|
|
10165
|
+
function resolveCofheReactLogger(logger) {
|
|
10166
|
+
if (logger === null || logger === void 0) return NOOP_COFHE_REACT_LOGGER;
|
|
10167
|
+
if (typeof logger !== "object") return NOOP_COFHE_REACT_LOGGER;
|
|
10168
|
+
const obj = logger;
|
|
10169
|
+
return {
|
|
10170
|
+
log: resolveLoggerMethod(obj.log),
|
|
10171
|
+
warn: resolveLoggerMethod(obj.warn),
|
|
10172
|
+
debug: resolveLoggerMethod(obj.debug),
|
|
10173
|
+
error: resolveLoggerMethod(obj.error)
|
|
10174
|
+
};
|
|
10175
|
+
}
|
|
10176
|
+
var CofheReactLoggerSchema = import_zod.z.custom((value) => value === null || typeof value === "object" && value !== null, {
|
|
10177
|
+
error: "Invalid logger"
|
|
10178
|
+
}).optional().default(null).transform((value) => resolveCofheReactLogger(value));
|
|
10143
10179
|
var addressSchema = import_zod.z.string().refine((val) => (0, import_viem26.isAddress)(val), {
|
|
10144
10180
|
error: "Invalid address"
|
|
10145
10181
|
}).refine((val) => val !== import_viem26.zeroAddress, {
|
|
@@ -10149,6 +10185,7 @@ var CofheReactConfigSchema = import_zod.z.object({
|
|
|
10149
10185
|
shareablePermits: import_zod.z.boolean().optional().default(false),
|
|
10150
10186
|
enableShieldUnshield: import_zod.z.boolean().optional().default(true),
|
|
10151
10187
|
autogeneratePermits: import_zod.z.boolean().optional().default(true),
|
|
10188
|
+
logger: CofheReactLoggerSchema,
|
|
10152
10189
|
permitExpirationOptions: import_zod.z.array(
|
|
10153
10190
|
import_zod.z.object({
|
|
10154
10191
|
label: import_zod.z.string(),
|
|
@@ -10178,6 +10215,7 @@ function createCofheConfig(config) {
|
|
|
10178
10215
|
cause: reactConfigResult.error
|
|
10179
10216
|
});
|
|
10180
10217
|
}
|
|
10218
|
+
setReactLogger(reactConfigResult.data.logger);
|
|
10181
10219
|
return {
|
|
10182
10220
|
...webClientConfig,
|
|
10183
10221
|
react: reactConfigResult.data
|
|
@@ -10188,20 +10226,20 @@ function createCofheConfig(config) {
|
|
|
10188
10226
|
var import_chains5 = require("@cofhe/sdk/chains");
|
|
10189
10227
|
var import_ts_essentials25 = __toESM(require_dist(), 1);
|
|
10190
10228
|
var import_jsx_runtime66 = require("react/jsx-runtime");
|
|
10191
|
-
var CofheContext = (0,
|
|
10229
|
+
var CofheContext = (0, import_react63.createContext)(void 0);
|
|
10192
10230
|
function CofheProvider(props) {
|
|
10193
10231
|
const { children, queryClient, publicClient, walletClient } = props;
|
|
10194
|
-
const config = (0,
|
|
10232
|
+
const config = (0, import_react63.useMemo)(() => {
|
|
10195
10233
|
if (props.config) return props.config;
|
|
10196
10234
|
if (props.cofheClient) {
|
|
10197
|
-
(0, import_ts_essentials25.assert)(config.environment === "react", "Provided cofheClient must have react config");
|
|
10235
|
+
(0, import_ts_essentials25.assert)(props.cofheClient.config.environment === "react", "Provided cofheClient must have react config");
|
|
10198
10236
|
return props.cofheClient.config;
|
|
10199
10237
|
}
|
|
10200
10238
|
return createCofheConfig({ supportedChains: Object.values(import_chains5.chains) });
|
|
10201
10239
|
}, [props.config, props.cofheClient]);
|
|
10202
|
-
const cofheClient = (0,
|
|
10203
|
-
const [position, setPosition] = (0,
|
|
10204
|
-
const [theme, setTheme] = (0,
|
|
10240
|
+
const cofheClient = (0, import_react63.useMemo)(() => props.cofheClient ?? (0, import_web3.createCofheClient)(config), [props.cofheClient, config]);
|
|
10241
|
+
const [position, setPosition] = (0, import_react63.useState)(config.react.position);
|
|
10242
|
+
const [theme, setTheme] = (0, import_react63.useState)(config.react.initialTheme);
|
|
10205
10243
|
return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
10206
10244
|
CofheContext.Provider,
|
|
10207
10245
|
{
|
|
@@ -10226,7 +10264,7 @@ function AutoConnect({ walletClient, publicClient }) {
|
|
|
10226
10264
|
return null;
|
|
10227
10265
|
}
|
|
10228
10266
|
function useCofheContext() {
|
|
10229
|
-
const context = (0,
|
|
10267
|
+
const context = (0, import_react63.useContext)(CofheContext);
|
|
10230
10268
|
if (context === void 0) {
|
|
10231
10269
|
throw new Error("useCofheContext must be used within a CofheProvider");
|
|
10232
10270
|
}
|
|
@@ -10234,7 +10272,7 @@ function useCofheContext() {
|
|
|
10234
10272
|
}
|
|
10235
10273
|
|
|
10236
10274
|
// src/components/FnxEncryptInput.tsx
|
|
10237
|
-
var
|
|
10275
|
+
var import_react64 = require("react");
|
|
10238
10276
|
var import_Security = __toESM(require("@mui/icons-material/Security"), 1);
|
|
10239
10277
|
var import_KeyboardArrowDown2 = __toESM(require("@mui/icons-material/KeyboardArrowDown"), 1);
|
|
10240
10278
|
var import_ContentCopy = __toESM(require("@mui/icons-material/ContentCopy"), 1);
|
|
@@ -10260,30 +10298,30 @@ var FnxEncryptInput = ({
|
|
|
10260
10298
|
onEncryptComplete,
|
|
10261
10299
|
onEncryptError
|
|
10262
10300
|
}) => {
|
|
10263
|
-
const [textValue, setTextValue] = (0,
|
|
10264
|
-
const [selectedType, setSelectedType] = (0,
|
|
10265
|
-
const [isDropdownOpen, setIsDropdownOpen] = (0,
|
|
10266
|
-
const [showProgress, setShowProgress] = (0,
|
|
10267
|
-
const [encryptedResult, setEncryptedResult] = (0,
|
|
10268
|
-
const [copySuccess, setCopySuccess] = (0,
|
|
10269
|
-
const dropdownRef = (0,
|
|
10301
|
+
const [textValue, setTextValue] = (0, import_react64.useState)(initialValue);
|
|
10302
|
+
const [selectedType, setSelectedType] = (0, import_react64.useState)(options[0]?.value || "uint32");
|
|
10303
|
+
const [isDropdownOpen, setIsDropdownOpen] = (0, import_react64.useState)(false);
|
|
10304
|
+
const [showProgress, setShowProgress] = (0, import_react64.useState)(false);
|
|
10305
|
+
const [encryptedResult, setEncryptedResult] = (0, import_react64.useState)(null);
|
|
10306
|
+
const [copySuccess, setCopySuccess] = (0, import_react64.useState)(false);
|
|
10307
|
+
const dropdownRef = (0, import_react64.useRef)(null);
|
|
10270
10308
|
const {
|
|
10271
10309
|
encryptInputsAsync: encrypt,
|
|
10272
10310
|
isEncrypting,
|
|
10273
10311
|
stepsState: { lastStep: lastEncryptionStep }
|
|
10274
10312
|
} = useCofheEncrypt();
|
|
10275
|
-
const { progress: encryptionProgress, label: encryptionProgressLabel } = (0,
|
|
10313
|
+
const { progress: encryptionProgress, label: encryptionProgressLabel } = (0, import_react64.useMemo)(() => {
|
|
10276
10314
|
return lastEncryptionStep ? getStepConfig(lastEncryptionStep) : {
|
|
10277
10315
|
progress: void 0,
|
|
10278
10316
|
label: void 0
|
|
10279
10317
|
};
|
|
10280
10318
|
}, [lastEncryptionStep]);
|
|
10281
|
-
const debouncedValidation = (0,
|
|
10319
|
+
const debouncedValidation = (0, import_react64.useRef)(
|
|
10282
10320
|
debounce((value) => {
|
|
10283
|
-
|
|
10321
|
+
cofheLogger.log("Debounced validation for:", value);
|
|
10284
10322
|
}, debounceMs)
|
|
10285
10323
|
).current;
|
|
10286
|
-
(0,
|
|
10324
|
+
(0, import_react64.useEffect)(() => {
|
|
10287
10325
|
if (showProgressBar && isEncrypting) {
|
|
10288
10326
|
setShowProgress(true);
|
|
10289
10327
|
} else if (!isEncrypting) {
|
|
@@ -10291,7 +10329,7 @@ var FnxEncryptInput = ({
|
|
|
10291
10329
|
return () => clearTimeout(timer);
|
|
10292
10330
|
}
|
|
10293
10331
|
}, [showProgressBar, isEncrypting]);
|
|
10294
|
-
(0,
|
|
10332
|
+
(0, import_react64.useEffect)(() => {
|
|
10295
10333
|
if (isEncrypting && lastEncryptionStep && encryptionProgress && encryptionProgressLabel) {
|
|
10296
10334
|
onEncryptProgress?.({
|
|
10297
10335
|
step: lastEncryptionStep.step,
|
|
@@ -10300,7 +10338,7 @@ var FnxEncryptInput = ({
|
|
|
10300
10338
|
});
|
|
10301
10339
|
}
|
|
10302
10340
|
}, [encryptionProgress, encryptionProgressLabel, onEncryptProgress, isEncrypting, lastEncryptionStep]);
|
|
10303
|
-
(0,
|
|
10341
|
+
(0, import_react64.useEffect)(() => {
|
|
10304
10342
|
const handleClickOutside = (event) => {
|
|
10305
10343
|
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
10306
10344
|
setIsDropdownOpen(false);
|
|
@@ -10403,7 +10441,7 @@ var FnxEncryptInput = ({
|
|
|
10403
10441
|
2
|
|
10404
10442
|
);
|
|
10405
10443
|
await navigator.clipboard.writeText(textToCopy);
|
|
10406
|
-
|
|
10444
|
+
cofheLogger.log("Copied to clipboard:", textToCopy);
|
|
10407
10445
|
setCopySuccess(true);
|
|
10408
10446
|
setTimeout(() => {
|
|
10409
10447
|
setCopySuccess(false);
|
|
@@ -10418,7 +10456,7 @@ var FnxEncryptInput = ({
|
|
|
10418
10456
|
onTypeChange?.(type);
|
|
10419
10457
|
if (textValue.trim() !== "") {
|
|
10420
10458
|
try {
|
|
10421
|
-
|
|
10459
|
+
cofheLogger.log("Auto-encrypting value:", textValue, "as type:", type);
|
|
10422
10460
|
onEncryptStart?.({ value: textValue, type });
|
|
10423
10461
|
(async () => {
|
|
10424
10462
|
try {
|
|
@@ -10564,8 +10602,6 @@ var import_web4 = require("@cofhe/sdk/web");
|
|
|
10564
10602
|
actionToString,
|
|
10565
10603
|
createCofheClient,
|
|
10566
10604
|
createCofheConfig,
|
|
10567
|
-
encryptedValueToString,
|
|
10568
|
-
fheTypeToString,
|
|
10569
10605
|
formatRelativeTime,
|
|
10570
10606
|
getBlockExplorerAddressUrl,
|
|
10571
10607
|
getBlockExplorerTokenUrl,
|
|
@@ -10584,6 +10620,7 @@ var import_web4 = require("@cofhe/sdk/web");
|
|
|
10584
10620
|
useCofheClient,
|
|
10585
10621
|
useCofheConnection,
|
|
10586
10622
|
useCofheContext,
|
|
10623
|
+
useCofheEnabled,
|
|
10587
10624
|
useCofheEncrypt,
|
|
10588
10625
|
useCofheEncryptAndWriteContract,
|
|
10589
10626
|
useCofheNavigateToCreatePermit,
|