@cmdoss/walrus-site-builder-react 2.4.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +130 -14
- package/dist/index.d.ts +65 -31
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +288 -111
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -4,10 +4,10 @@ import { ALLOWED_METADATA, SuinsClient, SuinsTransaction, mainPackage as mainPac
|
|
|
4
4
|
import { MAINNET_WALRUS_PACKAGE_CONFIG, TESTNET_WALRUS_PACKAGE_CONFIG } from "@mysten/walrus";
|
|
5
5
|
import { useStore } from "@nanostores/react";
|
|
6
6
|
import { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
7
|
-
import { useQueries, useQuery } from "@tanstack/react-query";
|
|
7
|
+
import { useMutation, useQueries, useQuery } from "@tanstack/react-query";
|
|
8
8
|
import { atom, computed } from "nanostores";
|
|
9
9
|
import * as Dialog from "@radix-ui/react-dialog";
|
|
10
|
-
import { AlertCircle, AlertTriangle, Calendar, CalendarClock, CheckCircle, CheckCircle2, Clock, ExternalLink, Globe2, Info, Link2, Loader2, Pencil, Search, Upload, X, XCircle } from "lucide-react";
|
|
10
|
+
import { AlertCircle, AlertTriangle, Calendar, CalendarClock, CheckCircle, CheckCircle2, Clock, DollarSign, ExternalLink, Globe2, Info, Link2, Loader2, Pencil, Search, Upload, X, XCircle } from "lucide-react";
|
|
11
11
|
import { AggregatorClient, Env } from "@cetusprotocol/aggregator-sdk";
|
|
12
12
|
import BN from "bn.js";
|
|
13
13
|
import { ZenFsFileManager } from "@cmdoss/file-manager";
|
|
@@ -1337,6 +1337,43 @@ function useSuiNsRegistration({ currentAccount, clients: { suiClient, queryClien
|
|
|
1337
1337
|
};
|
|
1338
1338
|
}
|
|
1339
1339
|
|
|
1340
|
+
//#endregion
|
|
1341
|
+
//#region src/hooks/useUpdateSiteMetadata.ts
|
|
1342
|
+
function useUpdateSiteMetadata({ siteId, clients: { suiClient, queryClient, walrusClient }, currentAccount, signAndExecuteTransaction, sponsorConfig }) {
|
|
1343
|
+
const network = suiClient.network;
|
|
1344
|
+
const sdk = useMemo(() => {
|
|
1345
|
+
if (!currentAccount || !suiClient || !walrusClient) return null;
|
|
1346
|
+
return new WalrusSiteBuilderSdk(walrusClient, suiClient, currentAccount.address, signAndExecuteTransaction, sponsorConfig);
|
|
1347
|
+
}, [
|
|
1348
|
+
currentAccount,
|
|
1349
|
+
suiClient,
|
|
1350
|
+
walrusClient,
|
|
1351
|
+
signAndExecuteTransaction,
|
|
1352
|
+
sponsorConfig
|
|
1353
|
+
]);
|
|
1354
|
+
const mutation = useMutation({
|
|
1355
|
+
mutationFn: async ({ siteName, metadata }) => {
|
|
1356
|
+
if (!sdk) throw new Error("SDK not initialized");
|
|
1357
|
+
return await sdk.updateSiteMetadata(siteId, siteName, metadata);
|
|
1358
|
+
},
|
|
1359
|
+
onSuccess: (digest) => {
|
|
1360
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.walrusSite(siteId) });
|
|
1361
|
+
if (currentAccount?.address) queryClient.invalidateQueries({ queryKey: queryKeys.walrusSites(currentAccount.address, network) });
|
|
1362
|
+
console.log("✅ Site metadata updated successfully:", digest);
|
|
1363
|
+
},
|
|
1364
|
+
onError: (error) => {
|
|
1365
|
+
console.error("❌ Failed to update site metadata:", error);
|
|
1366
|
+
}
|
|
1367
|
+
}, queryClient);
|
|
1368
|
+
return {
|
|
1369
|
+
updateSiteMetadata: mutation.mutateAsync,
|
|
1370
|
+
isUpdating: mutation.isPending,
|
|
1371
|
+
error: mutation.error,
|
|
1372
|
+
isSuccess: mutation.isSuccess,
|
|
1373
|
+
data: mutation.data
|
|
1374
|
+
};
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1340
1377
|
//#endregion
|
|
1341
1378
|
//#region src/hooks/useZenFsWorkspace.ts
|
|
1342
1379
|
function useZenFsWorkspace(workspaceDir = "/workspace", mountDir = "/workspace", queryClient) {
|
|
@@ -1361,6 +1398,27 @@ function useZenFsWorkspace(workspaceDir = "/workspace", mountDir = "/workspace",
|
|
|
1361
1398
|
};
|
|
1362
1399
|
}
|
|
1363
1400
|
|
|
1401
|
+
//#endregion
|
|
1402
|
+
//#region src/queries/storage-cost.query.ts
|
|
1403
|
+
function useStorageCostQuery(fileSize, epochs, clients) {
|
|
1404
|
+
const { walrusClient, queryClient } = clients;
|
|
1405
|
+
return useQuery({
|
|
1406
|
+
queryKey: queryKeys.storageCost(fileSize, epochs),
|
|
1407
|
+
queryFn: async () => {
|
|
1408
|
+
if (!walrusClient) throw new Error("Walrus client not available");
|
|
1409
|
+
if (fileSize === null) throw new Error("Invalid file size");
|
|
1410
|
+
const storageCost = await walrusClient.storageCost(fileSize, epochs);
|
|
1411
|
+
return {
|
|
1412
|
+
storageCost: storageCost.storageCost.toString(),
|
|
1413
|
+
writeCost: storageCost.writeCost.toString(),
|
|
1414
|
+
totalCost: storageCost.totalCost.toString()
|
|
1415
|
+
};
|
|
1416
|
+
},
|
|
1417
|
+
enabled: !!walrusClient && fileSize !== null && fileSize > 0 && epochs > 0,
|
|
1418
|
+
staleTime: 300 * 1e3
|
|
1419
|
+
}, queryClient);
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1364
1422
|
//#endregion
|
|
1365
1423
|
//#region ../../node_modules/.pnpm/@vanilla-extract+recipes@0.5.7_@vanilla-extract+css@1.18.0/node_modules/@vanilla-extract/recipes/dist/createRuntimeFn-166334d7.cjs.prod.js
|
|
1366
1424
|
var require_createRuntimeFn_166334d7_cjs_prod = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
@@ -2048,9 +2106,20 @@ const Stepper = ({ steps, currentStep, isLoading }) => {
|
|
|
2048
2106
|
var body$1 = "ExtendTimeDialog_body__1augvc0a";
|
|
2049
2107
|
var closeButton = "ExtendTimeDialog_closeButton__1augvc09";
|
|
2050
2108
|
var content$3 = "ExtendTimeDialog_content__1augvc02";
|
|
2109
|
+
var costContent = "ExtendTimeDialog_costContent__1augvc0u";
|
|
2110
|
+
var costDivider = "ExtendTimeDialog_costDivider__1augvc011";
|
|
2111
|
+
var costError = "ExtendTimeDialog_costError__1augvc0z";
|
|
2112
|
+
var costHeader = "ExtendTimeDialog_costHeader__1augvc0t";
|
|
2113
|
+
var costLabel = "ExtendTimeDialog_costLabel__1augvc0w";
|
|
2114
|
+
var costLoading = "ExtendTimeDialog_costLoading__1augvc0y";
|
|
2115
|
+
var costRow = "ExtendTimeDialog_costRow__1augvc0v";
|
|
2116
|
+
var costSection = "ExtendTimeDialog_costSection__1augvc0s";
|
|
2117
|
+
var costValue = "ExtendTimeDialog_costValue__1augvc0x";
|
|
2118
|
+
var costWarning = "ExtendTimeDialog_costWarning__1augvc010";
|
|
2051
2119
|
var dateInputWrapper = "ExtendTimeDialog_dateInputWrapper__1augvc0d";
|
|
2052
2120
|
var description$3 = "ExtendTimeDialog_description__1augvc08";
|
|
2053
2121
|
var errorText = "ExtendTimeDialog_errorText__1augvc0h";
|
|
2122
|
+
var estimatedBadge = "ExtendTimeDialog_estimatedBadge__1augvc015";
|
|
2054
2123
|
var fieldGroup = "ExtendTimeDialog_fieldGroup__1augvc0c";
|
|
2055
2124
|
var footer$1 = "ExtendTimeDialog_footer__1augvc0r";
|
|
2056
2125
|
var formSection = "ExtendTimeDialog_formSection__1augvc0b";
|
|
@@ -2080,6 +2149,7 @@ const ExtendTimeDialog = ({ siteId, currentAccount, clients: { suiClient, queryC
|
|
|
2080
2149
|
const [dateError, setDateError] = useState(null);
|
|
2081
2150
|
const [currentEpochsRemaining, setCurrentEpochsRemaining] = useState(null);
|
|
2082
2151
|
const [expirationDates, setExpirationDates] = useState(/* @__PURE__ */ new Map());
|
|
2152
|
+
const [totalFileSize, setTotalFileSize] = useState(null);
|
|
2083
2153
|
const { epochDurationMs, formatDate } = useEpochDuration(walrusClient);
|
|
2084
2154
|
const txExecutor = useTransactionExecutor({
|
|
2085
2155
|
suiClient,
|
|
@@ -2096,6 +2166,7 @@ const ExtendTimeDialog = ({ siteId, currentAccount, clients: { suiClient, queryC
|
|
|
2096
2166
|
try {
|
|
2097
2167
|
const blobType = await walrusClient.getBlobType();
|
|
2098
2168
|
const datesMap = /* @__PURE__ */ new Map();
|
|
2169
|
+
let totalSize = 0;
|
|
2099
2170
|
const stakingState = await walrusClient.stakingState();
|
|
2100
2171
|
const currentEpoch = Number(stakingState.epoch);
|
|
2101
2172
|
const epochDuration = Number(stakingState.epoch_duration);
|
|
@@ -2120,6 +2191,11 @@ const ExtendTimeDialog = ({ siteId, currentAccount, clients: { suiClient, queryC
|
|
|
2120
2191
|
const remainingEpochs = Number(storage.fields.end_epoch) - currentEpoch;
|
|
2121
2192
|
const expirationTime = Date.now() + remainingEpochs * epochDuration;
|
|
2122
2193
|
datesMap.set(blobId, new Date(expirationTime));
|
|
2194
|
+
const sizeField = fields.size;
|
|
2195
|
+
if (sizeField !== void 0) {
|
|
2196
|
+
const size = typeof sizeField === "string" ? Number(sizeField) : Number(sizeField);
|
|
2197
|
+
if (!Number.isNaN(size) && size > 0) totalSize += size;
|
|
2198
|
+
}
|
|
2123
2199
|
break;
|
|
2124
2200
|
}
|
|
2125
2201
|
}
|
|
@@ -2130,6 +2206,7 @@ const ExtendTimeDialog = ({ siteId, currentAccount, clients: { suiClient, queryC
|
|
|
2130
2206
|
cursor = ownedObjects.nextCursor;
|
|
2131
2207
|
}
|
|
2132
2208
|
setExpirationDates(datesMap);
|
|
2209
|
+
setTotalFileSize(totalSize > 0 ? totalSize : null);
|
|
2133
2210
|
} catch (error) {
|
|
2134
2211
|
console.error("Error fetching expiration dates:", error);
|
|
2135
2212
|
}
|
|
@@ -2140,6 +2217,40 @@ const ExtendTimeDialog = ({ siteId, currentAccount, clients: { suiClient, queryC
|
|
|
2140
2217
|
suiClient,
|
|
2141
2218
|
siteData
|
|
2142
2219
|
]);
|
|
2220
|
+
const { data: storageCostData, isLoading: isStorageCostLoading, error: storageCostError } = useStorageCostQuery(totalFileSize, epochs, {
|
|
2221
|
+
queryClient,
|
|
2222
|
+
walrusClient
|
|
2223
|
+
});
|
|
2224
|
+
const estimatedFileSize = useMemo(() => {
|
|
2225
|
+
if (totalFileSize !== null) return null;
|
|
2226
|
+
if (!siteData?.resources) return null;
|
|
2227
|
+
return siteData.resources.length * 10 * 1024;
|
|
2228
|
+
}, [totalFileSize, siteData?.resources]);
|
|
2229
|
+
const { data: estimatedCostData, isLoading: isEstimatedCostLoading } = useStorageCostQuery(estimatedFileSize, epochs, {
|
|
2230
|
+
queryClient,
|
|
2231
|
+
walrusClient
|
|
2232
|
+
});
|
|
2233
|
+
const formatFileSize = useCallback((bytes) => {
|
|
2234
|
+
if (bytes === null || bytes === 0) return "Unknown";
|
|
2235
|
+
const units = [
|
|
2236
|
+
"B",
|
|
2237
|
+
"KB",
|
|
2238
|
+
"MB",
|
|
2239
|
+
"GB"
|
|
2240
|
+
];
|
|
2241
|
+
let size = bytes;
|
|
2242
|
+
let unitIndex = 0;
|
|
2243
|
+
while (size >= 1024 && unitIndex < units.length - 1) {
|
|
2244
|
+
size /= 1024;
|
|
2245
|
+
unitIndex++;
|
|
2246
|
+
}
|
|
2247
|
+
return `${size.toFixed(2)} ${units[unitIndex]}`;
|
|
2248
|
+
}, []);
|
|
2249
|
+
const formatWalAmount = useCallback((amount) => {
|
|
2250
|
+
if (!amount) return "—";
|
|
2251
|
+
const num = BigInt(amount);
|
|
2252
|
+
return (Number(num) / 1e9).toFixed(6);
|
|
2253
|
+
}, []);
|
|
2143
2254
|
useEffect(() => {
|
|
2144
2255
|
if (isOpen && siteId) fetchExpirationDates();
|
|
2145
2256
|
}, [
|
|
@@ -2380,104 +2491,191 @@ const ExtendTimeDialog = ({ siteId, currentAccount, clients: { suiClient, queryC
|
|
|
2380
2491
|
}),
|
|
2381
2492
|
/* @__PURE__ */ jsxs("div", {
|
|
2382
2493
|
className: formSection,
|
|
2383
|
-
children: [
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2494
|
+
children: [
|
|
2495
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2496
|
+
className: fieldGroup,
|
|
2497
|
+
children: [
|
|
2498
|
+
/* @__PURE__ */ jsx(Label, {
|
|
2499
|
+
htmlFor: "expiration-date",
|
|
2500
|
+
children: "Target Expiration Date"
|
|
2501
|
+
}),
|
|
2502
|
+
/* @__PURE__ */ jsx("div", {
|
|
2503
|
+
className: dateInputWrapper,
|
|
2504
|
+
children: /* @__PURE__ */ jsx(Input, {
|
|
2505
|
+
id: "expiration-date",
|
|
2506
|
+
type: "date",
|
|
2507
|
+
value: selectedDate,
|
|
2508
|
+
min: minDate,
|
|
2509
|
+
max: maxDate,
|
|
2510
|
+
onChange: handleDateChange,
|
|
2511
|
+
disabled: currentEpochsRemaining === 0 || isExtending,
|
|
2512
|
+
className: dateError ? inputError : ""
|
|
2513
|
+
})
|
|
2514
|
+
}),
|
|
2515
|
+
epochDurationMs && /* @__PURE__ */ jsxs("div", {
|
|
2516
|
+
className: infoText,
|
|
2517
|
+
children: [/* @__PURE__ */ jsx(Info, { size: 14 }), /* @__PURE__ */ jsxs("span", { children: [
|
|
2518
|
+
"1 epoch ≈",
|
|
2519
|
+
" ",
|
|
2520
|
+
(epochDurationMs / (1e3 * 60 * 60 * 24)).toFixed(1),
|
|
2521
|
+
" ",
|
|
2522
|
+
"days • Duration rounded up. Maximum 365 epochs per extend."
|
|
2523
|
+
] })]
|
|
2524
|
+
}),
|
|
2525
|
+
dateError && /* @__PURE__ */ jsx("p", {
|
|
2526
|
+
className: errorText,
|
|
2527
|
+
children: dateError
|
|
2401
2528
|
})
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
"1 epoch ≈",
|
|
2407
|
-
" ",
|
|
2408
|
-
(epochDurationMs / (1e3 * 60 * 60 * 24)).toFixed(1),
|
|
2409
|
-
" ",
|
|
2410
|
-
"days • Duration rounded up. Maximum 365 epochs per extend."
|
|
2411
|
-
] })]
|
|
2412
|
-
}),
|
|
2413
|
-
dateError && /* @__PURE__ */ jsx("p", {
|
|
2414
|
-
className: errorText,
|
|
2415
|
-
children: dateError
|
|
2416
|
-
})
|
|
2417
|
-
]
|
|
2418
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
2419
|
-
className: summaryGrid,
|
|
2420
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
2421
|
-
className: summaryCard,
|
|
2529
|
+
]
|
|
2530
|
+
}),
|
|
2531
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2532
|
+
className: summaryGrid,
|
|
2422
2533
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
2423
|
-
className:
|
|
2424
|
-
children: [/* @__PURE__ */
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2534
|
+
className: summaryCard,
|
|
2535
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
2536
|
+
className: summaryHeader,
|
|
2537
|
+
children: [/* @__PURE__ */ jsx(Calendar, { size: 14 }), /* @__PURE__ */ jsx("span", { children: "Current Expiration" })]
|
|
2538
|
+
}), currentExpiredDateMemo ? /* @__PURE__ */ jsxs("div", {
|
|
2539
|
+
className: summaryContent,
|
|
2540
|
+
children: [
|
|
2541
|
+
/* @__PURE__ */ jsx("div", {
|
|
2542
|
+
className: summaryValue,
|
|
2543
|
+
children: formatDate(currentExpiredDateMemo)
|
|
2544
|
+
}),
|
|
2545
|
+
currentEpochsRemaining !== null && currentEpochsRemaining > 0 && /* @__PURE__ */ jsxs("div", {
|
|
2546
|
+
className: summarySubtext,
|
|
2547
|
+
children: [
|
|
2548
|
+
currentEpochsRemaining,
|
|
2549
|
+
" epoch",
|
|
2550
|
+
currentEpochsRemaining !== 1 ? "s" : "",
|
|
2551
|
+
" remaining"
|
|
2552
|
+
]
|
|
2553
|
+
}),
|
|
2554
|
+
currentEpochsRemaining === 0 && /* @__PURE__ */ jsx("div", {
|
|
2555
|
+
className: summaryError,
|
|
2556
|
+
children: "Expired"
|
|
2557
|
+
})
|
|
2558
|
+
]
|
|
2559
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
2560
|
+
className: summaryValue,
|
|
2561
|
+
children: "Unavailable"
|
|
2562
|
+
})]
|
|
2563
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
2564
|
+
className: summaryCard,
|
|
2565
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
2566
|
+
className: summaryHeader,
|
|
2567
|
+
children: [/* @__PURE__ */ jsx(Clock, { size: 14 }), /* @__PURE__ */ jsx("span", { children: "New Expiration Date" })]
|
|
2568
|
+
}), projectedDate ? /* @__PURE__ */ jsxs("div", {
|
|
2569
|
+
className: summaryContent,
|
|
2570
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
2429
2571
|
className: summaryValue,
|
|
2430
|
-
children: formatDate(
|
|
2431
|
-
}),
|
|
2432
|
-
currentEpochsRemaining !== null && currentEpochsRemaining > 0 && /* @__PURE__ */ jsxs("div", {
|
|
2572
|
+
children: formatDate(projectedDate)
|
|
2573
|
+
}), currentEpochsRemaining !== null && /* @__PURE__ */ jsxs("div", {
|
|
2433
2574
|
className: summarySubtext,
|
|
2434
2575
|
children: [
|
|
2435
2576
|
currentEpochsRemaining,
|
|
2436
|
-
"
|
|
2437
|
-
|
|
2438
|
-
|
|
2577
|
+
" →",
|
|
2578
|
+
" ",
|
|
2579
|
+
currentEpochsRemaining + epochs,
|
|
2580
|
+
" epochs (+",
|
|
2581
|
+
epochs,
|
|
2582
|
+
" ",
|
|
2583
|
+
"epoch",
|
|
2584
|
+
epochs !== 1 ? "s" : "",
|
|
2585
|
+
")"
|
|
2439
2586
|
]
|
|
2587
|
+
})]
|
|
2588
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
2589
|
+
className: summaryValue,
|
|
2590
|
+
children: "Select a date"
|
|
2591
|
+
})]
|
|
2592
|
+
})]
|
|
2593
|
+
}),
|
|
2594
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2595
|
+
className: costSection,
|
|
2596
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
2597
|
+
className: costHeader,
|
|
2598
|
+
children: [
|
|
2599
|
+
/* @__PURE__ */ jsx(DollarSign, { size: 16 }),
|
|
2600
|
+
/* @__PURE__ */ jsx("span", { children: "Storage Cost" }),
|
|
2601
|
+
totalFileSize === null && estimatedFileSize !== null && /* @__PURE__ */ jsx("span", {
|
|
2602
|
+
className: estimatedBadge,
|
|
2603
|
+
children: "Estimated"
|
|
2604
|
+
})
|
|
2605
|
+
]
|
|
2606
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
2607
|
+
className: costContent,
|
|
2608
|
+
children: [
|
|
2609
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2610
|
+
className: costRow,
|
|
2611
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
2612
|
+
className: costLabel,
|
|
2613
|
+
children: "Size:"
|
|
2614
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
2615
|
+
className: costValue,
|
|
2616
|
+
children: totalFileSize !== null ? formatFileSize(totalFileSize) : estimatedFileSize !== null ? formatFileSize(estimatedFileSize) : "Unknown"
|
|
2617
|
+
})]
|
|
2440
2618
|
}),
|
|
2441
|
-
|
|
2442
|
-
className:
|
|
2443
|
-
children: "
|
|
2619
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2620
|
+
className: costRow,
|
|
2621
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
2622
|
+
className: costLabel,
|
|
2623
|
+
children: "Resources:"
|
|
2624
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
2625
|
+
className: costValue,
|
|
2626
|
+
children: [
|
|
2627
|
+
siteData?.resources?.length || 0,
|
|
2628
|
+
" resources • ",
|
|
2629
|
+
epochs,
|
|
2630
|
+
" ",
|
|
2631
|
+
"epoch",
|
|
2632
|
+
epochs !== 1 ? "s" : ""
|
|
2633
|
+
]
|
|
2634
|
+
})]
|
|
2635
|
+
}),
|
|
2636
|
+
isStorageCostLoading || isEstimatedCostLoading ? /* @__PURE__ */ jsxs("div", {
|
|
2637
|
+
className: costLoading,
|
|
2638
|
+
children: [/* @__PURE__ */ jsx(Loader2, {
|
|
2639
|
+
size: 14,
|
|
2640
|
+
className: spinner$1
|
|
2641
|
+
}), /* @__PURE__ */ jsx("span", { children: "Calculating cost..." })]
|
|
2642
|
+
}) : storageCostData || estimatedCostData ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2643
|
+
totalFileSize === null && estimatedFileSize !== null && /* @__PURE__ */ jsxs("div", {
|
|
2644
|
+
className: costWarning,
|
|
2645
|
+
children: [/* @__PURE__ */ jsx(Info, { size: 12 }), /* @__PURE__ */ jsxs("span", { children: [
|
|
2646
|
+
"Estimated cost based on",
|
|
2647
|
+
" ",
|
|
2648
|
+
siteData?.resources?.length || 0,
|
|
2649
|
+
" resource",
|
|
2650
|
+
siteData?.resources?.length !== 1 ? "s" : ""
|
|
2651
|
+
] })]
|
|
2652
|
+
}),
|
|
2653
|
+
/* @__PURE__ */ jsx("div", { className: costDivider }),
|
|
2654
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2655
|
+
className: costRow,
|
|
2656
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
2657
|
+
className: costLabel,
|
|
2658
|
+
children: "Storage Cost:"
|
|
2659
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
2660
|
+
className: costValue,
|
|
2661
|
+
children: [
|
|
2662
|
+
formatWalAmount(storageCostData?.storageCost || estimatedCostData?.storageCost),
|
|
2663
|
+
" ",
|
|
2664
|
+
"WAL"
|
|
2665
|
+
]
|
|
2666
|
+
})]
|
|
2667
|
+
})
|
|
2668
|
+
] }) : storageCostError ? /* @__PURE__ */ jsxs("div", {
|
|
2669
|
+
className: costError,
|
|
2670
|
+
children: [/* @__PURE__ */ jsx(Info, { size: 14 }), /* @__PURE__ */ jsx("span", { children: "Unable to calculate cost. Please ensure you have sufficient WAL balance." })]
|
|
2671
|
+
}) : /* @__PURE__ */ jsxs("div", {
|
|
2672
|
+
className: costError,
|
|
2673
|
+
children: [/* @__PURE__ */ jsx(Info, { size: 14 }), /* @__PURE__ */ jsx("span", { children: "Unable to calculate cost" })]
|
|
2444
2674
|
})
|
|
2445
2675
|
]
|
|
2446
|
-
}) : /* @__PURE__ */ jsx("div", {
|
|
2447
|
-
className: summaryValue,
|
|
2448
|
-
children: "Unavailable"
|
|
2449
2676
|
})]
|
|
2450
|
-
})
|
|
2451
|
-
|
|
2452
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
2453
|
-
className: summaryHeader,
|
|
2454
|
-
children: [/* @__PURE__ */ jsx(Clock, { size: 14 }), /* @__PURE__ */ jsx("span", { children: "New Expiration Date" })]
|
|
2455
|
-
}), projectedDate ? /* @__PURE__ */ jsxs("div", {
|
|
2456
|
-
className: summaryContent,
|
|
2457
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
2458
|
-
className: summaryValue,
|
|
2459
|
-
children: formatDate(projectedDate)
|
|
2460
|
-
}), currentEpochsRemaining !== null && /* @__PURE__ */ jsxs("div", {
|
|
2461
|
-
className: summarySubtext,
|
|
2462
|
-
children: [
|
|
2463
|
-
currentEpochsRemaining,
|
|
2464
|
-
" →",
|
|
2465
|
-
" ",
|
|
2466
|
-
currentEpochsRemaining + epochs,
|
|
2467
|
-
" epochs (+",
|
|
2468
|
-
epochs,
|
|
2469
|
-
" ",
|
|
2470
|
-
"epoch",
|
|
2471
|
-
epochs !== 1 ? "s" : "",
|
|
2472
|
-
")"
|
|
2473
|
-
]
|
|
2474
|
-
})]
|
|
2475
|
-
}) : /* @__PURE__ */ jsx("div", {
|
|
2476
|
-
className: summaryValue,
|
|
2477
|
-
children: "Select a date"
|
|
2478
|
-
})]
|
|
2479
|
-
})]
|
|
2480
|
-
})]
|
|
2677
|
+
})
|
|
2678
|
+
]
|
|
2481
2679
|
})
|
|
2482
2680
|
]
|
|
2483
2681
|
}),
|
|
@@ -2685,27 +2883,6 @@ const PublishMenu = ({ children, siteId, onPublishClick, onDomainClick, portalDo
|
|
|
2685
2883
|
};
|
|
2686
2884
|
var PublishMenu_default = PublishMenu;
|
|
2687
2885
|
|
|
2688
|
-
//#endregion
|
|
2689
|
-
//#region src/queries/storage-cost.query.ts
|
|
2690
|
-
function useStorageCostQuery(fileSize, epochs, clients) {
|
|
2691
|
-
const { walrusClient, queryClient } = clients;
|
|
2692
|
-
return useQuery({
|
|
2693
|
-
queryKey: queryKeys.storageCost(fileSize, epochs),
|
|
2694
|
-
queryFn: async () => {
|
|
2695
|
-
if (!walrusClient) throw new Error("Walrus client not available");
|
|
2696
|
-
if (fileSize === null) throw new Error("Invalid file size");
|
|
2697
|
-
const storageCost = await walrusClient.storageCost(fileSize, epochs);
|
|
2698
|
-
return {
|
|
2699
|
-
storageCost: storageCost.storageCost.toString(),
|
|
2700
|
-
writeCost: storageCost.writeCost.toString(),
|
|
2701
|
-
totalCost: storageCost.totalCost.toString()
|
|
2702
|
-
};
|
|
2703
|
-
},
|
|
2704
|
-
enabled: !!walrusClient && fileSize !== null && fileSize > 0 && epochs > 0,
|
|
2705
|
-
staleTime: 300 * 1e3
|
|
2706
|
-
}, queryClient);
|
|
2707
|
-
}
|
|
2708
|
-
|
|
2709
2886
|
//#endregion
|
|
2710
2887
|
//#region src/components/publish-modal/PublishModal.css.ts
|
|
2711
2888
|
var buttonGroup = "PublishModal_buttonGroup__m8gxhre";
|
|
@@ -5252,5 +5429,5 @@ const PublishButton = ({ children, siteId, assets, onUpdateSiteMetadata, onAssoc
|
|
|
5252
5429
|
var PublishButton_default = PublishButton;
|
|
5253
5430
|
|
|
5254
5431
|
//#endregion
|
|
5255
|
-
export { Banner, Button, DeploySteps, DeploymentStatus, FlickeringGrid, Input, Label, PublishButton_default as PublishButton, PublishMenu_default as PublishMenu, PublishModal_default as PublishModal, Stepper, SuiNsModal_default as SuiNsModal, Textarea, isAssigningDomain, isDomainDialogOpen, isExtendTimeDialogOpen, isRegisterSuiNSDomainDialogOpen, siteMetadataStore, sitePublishingStore, useEpochDuration, useSitePublishing, useSuiNsDomainsQuery, useSuiNsRegistration, useTransactionExecutor, useWalrusSiteQuery, useWalrusSitesQuery, useZenFsWorkspace, useZenfsFilesQuery };
|
|
5432
|
+
export { Banner, Button, DeploySteps, DeploymentStatus, FlickeringGrid, Input, Label, PublishButton_default as PublishButton, PublishMenu_default as PublishMenu, PublishModal_default as PublishModal, Stepper, SuiNsModal_default as SuiNsModal, Textarea, isAssigningDomain, isDomainDialogOpen, isExtendTimeDialogOpen, isRegisterSuiNSDomainDialogOpen, siteMetadataStore, sitePublishingStore, useEpochDuration, useSitePublishing, useSuiNsDomainsQuery, useSuiNsRegistration, useTransactionExecutor, useUpdateSiteMetadata, useWalrusSiteQuery, useWalrusSitesQuery, useZenFsWorkspace, useZenfsFilesQuery };
|
|
5256
5433
|
//# sourceMappingURL=index.js.map
|