@cmdoss/walrus-site-builder-react 2.2.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.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";
@@ -921,11 +921,38 @@ function useSuiNsRegistration({ currentAccount, clients: { suiClient, queryClien
921
921
  const [isSwapping, setIsSwapping] = useState(false);
922
922
  const [estimatedPrice, setEstimatedPrice] = useState(null);
923
923
  const [error, setError] = useState(null);
924
+ const [selectedYears, setSelectedYears] = useState(1);
925
+ const [pricePerYear, setPricePerYear] = useState(null);
926
+ const [pricePerYearFormatted, setPricePerYearFormatted] = useState(null);
927
+ const [pricePerYearUsdc, setPricePerYearUsdc] = useState(null);
928
+ const [totalPriceUsdc, setTotalPriceUsdc] = useState(null);
929
+ const priceRefreshIntervalRef = useRef(null);
924
930
  const normalizedName = searchName.toLowerCase().trim();
925
931
  const fullName = normalizedName ? `${normalizedName}.sui` : "";
926
932
  const network = suiClient.network;
927
933
  const isMainnet = network === "mainnet";
928
934
  const isTestnet = network === "testnet";
935
+ const expirationDate = useMemo(() => {
936
+ if (!selectedYears) return null;
937
+ const date = /* @__PURE__ */ new Date();
938
+ date.setFullYear(date.getFullYear() + selectedYears);
939
+ return date;
940
+ }, [selectedYears]);
941
+ const totalPrice = useMemo(() => {
942
+ if (!pricePerYear || !selectedYears) return null;
943
+ return pricePerYear * selectedYears;
944
+ }, [pricePerYear, selectedYears]);
945
+ const totalPriceFormatted = useMemo(() => {
946
+ if (!totalPrice || !pricePerYearFormatted) return null;
947
+ const perYearValue = parseFloat(pricePerYearFormatted.replace(/[^\d.]/g, ""));
948
+ if (Number.isNaN(perYearValue)) return null;
949
+ const totalValue = perYearValue * selectedYears;
950
+ return pricePerYearFormatted.replace(/[\d.]+/, totalValue.toFixed(4));
951
+ }, [
952
+ totalPrice,
953
+ pricePerYearFormatted,
954
+ selectedYears
955
+ ]);
929
956
  const WAL_COIN_TYPE = mainPackage[network]?.walrusCoinType;
930
957
  const aggregatorClient = useMemo(() => {
931
958
  if (!suiClient || !currentAccount || !isMainnet) return null;
@@ -939,6 +966,131 @@ function useSuiNsRegistration({ currentAccount, clients: { suiClient, queryClien
939
966
  currentAccount,
940
967
  isMainnet
941
968
  ]);
969
+ const updatePriceEstimate = useCallback(async () => {
970
+ if (!suinsClient || !currentAccount || !isMainnet || !WAL_COIN_TYPE || !aggregatorClient || !normalizedName) return;
971
+ const priceList = await suinsClient.getPriceList();
972
+ const nameLength = normalizedName.length;
973
+ let pricePerYearValue = 0;
974
+ for (const [[from, to], price] of priceList.entries()) if (nameLength >= from && nameLength <= to) {
975
+ pricePerYearValue = price;
976
+ break;
977
+ }
978
+ if (pricePerYearValue > 0) {
979
+ setPricePerYear(pricePerYearValue);
980
+ const totalPriceValue = pricePerYearValue * selectedYears;
981
+ const requiredAmount = BigInt(Math.floor(totalPriceValue * 1.05));
982
+ const usdcBalance = (await suiClient.getCoins({
983
+ owner: currentAccount.address,
984
+ coinType: suinsClient.config.coins.USDC.type
985
+ })).data?.reduce((sum, coin) => sum + BigInt(coin.balance), 0n) ?? 0n;
986
+ const missingUsdc = usdcBalance < requiredAmount ? requiredAmount - usdcBalance : requiredAmount;
987
+ const baseWalAtomic = 1000000000n;
988
+ const rateRouter = await aggregatorClient.findRouters({
989
+ from: WAL_COIN_TYPE,
990
+ target: suinsClient.config.coins.USDC.type,
991
+ amount: new BN(baseWalAtomic.toString()),
992
+ byAmountIn: true,
993
+ providers: ["CETUS"]
994
+ });
995
+ if (rateRouter && !rateRouter.error && rateRouter.amountOut) {
996
+ const rawAmountOut = rateRouter.amountOut;
997
+ const usdcOutForOneWal = BigInt(rawAmountOut instanceof BN ? rawAmountOut.toString() : new BN(String(rawAmountOut)).toString());
998
+ if (usdcOutForOneWal > 0n) {
999
+ const exchangeRate = Number(baseWalAtomic) / Number(usdcOutForOneWal);
1000
+ const estimatedWalNeeded = missingUsdc * BigInt(Math.ceil(exchangeRate));
1001
+ const walNeededFormatted = (Number(estimatedWalNeeded) / 1e9).toFixed(4);
1002
+ setPricePerYearFormatted(`${(Number(estimatedWalNeeded) / selectedYears / 1e9).toFixed(4)} WAL`);
1003
+ setEstimatedPrice(`~${walNeededFormatted} WAL`);
1004
+ } else {
1005
+ const usdcPrice = (Number(requiredAmount) / 1e6).toFixed(2);
1006
+ setPricePerYearFormatted(`${(pricePerYearValue / 1e6).toFixed(2)} USDC`);
1007
+ setEstimatedPrice(`~${usdcPrice} USDC`);
1008
+ }
1009
+ } else {
1010
+ const usdcPrice = (Number(requiredAmount) / 1e6).toFixed(2);
1011
+ setPricePerYearFormatted(`${(pricePerYearValue / 1e6).toFixed(2)} USDC`);
1012
+ setEstimatedPrice(`~${usdcPrice} USDC`);
1013
+ }
1014
+ }
1015
+ }, [
1016
+ suinsClient,
1017
+ currentAccount,
1018
+ isMainnet,
1019
+ WAL_COIN_TYPE,
1020
+ aggregatorClient,
1021
+ normalizedName,
1022
+ selectedYears,
1023
+ suiClient
1024
+ ]);
1025
+ const updateTestnetPriceEstimate = useCallback(async () => {
1026
+ if (!suinsClient || !currentAccount || !isTestnet || !normalizedName) return;
1027
+ const priceList = await suinsClient.getPriceList();
1028
+ const nameLength = normalizedName.length;
1029
+ let pricePerYearValue = 0;
1030
+ for (const [[from, to], price] of priceList.entries()) if (nameLength >= from && nameLength <= to) {
1031
+ pricePerYearValue = price;
1032
+ break;
1033
+ }
1034
+ if (pricePerYearValue > 0) {
1035
+ setPricePerYear(pricePerYearValue);
1036
+ const totalPriceValue = pricePerYearValue * selectedYears;
1037
+ const usdcAmountAtomic = BigInt(Math.floor(totalPriceValue));
1038
+ const suiNeededAtomic = usdcAmountAtomic * 2n * 1000000000n / (3n * 1000000n);
1039
+ const suiPerYearAtomic = BigInt(Math.floor(pricePerYearValue)) * 2n * 1000000000n / (3n * 1000000n);
1040
+ const suiNeededFormatted = (Number(suiNeededAtomic) / 1e9).toFixed(4);
1041
+ const suiPerYearFormatted = (Number(suiPerYearAtomic) / 1e9).toFixed(4);
1042
+ const usdcPrice = (Number(usdcAmountAtomic) / 1e6).toFixed(2);
1043
+ const usdcPerYear = (pricePerYearValue / 1e6).toFixed(2);
1044
+ setPricePerYearFormatted(`${suiPerYearFormatted} SUI`);
1045
+ setEstimatedPrice(`${suiNeededFormatted} SUI`);
1046
+ setPricePerYearUsdc(`${usdcPerYear} USDC`);
1047
+ setTotalPriceUsdc(`${usdcPrice} USDC`);
1048
+ }
1049
+ }, [
1050
+ suinsClient,
1051
+ currentAccount,
1052
+ isTestnet,
1053
+ normalizedName,
1054
+ selectedYears
1055
+ ]);
1056
+ useEffect(() => {
1057
+ if (isMainnet && isAvailable && normalizedName && !isRegistering && aggregatorClient) {
1058
+ if (priceRefreshIntervalRef.current) clearInterval(priceRefreshIntervalRef.current);
1059
+ priceRefreshIntervalRef.current = setInterval(() => {
1060
+ updatePriceEstimate().catch((err) => {
1061
+ console.error("Error refreshing price:", err);
1062
+ });
1063
+ }, 1e4);
1064
+ return () => {
1065
+ if (priceRefreshIntervalRef.current) clearInterval(priceRefreshIntervalRef.current);
1066
+ };
1067
+ }
1068
+ }, [
1069
+ isMainnet,
1070
+ isAvailable,
1071
+ normalizedName,
1072
+ isRegistering,
1073
+ aggregatorClient,
1074
+ updatePriceEstimate
1075
+ ]);
1076
+ useEffect(() => {
1077
+ if (isAvailable && pricePerYear !== null) {
1078
+ if (isMainnet && aggregatorClient) updatePriceEstimate().catch((err) => {
1079
+ console.error("Error updating price:", err);
1080
+ });
1081
+ else if (isTestnet) updateTestnetPriceEstimate().catch((err) => {
1082
+ console.error("Error updating price:", err);
1083
+ });
1084
+ }
1085
+ }, [
1086
+ isAvailable,
1087
+ pricePerYear,
1088
+ isMainnet,
1089
+ isTestnet,
1090
+ aggregatorClient,
1091
+ updatePriceEstimate,
1092
+ updateTestnetPriceEstimate
1093
+ ]);
942
1094
  return {
943
1095
  searchName,
944
1096
  setSearchName,
@@ -950,6 +1102,15 @@ function useSuiNsRegistration({ currentAccount, clients: { suiClient, queryClien
950
1102
  error,
951
1103
  normalizedName,
952
1104
  fullName,
1105
+ selectedYears,
1106
+ setSelectedYears,
1107
+ pricePerYear,
1108
+ pricePerYearFormatted,
1109
+ pricePerYearUsdc,
1110
+ totalPrice,
1111
+ totalPriceFormatted,
1112
+ totalPriceUsdc,
1113
+ expirationDate,
953
1114
  handleSearch: useCallback(async () => {
954
1115
  if (!normalizedName || !suinsClient) return;
955
1116
  if (normalizedName.length < 3) {
@@ -965,40 +1126,9 @@ function useSuiNsRegistration({ currentAccount, clients: { suiClient, queryClien
965
1126
  try {
966
1127
  const available = !(await suinsClient.getNameRecord(fullName))?.nftId;
967
1128
  setIsAvailable(available);
968
- if (available && currentAccount && isMainnet && WAL_COIN_TYPE && aggregatorClient) try {
969
- const priceList = await suinsClient.getPriceList();
970
- const nameLength = normalizedName.length;
971
- let pricePerYear = 0;
972
- for (const [[from, to], price] of priceList.entries()) if (nameLength >= from && nameLength <= to) {
973
- pricePerYear = price;
974
- break;
975
- }
976
- if (pricePerYear > 0) {
977
- const totalPrice = pricePerYear * 1;
978
- const requiredAmount = BigInt(Math.floor(totalPrice * 1.05));
979
- const usdcBalance = (await suiClient.getCoins({
980
- owner: currentAccount.address,
981
- coinType: suinsClient.config.coins.USDC.type
982
- })).data?.reduce((sum, coin) => sum + BigInt(coin.balance), 0n) ?? 0n;
983
- const missingUsdc = usdcBalance < requiredAmount ? requiredAmount - usdcBalance : requiredAmount;
984
- const baseWalAtomic = 1000000000n;
985
- const rateRouter = await aggregatorClient.findRouters({
986
- from: WAL_COIN_TYPE,
987
- target: suinsClient.config.coins.USDC.type,
988
- amount: new BN(baseWalAtomic.toString()),
989
- byAmountIn: true,
990
- providers: ["CETUS"]
991
- });
992
- if (rateRouter && !rateRouter.error && rateRouter.amountOut) {
993
- const rawAmountOut = rateRouter.amountOut;
994
- const usdcOutForOneWal = BigInt(rawAmountOut instanceof BN ? rawAmountOut.toString() : new BN(String(rawAmountOut)).toString());
995
- if (usdcOutForOneWal > 0n) {
996
- const exchangeRate = Number(baseWalAtomic) / Number(usdcOutForOneWal);
997
- const estimatedWalNeeded = missingUsdc * BigInt(Math.ceil(exchangeRate));
998
- setEstimatedPrice(`~${(Number(estimatedWalNeeded) / 1e9).toFixed(4)} WAL`);
999
- } else setEstimatedPrice(`~${(Number(requiredAmount) / 1e6).toFixed(2)} USDC`);
1000
- } else setEstimatedPrice(`~${(Number(requiredAmount) / 1e6).toFixed(2)} USDC`);
1001
- }
1129
+ if (available && currentAccount && aggregatorClient) try {
1130
+ if (isMainnet && WAL_COIN_TYPE) await updatePriceEstimate();
1131
+ else if (isTestnet) await updateTestnetPriceEstimate();
1002
1132
  } catch (priceError) {
1003
1133
  console.error("Error estimating price:", priceError);
1004
1134
  }
@@ -1014,9 +1144,11 @@ function useSuiNsRegistration({ currentAccount, clients: { suiClient, queryClien
1014
1144
  suinsClient,
1015
1145
  currentAccount,
1016
1146
  isMainnet,
1147
+ isTestnet,
1017
1148
  WAL_COIN_TYPE,
1018
1149
  aggregatorClient,
1019
- suiClient
1150
+ updatePriceEstimate,
1151
+ updateTestnetPriceEstimate
1020
1152
  ]),
1021
1153
  handleRegister: useCallback(async () => {
1022
1154
  if (!suinsClient || !currentAccount || !isAvailable || !normalizedName) return;
@@ -1029,14 +1161,14 @@ function useSuiNsRegistration({ currentAccount, clients: { suiClient, queryClien
1029
1161
  try {
1030
1162
  const priceList = await suinsClient.getPriceList();
1031
1163
  const nameLength = normalizedName.length;
1032
- let pricePerYear = 0;
1164
+ let pricePerYear$1 = 0;
1033
1165
  for (const [[from, to], price] of priceList.entries()) if (nameLength >= from && nameLength <= to) {
1034
- pricePerYear = price;
1166
+ pricePerYear$1 = price;
1035
1167
  break;
1036
1168
  }
1037
- if (pricePerYear === 0) throw new Error("Unable to determine price for this domain");
1038
- const years = 1;
1039
- const totalPrice = pricePerYear * years;
1169
+ if (pricePerYear$1 === 0) throw new Error("Unable to determine price for this domain");
1170
+ const years = selectedYears;
1171
+ const totalPrice$1 = pricePerYear$1 * years;
1040
1172
  const coinType = isTestnet ? "SUI" : "USDC";
1041
1173
  const coinConfig = suinsClient.config.coins[coinType];
1042
1174
  const [usdcCoins, walCoins] = await Promise.all([isMainnet ? suiClient.getCoins({
@@ -1048,7 +1180,7 @@ function useSuiNsRegistration({ currentAccount, clients: { suiClient, queryClien
1048
1180
  }) : Promise.resolve({ data: [] })]);
1049
1181
  const usdcBalance = usdcCoins.data?.reduce((sum, coin) => sum + BigInt(coin.balance), 0n) ?? 0n;
1050
1182
  const walBalance = walCoins.data?.reduce((sum, coin) => sum + BigInt(coin.balance), 0n) ?? 0n;
1051
- const requiredAmount = BigInt(Math.floor(totalPrice * 1.05));
1183
+ const requiredAmount = BigInt(Math.floor(totalPrice$1 * 1.05));
1052
1184
  if (isMainnet && coinType === "USDC") {
1053
1185
  if (usdcBalance < requiredAmount) {
1054
1186
  if (!aggregatorClient || !WAL_COIN_TYPE) throw new Error("Swap client not ready. Please try again in a few seconds.");
@@ -1115,7 +1247,7 @@ function useSuiNsRegistration({ currentAccount, clients: { suiClient, queryClien
1115
1247
  coinType: coinConfig.type
1116
1248
  });
1117
1249
  if (coins.data.length === 0) throw new Error(`No ${coinType} coins found in your wallet`);
1118
- const maxPaymentAmount = Math.floor(totalPrice * 1.05);
1250
+ const maxPaymentAmount = Math.floor(totalPrice$1 * 1.05);
1119
1251
  const totalBalance = coins.data.reduce((sum, coin) => sum + BigInt(coin.balance), 0n);
1120
1252
  const requiredBalance = BigInt(maxPaymentAmount) + 10000000n;
1121
1253
  if (totalBalance < requiredBalance) throw new Error(`Insufficient balance. Need approximately ${(Number(requiredBalance) / 1e9).toFixed(4)} ${coinType}`);
@@ -1174,6 +1306,7 @@ function useSuiNsRegistration({ currentAccount, clients: { suiClient, queryClien
1174
1306
  isAvailable,
1175
1307
  normalizedName,
1176
1308
  fullName,
1309
+ selectedYears,
1177
1310
  txExecutor,
1178
1311
  isTestnet,
1179
1312
  isMainnet,
@@ -1191,10 +1324,56 @@ function useSuiNsRegistration({ currentAccount, clients: { suiClient, queryClien
1191
1324
  setIsSearching(false);
1192
1325
  setIsRegistering(false);
1193
1326
  setIsSwapping(false);
1327
+ setSelectedYears(1);
1328
+ setPricePerYear(null);
1329
+ setPricePerYearFormatted(null);
1330
+ setPricePerYearUsdc(null);
1331
+ setTotalPriceUsdc(null);
1332
+ if (priceRefreshIntervalRef.current) {
1333
+ clearInterval(priceRefreshIntervalRef.current);
1334
+ priceRefreshIntervalRef.current = null;
1335
+ }
1194
1336
  }, [])
1195
1337
  };
1196
1338
  }
1197
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
+
1198
1377
  //#endregion
1199
1378
  //#region src/hooks/useZenFsWorkspace.ts
1200
1379
  function useZenFsWorkspace(workspaceDir = "/workspace", mountDir = "/workspace", queryClient) {
@@ -1219,6 +1398,27 @@ function useZenFsWorkspace(workspaceDir = "/workspace", mountDir = "/workspace",
1219
1398
  };
1220
1399
  }
1221
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
+
1222
1422
  //#endregion
1223
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
1224
1424
  var require_createRuntimeFn_166334d7_cjs_prod = /* @__PURE__ */ __commonJSMin(((exports) => {
@@ -1906,9 +2106,20 @@ const Stepper = ({ steps, currentStep, isLoading }) => {
1906
2106
  var body$1 = "ExtendTimeDialog_body__1augvc0a";
1907
2107
  var closeButton = "ExtendTimeDialog_closeButton__1augvc09";
1908
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";
1909
2119
  var dateInputWrapper = "ExtendTimeDialog_dateInputWrapper__1augvc0d";
1910
2120
  var description$3 = "ExtendTimeDialog_description__1augvc08";
1911
2121
  var errorText = "ExtendTimeDialog_errorText__1augvc0h";
2122
+ var estimatedBadge = "ExtendTimeDialog_estimatedBadge__1augvc015";
1912
2123
  var fieldGroup = "ExtendTimeDialog_fieldGroup__1augvc0c";
1913
2124
  var footer$1 = "ExtendTimeDialog_footer__1augvc0r";
1914
2125
  var formSection = "ExtendTimeDialog_formSection__1augvc0b";
@@ -1938,6 +2149,7 @@ const ExtendTimeDialog = ({ siteId, currentAccount, clients: { suiClient, queryC
1938
2149
  const [dateError, setDateError] = useState(null);
1939
2150
  const [currentEpochsRemaining, setCurrentEpochsRemaining] = useState(null);
1940
2151
  const [expirationDates, setExpirationDates] = useState(/* @__PURE__ */ new Map());
2152
+ const [totalFileSize, setTotalFileSize] = useState(null);
1941
2153
  const { epochDurationMs, formatDate } = useEpochDuration(walrusClient);
1942
2154
  const txExecutor = useTransactionExecutor({
1943
2155
  suiClient,
@@ -1954,6 +2166,7 @@ const ExtendTimeDialog = ({ siteId, currentAccount, clients: { suiClient, queryC
1954
2166
  try {
1955
2167
  const blobType = await walrusClient.getBlobType();
1956
2168
  const datesMap = /* @__PURE__ */ new Map();
2169
+ let totalSize = 0;
1957
2170
  const stakingState = await walrusClient.stakingState();
1958
2171
  const currentEpoch = Number(stakingState.epoch);
1959
2172
  const epochDuration = Number(stakingState.epoch_duration);
@@ -1978,6 +2191,11 @@ const ExtendTimeDialog = ({ siteId, currentAccount, clients: { suiClient, queryC
1978
2191
  const remainingEpochs = Number(storage.fields.end_epoch) - currentEpoch;
1979
2192
  const expirationTime = Date.now() + remainingEpochs * epochDuration;
1980
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
+ }
1981
2199
  break;
1982
2200
  }
1983
2201
  }
@@ -1988,6 +2206,7 @@ const ExtendTimeDialog = ({ siteId, currentAccount, clients: { suiClient, queryC
1988
2206
  cursor = ownedObjects.nextCursor;
1989
2207
  }
1990
2208
  setExpirationDates(datesMap);
2209
+ setTotalFileSize(totalSize > 0 ? totalSize : null);
1991
2210
  } catch (error) {
1992
2211
  console.error("Error fetching expiration dates:", error);
1993
2212
  }
@@ -1998,6 +2217,40 @@ const ExtendTimeDialog = ({ siteId, currentAccount, clients: { suiClient, queryC
1998
2217
  suiClient,
1999
2218
  siteData
2000
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
+ }, []);
2001
2254
  useEffect(() => {
2002
2255
  if (isOpen && siteId) fetchExpirationDates();
2003
2256
  }, [
@@ -2238,104 +2491,191 @@ const ExtendTimeDialog = ({ siteId, currentAccount, clients: { suiClient, queryC
2238
2491
  }),
2239
2492
  /* @__PURE__ */ jsxs("div", {
2240
2493
  className: formSection,
2241
- children: [/* @__PURE__ */ jsxs("div", {
2242
- className: fieldGroup,
2243
- children: [
2244
- /* @__PURE__ */ jsx(Label, {
2245
- htmlFor: "expiration-date",
2246
- children: "Target Expiration Date"
2247
- }),
2248
- /* @__PURE__ */ jsx("div", {
2249
- className: dateInputWrapper,
2250
- children: /* @__PURE__ */ jsx(Input, {
2251
- id: "expiration-date",
2252
- type: "date",
2253
- value: selectedDate,
2254
- min: minDate,
2255
- max: maxDate,
2256
- onChange: handleDateChange,
2257
- disabled: currentEpochsRemaining === 0 || isExtending,
2258
- className: dateError ? inputError : ""
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
2259
2528
  })
2260
- }),
2261
- epochDurationMs && /* @__PURE__ */ jsxs("div", {
2262
- className: infoText,
2263
- children: [/* @__PURE__ */ jsx(Info, { size: 14 }), /* @__PURE__ */ jsxs("span", { children: [
2264
- "1 epoch ≈",
2265
- " ",
2266
- (epochDurationMs / (1e3 * 60 * 60 * 24)).toFixed(1),
2267
- " ",
2268
- "days • Duration rounded up. Maximum 365 epochs per extend."
2269
- ] })]
2270
- }),
2271
- dateError && /* @__PURE__ */ jsx("p", {
2272
- className: errorText,
2273
- children: dateError
2274
- })
2275
- ]
2276
- }), /* @__PURE__ */ jsxs("div", {
2277
- className: summaryGrid,
2278
- children: [/* @__PURE__ */ jsxs("div", {
2279
- className: summaryCard,
2529
+ ]
2530
+ }),
2531
+ /* @__PURE__ */ jsxs("div", {
2532
+ className: summaryGrid,
2280
2533
  children: [/* @__PURE__ */ jsxs("div", {
2281
- className: summaryHeader,
2282
- children: [/* @__PURE__ */ jsx(Calendar, { size: 14 }), /* @__PURE__ */ jsx("span", { children: "Current Expiration" })]
2283
- }), currentExpiredDateMemo ? /* @__PURE__ */ jsxs("div", {
2284
- className: summaryContent,
2285
- children: [
2286
- /* @__PURE__ */ jsx("div", {
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", {
2287
2571
  className: summaryValue,
2288
- children: formatDate(currentExpiredDateMemo)
2289
- }),
2290
- currentEpochsRemaining !== null && currentEpochsRemaining > 0 && /* @__PURE__ */ jsxs("div", {
2572
+ children: formatDate(projectedDate)
2573
+ }), currentEpochsRemaining !== null && /* @__PURE__ */ jsxs("div", {
2291
2574
  className: summarySubtext,
2292
2575
  children: [
2293
2576
  currentEpochsRemaining,
2294
- " epoch",
2295
- currentEpochsRemaining !== 1 ? "s" : "",
2296
- " remaining"
2577
+ " ",
2578
+ " ",
2579
+ currentEpochsRemaining + epochs,
2580
+ " epochs (+",
2581
+ epochs,
2582
+ " ",
2583
+ "epoch",
2584
+ epochs !== 1 ? "s" : "",
2585
+ ")"
2297
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
+ })]
2298
2618
  }),
2299
- currentEpochsRemaining === 0 && /* @__PURE__ */ jsx("div", {
2300
- className: summaryError,
2301
- children: "Expired"
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" })]
2302
2674
  })
2303
2675
  ]
2304
- }) : /* @__PURE__ */ jsx("div", {
2305
- className: summaryValue,
2306
- children: "Unavailable"
2307
2676
  })]
2308
- }), /* @__PURE__ */ jsxs("div", {
2309
- className: summaryCard,
2310
- children: [/* @__PURE__ */ jsxs("div", {
2311
- className: summaryHeader,
2312
- children: [/* @__PURE__ */ jsx(Clock, { size: 14 }), /* @__PURE__ */ jsx("span", { children: "New Expiration Date" })]
2313
- }), projectedDate ? /* @__PURE__ */ jsxs("div", {
2314
- className: summaryContent,
2315
- children: [/* @__PURE__ */ jsx("div", {
2316
- className: summaryValue,
2317
- children: formatDate(projectedDate)
2318
- }), currentEpochsRemaining !== null && /* @__PURE__ */ jsxs("div", {
2319
- className: summarySubtext,
2320
- children: [
2321
- currentEpochsRemaining,
2322
- " →",
2323
- " ",
2324
- currentEpochsRemaining + epochs,
2325
- " epochs (+",
2326
- epochs,
2327
- " ",
2328
- "epoch",
2329
- epochs !== 1 ? "s" : "",
2330
- ")"
2331
- ]
2332
- })]
2333
- }) : /* @__PURE__ */ jsx("div", {
2334
- className: summaryValue,
2335
- children: "Select a date"
2336
- })]
2337
- })]
2338
- })]
2677
+ })
2678
+ ]
2339
2679
  })
2340
2680
  ]
2341
2681
  }),
@@ -2543,27 +2883,6 @@ const PublishMenu = ({ children, siteId, onPublishClick, onDomainClick, portalDo
2543
2883
  };
2544
2884
  var PublishMenu_default = PublishMenu;
2545
2885
 
2546
- //#endregion
2547
- //#region src/queries/storage-cost.query.ts
2548
- function useStorageCostQuery(fileSize, epochs, clients) {
2549
- const { walrusClient, queryClient } = clients;
2550
- return useQuery({
2551
- queryKey: queryKeys.storageCost(fileSize, epochs),
2552
- queryFn: async () => {
2553
- if (!walrusClient) throw new Error("Walrus client not available");
2554
- if (fileSize === null) throw new Error("Invalid file size");
2555
- const storageCost = await walrusClient.storageCost(fileSize, epochs);
2556
- return {
2557
- storageCost: storageCost.storageCost.toString(),
2558
- writeCost: storageCost.writeCost.toString(),
2559
- totalCost: storageCost.totalCost.toString()
2560
- };
2561
- },
2562
- enabled: !!walrusClient && fileSize !== null && fileSize > 0 && epochs > 0,
2563
- staleTime: 300 * 1e3
2564
- }, queryClient);
2565
- }
2566
-
2567
2886
  //#endregion
2568
2887
  //#region src/components/publish-modal/PublishModal.css.ts
2569
2888
  var buttonGroup = "PublishModal_buttonGroup__m8gxhre";
@@ -4331,7 +4650,7 @@ var title = "SuiNsModal_title__lh8k8k3";
4331
4650
  //#endregion
4332
4651
  //#region src/components/suins-modal/RegisterSuiNsDialog.tsx
4333
4652
  const RegisterSuiNsDialog = ({ isOpen, onClose, onRegistered, currentAccount, clients: { suiClient, queryClient, suinsClient }, signAndExecuteTransaction, sponsorConfig }) => {
4334
- const { searchName, setSearchName, isSearching, isAvailable, isRegistering, isSwapping, estimatedPrice, error, normalizedName, fullName, handleSearch, handleRegister: handleRegisterInternal, reset } = useSuiNsRegistration({
4653
+ const { searchName, setSearchName, isSearching, isAvailable, isRegistering, isSwapping, estimatedPrice, error, normalizedName, fullName, selectedYears, setSelectedYears, pricePerYearFormatted, pricePerYearUsdc, totalPriceFormatted, totalPriceUsdc, expirationDate, handleSearch, handleRegister: handleRegisterInternal, reset } = useSuiNsRegistration({
4335
4654
  currentAccount,
4336
4655
  clients: {
4337
4656
  suiClient,
@@ -4341,6 +4660,7 @@ const RegisterSuiNsDialog = ({ isOpen, onClose, onRegistered, currentAccount, cl
4341
4660
  signAndExecuteTransaction,
4342
4661
  sponsorConfig
4343
4662
  });
4663
+ const isTestnet = suiClient.network === "testnet";
4344
4664
  const handleRegister = async () => {
4345
4665
  if (await handleRegisterInternal()) {
4346
4666
  if (onRegistered) onRegistered();
@@ -4519,25 +4839,230 @@ const RegisterSuiNsDialog = ({ isOpen, onClose, onRegistered, currentAccount, cl
4519
4839
  width: "1.25rem",
4520
4840
  height: "1.25rem",
4521
4841
  flexShrink: 0
4522
- } }), /* @__PURE__ */ jsxs("div", {
4842
+ } }), /* @__PURE__ */ jsx("div", {
4523
4843
  style: {
4524
4844
  flex: 1,
4525
4845
  minWidth: 0
4526
4846
  },
4527
- children: [/* @__PURE__ */ jsx("p", {
4847
+ children: /* @__PURE__ */ jsx("p", {
4528
4848
  style: {
4529
4849
  fontSize: "0.875rem",
4530
4850
  fontWeight: 600
4531
4851
  },
4532
4852
  children: isAvailable ? `${fullName} is available!` : `${fullName} is already taken`
4533
- }), isAvailable && estimatedPrice && /* @__PURE__ */ jsxs("p", {
4853
+ })
4854
+ })]
4855
+ }),
4856
+ isAvailable && /* @__PURE__ */ jsxs("div", {
4857
+ style: { marginBottom: "1rem" },
4858
+ children: [/* @__PURE__ */ jsx("label", {
4859
+ htmlFor: "year-select",
4860
+ style: {
4861
+ display: "block",
4862
+ fontSize: "0.875rem",
4863
+ fontWeight: 500,
4864
+ marginBottom: "0.5rem"
4865
+ },
4866
+ children: "Registration Period"
4867
+ }), /* @__PURE__ */ jsx("div", {
4868
+ style: {
4869
+ display: "flex",
4870
+ gap: "0.5rem",
4871
+ flexWrap: "wrap"
4872
+ },
4873
+ children: [
4874
+ 1,
4875
+ 2,
4876
+ 3,
4877
+ 4,
4878
+ 5
4879
+ ].map((year) => /* @__PURE__ */ jsxs("button", {
4880
+ type: "button",
4881
+ onClick: () => setSelectedYears(year),
4882
+ disabled: isRegistering || isSwapping,
4534
4883
  style: {
4535
- fontSize: "0.75rem",
4536
- opacity: .8,
4537
- marginTop: "0.125rem"
4884
+ padding: "0.5rem 1rem",
4885
+ borderRadius: "0.375rem",
4886
+ border: `1px solid ${selectedYears === year ? "rgba(59, 130, 246, 0.5)" : "rgba(229, 231, 235, 1)"}`,
4887
+ backgroundColor: selectedYears === year ? "rgba(59, 130, 246, 0.1)" : "transparent",
4888
+ color: selectedYears === year ? "rgb(37, 99, 235)" : "inherit",
4889
+ fontWeight: selectedYears === year ? 600 : 400,
4890
+ cursor: isRegistering || isSwapping ? "not-allowed" : "pointer",
4891
+ fontSize: "0.875rem",
4892
+ transition: "all 0.2s",
4893
+ opacity: isRegistering || isSwapping ? .5 : 1
4538
4894
  },
4539
- children: ["Estimated cost: ", estimatedPrice]
4540
- })]
4895
+ children: [
4896
+ year,
4897
+ " ",
4898
+ year === 1 ? "Year" : "Years"
4899
+ ]
4900
+ }, year))
4901
+ })]
4902
+ }),
4903
+ isAvailable && (pricePerYearFormatted || estimatedPrice) && /* @__PURE__ */ jsxs("div", {
4904
+ style: {
4905
+ padding: "1rem",
4906
+ borderRadius: "0.5rem",
4907
+ backgroundColor: "rgba(249, 250, 251, 1)",
4908
+ border: "1px solid rgba(229, 231, 235, 1)",
4909
+ marginBottom: "1rem"
4910
+ },
4911
+ children: [/* @__PURE__ */ jsx("h3", {
4912
+ style: {
4913
+ fontSize: "0.875rem",
4914
+ fontWeight: 600,
4915
+ marginBottom: "0.75rem",
4916
+ color: "rgb(17, 24, 39)"
4917
+ },
4918
+ children: "Price Breakdown"
4919
+ }), /* @__PURE__ */ jsxs("div", {
4920
+ style: {
4921
+ display: "flex",
4922
+ flexDirection: "column",
4923
+ gap: "0.5rem"
4924
+ },
4925
+ children: [
4926
+ /* @__PURE__ */ jsxs("div", {
4927
+ style: {
4928
+ display: "flex",
4929
+ justifyContent: "space-between",
4930
+ alignItems: "center"
4931
+ },
4932
+ children: [/* @__PURE__ */ jsx("span", {
4933
+ style: {
4934
+ fontSize: "0.875rem",
4935
+ color: "rgb(107, 114, 128)"
4936
+ },
4937
+ children: "Price per year:"
4938
+ }), /* @__PURE__ */ jsxs("div", {
4939
+ style: {
4940
+ display: "flex",
4941
+ flexDirection: "column",
4942
+ alignItems: "flex-end",
4943
+ gap: "0.125rem"
4944
+ },
4945
+ children: [/* @__PURE__ */ jsx("span", {
4946
+ style: {
4947
+ fontSize: "0.875rem",
4948
+ fontWeight: 600,
4949
+ color: "rgb(17, 24, 39)"
4950
+ },
4951
+ children: pricePerYearFormatted || estimatedPrice
4952
+ }), isTestnet && pricePerYearUsdc && /* @__PURE__ */ jsxs("span", {
4953
+ style: {
4954
+ fontSize: "0.75rem",
4955
+ color: "rgb(107, 114, 128)",
4956
+ opacity: .8
4957
+ },
4958
+ children: [
4959
+ "(",
4960
+ pricePerYearUsdc,
4961
+ ")"
4962
+ ]
4963
+ })]
4964
+ })]
4965
+ }),
4966
+ /* @__PURE__ */ jsxs("div", {
4967
+ style: {
4968
+ display: "flex",
4969
+ justifyContent: "space-between",
4970
+ alignItems: "center"
4971
+ },
4972
+ children: [/* @__PURE__ */ jsx("span", {
4973
+ style: {
4974
+ fontSize: "0.875rem",
4975
+ color: "rgb(107, 114, 128)"
4976
+ },
4977
+ children: "Number of years:"
4978
+ }), /* @__PURE__ */ jsx("span", {
4979
+ style: {
4980
+ fontSize: "0.875rem",
4981
+ fontWeight: 600,
4982
+ color: "rgb(17, 24, 39)"
4983
+ },
4984
+ children: selectedYears
4985
+ })]
4986
+ }),
4987
+ /* @__PURE__ */ jsx("div", { style: {
4988
+ height: "1px",
4989
+ backgroundColor: "rgba(229, 231, 235, 1)",
4990
+ margin: "0.5rem 0"
4991
+ } }),
4992
+ /* @__PURE__ */ jsxs("div", {
4993
+ style: {
4994
+ display: "flex",
4995
+ justifyContent: "space-between",
4996
+ alignItems: "center"
4997
+ },
4998
+ children: [/* @__PURE__ */ jsx("span", {
4999
+ style: {
5000
+ fontSize: "0.875rem",
5001
+ fontWeight: 600,
5002
+ color: "rgb(17, 24, 39)"
5003
+ },
5004
+ children: "Total:"
5005
+ }), /* @__PURE__ */ jsxs("div", {
5006
+ style: {
5007
+ display: "flex",
5008
+ flexDirection: "column",
5009
+ alignItems: "flex-end",
5010
+ gap: "0.125rem"
5011
+ },
5012
+ children: [/* @__PURE__ */ jsx("span", {
5013
+ style: {
5014
+ fontSize: "1rem",
5015
+ fontWeight: 700,
5016
+ color: "rgb(17, 24, 39)"
5017
+ },
5018
+ children: totalPriceFormatted || estimatedPrice
5019
+ }), isTestnet && totalPriceUsdc && /* @__PURE__ */ jsxs("span", {
5020
+ style: {
5021
+ fontSize: "0.75rem",
5022
+ color: "rgb(107, 114, 128)",
5023
+ opacity: .8
5024
+ },
5025
+ children: [
5026
+ "(",
5027
+ totalPriceUsdc,
5028
+ ")"
5029
+ ]
5030
+ })]
5031
+ })]
5032
+ }),
5033
+ expirationDate && /* @__PURE__ */ jsx("div", {
5034
+ style: {
5035
+ marginTop: "0.5rem",
5036
+ paddingTop: "0.5rem",
5037
+ borderTop: "1px solid rgba(229, 231, 235, 1)"
5038
+ },
5039
+ children: /* @__PURE__ */ jsxs("div", {
5040
+ style: {
5041
+ display: "flex",
5042
+ justifyContent: "space-between",
5043
+ alignItems: "center"
5044
+ },
5045
+ children: [/* @__PURE__ */ jsx("span", {
5046
+ style: {
5047
+ fontSize: "0.75rem",
5048
+ color: "rgb(107, 114, 128)"
5049
+ },
5050
+ children: "Expires on:"
5051
+ }), /* @__PURE__ */ jsx("span", {
5052
+ style: {
5053
+ fontSize: "0.75rem",
5054
+ fontWeight: 500,
5055
+ color: "rgb(17, 24, 39)"
5056
+ },
5057
+ children: expirationDate.toLocaleDateString("en-US", {
5058
+ year: "numeric",
5059
+ month: "long",
5060
+ day: "numeric"
5061
+ })
5062
+ })]
5063
+ })
5064
+ })
5065
+ ]
4541
5066
  })]
4542
5067
  }),
4543
5068
  error && /* @__PURE__ */ jsx("div", {
@@ -4567,7 +5092,7 @@ const RegisterSuiNsDialog = ({ isOpen, onClose, onRegistered, currentAccount, cl
4567
5092
  height: "1rem",
4568
5093
  animation: "spin 1s linear infinite",
4569
5094
  marginRight: "0.5rem"
4570
- } }), "Registering..."] }) : `Register ${fullName}`
5095
+ } }), "Registering..."] }) : `Register ${fullName} for ${selectedYears} ${selectedYears === 1 ? "year" : "years"}`
4571
5096
  })
4572
5097
  ]
4573
5098
  })
@@ -4904,5 +5429,5 @@ const PublishButton = ({ children, siteId, assets, onUpdateSiteMetadata, onAssoc
4904
5429
  var PublishButton_default = PublishButton;
4905
5430
 
4906
5431
  //#endregion
4907
- 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 };
4908
5433
  //# sourceMappingURL=index.js.map