diff --git a/apps/api/src/app.ts b/apps/api/src/app.ts index c239f93ea..c36995882 100644 --- a/apps/api/src/app.ts +++ b/apps/api/src/app.ts @@ -1,23 +1,24 @@ -import packageJson from "../package.json"; -import { isProd } from "./utils/constants"; -import * as Sentry from "@sentry/node"; -import { Scheduler } from "./scheduler"; -import { apiRouter } from "./routers/apiRouter"; -import { userRouter } from "./routers/userRouter"; -import { web3IndexRouter } from "./routers/web3indexRouter"; -import { bytesToHumanReadableSize } from "./utils/files"; -import { env } from "./utils/env"; -import { chainDb, syncUserSchema, userDb } from "./db/dbConnection"; -import { dashboardRouter } from "./routers/dashboardRouter"; -import { Hono } from "hono"; -import { cors } from "hono/cors"; import { serve } from "@hono/node-server"; -import { legacyRouter } from "./routers/legacyRouter"; // TODO: find out how to properly import this // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-expect-error import { sentry } from "@hono/sentry"; +import * as Sentry from "@sentry/node"; +import { Hono } from "hono"; +import { cors } from "hono/cors"; + +import packageJson from "../package.json"; +import { chainDb, syncUserSchema, userDb } from "./db/dbConnection"; +import { apiRouter } from "./routers/apiRouter"; +import { dashboardRouter } from "./routers/dashboardRouter"; import { internalRouter } from "./routers/internalRouter"; +import { legacyRouter } from "./routers/legacyRouter"; +import { userRouter } from "./routers/userRouter"; +import { web3IndexRouter } from "./routers/web3indexRouter"; +import { isProd } from "./utils/constants"; +import { env } from "./utils/env"; +import { bytesToHumanReadableSize } from "./utils/files"; +import { Scheduler } from "./scheduler"; const appHono = new Hono(); appHono.use( @@ -59,7 +60,7 @@ appHono.use( sentry({ dsn: env.SentryDSN, environment: env.NODE_ENV, - beforeSend: (event) => { + beforeSend: event => { event.server_name = env.SentryServerName; return event; }, @@ -76,7 +77,7 @@ appHono.route("/web3-index", web3IndexRouter); appHono.route("/dashboard", dashboardRouter); appHono.route("/internal", internalRouter); -appHono.get("/status", (c) => { +appHono.get("/status", c => { const version = packageJson.version; const tasksStatus = scheduler.getTasksStatus(); const memoryInBytes = process.memoryUsage(); diff --git a/apps/api/src/caching/helpers.ts b/apps/api/src/caching/helpers.ts index 97dc43f68..1374011c8 100644 --- a/apps/api/src/caching/helpers.ts +++ b/apps/api/src/caching/helpers.ts @@ -1,6 +1,7 @@ +import * as Sentry from "@sentry/node"; import { differenceInSeconds } from "date-fns"; + import MemoryCacheEngine from "./memoryCacheEngine"; -import * as Sentry from "@sentry/node"; export const cacheEngine = new MemoryCacheEngine(); const pendingRequests: { [key: string]: Promise } = {}; @@ -36,11 +37,11 @@ export async function cacheResponse(seconds: number, key: string, refreshRequ if ((!cachedObject || cacheExpired) && !(key in pendingRequests)) { // console.log(`Making request: ${key}`); pendingRequests[key] = refreshRequest() - .then((data) => { + .then(data => { cacheEngine.storeInCache(key, { date: new Date(), data: data }, keepData ? undefined : duration); return data; }) - .catch((err) => { + .catch(err => { // console.log(`Error making cache request ${err}`); Sentry.captureException(err); }) diff --git a/apps/api/src/db/dbConnection.ts b/apps/api/src/db/dbConnection.ts index 3cafa039f..f68949e74 100644 --- a/apps/api/src/db/dbConnection.ts +++ b/apps/api/src/db/dbConnection.ts @@ -1,10 +1,11 @@ +import { chainDefinitions } from "@akashnetwork/cloudmos-shared/chainDefinitions"; +import { chainModels, getChainModels, userModels } from "@akashnetwork/cloudmos-shared/dbSchemas"; +import { Template, TemplateFavorite, UserAddressName, UserSetting } from "@akashnetwork/cloudmos-shared/dbSchemas/user"; import pg from "pg"; -import { env } from "@src/utils/env"; import { Transaction as DbTransaction } from "sequelize"; import { Sequelize } from "sequelize-typescript"; -import { chainModels, getChainModels, userModels } from "@akashnetwork/cloudmos-shared/dbSchemas"; -import { Template, TemplateFavorite, UserAddressName, UserSetting } from "@akashnetwork/cloudmos-shared/dbSchemas/user"; -import { chainDefinitions } from "@akashnetwork/cloudmos-shared/chainDefinitions"; + +import { env } from "@src/utils/env"; function isValidNetwork(network: string): network is keyof typeof csMap { return network in csMap; @@ -37,7 +38,7 @@ export const chainDb = new Sequelize(csMap[env.Network], { }); export const chainDbs: { [key: string]: Sequelize } = Object.keys(chainDefinitions) - .filter((x) => chainDefinitions[x].connectionString) + .filter(x => chainDefinitions[x].connectionString) .reduce( (obj, chain) => ({ ...obj, @@ -74,4 +75,4 @@ export async function syncUserSchema() { await TemplateFavorite.sync(); } -export const closeConnections = async () => await Promise.all([chainDb.close(), userDb.close(), ...Object.values(chainDbs).map((db) => db.close())]); +export const closeConnections = async () => await Promise.all([chainDb.close(), userDb.close(), ...Object.values(chainDbs).map(db => db.close())]); diff --git a/apps/api/src/middlewares/privateMiddleware.ts b/apps/api/src/middlewares/privateMiddleware.ts index 2149455d9..5b7562272 100644 --- a/apps/api/src/middlewares/privateMiddleware.ts +++ b/apps/api/src/middlewares/privateMiddleware.ts @@ -1,6 +1,7 @@ -import { env } from "@src/utils/env"; import { Context, Next } from "hono"; +import { env } from "@src/utils/env"; + export async function privateMiddleware(c: Context, next: Next) { if (!env.SecretToken) { await next(); diff --git a/apps/api/src/middlewares/userMiddleware.ts b/apps/api/src/middlewares/userMiddleware.ts index 63a98b1c3..8acc3bc3e 100644 --- a/apps/api/src/middlewares/userMiddleware.ts +++ b/apps/api/src/middlewares/userMiddleware.ts @@ -1,7 +1,8 @@ -import { env } from "@src/utils/env"; -import { getPayloadFromContext, verifyRsaJwt } from "../verify-rsa-jwt-cloudflare-worker-main"; import { Context } from "hono"; + import { cacheEngine } from "@src/caching/helpers"; +import { env } from "@src/utils/env"; +import { getPayloadFromContext, verifyRsaJwt } from "../verify-rsa-jwt-cloudflare-worker-main"; export const kvStore = { async get(key: string, format: string) { diff --git a/apps/api/src/routers/apiRouter.ts b/apps/api/src/routers/apiRouter.ts index d67f12230..cabe5509c 100644 --- a/apps/api/src/routers/apiRouter.ts +++ b/apps/api/src/routers/apiRouter.ts @@ -1,7 +1,8 @@ -import { OpenAPIHono } from "@hono/zod-openapi"; import { swaggerUI } from "@hono/swagger-ui"; -import routesV1 from "../routes/v1"; +import { OpenAPIHono } from "@hono/zod-openapi"; + import { env } from "@src/utils/env"; +import routesV1 from "../routes/v1"; export const apiRouter = new OpenAPIHono(); @@ -20,9 +21,9 @@ function registerApiVersion(version: string, baseRouter: OpenAPIHono, versionRou const swaggerInstance = swaggerUI({ url: `/${version}/doc` }); versionRouter.get(`/swagger`, swaggerInstance); - versionRouter.get(`/swagger/`, (c) => c.redirect(`/${version}/swagger`)); + versionRouter.get(`/swagger/`, c => c.redirect(`/${version}/swagger`)); - versionRoutes.forEach((route) => versionRouter.route(`/`, route)); + versionRoutes.forEach(route => versionRouter.route(`/`, route)); baseRouter.route(`/${version}`, versionRouter); } diff --git a/apps/api/src/routers/dashboardRouter.ts b/apps/api/src/routers/dashboardRouter.ts index 62518a94f..ab7d2290b 100644 --- a/apps/api/src/routers/dashboardRouter.ts +++ b/apps/api/src/routers/dashboardRouter.ts @@ -1,12 +1,13 @@ import { Template, UserSetting } from "@akashnetwork/cloudmos-shared/dbSchemas/user"; -import { privateMiddleware } from "@src/middlewares/privateMiddleware"; import { Hono } from "hono"; +import { privateMiddleware } from "@src/middlewares/privateMiddleware"; + export const dashboardRouter = new Hono(); dashboardRouter.use("*", privateMiddleware); -dashboardRouter.get("/stats", async (c) => { +dashboardRouter.get("/stats", async c => { const userCountRequest = UserSetting.count(); const publicTemplateCountRequest = Template.count({ where: { isPublic: true } diff --git a/apps/api/src/routers/internalRouter.ts b/apps/api/src/routers/internalRouter.ts index 244781132..60b5feca8 100644 --- a/apps/api/src/routers/internalRouter.ts +++ b/apps/api/src/routers/internalRouter.ts @@ -1,7 +1,8 @@ -import { OpenAPIHono } from "@hono/zod-openapi"; import { swaggerUI } from "@hono/swagger-ui"; -import routes from "../routes/internal"; +import { OpenAPIHono } from "@hono/zod-openapi"; + import { env } from "@src/utils/env"; +import routes from "../routes/internal"; export const internalRouter = new OpenAPIHono(); @@ -19,4 +20,4 @@ const swaggerInstance = swaggerUI({ url: `/internal/doc` }); internalRouter.get(`/swagger`, swaggerInstance); -routes.forEach((route) => internalRouter.route(`/`, route)); +routes.forEach(route => internalRouter.route(`/`, route)); diff --git a/apps/api/src/routers/legacyRouter.ts b/apps/api/src/routers/legacyRouter.ts index 785338d30..b4c6f0c8d 100644 --- a/apps/api/src/routers/legacyRouter.ts +++ b/apps/api/src/routers/legacyRouter.ts @@ -4,53 +4,53 @@ export const legacyRouter = new Hono(); const redirectStatusCode = 302; // Temporary Redirect -legacyRouter.get("/blocks", async (c) => { +legacyRouter.get("/blocks", async c => { const limit = c.req.query("limit"); return c.redirect(`/v1/blocks${limit ? `?limit=${limit}` : ""}`, redirectStatusCode); }); -legacyRouter.get("/blocks/:height", async (c) => { +legacyRouter.get("/blocks/:height", async c => { const height = c.req.param("height"); return c.redirect(`/v1/blocks/${height}`, redirectStatusCode); }); -legacyRouter.get("/predicted-block-date/:height/:blockWindow?", async (c) => { +legacyRouter.get("/predicted-block-date/:height/:blockWindow?", async c => { const height = c.req.param("height"); const blockWindow = c.req.param("blockWindow"); return c.redirect(`/v1/predicted-block-date/${height}${blockWindow ? `?blockWindow=${blockWindow}` : ""}`, redirectStatusCode); }); -legacyRouter.get("/predicted-date-height/:date/:blockWindow?", async (c) => { +legacyRouter.get("/predicted-date-height/:date/:blockWindow?", async c => { const date = c.req.param("date"); const blockWindow = c.req.param("blockWindow"); return c.redirect(`/v1/predicted-date-height/${date}${blockWindow ? `?blockWindow=${blockWindow}` : ""}`, redirectStatusCode); }); -legacyRouter.get("/transactions", async (c) => { +legacyRouter.get("/transactions", async c => { const limit = c.req.query("limit"); return c.redirect(`/v1/transactions${limit ? `?limit=${limit}` : ""}`, redirectStatusCode); }); -legacyRouter.get("/transactions/:hash", async (c) => { +legacyRouter.get("/transactions/:hash", async c => { const hash = c.req.param("hash"); return c.redirect(`/v1/transactions/${hash}`, redirectStatusCode); }); -legacyRouter.get("/addresses/:address", async (c) => { +legacyRouter.get("/addresses/:address", async c => { const address = c.req.param("address"); return c.redirect(`/v1/addresses/${address}`, redirectStatusCode); }); -legacyRouter.get("/addresses/:address/transactions/:skip/:limit", async (c) => { +legacyRouter.get("/addresses/:address/transactions/:skip/:limit", async c => { const address = c.req.param("address"); const skip = c.req.param("skip"); const limit = c.req.param("limit"); return c.redirect(`/v1/addresses/${address}/transactions/${skip}/${limit}`, redirectStatusCode); }); -legacyRouter.get("/addresses/:address/deployments/:skip/:limit", async (c) => { +legacyRouter.get("/addresses/:address/deployments/:skip/:limit", async c => { const address = c.req.param("address"); const skip = c.req.param("skip"); const limit = c.req.param("limit"); @@ -72,16 +72,16 @@ legacyRouter.get("/addresses/:address/deployments/:skip/:limit", async (c) => { return c.redirect(`/v1/addresses/${address}/deployments/${skip}/${limit}${q ? "?" + q : ""}`, redirectStatusCode); }); -legacyRouter.get("/providers/:address", async (c) => { +legacyRouter.get("/providers/:address", async c => { const address = c.req.param("address"); return c.redirect(`/v1/providers/${address}`, redirectStatusCode); }); -legacyRouter.get("/providers", async (c) => { +legacyRouter.get("/providers", async c => { return c.redirect("/v1/providers", redirectStatusCode); }); -legacyRouter.get("/providers/:provider/deployments/:skip/:limit/:status?", async (c) => { +legacyRouter.get("/providers/:provider/deployments/:skip/:limit/:status?", async c => { const provider = c.req.param("provider"); const skip = c.req.param("skip"); const limit = c.req.param("limit"); @@ -89,101 +89,101 @@ legacyRouter.get("/providers/:provider/deployments/:skip/:limit/:status?", async return c.redirect(`/v1/providers/${provider}/deployments/${skip}/${limit}${status ? `?status=${status}` : ""}`, redirectStatusCode); }); -legacyRouter.get("/provider-attributes-schema", async (c) => { +legacyRouter.get("/provider-attributes-schema", async c => { return c.redirect("/v1/provider-attributes-schema", redirectStatusCode); }); -legacyRouter.get("/provider-regions", async (c) => { +legacyRouter.get("/provider-regions", async c => { return c.redirect("/v1/provider-regions", redirectStatusCode); }); -legacyRouter.get("/validators", async (c) => { +legacyRouter.get("/validators", async c => { return c.redirect("/v1/validators", redirectStatusCode); }); -legacyRouter.get("/validators/:address", async (c) => { +legacyRouter.get("/validators/:address", async c => { const address = c.req.param("address"); return c.redirect(`/v1/validators/${address}`, redirectStatusCode); }); -legacyRouter.get("/proposals", async (c) => { +legacyRouter.get("/proposals", async c => { return c.redirect("/v1/proposals", redirectStatusCode); }); -legacyRouter.get("/proposals/:id", async (c) => { +legacyRouter.get("/proposals/:id", async c => { const id = c.req.param("id"); return c.redirect(`/v1/proposals/${id}`, redirectStatusCode); }); -legacyRouter.get("/templates", async (c) => { +legacyRouter.get("/templates", async c => { return c.redirect("/v1/templates", redirectStatusCode); }); -legacyRouter.get("/getNetworkCapacity", async (c) => { +legacyRouter.get("/getNetworkCapacity", async c => { return c.redirect("/v1/network-capacity", redirectStatusCode); }); -legacyRouter.get("/marketData", async (c) => { +legacyRouter.get("/marketData", async c => { return c.redirect("/v1/market-data", redirectStatusCode); }); -legacyRouter.get("/dashboardData", async (c) => { +legacyRouter.get("/dashboardData", async c => { return c.redirect("/v1/dashboard-data", redirectStatusCode); }); -legacyRouter.post("/pricing", async (c) => { +legacyRouter.post("/pricing", async c => { return c.redirect("/v1/pricing", 307); }); -legacyRouter.get("/getAuditors", async (c) => { +legacyRouter.get("/getAuditors", async c => { return c.redirect("/v1/auditors", redirectStatusCode); }); -legacyRouter.get("/getMainnetNodes", async (c) => { +legacyRouter.get("/getMainnetNodes", async c => { return c.redirect("/v1/nodes/mainnet", redirectStatusCode); }); -legacyRouter.get("/getSandboxNodes", async (c) => { +legacyRouter.get("/getSandboxNodes", async c => { return c.redirect("/v1/nodes/sandbox", redirectStatusCode); }); -legacyRouter.get("/getTestnetNodes", async (c) => { +legacyRouter.get("/getTestnetNodes", async c => { return c.redirect("/v1/nodes/testnet", redirectStatusCode); }); -legacyRouter.get("/getProviderAttributesSchema", async (c) => { +legacyRouter.get("/getProviderAttributesSchema", async c => { return c.redirect("/v1/provider-attributes-schema", redirectStatusCode); }); -legacyRouter.get("/getMainnetVersion", async (c) => { +legacyRouter.get("/getMainnetVersion", async c => { return c.redirect("/v1/version/mainnet", redirectStatusCode); }); -legacyRouter.get("/getSandboxVersion", async (c) => { +legacyRouter.get("/getSandboxVersion", async c => { return c.redirect("/v1/version/sandbox", redirectStatusCode); }); -legacyRouter.get("/getTestnetVersion", async (c) => { +legacyRouter.get("/getTestnetVersion", async c => { return c.redirect("/v1/version/testnet", redirectStatusCode); }); -legacyRouter.get("/deployment/:owner/:dseq", async (c) => { +legacyRouter.get("/deployment/:owner/:dseq", async c => { const owner = c.req.param("owner"); const dseq = c.req.param("dseq"); return c.redirect(`/v1/deployment/${owner}/${dseq}`, redirectStatusCode); }); -legacyRouter.get("/getProviderGraphData/:dataName", async (c) => { +legacyRouter.get("/getProviderGraphData/:dataName", async c => { const dataName = c.req.param("dataName"); return c.redirect(`/v1/provider-graph-data/${dataName}`, redirectStatusCode); }); -legacyRouter.get("/getProviderActiveLeasesGraphData/:address", async (c) => { +legacyRouter.get("/getProviderActiveLeasesGraphData/:address", async c => { const address = c.req.param("address"); return c.redirect(`/v1/provider-active-leases-graph-data/${address}`, redirectStatusCode); }); -legacyRouter.get("/getGraphData/:dataName", async (c) => { +legacyRouter.get("/getGraphData/:dataName", async c => { const dataName = c.req.param("dataName"); return c.redirect(`/v1/graph-data/${dataName}`, redirectStatusCode); }); diff --git a/apps/api/src/routers/userRouter.ts b/apps/api/src/routers/userRouter.ts index fc3848423..b4c4de3e2 100644 --- a/apps/api/src/routers/userRouter.ts +++ b/apps/api/src/routers/userRouter.ts @@ -1,28 +1,29 @@ -import { - saveAddressName, - getAddressNames, - removeAddressName, - getSettingsOrInit, - updateSettings, - getUserByUsername, - checkUsernameAvailable, - subscribeToNewsletter -} from "@src/services/db/userDataService"; -import { isValidBech32Address } from "@src/utils/addresses"; +import { Hono } from "hono"; import * as uuid from "uuid"; + +import { getCurrentUserId, optionalUserMiddleware, requiredUserMiddleware } from "@src/middlewares/userMiddleware"; import { + addTemplateFavorite, deleteTemplate, - getTemplateById, getFavoriteTemplates, + getTemplateById, getTemplates, - saveTemplate, - saveTemplateDesc, removeTemplateFavorite, - addTemplateFavorite + saveTemplate, + saveTemplateDesc } from "@src/services/db/templateService"; +import { + checkUsernameAvailable, + getAddressNames, + getSettingsOrInit, + getUserByUsername, + removeAddressName, + saveAddressName, + subscribeToNewsletter, + updateSettings +} from "@src/services/db/userDataService"; import { getBillingPortalUrl, getCheckoutUrl } from "@src/services/external/stripeService"; -import { Hono } from "hono"; -import { getCurrentUserId, optionalUserMiddleware, requiredUserMiddleware } from "@src/middlewares/userMiddleware"; +import { isValidBech32Address } from "@src/utils/addresses"; export const userRouter = new Hono(); @@ -32,14 +33,14 @@ userRequiredRouter.use("*", requiredUserMiddleware); const userOptionalRouter = new Hono(); userOptionalRouter.use("*", optionalUserMiddleware); -userRequiredRouter.post("/manage-subscription", async (c) => { +userRequiredRouter.post("/manage-subscription", async c => { const userId = getCurrentUserId(c); const portalUrl = await getBillingPortalUrl(userId); return c.redirect(portalUrl); }); -userRequiredRouter.post("/subscribe", async (c) => { +userRequiredRouter.post("/subscribe", async c => { const userId = getCurrentUserId(c); const { planCode, period } = await c.req.json(); // TODO Test @@ -55,7 +56,7 @@ userRequiredRouter.post("/subscribe", async (c) => { return c.redirect(checkoutUrl, 303); }); -userOptionalRouter.get("/byUsername/:username", async (c) => { +userOptionalRouter.get("/byUsername/:username", async c => { const username = c.req.param("username"); const user = await getUserByUsername(username); @@ -67,14 +68,14 @@ userOptionalRouter.get("/byUsername/:username", async (c) => { return c.json(user); }); -userRequiredRouter.get("/addressNames", async (c) => { +userRequiredRouter.get("/addressNames", async c => { const userId = getCurrentUserId(c); const addressNames = await getAddressNames(userId); return c.json(addressNames); }); -userRequiredRouter.post("/saveAddressName", async (c) => { +userRequiredRouter.post("/saveAddressName", async c => { const userId = getCurrentUserId(c); const { address, name } = await c.req.json(); @@ -95,7 +96,7 @@ userRequiredRouter.post("/saveAddressName", async (c) => { return c.text("Saved"); }); -userRequiredRouter.delete("/removeAddressName/:address", async (c) => { +userRequiredRouter.delete("/removeAddressName/:address", async c => { const userId = getCurrentUserId(c); if (!c.req.param("address")) { @@ -111,7 +112,7 @@ userRequiredRouter.delete("/removeAddressName/:address", async (c) => { return c.text("Removed"); }); -userRequiredRouter.post("/tokenInfo", async (c) => { +userRequiredRouter.post("/tokenInfo", async c => { const userId = getCurrentUserId(c); const { wantedUsername, email, emailVerified, subscribedToNewsletter } = await c.req.json(); @@ -120,7 +121,7 @@ userRequiredRouter.post("/tokenInfo", async (c) => { return c.json(settings); }); -userRequiredRouter.put("/updateSettings", async (c) => { +userRequiredRouter.put("/updateSettings", async c => { const userId = getCurrentUserId(c); const { username, subscribedToNewsletter, bio, youtubeUsername, twitterUsername, githubUsername } = await c.req.json(); @@ -133,7 +134,7 @@ userRequiredRouter.put("/updateSettings", async (c) => { return c.text("Saved"); }); -userOptionalRouter.get("/template/:id", async (c) => { +userOptionalRouter.get("/template/:id", async c => { const userId = getCurrentUserId(c); const templateId = c.req.param("id"); @@ -150,7 +151,7 @@ userOptionalRouter.get("/template/:id", async (c) => { return c.json(template); }); -userRequiredRouter.post("/saveTemplate", async (c) => { +userRequiredRouter.post("/saveTemplate", async c => { const userId = getCurrentUserId(c); const { id, sdl, isPublic, title, cpu, ram, storage } = await c.req.json(); @@ -167,7 +168,7 @@ userRequiredRouter.post("/saveTemplate", async (c) => { return c.text(templateId); }); -userRequiredRouter.post("/saveTemplateDesc", async (c) => { +userRequiredRouter.post("/saveTemplateDesc", async c => { const userId = getCurrentUserId(c); const { id, description } = await c.req.json(); @@ -176,7 +177,7 @@ userRequiredRouter.post("/saveTemplateDesc", async (c) => { return c.text("Saved"); }); -userOptionalRouter.get("/templates/:username", async (c) => { +userOptionalRouter.get("/templates/:username", async c => { const username = c.req.param("username"); const userId = getCurrentUserId(c); @@ -189,7 +190,7 @@ userOptionalRouter.get("/templates/:username", async (c) => { return c.json(templates); }); -userRequiredRouter.delete("/deleteTemplate/:id", async (c) => { +userRequiredRouter.delete("/deleteTemplate/:id", async c => { const userId = getCurrentUserId(c); if (!c.req.param("id")) { @@ -205,20 +206,20 @@ userRequiredRouter.delete("/deleteTemplate/:id", async (c) => { return c.text("Removed"); }); -userOptionalRouter.get("/checkUsernameAvailability/:username", async (c) => { +userOptionalRouter.get("/checkUsernameAvailability/:username", async c => { const isAvailable = await checkUsernameAvailable(c.req.param("username")); return c.json({ isAvailable: isAvailable }); }); -userRequiredRouter.get("/favoriteTemplates", async (c) => { +userRequiredRouter.get("/favoriteTemplates", async c => { const userId = getCurrentUserId(c); const templates = await getFavoriteTemplates(userId); return c.json(templates); }); -userRequiredRouter.post("/addFavoriteTemplate/:templateId", async (c) => { +userRequiredRouter.post("/addFavoriteTemplate/:templateId", async c => { const userId = getCurrentUserId(c); if (!c.req.param("templateId")) { @@ -230,7 +231,7 @@ userRequiredRouter.post("/addFavoriteTemplate/:templateId", async (c) => { return c.text("Added"); }); -userRequiredRouter.delete("/removeFavoriteTemplate/:templateId", async (c) => { +userRequiredRouter.delete("/removeFavoriteTemplate/:templateId", async c => { const userId = getCurrentUserId(c); if (!c.req.param("templateId")) { @@ -242,7 +243,7 @@ userRequiredRouter.delete("/removeFavoriteTemplate/:templateId", async (c) => { return c.text("Removed"); }); -userRequiredRouter.post("/subscribeToNewsletter", async (c) => { +userRequiredRouter.post("/subscribeToNewsletter", async c => { const userId = getCurrentUserId(c); await subscribeToNewsletter(userId); diff --git a/apps/api/src/routers/web3indexRouter.ts b/apps/api/src/routers/web3indexRouter.ts index 642d9c4bb..450eef3fc 100644 --- a/apps/api/src/routers/web3indexRouter.ts +++ b/apps/api/src/routers/web3indexRouter.ts @@ -1,10 +1,11 @@ -import { getWeb3IndexRevenue } from "@src/services/db/networkRevenueService"; -import { cacheKeys, cacheResponse } from "@src/caching/helpers"; import { Hono } from "hono"; +import { cacheKeys, cacheResponse } from "@src/caching/helpers"; +import { getWeb3IndexRevenue } from "@src/services/db/networkRevenueService"; + export const web3IndexRouter = new Hono(); -web3IndexRouter.get("/revenue", async (c) => { +web3IndexRouter.get("/revenue", async c => { console.log("calculating revenue"); const isDebug = c.req.query("debug") === "true"; diff --git a/apps/api/src/routes/internal/gpu.ts b/apps/api/src/routes/internal/gpu.ts index 2c848017b..97b8f1ae6 100644 --- a/apps/api/src/routes/internal/gpu.ts +++ b/apps/api/src/routes/internal/gpu.ts @@ -1,10 +1,11 @@ -import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; +import { sub } from "date-fns"; +import { QueryTypes } from "sequelize"; + import { chainDb } from "@src/db/dbConnection"; import { toUTC } from "@src/utils"; import { isValidBech32Address } from "@src/utils/addresses"; import { env } from "@src/utils/env"; -import { sub } from "date-fns"; -import { QueryTypes } from "sequelize"; const route = createRoute({ method: "get", @@ -52,7 +53,7 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { const provider = c.req.query("provider"); const vendor = c.req.query("vendor"); const model = c.req.query("model"); @@ -122,8 +123,8 @@ export default new OpenAPIHono().openapi(route, async (c) => { const response = { gpus: { total: { - allocatable: gpuNodes.map((x) => x.allocatable).reduce((acc, x) => acc + x, 0), - allocated: gpuNodes.map((x) => x.allocated).reduce((acc, x) => acc + x, 0) + allocatable: gpuNodes.map(x => x.allocatable).reduce((acc, x) => acc + x, 0), + allocated: gpuNodes.map(x => x.allocated).reduce((acc, x) => acc + x, 0) }, details: {} as { [key: string]: { model: string; ram: string; interface: string; allocatable: number; allocated: number }[] } } @@ -136,7 +137,7 @@ export default new OpenAPIHono().openapi(route, async (c) => { } const existing = response.gpus.details[vendorName].find( - (x) => x.model === gpuNode.modelName && x.interface === gpuNode.interface && x.ram === gpuNode.memorySize + x => x.model === gpuNode.modelName && x.interface === gpuNode.interface && x.ram === gpuNode.memorySize ); if (existing) { diff --git a/apps/api/src/routes/internal/gpuModels.ts b/apps/api/src/routes/internal/gpuModels.ts index c42b2a28b..aae1678ff 100644 --- a/apps/api/src/routes/internal/gpuModels.ts +++ b/apps/api/src/routes/internal/gpuModels.ts @@ -1,8 +1,9 @@ -import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; +import axios from "axios"; + import { cacheKeys, cacheResponse } from "@src/caching/helpers"; import { GpuVendor, ProviderConfigGpusType } from "@src/types/gpu"; import { getGpuInterface } from "@src/utils/gpu"; -import axios from "axios"; const route = createRoute({ method: "get", @@ -32,7 +33,7 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { const response = await cacheResponse(60 * 2, cacheKeys.getGpuModels, async () => { const res = await axios.get("https://raw.githubusercontent.com/akash-network/provider-configs/main/devices/pcie/gpus.json"); return res.data; @@ -54,7 +55,7 @@ export default new OpenAPIHono().openapi(route, async (c) => { memory_size: string; interface: string; }; - const existingModel = vendor.models.find((x) => x.name === _modelValue.name); + const existingModel = vendor.models.find(x => x.name === _modelValue.name); if (existingModel) { if (!existingModel.memory.includes(_modelValue.memory_size)) { diff --git a/apps/api/src/routes/internal/gpuPrices.ts b/apps/api/src/routes/internal/gpuPrices.ts index 7f98f3628..0cd17dec5 100644 --- a/apps/api/src/routes/internal/gpuPrices.ts +++ b/apps/api/src/routes/internal/gpuPrices.ts @@ -1,17 +1,18 @@ -import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; +import { MsgCreateBid } from "@akashnetwork/akash-api/akash/market/v1beta4"; import { Block } from "@akashnetwork/cloudmos-shared/dbSchemas"; import { AkashMessage, Deployment, DeploymentGroup, DeploymentGroupResource } from "@akashnetwork/cloudmos-shared/dbSchemas/akash"; import { Day, Transaction } from "@akashnetwork/cloudmos-shared/dbSchemas/base"; +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; +import { addDays, sub } from "date-fns"; +import { Op, QueryTypes } from "sequelize"; + import { cacheResponse } from "@src/caching/helpers"; import { chainDb } from "@src/db/dbConnection"; -import { MsgCreateBid } from "@akashnetwork/akash-api/akash/market/v1beta4"; import { toUTC } from "@src/utils"; import { averageBlockCountInAMonth, averageBlockCountInAnHour } from "@src/utils/constants"; import { env } from "@src/utils/env"; import { average, median, round, weightedAverage } from "@src/utils/math"; import { decodeMsg, uint8arrayToString } from "@src/utils/protobuf"; -import { addDays, sub } from "date-fns"; -import { Op, QueryTypes } from "sequelize"; const route = createRoute({ method: "get", @@ -58,7 +59,7 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { const debug = c.req.query("debug") === "true"; console.time("gpu prices"); @@ -145,9 +146,9 @@ async function getGpuPrices(debug: boolean) { // Decode the MsgCreateBid messages and calculate the hourly and monthly price for each bid const gpuBids: GpuBidType[] = deployments - .flatMap((d) => - d.relatedMessages.map((x) => { - const day = days.find((d) => d.id === x.block.dayId); + .flatMap(d => + d.relatedMessages.map(x => { + const day = days.find(d => d.id === x.block.dayId); const decodedBid = decodeMsg("/akash.market.v1beta4.MsgCreateBid", x.data) as MsgCreateBid; if (!day || !day.aktPrice) return null; // Ignore bids for days where we don't have the AKT price @@ -164,29 +165,29 @@ async function getGpuPrices(debug: boolean) { monthlyPrice: blockPriceToMonthlyPrice(parseFloat(decodedBid.price.amount), day?.aktPrice), deployment: { owner: d.owner, - cpuUnits: decodedBid.resourcesOffer.flatMap((r) => parseInt(uint8arrayToString(r.resources.cpu.units.val))).reduce((a, b) => a + b, 0), - memoryUnits: decodedBid.resourcesOffer.flatMap((r) => parseInt(uint8arrayToString(r.resources.memory.quantity.val))).reduce((a, b) => a + b, 0), + cpuUnits: decodedBid.resourcesOffer.flatMap(r => parseInt(uint8arrayToString(r.resources.cpu.units.val))).reduce((a, b) => a + b, 0), + memoryUnits: decodedBid.resourcesOffer.flatMap(r => parseInt(uint8arrayToString(r.resources.memory.quantity.val))).reduce((a, b) => a + b, 0), storageUnits: decodedBid.resourcesOffer - .flatMap((r) => r.resources.storage) - .map((s) => parseInt(uint8arrayToString(s.quantity.val))) + .flatMap(r => r.resources.storage) + .map(s => parseInt(uint8arrayToString(s.quantity.val))) .reduce((a, b) => a + b, 0), gpus: decodedBid.resourcesOffer - .filter((x) => parseInt(uint8arrayToString(x.resources.gpu.units.val)) > 0) - .flatMap((r) => getGpusFromAttributes(r.resources.gpu.attributes)) + .filter(x => parseInt(uint8arrayToString(x.resources.gpu.units.val)) > 0) + .flatMap(r => getGpusFromAttributes(r.resources.gpu.attributes)) }, data: decodedBid }; }) ) - .filter((x) => x) - .filter((x) => x.deployment.gpus.length === 1); // Ignore bids for deployments with more than 1 GPU + .filter(x => x) + .filter(x => x.deployment.gpus.length === 1); // Ignore bids for deployments with more than 1 GPU - const gpuModels: GpuWithPricesType[] = gpus.map((x) => ({ ...x, prices: [] })); + const gpuModels: GpuWithPricesType[] = gpus.map(x => ({ ...x, prices: [] })); // Add bids to their corresponding GPU models for (const bid of gpuBids) { const gpu = bid.deployment.gpus[0]; - const matchingGpuModels = gpuModels.filter((x) => x.vendor === gpu.vendor && x.model === gpu.model); + const matchingGpuModels = gpuModels.filter(x => x.vendor === gpu.vendor && x.model === gpu.model); for (const gpuModel of matchingGpuModels) { gpuModel.prices.push(bid); @@ -198,15 +199,15 @@ async function getGpuPrices(debug: boolean) { (a, b) => a.vendor.localeCompare(b.vendor) || a.model.localeCompare(b.model) || a.ram.localeCompare(b.ram) || a.interface.localeCompare(b.interface) ); - const totalAllocatable = gpuModels.map((x) => x.allocatable).reduce((a, b) => a + b, 0); - const totalAllocated = gpuModels.map((x) => x.allocated).reduce((a, b) => a + b, 0); + const totalAllocatable = gpuModels.map(x => x.allocatable).reduce((a, b) => a + b, 0); + const totalAllocated = gpuModels.map(x => x.allocated).reduce((a, b) => a + b, 0); return { availability: { total: totalAllocatable, available: totalAllocatable - totalAllocated }, - models: gpuModels.map((x) => { + models: gpuModels.map(x => { /* For each providers get their most relevent bid based on this order of priority: 1- Most recent bid from the pricing bot (those deployment have tiny cpu/ram/storage specs to improve gpu price accuracy) @@ -216,12 +217,12 @@ async function getGpuPrices(debug: boolean) { 5- If no bids are found, increase search range from 14 to 31 days and repeat steps 2-4 */ const providersWithBestBid = x.providers - .map((p) => { - const providerBids = x.prices.filter((b) => b.provider === p.owner); - const providerBidsLast14d = providerBids.filter((x) => x.datetime > addDays(new Date(), -14)); + .map(p => { + const providerBids = x.prices.filter(b => b.provider === p.owner); + const providerBidsLast14d = providerBids.filter(x => x.datetime > addDays(new Date(), -14)); const pricingBotAddress = "akash1pas6v0905jgyznpvnjhg7tsthuyqek60gkz7uf"; - const bidsFromPricingBot = providerBids.filter((x) => x.deployment.owner === pricingBotAddress && x.deployment.cpuUnits === 100); + const bidsFromPricingBot = providerBids.filter(x => x.deployment.owner === pricingBotAddress && x.deployment.cpuUnits === 100); let bestBid = null; if (bidsFromPricingBot.length > 0) { @@ -235,7 +236,7 @@ async function getGpuPrices(debug: boolean) { bestBid: bestBid }; }) - .filter((x) => x.bestBid); + .filter(x => x.bestBid); return { vendor: x.vendor, @@ -268,14 +269,14 @@ function getPricing( try { if (!providersWithBestBid || providersWithBestBid.length === 0) return null; - const prices = providersWithBestBid.map((x) => x.bestBid.hourlyPrice); + const prices = providersWithBestBid.map(x => x.bestBid.hourlyPrice); return { currency: "USD", min: Math.min(...prices), max: Math.max(...prices), avg: round(average(prices), 2), - weightedAverage: round(weightedAverage(providersWithBestBid.map((p) => ({ value: p.bestBid.hourlyPrice, weight: p.provider.allocatable }))), 2), + weightedAverage: round(weightedAverage(providersWithBestBid.map(p => ({ value: p.bestBid.hourlyPrice, weight: p.provider.allocatable }))), 2), med: round(median(prices), 2) }; } catch (e) { @@ -286,12 +287,12 @@ function getPricing( function findBestProviderBid(providerBids: GpuBidType[], gpuModel: GpuWithPricesType) { const providerBidsWithRamAndInterface = providerBids.filter( - (b) => b.deployment.gpus[0].ram === gpuModel.ram && isInterfaceMatching(gpuModel.interface, b.deployment.gpus[0].interface) + b => b.deployment.gpus[0].ram === gpuModel.ram && isInterfaceMatching(gpuModel.interface, b.deployment.gpus[0].interface) ); if (providerBidsWithRamAndInterface.length > 0) return providerBidsWithRamAndInterface.sort((a, b) => a.hourlyPrice - b.hourlyPrice)[0]; - const providerBidsWithRam = providerBids.filter((b) => b.deployment.gpus[0].ram === gpuModel.ram); + const providerBidsWithRam = providerBids.filter(b => b.deployment.gpus[0].ram === gpuModel.ram); if (providerBidsWithRam.length > 0) return providerBidsWithRam.sort((a, b) => a.hourlyPrice - b.hourlyPrice)[0]; @@ -307,8 +308,8 @@ export function isInterfaceMatching(gpuInterface: string, bidInterface: string) export function getGpusFromAttributes(attributes: { key: string; value: string }[]) { return attributes - .filter((attr) => attr.key.startsWith("vendor/") && attr.value === "true") - .map((attr) => { + .filter(attr => attr.key.startsWith("vendor/") && attr.value === "true") + .map(attr => { const vendor = /vendor\/([^/]+)/.exec(attr.key)?.[1]; const model = /model\/([^/]+)/.exec(attr.key)?.[1]; const ram = /ram\/([^/]+)/.exec(attr.key)?.[1]; @@ -375,14 +376,14 @@ async function getGpus() { const nodeInfo = { owner: gpuNode.owner, hostUri: gpuNode.hostUri, allocated: gpuNode.allocated, allocatable: gpuNode.allocatable }; const existingGpu = gpus.find( - (x) => x.vendor === gpuNode.vendor && x.model === gpuNode.modelName && x.interface === gpuNode.interface && x.ram === gpuNode.memorySize + x => x.vendor === gpuNode.vendor && x.model === gpuNode.modelName && x.interface === gpuNode.interface && x.ram === gpuNode.memorySize ); if (existingGpu) { existingGpu.allocatable += gpuNode.allocatable; existingGpu.allocated += gpuNode.allocated; - const existingProvider = existingGpu.providers.find((p) => p.hostUri === gpuNode.hostUri); + const existingProvider = existingGpu.providers.find(p => p.hostUri === gpuNode.hostUri); if (!existingProvider) { existingGpu.providers.push(nodeInfo); } else { @@ -390,7 +391,7 @@ async function getGpus() { existingProvider.allocatable += gpuNode.allocatable; } - existingGpu.availableProviders = existingGpu.providers.filter((p) => p.allocated < p.allocatable); + existingGpu.availableProviders = existingGpu.providers.filter(p => p.allocated < p.allocatable); } else { gpus.push({ vendor: gpuNode.vendor, diff --git a/apps/api/src/routes/internal/index.ts b/apps/api/src/routes/internal/index.ts index f0a1c2b52..389829203 100644 --- a/apps/api/src/routes/internal/index.ts +++ b/apps/api/src/routes/internal/index.ts @@ -1,7 +1,7 @@ -import providerVersions from "./providerVersions"; import gpu from "./gpu"; -import leasesDuration from "./leasesDuration"; import gpuModels from "./gpuModels"; import gpuPrices from "./gpuPrices"; +import leasesDuration from "./leasesDuration"; +import providerVersions from "./providerVersions"; export default [providerVersions, gpu, leasesDuration, gpuModels, gpuPrices]; diff --git a/apps/api/src/routes/internal/leasesDuration.ts b/apps/api/src/routes/internal/leasesDuration.ts index d7b3c5a3b..bb0af8076 100644 --- a/apps/api/src/routes/internal/leasesDuration.ts +++ b/apps/api/src/routes/internal/leasesDuration.ts @@ -1,10 +1,11 @@ -import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; import { Block } from "@akashnetwork/cloudmos-shared/dbSchemas"; import { Lease } from "@akashnetwork/cloudmos-shared/dbSchemas/akash"; -import { openApiExampleAddress } from "@src/utils/constants"; +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; import { differenceInSeconds } from "date-fns"; import { Op } from "sequelize"; +import { openApiExampleAddress } from "@src/utils/constants"; + const route = createRoute({ method: "get", path: "/leases-duration/{owner}", @@ -53,7 +54,7 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { const dateFormat = /^\d{4}-\d{2}-\d{2}$/; let startTime: Date = new Date("2000-01-01"); @@ -102,7 +103,7 @@ export default new OpenAPIHono().openapi(route, async (c) => { ] }); - const leases = closedLeases.map((x) => ({ + const leases = closedLeases.map(x => ({ dseq: x.dseq, oseq: x.oseq, gseq: x.gseq, @@ -116,7 +117,7 @@ export default new OpenAPIHono().openapi(route, async (c) => { durationInHours: differenceInSeconds(x.closedBlock.datetime, x.createdBlock.datetime) / 3600 })); - const totalSeconds = leases.map((x) => x.durationInSeconds).reduce((a, b) => a + b, 0); + const totalSeconds = leases.map(x => x.durationInSeconds).reduce((a, b) => a + b, 0); return c.json({ leaseCount: leases.length, diff --git a/apps/api/src/routes/internal/providerVersions.ts b/apps/api/src/routes/internal/providerVersions.ts index 282b3ea5c..e4ea77b5f 100644 --- a/apps/api/src/routes/internal/providerVersions.ts +++ b/apps/api/src/routes/internal/providerVersions.ts @@ -1,11 +1,12 @@ -import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; +import { sub } from "date-fns"; +import * as semver from "semver"; +import { QueryTypes } from "sequelize"; + import { chainDb } from "@src/db/dbConnection"; import { toUTC } from "@src/utils"; import { env } from "@src/utils/env"; import { round } from "@src/utils/math"; -import { sub } from "date-fns"; -import * as semver from "semver"; -import { QueryTypes } from "sequelize"; const route = createRoute({ method: "get", @@ -31,7 +32,7 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { const providers = await chainDb.query<{ hostUri: string; akashVersion: string }>( ` SELECT DISTINCT ON ("hostUri") "hostUri","akashVersion" @@ -50,7 +51,7 @@ export default new OpenAPIHono().openapi(route, async (c) => { const grouped: { version: string; providers: string[] }[] = []; for (const provider of providers) { - const existing = grouped.find((x) => x.version === provider.akashVersion); + const existing = grouped.find(x => x.version === provider.akashVersion); if (existing) { existing.providers.push(provider.hostUri); @@ -63,7 +64,7 @@ export default new OpenAPIHono().openapi(route, async (c) => { } const nullVersionName = ""; - const results = grouped.map((x) => ({ + const results = grouped.map(x => ({ version: x.version ?? nullVersionName, count: x.providers.length, ratio: round(x.providers.length / providers.length, 2), @@ -71,9 +72,9 @@ export default new OpenAPIHono().openapi(route, async (c) => { })); const sorted = results - .filter((x) => x.version !== nullVersionName) // Remove version for sorting + .filter(x => x.version !== nullVersionName) // Remove version for sorting .sort((a, b) => semver.compare(b.version, a.version)) - .concat(results.filter((x) => x.version === nullVersionName)) // Add back version at the end + .concat(results.filter(x => x.version === nullVersionName)) // Add back version at the end .reduce( (acc, x) => { acc[x.version] = x; diff --git a/apps/api/src/routes/v1/addresses/address.ts b/apps/api/src/routes/v1/addresses/address.ts index 7d879e379..f06e06f5d 100644 --- a/apps/api/src/routes/v1/addresses/address.ts +++ b/apps/api/src/routes/v1/addresses/address.ts @@ -1,4 +1,5 @@ -import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; + import { getAddressBalance } from "@src/services/external/apiNodeService"; import { isValidBech32Address } from "@src/utils/addresses"; import { openApiExampleAddress } from "@src/utils/constants"; @@ -99,7 +100,7 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { if (!isValidBech32Address(c.req.valid("param").address, "akash")) { return c.text("Invalid address", 400); } diff --git a/apps/api/src/routes/v1/addresses/deployments.ts b/apps/api/src/routes/v1/addresses/deployments.ts index 47d1994bb..559a53c80 100644 --- a/apps/api/src/routes/v1/addresses/deployments.ts +++ b/apps/api/src/routes/v1/addresses/deployments.ts @@ -1,4 +1,5 @@ -import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; + import { getAddressDeployments } from "@src/services/external/apiNodeService"; import { openApiExampleAddress } from "@src/utils/constants"; @@ -62,7 +63,7 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { const skip = parseInt(c.req.valid("param").skip); const limit = Math.min(maxLimit, parseInt(c.req.valid("param").limit)); diff --git a/apps/api/src/routes/v1/addresses/transactions.ts b/apps/api/src/routes/v1/addresses/transactions.ts index f974fff3a..47c635208 100644 --- a/apps/api/src/routes/v1/addresses/transactions.ts +++ b/apps/api/src/routes/v1/addresses/transactions.ts @@ -1,4 +1,5 @@ -import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; + import { getTransactionByAddress } from "@src/services/db/transactionsService"; import { isValidBech32Address } from "@src/utils/addresses"; import { openApiExampleAddress } from "@src/utils/constants"; @@ -66,7 +67,7 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { if (!isValidBech32Address(c.req.valid("param").address, "akash")) { return c.text("Invalid address", 400); } diff --git a/apps/api/src/routes/v1/auditors.ts b/apps/api/src/routes/v1/auditors.ts index 9e6101f12..19f986528 100644 --- a/apps/api/src/routes/v1/auditors.ts +++ b/apps/api/src/routes/v1/auditors.ts @@ -1,4 +1,5 @@ -import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; + import { getAuditors } from "@src/services/external/githubService"; const route = createRoute({ @@ -25,7 +26,7 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { const response = await getAuditors(); return c.json(response); }); diff --git a/apps/api/src/routes/v1/blocks/byHeight.ts b/apps/api/src/routes/v1/blocks/byHeight.ts index e9d6b5a87..d81b72fc9 100644 --- a/apps/api/src/routes/v1/blocks/byHeight.ts +++ b/apps/api/src/routes/v1/blocks/byHeight.ts @@ -1,4 +1,5 @@ -import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; + import { getBlock } from "@src/services/db/blocksService"; const route = createRoute({ @@ -60,7 +61,7 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { const heightInt = parseInt(c.req.valid("param").height); if (isNaN(heightInt)) { diff --git a/apps/api/src/routes/v1/blocks/list.ts b/apps/api/src/routes/v1/blocks/list.ts index d1293588f..f23cfc710 100644 --- a/apps/api/src/routes/v1/blocks/list.ts +++ b/apps/api/src/routes/v1/blocks/list.ts @@ -1,4 +1,5 @@ -import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; + import { getBlocks } from "@src/services/db/blocksService"; const defaultLimit = 20; @@ -45,7 +46,7 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { const limit = parseInt(c.req.valid("query").limit?.toString()); const blocks = await getBlocks(limit || defaultLimit); diff --git a/apps/api/src/routes/v1/dashboardData.ts b/apps/api/src/routes/v1/dashboardData.ts index 97d72c861..d050a3ea0 100644 --- a/apps/api/src/routes/v1/dashboardData.ts +++ b/apps/api/src/routes/v1/dashboardData.ts @@ -1,9 +1,10 @@ -import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; + import { getBlocks } from "@src/services/db/blocksService"; +import { getNetworkCapacity } from "@src/services/db/providerStatusService"; import { getDashboardData, getProviderGraphData } from "@src/services/db/statsService"; import { getTransactions } from "@src/services/db/transactionsService"; import { getChainStats } from "@src/services/external/apiNodeService"; -import { getNetworkCapacity } from "@src/services/db/providerStatusService"; const route = createRoute({ method: "get", @@ -142,7 +143,7 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { const chainStatsQuery = await getChainStats(); const dashboardData = await getDashboardData(); const networkCapacity = await getNetworkCapacity(); diff --git a/apps/api/src/routes/v1/deployments/byOwnerDseq.ts b/apps/api/src/routes/v1/deployments/byOwnerDseq.ts index ad9eb9313..cc3bbec8e 100644 --- a/apps/api/src/routes/v1/deployments/byOwnerDseq.ts +++ b/apps/api/src/routes/v1/deployments/byOwnerDseq.ts @@ -1,4 +1,5 @@ -import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; + import { getDeployment } from "@src/services/external/apiNodeService"; import { isValidBech32Address } from "@src/utils/addresses"; import { openApiExampleAddress } from "@src/utils/constants"; @@ -70,7 +71,7 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { if (isNaN(parseInt(c.req.valid("param").dseq))) { return c.text("Invalid dseq.", 400); } diff --git a/apps/api/src/routes/v1/graphData.ts b/apps/api/src/routes/v1/graphData.ts index 51e63da42..77809f6a8 100644 --- a/apps/api/src/routes/v1/graphData.ts +++ b/apps/api/src/routes/v1/graphData.ts @@ -1,4 +1,5 @@ -import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; + import { AuthorizedGraphDataNames, getGraphData, isValidGraphDataName } from "@src/services/db/statsService"; const route = createRoute({ @@ -34,7 +35,7 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { const dataName = c.req.valid("param").dataName; if (!isValidGraphDataName(dataName)) { diff --git a/apps/api/src/routes/v1/index.ts b/apps/api/src/routes/v1/index.ts index dd75e2194..9ae41b5e6 100644 --- a/apps/api/src/routes/v1/index.ts +++ b/apps/api/src/routes/v1/index.ts @@ -1,37 +1,37 @@ -import predictedBlockDate from "./predictedBlockDate"; -import predictedDateHeight from "./predictedDateHeight"; -import blocks from "./blocks/list"; -import blockByHeight from "./blocks/byHeight"; -import transactions from "./transactions/list"; -import transactionByHash from "./transactions/byHash"; import address from "./addresses/address"; -import addressTransactions from "./addresses/transactions"; import addressDeployments from "./addresses/deployments"; +import addressTransactions from "./addresses/transactions"; +import blockByHeight from "./blocks/byHeight"; +import blocks from "./blocks/list"; +import deploymentByOwnerDseq from "./deployments/byOwnerDseq"; +import nodesMainnet from "./nodes/mainnet"; +import nodesSandbox from "./nodes/sandbox"; +import nodesTestnet from "./nodes/testnet"; +import proposalById from "./proposals/byId"; +import proposals from "./proposals/list"; import providerByAddress from "./providers/byAddress"; import providerDeployments from "./providers/deployments"; import providerList from "./providers/list"; -import providerAttributesSchema from "./providerAttributesSchema"; -import providerRegions from "./providerRegions"; -import validators from "./validators/list"; +import transactionByHash from "./transactions/byHash"; +import transactions from "./transactions/list"; import validatorByAddress from "./validators/byAddress"; -import proposals from "./proposals/list"; -import proposalById from "./proposals/byId"; -import templates from "./templates"; -import networkCapacity from "./networkCapacity"; -import marketData from "./marketData"; -import dashboardData from "./dashboardData"; -import pricing from "./pricing"; -import auditors from "./auditors"; -import nodesMainnet from "./nodes/mainnet"; -import nodesSandbox from "./nodes/sandbox"; -import nodesTestnet from "./nodes/testnet"; +import validators from "./validators/list"; import versionMainnet from "./version/mainnet"; import versionSandbox from "./version/sandbox"; import versionTestnet from "./version/testnet"; -import deploymentByOwnerDseq from "./deployments/byOwnerDseq"; -import providerGraphData from "./providerGraphData"; +import auditors from "./auditors"; +import dashboardData from "./dashboardData"; import graphData from "./graphData"; +import marketData from "./marketData"; +import networkCapacity from "./networkCapacity"; +import predictedBlockDate from "./predictedBlockDate"; +import predictedDateHeight from "./predictedDateHeight"; +import pricing from "./pricing"; import providerActiveLeasesGraphData from "./providerActiveLeasesGraphData"; +import providerAttributesSchema from "./providerAttributesSchema"; +import providerGraphData from "./providerGraphData"; +import providerRegions from "./providerRegions"; +import templates from "./templates"; export default [ blocks, diff --git a/apps/api/src/routes/v1/marketData.ts b/apps/api/src/routes/v1/marketData.ts index 9ff3b4e29..df05788a1 100644 --- a/apps/api/src/routes/v1/marketData.ts +++ b/apps/api/src/routes/v1/marketData.ts @@ -1,4 +1,5 @@ -import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; + import { cacheKeys, cacheResponse } from "@src/caching/helpers"; import { getMarketData } from "@src/services/external/marketDataService"; @@ -25,7 +26,7 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { const response = await cacheResponse(60 * 5, cacheKeys.getMarketData, getMarketData); return c.json(response); }); diff --git a/apps/api/src/routes/v1/networkCapacity.ts b/apps/api/src/routes/v1/networkCapacity.ts index acb94956b..eef693da0 100644 --- a/apps/api/src/routes/v1/networkCapacity.ts +++ b/apps/api/src/routes/v1/networkCapacity.ts @@ -1,4 +1,5 @@ -import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; + import { getNetworkCapacity } from "@src/services/db/providerStatusService"; const route = createRoute({ @@ -35,7 +36,7 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { const networkCapacity = await getNetworkCapacity(); return c.json(networkCapacity); }); diff --git a/apps/api/src/routes/v1/nodes/mainnet.ts b/apps/api/src/routes/v1/nodes/mainnet.ts index d69628cbf..3815a3fe1 100644 --- a/apps/api/src/routes/v1/nodes/mainnet.ts +++ b/apps/api/src/routes/v1/nodes/mainnet.ts @@ -1,5 +1,6 @@ -import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; -import { nodeClient } from '@src/routes/v1/nodes/nodeClient'; +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; + +import { nodeClient } from "@src/routes/v1/nodes/nodeClient"; const route = createRoute({ method: "get", @@ -24,6 +25,6 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { return c.json(await nodeClient.getMainnetNodes()); }); diff --git a/apps/api/src/routes/v1/nodes/nodeClient.ts b/apps/api/src/routes/v1/nodes/nodeClient.ts index e26a32b25..6517d4846 100644 --- a/apps/api/src/routes/v1/nodes/nodeClient.ts +++ b/apps/api/src/routes/v1/nodes/nodeClient.ts @@ -1,4 +1,5 @@ import axios, { AxiosInstance } from "axios"; + import { Memoize } from "@src/caching/helpers"; import { env } from "@src/utils/env"; diff --git a/apps/api/src/routes/v1/nodes/sandbox.ts b/apps/api/src/routes/v1/nodes/sandbox.ts index 0a839cc69..c7f78c554 100644 --- a/apps/api/src/routes/v1/nodes/sandbox.ts +++ b/apps/api/src/routes/v1/nodes/sandbox.ts @@ -1,5 +1,6 @@ -import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; -import { nodeClient } from '@src/routes/v1/nodes/nodeClient'; +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; + +import { nodeClient } from "@src/routes/v1/nodes/nodeClient"; const route = createRoute({ method: "get", @@ -24,6 +25,6 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { return c.json(await nodeClient.getSandboxNodes()); }); diff --git a/apps/api/src/routes/v1/nodes/testnet.ts b/apps/api/src/routes/v1/nodes/testnet.ts index 89381d783..a153ab228 100644 --- a/apps/api/src/routes/v1/nodes/testnet.ts +++ b/apps/api/src/routes/v1/nodes/testnet.ts @@ -1,5 +1,6 @@ -import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; -import { nodeClient } from '@src/routes/v1/nodes/nodeClient'; +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; + +import { nodeClient } from "@src/routes/v1/nodes/nodeClient"; const route = createRoute({ method: "get", @@ -24,6 +25,6 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { return c.json(await nodeClient.getTestnetNodes()); }); diff --git a/apps/api/src/routes/v1/predictedBlockDate.ts b/apps/api/src/routes/v1/predictedBlockDate.ts index 096a0ec47..0016fb5ee 100644 --- a/apps/api/src/routes/v1/predictedBlockDate.ts +++ b/apps/api/src/routes/v1/predictedBlockDate.ts @@ -1,7 +1,8 @@ -import { OpenAPIHono, createRoute } from "@hono/zod-openapi"; -import { getPredictedBlockDate } from "@src/services/db/blocksService"; +import { createRoute, OpenAPIHono } from "@hono/zod-openapi"; import { z } from "zod"; +import { getPredictedBlockDate } from "@src/services/db/blocksService"; + const defaultBlockWindow = 10_000; const route = createRoute({ @@ -52,7 +53,7 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { const height = parseInt(c.req.valid("param").height); const blockWindow = c.req.valid("query").blockWindow ? parseInt(c.req.valid("query").blockWindow) : defaultBlockWindow; diff --git a/apps/api/src/routes/v1/predictedDateHeight.ts b/apps/api/src/routes/v1/predictedDateHeight.ts index 6ad7e1c67..44403c3ad 100644 --- a/apps/api/src/routes/v1/predictedDateHeight.ts +++ b/apps/api/src/routes/v1/predictedDateHeight.ts @@ -1,7 +1,8 @@ -import { OpenAPIHono, createRoute } from "@hono/zod-openapi"; -import { getPredictedDateHeight } from "@src/services/db/blocksService"; +import { createRoute, OpenAPIHono } from "@hono/zod-openapi"; import { z } from "zod"; +import { getPredictedDateHeight } from "@src/services/db/blocksService"; + const defaultBlockWindow = 10_000; const route = createRoute({ @@ -52,7 +53,7 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { const timestamp = parseInt(c.req.param("timestamp")); const blockWindow = c.req.valid("query").blockWindow ? parseInt(c.req.valid("query").blockWindow) : defaultBlockWindow; diff --git a/apps/api/src/routes/v1/pricing.ts b/apps/api/src/routes/v1/pricing.ts index 2601e31cc..d69ed5e1c 100644 --- a/apps/api/src/routes/v1/pricing.ts +++ b/apps/api/src/routes/v1/pricing.ts @@ -1,6 +1,7 @@ -import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; + import { round } from "@src/utils/math"; -import { getAWSPricing, getAkashPricing, getAzurePricing, getGCPPricing } from "@src/utils/pricing"; +import { getAkashPricing, getAWSPricing, getAzurePricing, getGCPPricing } from "@src/utils/pricing"; const specsType = z.object({ cpu: z.number().openapi({ description: "CPU in tousandths of a core. 1000 = 1 core", example: 1000 }), @@ -47,7 +48,7 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { const body = await c.req.json(); const isArray = Array.isArray(body); const specs = isArray ? body : [body]; diff --git a/apps/api/src/routes/v1/proposals/byId.ts b/apps/api/src/routes/v1/proposals/byId.ts index a4a790299..dd68d4d4d 100644 --- a/apps/api/src/routes/v1/proposals/byId.ts +++ b/apps/api/src/routes/v1/proposals/byId.ts @@ -1,4 +1,5 @@ -import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; + import { getProposal } from "@src/services/external/apiNodeService"; const route = createRoute({ @@ -54,7 +55,7 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { const proposalId = parseInt(c.req.valid("param").id); if (isNaN(proposalId)) { diff --git a/apps/api/src/routes/v1/proposals/list.ts b/apps/api/src/routes/v1/proposals/list.ts index 009c90cc4..09e691085 100644 --- a/apps/api/src/routes/v1/proposals/list.ts +++ b/apps/api/src/routes/v1/proposals/list.ts @@ -1,4 +1,5 @@ -import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; + import { getProposals } from "@src/services/external/apiNodeService"; const route = createRoute({ @@ -27,7 +28,7 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { const proposals = await getProposals(); return c.json(proposals); }); diff --git a/apps/api/src/routes/v1/providerActiveLeasesGraphData.ts b/apps/api/src/routes/v1/providerActiveLeasesGraphData.ts index eefe36976..77d89a657 100644 --- a/apps/api/src/routes/v1/providerActiveLeasesGraphData.ts +++ b/apps/api/src/routes/v1/providerActiveLeasesGraphData.ts @@ -1,4 +1,5 @@ -import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; + import { getProviderActiveLeasesGraphData } from "@src/services/db/statsService"; import { isValidBech32Address } from "@src/utils/addresses"; import { openApiExampleProviderAddress } from "@src/utils/constants"; @@ -42,7 +43,7 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { const providerAddress = c.req.valid("param").providerAddress; if (!isValidBech32Address(providerAddress, "akash")) { diff --git a/apps/api/src/routes/v1/providerAttributesSchema.ts b/apps/api/src/routes/v1/providerAttributesSchema.ts index cb5df41f4..5ae93c21c 100644 --- a/apps/api/src/routes/v1/providerAttributesSchema.ts +++ b/apps/api/src/routes/v1/providerAttributesSchema.ts @@ -1,4 +1,5 @@ -import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; + import { getProviderAttributesSchema } from "@src/services/external/githubService"; const attributeSchemaType = z.object({ @@ -65,7 +66,7 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { const providerAttributesSchema = await getProviderAttributesSchema(); return c.json(providerAttributesSchema); }); diff --git a/apps/api/src/routes/v1/providerGraphData.ts b/apps/api/src/routes/v1/providerGraphData.ts index 6fee6547a..b261f248c 100644 --- a/apps/api/src/routes/v1/providerGraphData.ts +++ b/apps/api/src/routes/v1/providerGraphData.ts @@ -1,4 +1,5 @@ -import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; + import { getProviderGraphData } from "@src/services/db/statsService"; import { ProviderStatsKey } from "@src/types"; @@ -55,7 +56,7 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { const dataName = c.req.valid("param").dataName; if (!authorizedDataNames.includes(dataName)) { diff --git a/apps/api/src/routes/v1/providerRegions.ts b/apps/api/src/routes/v1/providerRegions.ts index 134f8fd8b..bbefaddbd 100644 --- a/apps/api/src/routes/v1/providerRegions.ts +++ b/apps/api/src/routes/v1/providerRegions.ts @@ -1,4 +1,5 @@ -import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; + import { cacheKeys, cacheResponse } from "@src/caching/helpers"; import { getProviderRegions } from "@src/services/db/providerDataService"; @@ -26,7 +27,7 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { const response = await cacheResponse(60 * 5, cacheKeys.getProviderRegions, getProviderRegions); return c.json(response); }); diff --git a/apps/api/src/routes/v1/providers/byAddress.ts b/apps/api/src/routes/v1/providers/byAddress.ts index 406fc0667..e87c5f792 100644 --- a/apps/api/src/routes/v1/providers/byAddress.ts +++ b/apps/api/src/routes/v1/providers/byAddress.ts @@ -1,4 +1,5 @@ -import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; + import { getProviderDetail } from "@src/services/db/providerStatusService"; import { openApiExampleProviderAddress } from "@src/utils/constants"; @@ -123,7 +124,7 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { if (!c.req.valid("param").address) { return c.text("Address is undefined.", 400); } diff --git a/apps/api/src/routes/v1/providers/deployments.ts b/apps/api/src/routes/v1/providers/deployments.ts index 706d3f300..036a2326f 100644 --- a/apps/api/src/routes/v1/providers/deployments.ts +++ b/apps/api/src/routes/v1/providers/deployments.ts @@ -1,4 +1,5 @@ -import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; + import { getProviderDeployments, getProviderDeploymentsCount } from "@src/services/db/deploymentService"; import { openApiExampleProviderAddress } from "@src/utils/constants"; @@ -90,7 +91,7 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { const skip = parseInt(c.req.valid("param").skip); const limit = Math.min(maxLimit, parseInt(c.req.valid("param").limit)); const statusParam = c.req.query("status") as "active" | "closed" | undefined; diff --git a/apps/api/src/routes/v1/providers/list.ts b/apps/api/src/routes/v1/providers/list.ts index 3f641bd6e..fb7708ef8 100644 --- a/apps/api/src/routes/v1/providers/list.ts +++ b/apps/api/src/routes/v1/providers/list.ts @@ -1,4 +1,5 @@ -import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; + import { cacheKeys, cacheResponse } from "@src/caching/helpers"; import { getProviderList } from "@src/services/db/providerStatusService"; @@ -104,7 +105,7 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { const providers = await cacheResponse(60, cacheKeys.getProviderList, getProviderList); return c.json(providers); }); diff --git a/apps/api/src/routes/v1/templates.ts b/apps/api/src/routes/v1/templates.ts index da1aaaf20..71841ab80 100644 --- a/apps/api/src/routes/v1/templates.ts +++ b/apps/api/src/routes/v1/templates.ts @@ -1,4 +1,5 @@ -import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; + import { cacheKeys, cacheResponse } from "@src/caching/helpers"; import { getTemplateGallery } from "@src/services/external/templateReposService"; @@ -36,7 +37,7 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { const response = await cacheResponse(60 * 5, cacheKeys.getTemplates, async () => await getTemplateGallery()); return c.json(response); }); diff --git a/apps/api/src/routes/v1/transactions/byHash.ts b/apps/api/src/routes/v1/transactions/byHash.ts index 23bde42eb..50cf5a313 100644 --- a/apps/api/src/routes/v1/transactions/byHash.ts +++ b/apps/api/src/routes/v1/transactions/byHash.ts @@ -1,4 +1,5 @@ -import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; + import { getTransaction } from "@src/services/db/transactionsService"; import { openApiExampleTransactionHash } from "@src/utils/constants"; @@ -50,7 +51,7 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { const txInfo = await getTransaction(c.req.valid("param").hash); if (txInfo) { diff --git a/apps/api/src/routes/v1/transactions/list.ts b/apps/api/src/routes/v1/transactions/list.ts index 31fc330ec..11156e8a6 100644 --- a/apps/api/src/routes/v1/transactions/list.ts +++ b/apps/api/src/routes/v1/transactions/list.ts @@ -1,4 +1,5 @@ -import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; + import { getTransactions } from "@src/services/db/transactionsService"; const defaultLimit = 20; @@ -66,7 +67,7 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { const limit = parseInt(c.req.query("limit")); if (isNaN(limit)) { diff --git a/apps/api/src/routes/v1/validators/byAddress.ts b/apps/api/src/routes/v1/validators/byAddress.ts index edd18e62a..3a6ed9684 100644 --- a/apps/api/src/routes/v1/validators/byAddress.ts +++ b/apps/api/src/routes/v1/validators/byAddress.ts @@ -1,4 +1,5 @@ -import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; + import { getValidator } from "@src/services/external/apiNodeService"; import { isValidBech32Address } from "@src/utils/addresses"; import { openApiExampleValidatorAddress } from "@src/utils/constants"; @@ -47,7 +48,7 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { if (!isValidBech32Address(c.req.valid("param").address, "akashvaloper")) { return c.text("Invalid address", 400); } diff --git a/apps/api/src/routes/v1/validators/list.ts b/apps/api/src/routes/v1/validators/list.ts index 85506129e..fbb71ea5f 100644 --- a/apps/api/src/routes/v1/validators/list.ts +++ b/apps/api/src/routes/v1/validators/list.ts @@ -1,4 +1,5 @@ -import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi"; +import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; + import { getValidators } from "@src/services/external/apiNodeService"; const route = createRoute({ @@ -27,7 +28,7 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { const validators = await getValidators(); return c.json(validators); }); diff --git a/apps/api/src/routes/v1/version/mainnet.ts b/apps/api/src/routes/v1/version/mainnet.ts index eae2e4c33..d7b6823f9 100644 --- a/apps/api/src/routes/v1/version/mainnet.ts +++ b/apps/api/src/routes/v1/version/mainnet.ts @@ -1,4 +1,5 @@ -import { OpenAPIHono, createRoute } from "@hono/zod-openapi"; +import { createRoute, OpenAPIHono } from "@hono/zod-openapi"; + import { nodeClient } from "@src/routes/v1/nodes/nodeClient"; const route = createRoute({ @@ -15,6 +16,6 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { return c.text(await nodeClient.getMainnetVersion()); }); diff --git a/apps/api/src/routes/v1/version/sandbox.ts b/apps/api/src/routes/v1/version/sandbox.ts index be8e57ac5..1b7bd5976 100644 --- a/apps/api/src/routes/v1/version/sandbox.ts +++ b/apps/api/src/routes/v1/version/sandbox.ts @@ -1,4 +1,5 @@ -import { OpenAPIHono, createRoute } from "@hono/zod-openapi"; +import { createRoute, OpenAPIHono } from "@hono/zod-openapi"; + import { nodeClient } from "@src/routes/v1/nodes/nodeClient"; const route = createRoute({ @@ -15,6 +16,6 @@ const route = createRoute({ } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { return c.text(await nodeClient.getSandboxVersion()); }); diff --git a/apps/api/src/routes/v1/version/testnet.ts b/apps/api/src/routes/v1/version/testnet.ts index dd88752b8..d8b646319 100644 --- a/apps/api/src/routes/v1/version/testnet.ts +++ b/apps/api/src/routes/v1/version/testnet.ts @@ -1,4 +1,5 @@ -import { OpenAPIHono, createRoute } from "@hono/zod-openapi"; +import { createRoute, OpenAPIHono } from "@hono/zod-openapi"; + import { nodeClient } from "@src/routes/v1/nodes/nodeClient"; const route = createRoute({ @@ -14,6 +15,6 @@ const route = createRoute({ } } }); -export default new OpenAPIHono().openapi(route, async (c) => { +export default new OpenAPIHono().openapi(route, async c => { return c.text(await nodeClient.getTestnetVersion()); }); diff --git a/apps/api/src/scheduler.ts b/apps/api/src/scheduler.ts index 6f46224c1..f6543592d 100644 --- a/apps/api/src/scheduler.ts +++ b/apps/api/src/scheduler.ts @@ -1,6 +1,7 @@ +import axios from "axios"; import humanInterval from "human-interval"; + import { getPrettyTime } from "@src/utils"; -import axios from "axios"; class TaskDef { name: string; @@ -107,7 +108,7 @@ export class Scheduler { pingStartPromise.finally(() => this.healthchecksPingSuccess(runningTask)); } }) - .catch((err) => { + .catch(err => { runningTask.failedRunCount++; runningTask.latestError = err; this.config.errorHandler(runningTask, err); @@ -146,7 +147,7 @@ export class Scheduler { } public getTasksStatus() { - return Array.from(this.tasks.values()).map((task) => ({ + return Array.from(this.tasks.values()).map(task => ({ name: task.name, isRunning: !!task.runningPromise, interval: getPrettyTime(task.interval), diff --git a/apps/api/src/services/db/blocksService.ts b/apps/api/src/services/db/blocksService.ts index 87931b05e..db7b9ede1 100644 --- a/apps/api/src/services/db/blocksService.ts +++ b/apps/api/src/services/db/blocksService.ts @@ -16,7 +16,7 @@ export async function getBlocks(limit: number) { ] }); - return blocks.map((block) => ({ + return blocks.map(block => ({ height: block.height, proposer: { address: block.proposerValidator.accountAddress, @@ -61,15 +61,15 @@ export async function getBlock(height: number) { address: block.proposerValidator.accountAddress }, hash: block.hash, - gasUsed: block.transactions.map((tx) => tx.gasUsed).reduce((a, b) => a + b, 0), - gasWanted: block.transactions.map((tx) => tx.gasWanted).reduce((a, b) => a + b, 0), - transactions: block.transactions.map((tx) => ({ + gasUsed: block.transactions.map(tx => tx.gasUsed).reduce((a, b) => a + b, 0), + gasWanted: block.transactions.map(tx => tx.gasWanted).reduce((a, b) => a + b, 0), + transactions: block.transactions.map(tx => ({ hash: tx.hash, isSuccess: !tx.hasProcessingError, error: tx.hasProcessingError ? tx.log : null, fee: tx.fee, datetime: block.datetime, - messages: tx.messages.map((message) => ({ + messages: tx.messages.map(message => ({ id: message.id, type: message.type, amount: message.amount diff --git a/apps/api/src/services/db/deploymentService.ts b/apps/api/src/services/db/deploymentService.ts index ab624f4ca..57d79cbac 100644 --- a/apps/api/src/services/db/deploymentService.ts +++ b/apps/api/src/services/db/deploymentService.ts @@ -1,10 +1,11 @@ -import * as v1beta1 from "@akashnetwork/akash-api/deprecated/akash/market/v1beta1"; import * as v2beta2 from "@akashnetwork/akash-api/akash/market/v1beta2"; -import { decodeMsg } from "@src/utils/protobuf"; -import { Transaction } from "@akashnetwork/cloudmos-shared/dbSchemas/base"; +import * as v1beta1 from "@akashnetwork/akash-api/deprecated/akash/market/v1beta1"; +import { Block, Message } from "@akashnetwork/cloudmos-shared/dbSchemas"; import { Deployment, Lease } from "@akashnetwork/cloudmos-shared/dbSchemas/akash"; +import { Transaction } from "@akashnetwork/cloudmos-shared/dbSchemas/base"; import { Op, WhereOptions } from "sequelize"; -import { Block, Message } from "@akashnetwork/cloudmos-shared/dbSchemas"; + +import { decodeMsg } from "@src/utils/protobuf"; export async function getDeploymentRelatedMessages(owner: string, dseq: string) { const deployment = await Deployment.findOne({ @@ -39,19 +40,19 @@ export async function getDeploymentRelatedMessages(owner: string, dseq: string) }); const createBidMsgs = relatedMessages - .filter((msg) => msg.type.endsWith("MsgCreateBid")) - .map((msg) => ({ + .filter(msg => msg.type.endsWith("MsgCreateBid")) + .map(msg => ({ decoded: decodeMsg(msg.type, msg.data) as v1beta1.MsgCreateBid | v2beta2.MsgCreateBid, msg: msg })); const createLeaseMsgs = relatedMessages - .filter((x) => x.type.endsWith("MsgCreateLease")) - .map((msg) => decodeMsg(msg.type, msg.data) as v1beta1.MsgCreateLease | v2beta2.MsgCreateLease); + .filter(x => x.type.endsWith("MsgCreateLease")) + .map(msg => decodeMsg(msg.type, msg.data) as v1beta1.MsgCreateLease | v2beta2.MsgCreateLease); - const acceptedBids = createBidMsgs.filter((createBidMsg) => + const acceptedBids = createBidMsgs.filter(createBidMsg => createLeaseMsgs.some( - (l) => + l => l.bidId.gseq === createBidMsg.decoded.order.gseq && l.bidId.oseq === createBidMsg.decoded.order.oseq && l.bidId.provider === createBidMsg.decoded.provider @@ -59,11 +60,11 @@ export async function getDeploymentRelatedMessages(owner: string, dseq: string) ); const filteredMessages = relatedMessages - .filter((msg) => !msg.type.endsWith("MsgCreateBid")) - .concat(acceptedBids.map((x) => x.msg)) + .filter(msg => !msg.type.endsWith("MsgCreateBid")) + .concat(acceptedBids.map(x => x.msg)) .sort((a, b) => b.height - a.height); - return filteredMessages.map((msg) => ({ + return filteredMessages.map(msg => ({ txHash: msg.transaction.hash, date: msg.block.datetime, type: msg.type @@ -100,7 +101,7 @@ export async function getProviderDeployments(provider: string, skip: number, lim const deployments = await Deployment.findAll({ where: { - dseq: { [Op.in]: deploymentDseqs.map((d) => d.dseq) } + dseq: { [Op.in]: deploymentDseqs.map(d => d.dseq) } }, include: [ { @@ -118,7 +119,7 @@ export async function getProviderDeployments(provider: string, skip: number, lim order: [["createdHeight", "DESC"]] }); - return deployments.map((d) => ({ + return deployments.map(d => ({ owner: d.owner, dseq: d.dseq, denom: d.denom, @@ -137,7 +138,7 @@ export async function getProviderDeployments(provider: string, skip: number, lim ephemeralStorage: d.leases.reduce((acc, l) => acc + l.ephemeralStorageQuantity, 0), persistentStorage: d.leases.reduce((acc, l) => acc + l.persistentStorageQuantity, 0) }, - leases: d.leases.map((l) => ({ + leases: d.leases.map(l => ({ provider: l.providerAddress, gseq: l.gseq, oseq: l.oseq, diff --git a/apps/api/src/services/db/networkRevenueService.ts b/apps/api/src/services/db/networkRevenueService.ts index e2805939a..a4df9069a 100644 --- a/apps/api/src/services/db/networkRevenueService.ts +++ b/apps/api/src/services/db/networkRevenueService.ts @@ -1,7 +1,8 @@ -import { Op } from "sequelize"; -import { Day } from "@akashnetwork/cloudmos-shared/dbSchemas/base"; import { AkashBlock as Block } from "@akashnetwork/cloudmos-shared/dbSchemas/akash"; +import { Day } from "@akashnetwork/cloudmos-shared/dbSchemas/base"; import { add } from "date-fns"; +import { Op } from "sequelize"; + import { getTodayUTC } from "@src/utils"; import { round, uaktToAKT, udenomToDenom } from "@src/utils/math"; @@ -44,7 +45,7 @@ type RevenueStatsType = { export const getWeb3IndexRevenue = async (debug?: boolean) => { const dailyNetworkRevenues = await getDailyRevenue(); - let days: DalyRevenueType[] = dailyNetworkRevenues.map((r) => ({ + let days: DalyRevenueType[] = dailyNetworkRevenues.map(r => ({ date: r.date.getTime() / 1000, revenue: round(r.usd, 2), revenueUAkt: r.uakt, @@ -86,7 +87,7 @@ export const getWeb3IndexRevenue = async (debug?: boolean) => { sixtyDaysAgoRevenueUUsdc: number = 0, ninetyDaysAgoRevenueUUsdc: number = 0; - days.forEach((b) => { + days.forEach(b => { const date = new Date(b.date * 1000); if (date <= ninetyDaysAgo) { @@ -192,7 +193,7 @@ export async function getDailyRevenue() { order: [["date", "ASC"]] }); - const stats = result.map((day) => ({ + const stats = result.map(day => ({ date: day.date, totalUAktSpent: (day.lastBlockYet as Block).totalUAktSpent, totalUUsdcSpent: (day.lastBlockYet as Block).totalUUsdcSpent, @@ -210,7 +211,7 @@ export async function getDailyRevenue() { return arr; }, []); - return relativeStats.map((x) => ({ + return relativeStats.map(x => ({ date: x.date, uakt: x.uakt, akt: uaktToAKT(x.uakt, 6), diff --git a/apps/api/src/services/db/providerDataService.ts b/apps/api/src/services/db/providerDataService.ts index b108c09a9..ad509f6b2 100644 --- a/apps/api/src/services/db/providerDataService.ts +++ b/apps/api/src/services/db/providerDataService.ts @@ -1,4 +1,5 @@ import { Provider, ProviderAttribute } from "@akashnetwork/cloudmos-shared/dbSchemas/akash"; + import { getProviderAttributesSchema } from "@src/services/external/githubService"; export async function getProviderRegions() { @@ -11,8 +12,8 @@ export async function getProviderRegions() { }); // console.log(JSON.stringify(providers, null, 2)); - const result = regions.map((region) => { - const filteredProviders = providers.filter((p) => p.providerAttributes.some((attr) => attr.value === region.key)).map((x) => x.owner); + const result = regions.map(region => { + const filteredProviders = providers.filter(p => p.providerAttributes.some(attr => attr.value === region.key)).map(x => x.owner); return { ...region, providers: filteredProviders }; }); diff --git a/apps/api/src/services/db/providerStatusService.ts b/apps/api/src/services/db/providerStatusService.ts index 90c69e1b4..27d6799fb 100644 --- a/apps/api/src/services/db/providerStatusService.ts +++ b/apps/api/src/services/db/providerStatusService.ts @@ -6,13 +6,14 @@ import { ProviderSnapshotNodeGPU } from "@akashnetwork/cloudmos-shared/dbSchemas/akash"; import { ProviderSnapshot } from "@akashnetwork/cloudmos-shared/dbSchemas/akash/providerSnapshot"; -import { toUTC } from "@src/utils"; import { add, sub } from "date-fns"; import { Op } from "sequelize"; -import { mapProviderToList } from "@src/utils/map/provider"; -import { getAuditors, getProviderAttributesSchema } from "../external/githubService"; + import { ProviderDetail } from "@src/types/provider"; +import { toUTC } from "@src/utils"; import { env } from "@src/utils/env"; +import { mapProviderToList } from "@src/utils/map/provider"; +import { getAuditors, getProviderAttributesSchema } from "../external/githubService"; export async function getNetworkCapacity() { const providers = await Provider.findAll({ @@ -30,23 +31,23 @@ export async function getNetworkCapacity() { }); const filteredProviders = providers - .filter((x) => x.isOnline || x.lastSuccessfulSnapshot) - .filter((value, index, self) => self.map((x) => x.hostUri).indexOf(value.hostUri) === index); + .filter(x => x.isOnline || x.lastSuccessfulSnapshot) + .filter((value, index, self) => self.map(x => x.hostUri).indexOf(value.hostUri) === index); const stats = { activeProviderCount: filteredProviders.length, - activeCPU: filteredProviders.map((x) => x.activeCPU).reduce((a, b) => a + b, 0), - activeGPU: filteredProviders.map((x) => x.activeGPU).reduce((a, b) => a + b, 0), - activeMemory: filteredProviders.map((x) => x.activeMemory).reduce((a, b) => a + b, 0), - activeStorage: filteredProviders.map((x) => x.activeStorage).reduce((a, b) => a + b, 0), - pendingCPU: filteredProviders.map((x) => x.pendingCPU).reduce((a, b) => a + b, 0), - pendingGPU: filteredProviders.map((x) => x.pendingGPU).reduce((a, b) => a + b, 0), - pendingMemory: filteredProviders.map((x) => x.pendingMemory).reduce((a, b) => a + b, 0), - pendingStorage: filteredProviders.map((x) => x.pendingStorage).reduce((a, b) => a + b, 0), - availableCPU: filteredProviders.map((x) => x.availableCPU).reduce((a, b) => a + b, 0), - availableGPU: filteredProviders.map((x) => x.availableGPU).reduce((a, b) => a + b, 0), - availableMemory: filteredProviders.map((x) => x.availableMemory).reduce((a, b) => a + b, 0), - availableStorage: filteredProviders.map((x) => x.availableStorage).reduce((a, b) => a + b, 0) + activeCPU: filteredProviders.map(x => x.activeCPU).reduce((a, b) => a + b, 0), + activeGPU: filteredProviders.map(x => x.activeGPU).reduce((a, b) => a + b, 0), + activeMemory: filteredProviders.map(x => x.activeMemory).reduce((a, b) => a + b, 0), + activeStorage: filteredProviders.map(x => x.activeStorage).reduce((a, b) => a + b, 0), + pendingCPU: filteredProviders.map(x => x.pendingCPU).reduce((a, b) => a + b, 0), + pendingGPU: filteredProviders.map(x => x.pendingGPU).reduce((a, b) => a + b, 0), + pendingMemory: filteredProviders.map(x => x.pendingMemory).reduce((a, b) => a + b, 0), + pendingStorage: filteredProviders.map(x => x.pendingStorage).reduce((a, b) => a + b, 0), + availableCPU: filteredProviders.map(x => x.availableCPU).reduce((a, b) => a + b, 0), + availableGPU: filteredProviders.map(x => x.availableGPU).reduce((a, b) => a + b, 0), + availableMemory: filteredProviders.map(x => x.availableMemory).reduce((a, b) => a + b, 0), + availableStorage: filteredProviders.map(x => x.availableStorage).reduce((a, b) => a + b, 0) }; return { @@ -97,14 +98,14 @@ export const getProviderList = async () => { ] }); - const distinctProviders = providersWithAttributesAndAuditors.filter((value, index, self) => self.map((x) => x.hostUri).lastIndexOf(value.hostUri) === index); + const distinctProviders = providersWithAttributesAndAuditors.filter((value, index, self) => self.map(x => x.hostUri).lastIndexOf(value.hostUri) === index); const providerAttributeSchemaQuery = getProviderAttributesSchema(); const auditorsQuery = getAuditors(); const [auditors, providerAttributeSchema] = await Promise.all([auditorsQuery, providerAttributeSchemaQuery]); - return distinctProviders.map((x) => { - const lastSuccessfulSnapshot = providerWithNodes.find((p) => p.owner === x.owner)?.lastSuccessfulSnapshot; + return distinctProviders.map(x => { + const lastSuccessfulSnapshot = providerWithNodes.find(p => p.owner === x.owner)?.lastSuccessfulSnapshot; return mapProviderToList(x, providerAttributeSchema, auditors, lastSuccessfulSnapshot); }); }; @@ -160,7 +161,7 @@ export const getProviderDetail = async (address: string): Promise ({ + uptime: uptimeSnapshots.map(ps => ({ id: ps.id, isOnline: ps.isOnline, checkDate: ps.checkDate diff --git a/apps/api/src/services/db/statsService.ts b/apps/api/src/services/db/statsService.ts index 206ee4075..b6aaad40b 100644 --- a/apps/api/src/services/db/statsService.ts +++ b/apps/api/src/services/db/statsService.ts @@ -1,10 +1,11 @@ -import { Day } from "@akashnetwork/cloudmos-shared/dbSchemas/base"; import { AkashBlock as Block } from "@akashnetwork/cloudmos-shared/dbSchemas/akash"; +import { Day } from "@akashnetwork/cloudmos-shared/dbSchemas/base"; import { subHours } from "date-fns"; import { Op, QueryTypes } from "sequelize"; + +import { cacheKeys, cacheResponse } from "@src/caching/helpers"; import { chainDb } from "@src/db/dbConnection"; import { ProviderActiveLeasesStats, ProviderStats, ProviderStatsKey } from "@src/types/graph"; -import { cacheKeys, cacheResponse } from "@src/caching/helpers"; import { env } from "@src/utils/env"; type GraphData = { @@ -161,7 +162,7 @@ export async function getGraphData(dataName: AuthorizedGraphDataName): Promise ({ + let stats = result.map(day => ({ date: day.date, value: getter(day.lastBlock) })); @@ -235,7 +236,7 @@ export const getProviderGraphData = async (dataName: ProviderStatsKey) => { const currentValue = result[result.length - 1]; const compareValue = result[result.length - 2]; - const stats = result.map((day) => ({ + const stats = result.map(day => ({ date: day.date, value: getter(day) })); @@ -288,7 +289,7 @@ export const getProviderActiveLeasesGraphData = async (providerAddress: string) return { currentValue: currentValue.count, compareValue: compareValue.count, - snapshots: result.map((day) => ({ + snapshots: result.map(day => ({ date: day.date, value: day.count })), diff --git a/apps/api/src/services/db/templateService.ts b/apps/api/src/services/db/templateService.ts index f5a2ba3a0..9a919b489 100644 --- a/apps/api/src/services/db/templateService.ts +++ b/apps/api/src/services/db/templateService.ts @@ -1,6 +1,7 @@ import { Template, TemplateFavorite, UserSetting } from "@akashnetwork/cloudmos-shared/dbSchemas/user"; -import * as uuid from "uuid"; import { Op } from "sequelize"; +import * as uuid from "uuid"; + import { toUTC } from "@src/utils"; export async function getTemplateById(id: string, userId: string = "") { @@ -124,7 +125,7 @@ export async function getFavoriteTemplates(userId: string) { } }); - return templateFavorites.map((t) => ({ + return templateFavorites.map(t => ({ id: t.template.id, title: t.template.title, description: t.template.description diff --git a/apps/api/src/services/db/transactionsService.ts b/apps/api/src/services/db/transactionsService.ts index be2d0ebbd..e8958a4bb 100644 --- a/apps/api/src/services/db/transactionsService.ts +++ b/apps/api/src/services/db/transactionsService.ts @@ -1,9 +1,10 @@ -import { Transaction, AddressReference } from "@akashnetwork/cloudmos-shared/dbSchemas/base"; import { AkashBlock as Block, AkashMessage as Message } from "@akashnetwork/cloudmos-shared/dbSchemas/akash"; -import { msgToJSON } from "@src/utils/protobuf"; +import { AddressReference, Transaction } from "@akashnetwork/cloudmos-shared/dbSchemas/base"; import { QueryTypes } from "sequelize"; + import { chainDb } from "@src/db/dbConnection"; import { ApiTransactionResponse } from "@src/types/transactions"; +import { msgToJSON } from "@src/utils/protobuf"; export async function getTransactions(limit: number) { const _limit = Math.min(limit, 100); @@ -24,7 +25,7 @@ export async function getTransactions(limit: number) { ] }); - return transactions.map((tx) => ({ + return transactions.map(tx => ({ height: tx.block.height, datetime: tx.block.datetime, hash: tx.hash, @@ -34,7 +35,7 @@ export async function getTransactions(limit: number) { gasWanted: tx.gasWanted, fee: tx.fee, memo: tx.memo, - messages: tx.messages.map((msg) => ({ + messages: tx.messages.map(msg => ({ id: msg.id, type: msg.type, amount: msg.amount @@ -79,13 +80,13 @@ export async function getTransaction(hash: string): Promise x.type === "Signer").map((x) => x.address), + signers: tx.addressReferences.filter(x => x.type === "Signer").map(x => x.address), error: tx.hasProcessingError ? tx.log : null, gasUsed: tx.gasUsed, gasWanted: tx.gasWanted, fee: tx.fee, memo: tx.memo, - messages: messages.map((msg) => ({ + messages: messages.map(msg => ({ id: msg.id, type: msg.type, data: msgToJSON(msg.type, msg.data), @@ -120,7 +121,7 @@ export async function getTransactionByAddress(address: string, skip: number, lim const txs = await Transaction.findAll({ include: [{ model: Block, required: true }, { model: Message }, { model: AddressReference, required: true, where: { address: address } }], - where: { id: txIds.map((x) => x.transactionId) }, + where: { id: txIds.map(x => x.transactionId) }, order: [ ["height", "DESC"], ["index", "DESC"] @@ -129,7 +130,7 @@ export async function getTransactionByAddress(address: string, skip: number, lim return { count: count, - results: txs.map((tx) => ({ + results: txs.map(tx => ({ height: tx.height, datetime: tx.block.datetime, hash: tx.hash, @@ -139,12 +140,12 @@ export async function getTransactionByAddress(address: string, skip: number, lim gasWanted: tx.gasWanted, fee: tx.fee, memo: tx.memo, - isSigner: tx.addressReferences.some((ar) => ar.type === "Signer"), - messages: tx.messages.map((msg) => ({ + isSigner: tx.addressReferences.some(ar => ar.type === "Signer"), + messages: tx.messages.map(msg => ({ id: msg.id, type: msg.type, amount: msg.amount, - isReceiver: tx.addressReferences.some((ar) => ar.messageId === msg.id && ar.type === "Receiver") + isReceiver: tx.addressReferences.some(ar => ar.messageId === msg.id && ar.type === "Receiver") })) })) }; diff --git a/apps/api/src/services/db/userDataService.ts b/apps/api/src/services/db/userDataService.ts index b8abd815f..31c5234e4 100644 --- a/apps/api/src/services/db/userDataService.ts +++ b/apps/api/src/services/db/userDataService.ts @@ -1,7 +1,8 @@ import { UserAddressName, UserSetting } from "@akashnetwork/cloudmos-shared/dbSchemas/user"; -import { getUserPlan } from "../external/stripeService"; import { Transaction } from "sequelize"; +import { getUserPlan } from "../external/stripeService"; + function randomIntFromInterval(min: number, max: number) { return Math.floor(Math.random() * (max - min + 1) + min); } diff --git a/apps/api/src/services/external/apiNodeService.ts b/apps/api/src/services/external/apiNodeService.ts index 399b7a06a..7d6bc9a21 100644 --- a/apps/api/src/services/external/apiNodeService.ts +++ b/apps/api/src/services/external/apiNodeService.ts @@ -1,37 +1,36 @@ -import fetch from "node-fetch"; -import { getDeploymentRelatedMessages } from "../db/deploymentService"; -import { apiNodeUrl, averageBlockCountInAMonth, betaTypeVersion, betaTypeVersionMarket } from "@src/utils/constants"; -import { coinToAsset } from "@src/utils/coin"; -import { getTransactionByAddress } from "@src/services/db/transactionsService"; -import axios from "axios"; +import { Block } from "@akashnetwork/cloudmos-shared/dbSchemas"; +import { Deployment, Lease, Provider, ProviderAttribute } from "@akashnetwork/cloudmos-shared/dbSchemas/akash"; import { Validator } from "@akashnetwork/cloudmos-shared/dbSchemas/base"; +import axios from "axios"; +import fetch from "node-fetch"; import { Op } from "sequelize"; -import { Deployment, Lease, Provider, ProviderAttribute } from "@akashnetwork/cloudmos-shared/dbSchemas/akash"; + import { cacheKeys, cacheResponse } from "@src/caching/helpers"; +import { getTransactionByAddress } from "@src/services/db/transactionsService"; import { CosmosGovProposalResponse, CosmosGovProposalsResponse, + RestAkashDeploymentListResponse, + RestAkasheploymentInfoResponse, + RestAkashLeaseListResponse, RestCosmosBankBalancesResponse, RestCosmosDistributionDelegatorsRewardsResponse, RestCosmosStakingDelegationsResponse, + RestCosmosStakingDelegatorsRedelegationsResponse, RestCosmosStakingValidatorsResponse, - RestAkasheploymentInfoResponse, - RestAkashLeaseListResponse, - RestAkashDeploymentListResponse, - RestGovProposalsTallyResponse, - RestCosmosStakingDelegatorsRedelegationsResponse + RestGovProposalsTallyResponse } from "@src/types/rest"; -import { Block } from "@akashnetwork/cloudmos-shared/dbSchemas"; -import { CosmosDistributionCommunityPoolResponse } from "@src/types/rest/cosmosDistributionCommunityPoolResponse"; -import { CosmosStakingPoolResponse } from "@src/types/rest/cosmosStakingPoolResponse"; import { CosmosBankSupplyResponse } from "@src/types/rest/cosmosBankSupplyResponse"; -import { CosmosMintInflationResponse } from "@src/types/rest/cosmosMintInflationResponse"; +import { CosmosDistributionCommunityPoolResponse } from "@src/types/rest/cosmosDistributionCommunityPoolResponse"; import { CosmosDistributionParamsResponse } from "@src/types/rest/cosmosDistributionParamsResponse"; import { CosmosDistributionValidatorsCommissionResponse } from "@src/types/rest/cosmosDistributionValidatorsCommissionResponse"; +import { CosmosMintInflationResponse } from "@src/types/rest/cosmosMintInflationResponse"; +import { CosmosStakingPoolResponse } from "@src/types/rest/cosmosStakingPoolResponse"; +import { coinToAsset } from "@src/utils/coin"; +import { apiNodeUrl, averageBlockCountInAMonth, betaTypeVersion, betaTypeVersionMarket } from "@src/utils/constants"; +import { getDeploymentRelatedMessages } from "../db/deploymentService"; import { getProviderList } from "../db/providerStatusService"; - - export async function getChainStats() { const result = await cacheResponse( 60 * 5, // 5 minutes @@ -52,11 +51,11 @@ export async function getChainStats() { ]); return { - communityPool: parseFloat(communityPoolResponse.data.pool.find((x) => x.denom === "uakt").amount), + communityPool: parseFloat(communityPoolResponse.data.pool.find(x => x.denom === "uakt").amount), inflation: parseFloat(inflationResponse.data.inflation), communityTax: parseFloat(distributionResponse.data.params.community_tax), bondedTokens: parseInt(bondedTokensResponse.data.pool.bonded_tokens), - totalSupply: parseInt(supplyResponse.data.supply.find((x) => x.denom === "uakt").amount) + totalSupply: parseInt(supplyResponse.data.supply.find(x => x.denom === "uakt").amount) }; }, true @@ -89,20 +88,20 @@ export async function getAddressBalance(address: string) { ]); const validatorsFromDb = await Validator.findAll(); - const validatorFromDb = validatorsFromDb.find((v) => v.accountAddress === address); + const validatorFromDb = validatorsFromDb.find(v => v.accountAddress === address); let commission = 0; if (validatorFromDb?.operatorAddress) { const commissionData = await axios.get( `${apiNodeUrl}/cosmos/distribution/v1beta1/validators/${validatorFromDb.operatorAddress}/commission` ); - const coin = commissionData.data.commission.commission.find((x) => x.denom === "uakt"); + const coin = commissionData.data.commission.commission.find(x => x.denom === "uakt"); commission = coin ? parseFloat(coin.amount) : 0; } - const assets = balancesResponse.data.balances.map((b) => coinToAsset(b)); - const delegations = delegationsResponse.data.delegation_responses.map((x) => { - const validator = validatorsFromDb.find((v) => v.operatorAddress === x.delegation.validator_address); + const assets = balancesResponse.data.balances.map(b => coinToAsset(b)); + const delegations = delegationsResponse.data.delegation_responses.map(x => { + const validator = validatorsFromDb.find(v => v.operatorAddress === x.delegation.validator_address); return { validator: { @@ -117,13 +116,13 @@ export async function getAddressBalance(address: string) { }); for (const reward of rewardsResponse.data.rewards) { - const delegation = delegations.find((x) => x.validator.operatorAddress === reward.validator_address); - const rewardAmount = reward.reward.length > 0 ? parseFloat(reward.reward.find((x) => x.denom === "uakt").amount) : 0; + const delegation = delegations.find(x => x.validator.operatorAddress === reward.validator_address); + const rewardAmount = reward.reward.length > 0 ? parseFloat(reward.reward.find(x => x.denom === "uakt").amount) : 0; if (delegation) { delegation.reward = rewardAmount; } else { - const validator = validatorsFromDb.find((v) => v.operatorAddress === reward.validator_address); + const validator = validatorsFromDb.find(v => v.operatorAddress === reward.validator_address); delegations.push({ validator: { address: validator.accountAddress, @@ -137,12 +136,12 @@ export async function getAddressBalance(address: string) { } } - const available = balancesResponse.data.balances.filter((x) => x.denom === "uakt").reduce((acc, cur) => acc + parseInt(cur.amount), 0); + const available = balancesResponse.data.balances.filter(x => x.denom === "uakt").reduce((acc, cur) => acc + parseInt(cur.amount), 0); const delegated = delegations.reduce((acc, cur) => acc + cur.amount, 0); - const rewards = rewardsResponse.data.total.length > 0 ? parseInt(rewardsResponse.data.total.find((x) => x.denom === "uakt").amount) : 0; - const redelegations = redelegationsResponse.data.redelegation_responses.map((x) => { - const srcValidator = validatorsFromDb.find((v) => v.operatorAddress === x.redelegation.validator_src_address); - const destValidator = validatorsFromDb.find((v) => v.operatorAddress === x.redelegation.validator_dst_address); + const rewards = rewardsResponse.data.total.length > 0 ? parseInt(rewardsResponse.data.total.find(x => x.denom === "uakt").amount) : 0; + const redelegations = redelegationsResponse.data.redelegation_responses.map(x => { + const srcValidator = validatorsFromDb.find(v => v.operatorAddress === x.redelegation.validator_src_address); + const destValidator = validatorsFromDb.find(v => v.operatorAddress === x.redelegation.validator_dst_address); return { srcAddress: { @@ -183,7 +182,7 @@ export async function getValidators() { `${apiNodeUrl}/cosmos/staking/v1beta1/validators?status=BOND_STATUS_BONDED&pagination.limit=1000` ); - const validators = response.data.validators.map((x) => ({ + const validators = response.data.validators.map(x => ({ operatorAddress: x.operator_address, moniker: x.description.moniker.trim(), votingPower: parseInt(x.tokens), @@ -205,7 +204,7 @@ export async function getValidators() { ...x, votingPowerRatio: x.votingPower / totalVotingPower, rank: i + 1, - keybaseAvatarUrl: validatorsFromDb.find((y) => y.operatorAddress === x.operatorAddress)?.keybaseAvatarUrl + keybaseAvatarUrl: validatorsFromDb.find(y => y.operatorAddress === x.operatorAddress)?.keybaseAvatarUrl })); return sortedValidators; @@ -226,11 +225,11 @@ export async function getValidator(address: string) { const validatorFromDb = await Validator.findOne({ where: { operatorAddress: address } }); const validatorRank = validatorsResponse.data.validators - .map((x) => { + .map(x => { return { votingPower: parseInt(x.tokens), address: x.operator_address }; }) .sort((a, b) => b.votingPower - a.votingPower) - .findIndex((x) => x.address === address); + .findIndex(x => x.address === address); return { operatorAddress: data.validator.operator_address, @@ -252,7 +251,7 @@ export async function getValidator(address: string) { export async function getProposals() { const response = await axios.get(`${apiNodeUrl}/cosmos/gov/v1beta1/proposals?pagination.limit=1000`); - const proposals = response.data.proposals.map((x) => ({ + const proposals = response.data.proposals.map(x => ({ id: parseInt(x.proposal_id), title: x.content.title, status: x.status, @@ -315,7 +314,7 @@ export async function getProposal(id: number) { totalDeposit: parseInt(data.proposal.total_deposit[0].amount), //proposer: proposer, tally: { ...tally, total: tally.yes + tally.abstain + tally.no + tally.noWithVeto }, - paramChanges: (data.proposal.content.changes || []).map((change) => ({ + paramChanges: (data.proposal.content.changes || []).map(change => ({ subspace: change.subspace, key: change.key, value: JSON.parse(change.value) @@ -376,7 +375,7 @@ export async function getDeployment(owner: string, dseq: string) { const leasesData = (await leasesResponse.json()) as RestAkashLeaseListResponse; - const providerAddresses = leasesData.leases.map((x) => x.lease.lease_id.provider); + const providerAddresses = leasesData.leases.map(x => x.lease.lease_id.provider); const providers = await Provider.findAll({ where: { owner: { @@ -387,10 +386,10 @@ export async function getDeployment(owner: string, dseq: string) { }); const deploymentDenom = deploymentData.escrow_account.balance.denom; - const leases = leasesData.leases.map((x) => { - const provider = providers.find((p) => p.owner === x.lease.lease_id.provider); - const group = deploymentData.groups.find((g) => g.group_id.gseq === x.lease.lease_id.gseq); - const dbLease = dbDeployment?.leases.find((l) => l.gseq === x.lease.lease_id.gseq && l.oseq === x.lease.lease_id.oseq); + const leases = leasesData.leases.map(x => { + const provider = providers.find(p => p.owner === x.lease.lease_id.provider); + const group = deploymentData.groups.find(g => g.group_id.gseq === x.lease.lease_id.gseq); + const dbLease = dbDeployment?.leases.find(l => l.gseq === x.lease.lease_id.gseq && l.oseq === x.lease.lease_id.oseq); return { gseq: x.lease.lease_id.gseq, @@ -403,18 +402,18 @@ export async function getDeployment(owner: string, dseq: string) { address: provider.owner, hostUri: provider.hostUri, isDeleted: !!provider.deletedHeight, - attributes: provider.providerAttributes.map((attr) => ({ + attributes: provider.providerAttributes.map(attr => ({ key: attr.key, value: attr.value })) }, status: x.lease.state, monthlyCostUDenom: Math.round(parseFloat(x.lease.price.amount) * averageBlockCountInAMonth), - cpuUnits: group.group_spec.resources.map((r) => parseInt(r.resource.cpu.units.val) * r.count).reduce((a, b) => a + b, 0), - gpuUnits: group.group_spec.resources.map((r) => parseInt(r.resource.gpu?.units?.val) * r.count || 0).reduce((a, b) => a + b, 0), - memoryQuantity: group.group_spec.resources.map((r) => parseInt(r.resource.memory.quantity.val) * r.count).reduce((a, b) => a + b, 0), + cpuUnits: group.group_spec.resources.map(r => parseInt(r.resource.cpu.units.val) * r.count).reduce((a, b) => a + b, 0), + gpuUnits: group.group_spec.resources.map(r => parseInt(r.resource.gpu?.units?.val) * r.count || 0).reduce((a, b) => a + b, 0), + memoryQuantity: group.group_spec.resources.map(r => parseInt(r.resource.memory.quantity.val) * r.count).reduce((a, b) => a + b, 0), storageQuantity: group.group_spec.resources - .map((r) => r.resource.storage.map((s) => parseInt(s.quantity.val)).reduce((a, b) => a + b, 0) * r.count) + .map(r => r.resource.storage.map(s => parseInt(s.quantity.val)).reduce((a, b) => a + b, 0) * r.count) .reduce((a, b) => a + b, 0) }; }); @@ -429,7 +428,7 @@ export async function getDeployment(owner: string, dseq: string) { createdDate: dbDeployment?.createdBlock?.datetime, closedHeight: dbDeployment?.closedHeight, closedDate: dbDeployment?.closedBlock?.datetime, - totalMonthlyCostUDenom: leases.map((x) => x.monthlyCostUDenom).reduce((a, b) => a + b, 0), + totalMonthlyCostUDenom: leases.map(x => x.monthlyCostUDenom).reduce((a, b) => a + b, 0), leases: leases, events: relatedMessages || [], other: deploymentData @@ -458,32 +457,30 @@ export async function getAddressDeployments(owner: string, skip: number, limit: return { count: parseInt(response.data.pagination.total), - results: response.data.deployments.map((x) => ({ + results: response.data.deployments.map(x => ({ owner: x.deployment.deployment_id.owner, dseq: x.deployment.deployment_id.dseq, status: x.deployment.state, createdHeight: parseInt(x.deployment.created_at), escrowAccount: x.escrow_account, cpuUnits: x.groups - .map((g) => g.group_spec.resources.map((r) => parseInt(r.resource.cpu.units.val) * r.count).reduce((a, b) => a + b, 0)) + .map(g => g.group_spec.resources.map(r => parseInt(r.resource.cpu.units.val) * r.count).reduce((a, b) => a + b, 0)) .reduce((a, b) => a + b, 0), gpuUnits: x.groups - .map((g) => g.group_spec.resources.map((r) => parseInt(r.resource.gpu?.units?.val) * r.count || 0).reduce((a, b) => a + b, 0)) + .map(g => g.group_spec.resources.map(r => parseInt(r.resource.gpu?.units?.val) * r.count || 0).reduce((a, b) => a + b, 0)) .reduce((a, b) => a + b, 0), memoryQuantity: x.groups - .map((g) => g.group_spec.resources.map((r) => parseInt(r.resource.memory.quantity.val) * r.count).reduce((a, b) => a + b, 0)) + .map(g => g.group_spec.resources.map(r => parseInt(r.resource.memory.quantity.val) * r.count).reduce((a, b) => a + b, 0)) .reduce((a, b) => a + b, 0), storageQuantity: x.groups - .map((g) => - g.group_spec.resources - .map((r) => r.resource.storage.map((s) => parseInt(s.quantity.val)).reduce((a, b) => a + b, 0) * r.count) - .reduce((a, b) => a + b, 0) + .map(g => + g.group_spec.resources.map(r => r.resource.storage.map(s => parseInt(s.quantity.val)).reduce((a, b) => a + b, 0) * r.count).reduce((a, b) => a + b, 0) ) .reduce((a, b) => a + b, 0), leases: leaseResponse.data.leases - .filter((l) => l.lease.lease_id.dseq === x.deployment.deployment_id.dseq) - .map((lease) => { - const provider = providers.find((p) => p.owner === lease.lease.lease_id.provider); + .filter(l => l.lease.lease_id.dseq === x.deployment.deployment_id.dseq) + .map(lease => { + const provider = providers.find(p => p.owner === lease.lease.lease_id.provider); return { id: lease.lease.lease_id.dseq + lease.lease.lease_id.gseq + lease.lease.lease_id.oseq, owner: lease.lease.lease_id.owner, diff --git a/apps/api/src/services/external/githubService.ts b/apps/api/src/services/external/githubService.ts index 9aeeab818..c277fd882 100644 --- a/apps/api/src/services/external/githubService.ts +++ b/apps/api/src/services/external/githubService.ts @@ -1,8 +1,9 @@ import { Octokit } from "@octokit/rest"; +import axios from "axios"; + import { cacheKeys, cacheResponse } from "@src/caching/helpers"; import { Auditor, ProviderAttributesSchema } from "@src/types/provider"; import { env } from "@src/utils/env"; -import axios from "axios"; export function getOctokit() { const githubPAT = env.AkashlyticsGithubPAT; diff --git a/apps/api/src/services/external/marketDataService.ts b/apps/api/src/services/external/marketDataService.ts index 484c5933c..3cb1fbadf 100644 --- a/apps/api/src/services/external/marketDataService.ts +++ b/apps/api/src/services/external/marketDataService.ts @@ -1,6 +1,7 @@ -import { CoinGeckoCoinsResponse } from "@src/types/coingeckoCoinsResponse"; import axios from "axios"; +import { CoinGeckoCoinsResponse } from "@src/types/coingeckoCoinsResponse"; + interface AktMarketData { price: number; volume: number; diff --git a/apps/api/src/services/external/stripeService.ts b/apps/api/src/services/external/stripeService.ts index f3f8d922e..2b3014730 100644 --- a/apps/api/src/services/external/stripeService.ts +++ b/apps/api/src/services/external/stripeService.ts @@ -1,9 +1,9 @@ import { UserSetting } from "@akashnetwork/cloudmos-shared/dbSchemas/user"; import { PlanCode } from "@akashnetwork/cloudmos-shared/plans"; -import { env } from "@src/utils/env"; - import Stripe from "stripe"; +import { env } from "@src/utils/env"; + const stripe = new Stripe(process.env.StripeSecretKey, { apiVersion: "2022-08-01" }); export async function getBillingPortalUrl(userId: string) { @@ -42,7 +42,7 @@ export async function getCheckoutUrl(userId: string, planCode: string, isMonthly product: products.data[0].id }); - const price = prices.data.find((x) => x.recurring.interval === (isMonthly ? "month" : "year") && x.active === true); + const price = prices.data.find(x => x.recurring.interval === (isMonthly ? "month" : "year") && x.active === true); if (!userSettings.stripeCustomerId) { const createdCustomer = await stripe.customers.create({ email: userSettings.email }); diff --git a/apps/api/src/services/external/templateReposService.ts b/apps/api/src/services/external/templateReposService.ts index 58099a9c0..bba5a898c 100644 --- a/apps/api/src/services/external/templateReposService.ts +++ b/apps/api/src/services/external/templateReposService.ts @@ -1,14 +1,15 @@ +import { Octokit } from "@octokit/rest"; +import * as fs from "fs"; +import { markdownToTxt } from "markdown-to-txt"; import fetch from "node-fetch"; import path from "path"; -import { markdownToTxt } from "markdown-to-txt"; -import { getOctokit } from "./githubService"; -import { isUrlAbsolute } from "@src/utils/urls"; -import { Octokit } from "@octokit/rest"; -import { dataFolderPath } from "@src/utils/constants"; + import { GithubChainRegistryChainResponse } from "@src/types"; import { GithubDirectoryItem } from "@src/types/github"; +import { dataFolderPath } from "@src/utils/constants"; import { getLogoFromPath } from "@src/utils/templateReposLogos"; -import * as fs from "fs"; +import { isUrlAbsolute } from "@src/utils/urls"; +import { getOctokit } from "./githubService"; const generatingTasks: { [key: string]: Promise } = {}; let lastServedData: FinalCategory[] | null = null; @@ -82,7 +83,7 @@ async function getTemplatesFromRepo( function mergeTemplateCategories(...categories: Category[]) { const mergedCategories: Category[] = []; for (const category of categories.flat()) { - const existingCategory = mergedCategories.find((c) => c.title.toLowerCase() === category.title.toLowerCase()); + const existingCategory = mergedCategories.find(c => c.title.toLowerCase() === category.title.toLowerCase()); if (existingCategory) { existingCategory.templates = (existingCategory.templates || []).concat(category.templates); } else { @@ -160,8 +161,8 @@ async function fetchOmnibusTemplates(octokit: Octokit, repoVersion: string) { if (!Array.isArray(response.data)) throw "Could not fetch list of files from akash-network/cosmos-omnibus"; - const folders = response.data.filter((f) => f.type === "dir" && !f.name.startsWith(".") && !f.name.startsWith("_")); - const templateSources: TemplateSource[] = folders.map((x) => ({ + const folders = response.data.filter(f => f.type === "dir" && !f.name.startsWith(".") && !f.name.startsWith("_")); + const templateSources: TemplateSource[] = folders.map(x => ({ name: x.name, path: x.path, logoUrl: null, @@ -231,7 +232,7 @@ async function fetchAwesomeAkashTemplates(octokit: Octokit, repoVersion: string) const templatesStr = match[3]; // Ignore duplicate categories - if (categories.some((x) => x.title === title)) { + if (categories.some(x => x.title === title)) { continue; } @@ -293,7 +294,7 @@ async function fetchLinuxServerTemplates(octokit: Octokit, repoVersion: string) const templatesStr = match[3]; // Ignore duplicate categories - if (categories.some((x) => x.title === title)) { + if (categories.some(x => x.title === title)) { continue; } @@ -357,7 +358,7 @@ export async function fetchLinuxServerTemplatesInfo(octokit: Octokit, categories "Not for public consumption" ]; - if (ignoreList.map((x) => x.toLowerCase()).some((x) => readme.toLowerCase().includes(x))) { + if (ignoreList.map(x => x.toLowerCase()).some(x => readme.toLowerCase().includes(x))) { continue; } @@ -403,10 +404,10 @@ export async function fetchLinuxServerTemplatesInfo(octokit: Octokit, categories } // Remove templates without "README.md" and "deploy.yml" - categories.forEach((c) => { - c.templates = c.templates.filter((x) => x.readme && x.deploy); + categories.forEach(c => { + c.templates = c.templates.filter(x => x.readme && x.deploy); }); - categories = categories.filter((x) => x.templates?.length > 0); + categories = categories.filter(x => x.templates?.length > 0); //console.log("Requests remaining: " + reqRemaining); @@ -475,10 +476,10 @@ export async function fetchTemplatesInfo(octokit: Octokit, categories: Category[ } // Remove templates without "README.md" and "deploy.yml" - categories.forEach((c) => { - c.templates = c.templates.filter((x) => x.readme && x.deploy); + categories.forEach(c => { + c.templates = c.templates.filter(x => x.readme && x.deploy); }); - categories = categories.filter((x) => x.templates?.length > 0); + categories = categories.filter(x => x.templates?.length > 0); //console.log("Requests remaining: " + reqRemaining); @@ -488,7 +489,7 @@ export async function fetchTemplatesInfo(octokit: Octokit, categories: Category[ // Find a github file by name and dowload it async function findFileContentAsync(filename: string | string[], fileList: GithubDirectoryItem[]) { const filenames = typeof filename === "string" ? [filename] : filename; - const fileDef = fileList.find((f) => filenames.some((x) => x.toLowerCase() === f.name.toLowerCase())); + const fileDef = fileList.find(f => filenames.some(x => x.toLowerCase() === f.name.toLowerCase())); if (!fileDef) return null; diff --git a/apps/api/src/types/gpu.ts b/apps/api/src/types/gpu.ts index 250a8da43..3e903d73b 100644 --- a/apps/api/src/types/gpu.ts +++ b/apps/api/src/types/gpu.ts @@ -20,4 +20,4 @@ export type ProviderConfigGpusType = { }; }; }; -}; \ No newline at end of file +}; diff --git a/apps/api/src/utils/array/array.ts b/apps/api/src/utils/array/array.ts index 3a22c4800..37190595b 100644 --- a/apps/api/src/utils/array/array.ts +++ b/apps/api/src/utils/array/array.ts @@ -2,6 +2,6 @@ type Matcher = (a: T, b: T) => boolean; export function createFilterUnique(matcher: Matcher = (a, b) => a === b): (value: T, index: number, array: T[]) => boolean { return (value, index, array) => { - return array.findIndex((other) => matcher(value, other)) === index; + return array.findIndex(other => matcher(value, other)) === index; }; } diff --git a/apps/api/src/utils/coin.ts b/apps/api/src/utils/coin.ts index 577c761fe..a8feabb7c 100644 --- a/apps/api/src/utils/coin.ts +++ b/apps/api/src/utils/coin.ts @@ -1,6 +1,6 @@ -import { Coin } from "cosmjs-types/cosmos/base/v1beta1/coin"; -import { asset_lists } from '@chain-registry/assets'; +import { asset_lists } from "@chain-registry/assets"; import * as Sentry from "@sentry/node"; +import { Coin } from "cosmjs-types/cosmos/base/v1beta1/coin"; export function coinToAsset(coin: Coin) { try { @@ -17,12 +17,12 @@ export function coinToAsset(coin: Coin) { amount: parseFloat(coin.amount) }; } else { - const akashChain = asset_lists.find((c) => c.chain_name === "akash"); - const ibcAsset = akashChain.assets.find((a) => a.base === coin.denom); + const akashChain = asset_lists.find(c => c.chain_name === "akash"); + const ibcAsset = akashChain.assets.find(a => a.base === coin.denom); if (!ibcAsset) throw new Error(`Unknown asset ${coin.denom}`); - const displayAsset = ibcAsset.denom_units.find((d) => d.denom === ibcAsset.display); + const displayAsset = ibcAsset.denom_units.find(d => d.denom === ibcAsset.display); if (!displayAsset) throw new Error(`Unable to find display asset for ${coin.denom}`); diff --git a/apps/api/src/utils/date/date.spec.ts b/apps/api/src/utils/date/date.spec.ts index f745ab9de..1583e336b 100644 --- a/apps/api/src/utils/date/date.spec.ts +++ b/apps/api/src/utils/date/date.spec.ts @@ -1,8 +1,8 @@ -import { getTodayUTC, toUTC, getPrettyTime } from './date'; +import { getPrettyTime, getTodayUTC, toUTC } from "./date"; -describe('date helpers', () => { - describe('getTodayUTC', () => { - it('should return the current date in UTC with the time set to 00:00:00', () => { +describe("date helpers", () => { + describe("getTodayUTC", () => { + it("should return the current date in UTC with the time set to 00:00:00", () => { const currentDate = new Date(); const expected = new Date(Date.UTC(currentDate.getUTCFullYear(), currentDate.getUTCMonth(), currentDate.getUTCDate(), 0, 0, 0, 0)); @@ -10,35 +10,37 @@ describe('date helpers', () => { }); }); - describe('toUTC', () => { - it('should return the date in UTC', () => { + describe("toUTC", () => { + it("should return the date in UTC", () => { const date = new Date(); - const expected = new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds())); + const expected = new Date( + Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds()) + ); expect(toUTC(date)).toEqual(expected); }); }); - describe('getPrettyTime', () => { - it('should return the time in milliseconds', () => { - expect(getPrettyTime(5)).toBe('5ms'); + describe("getPrettyTime", () => { + it("should return the time in milliseconds", () => { + expect(getPrettyTime(5)).toBe("5ms"); }); - it('should return the time in seconds', () => { - expect(getPrettyTime(500)).toBe('500ms'); - expect(getPrettyTime(5000)).toBe('5s'); + it("should return the time in seconds", () => { + expect(getPrettyTime(500)).toBe("500ms"); + expect(getPrettyTime(5000)).toBe("5s"); }); - it('should return the time in minutes and seconds', () => { - expect(getPrettyTime(60 * 1000)).toBe('1m 0s'); - expect(getPrettyTime(60 * 1000 + 400)).toBe('1m 0s'); - expect(getPrettyTime(60 * 1000 + 1400)).toBe('1m 1s'); + it("should return the time in minutes and seconds", () => { + expect(getPrettyTime(60 * 1000)).toBe("1m 0s"); + expect(getPrettyTime(60 * 1000 + 400)).toBe("1m 0s"); + expect(getPrettyTime(60 * 1000 + 1400)).toBe("1m 1s"); }); - it('should return the time in hours and minutes', () => { - expect(getPrettyTime(60 * 60 * 1000)).toBe('1h 0m'); - expect(getPrettyTime(60 * 60 * 1000 + 60 * 1000)).toBe('1h 1m'); - expect(getPrettyTime(60 * 60 * 1000 + 60 * 1000 + 500)).toBe('1h 1m'); + it("should return the time in hours and minutes", () => { + expect(getPrettyTime(60 * 60 * 1000)).toBe("1h 0m"); + expect(getPrettyTime(60 * 60 * 1000 + 60 * 1000)).toBe("1h 1m"); + expect(getPrettyTime(60 * 60 * 1000 + 60 * 1000 + 500)).toBe("1h 1m"); }); }); -}) +}); diff --git a/apps/api/src/utils/delay.ts b/apps/api/src/utils/delay.ts index 0d7f188e1..a3b773416 100644 --- a/apps/api/src/utils/delay.ts +++ b/apps/api/src/utils/delay.ts @@ -1,3 +1,3 @@ export function sleep(ms: number) { - return new Promise((resolve) => setTimeout(resolve, ms)); + return new Promise(resolve => setTimeout(resolve, ms)); } diff --git a/apps/api/src/utils/map/provider.ts b/apps/api/src/utils/map/provider.ts index 2e364ccd2..7019bd386 100644 --- a/apps/api/src/utils/map/provider.ts +++ b/apps/api/src/utils/map/provider.ts @@ -1,7 +1,8 @@ import { Provider, ProviderSnapshot, ProviderSnapshotNode } from "@akashnetwork/cloudmos-shared/dbSchemas/akash"; +import semver from "semver"; + import { Auditor, ProviderAttributesSchema, ProviderList } from "@src/types/provider"; import { createFilterUnique } from "../array/array"; -import semver from "semver"; export const mapProviderToList = ( provider: Provider, @@ -56,11 +57,11 @@ export const mapProviderToList = ( isValidVersion, isOnline: provider.isOnline, lastOnlineDate: lastSuccessfulSnapshot?.checkDate, - isAudited: provider.providerAttributeSignatures.some((a) => auditors.some((y) => y.address === a.auditor)), - attributes: provider.providerAttributes.map((attr) => ({ + isAudited: provider.providerAttributeSignatures.some(a => auditors.some(y => y.address === a.auditor)), + attributes: provider.providerAttributes.map(attr => ({ key: attr.key, value: attr.value, - auditedBy: provider.providerAttributeSignatures.filter((pas) => pas.key === attr.key && pas.value === attr.value).map((pas) => pas.auditor) + auditedBy: provider.providerAttributeSignatures.filter(pas => pas.key === attr.key && pas.value === attr.value).map(pas => pas.auditor) })), // Attributes schema @@ -93,7 +94,7 @@ export const mapProviderToList = ( }; function getDistinctGpuModelsFromNodes(nodes: ProviderSnapshotNode[]) { - const gpuModels = nodes.flatMap((x) => x.gpus).map((x) => ({ vendor: x.vendor, model: x.name, ram: x.memorySize, interface: x.interface })); + const gpuModels = nodes.flatMap(x => x.gpus).map(x => ({ vendor: x.vendor, model: x.name, ram: x.memorySize, interface: x.interface })); const distinctGpuModels = gpuModels.filter( createFilterUnique((a, b) => a.vendor === b.vendor && a.model === b.model && a.ram === b.ram && a.interface === b.interface) ); @@ -114,34 +115,34 @@ export const getProviderAttributeValue = ( case "string": return ( provider.providerAttributes - .filter((x) => x.key === _key) - .map((x) => x.value) + .filter(x => x.key === _key) + .map(x => x.value) .join(",") || null ); case "number": values = provider.providerAttributes - .filter((x) => x.key === _key) - .map((x) => x.value) + .filter(x => x.key === _key) + .map(x => x.value) .join(",") || "0"; return parseFloat(values); case "boolean": values = provider.providerAttributes - .filter((x) => x.key === _key) - .map((x) => x.value) + .filter(x => x.key === _key) + .map(x => x.value) .join(",") || null; return values ? values === "true" : false; case "option": return provider.providerAttributes - .filter((x) => x.key === _key) - .map((x) => possibleValues?.find((v) => v.key === x.value)?.description) - .filter((x) => x); + .filter(x => x.key === _key) + .map(x => possibleValues?.find(v => v.key === x.value)?.description) + .filter(x => x); case "multiple-option": return possibleValues - .filter((x) => provider.providerAttributes.some((at) => at.key === x.key)) - .map((x) => x.description) - .filter((x) => x); + .filter(x => provider.providerAttributes.some(at => at.key === x.key)) + .map(x => x.description) + .filter(x => x); default: console.error(`Unknown attribute type: ${providerAttributeSchema[key].type}`); return null; diff --git a/apps/api/src/utils/math.ts b/apps/api/src/utils/math.ts index 8bee95831..066692701 100644 --- a/apps/api/src/utils/math.ts +++ b/apps/api/src/utils/math.ts @@ -39,7 +39,7 @@ export function weightedAverage(values: { value: number; weight: number }[]): nu throw new Error("Input array is empty"); } - const totalWeight = values.map((x) => x.weight).reduce((acc, x) => acc + x, 0); + const totalWeight = values.map(x => x.weight).reduce((acc, x) => acc + x, 0); - return values.map((x) => x.value * x.weight).reduce((acc, x) => acc + x, 0) / totalWeight; + return values.map(x => x.value * x.weight).reduce((acc, x) => acc + x, 0) / totalWeight; } diff --git a/apps/api/src/utils/protobuf.ts b/apps/api/src/utils/protobuf.ts index bb406711f..ee5827878 100644 --- a/apps/api/src/utils/protobuf.ts +++ b/apps/api/src/utils/protobuf.ts @@ -1,19 +1,18 @@ -import { Registry, isTsProtoGeneratedType, GeneratedType } from "@cosmjs/proto-signing"; -import { defaultRegistryTypes } from "@cosmjs/stargate"; -import { MsgUnjail } from "cosmjs-types/cosmos/slashing/v1beta1/tx"; -import omit from "lodash/omit"; - import * as v1beta1 from "@akashnetwork/akash-api/v1beta1"; import * as v1beta2 from "@akashnetwork/akash-api/v1beta2"; import * as v1beta3 from "@akashnetwork/akash-api/v1beta3"; import * as v1beta4 from "@akashnetwork/akash-api/v1beta4"; +import { GeneratedType, isTsProtoGeneratedType, Registry } from "@cosmjs/proto-signing"; +import { defaultRegistryTypes } from "@cosmjs/stargate"; +import { MsgUnjail } from "cosmjs-types/cosmos/slashing/v1beta1/tx"; +import omit from "lodash/omit"; const akashTypes: ReadonlyArray<[string, GeneratedType]> = [ ...Object.values(v1beta1), ...Object.values(omit(v1beta2, "Storage")), ...Object.values(omit(v1beta3, ["DepositDeploymentAuthorization", "GPU"])), ...Object.values(v1beta4) -].map((x) => ["/" + x.$type, x]); +].map(x => ["/" + x.$type, x]); const missingTypes: ReadonlyArray<[string, GeneratedType]> = [["/cosmos.slashing.v1beta1.MsgUnjail", MsgUnjail]]; export function decodeMsg(type: string, msg: Uint8Array) { diff --git a/apps/api/src/verify-rsa-jwt-cloudflare-worker-main/get-jwks.ts b/apps/api/src/verify-rsa-jwt-cloudflare-worker-main/get-jwks.ts index ce2817625..4e926a4da 100644 --- a/apps/api/src/verify-rsa-jwt-cloudflare-worker-main/get-jwks.ts +++ b/apps/api/src/verify-rsa-jwt-cloudflare-worker-main/get-jwks.ts @@ -1,25 +1,17 @@ -import { KVStore } from './use-kv-store'; +import { KVStore } from "./use-kv-store"; export type Jwks = { keys: JsonWebKey[] }; -const DEFAULT_JWK_CACHE_KEY = 'verify-rsa-jwt-cloudflare-worker-jwks-cache-key'; -export async function getJwks( - jwksUri: string, - kvStore: KVStore, - jwkCacheKey?: string, -): Promise { +const DEFAULT_JWK_CACHE_KEY = "verify-rsa-jwt-cloudflare-worker-jwks-cache-key"; +export async function getJwks(jwksUri: string, kvStore: KVStore, jwkCacheKey?: string): Promise { if (!jwksUri) { - throw new Error('No JWKS URI provided.'); + throw new Error("No JWKS URI provided."); } try { new URL(jwksUri); } catch (error) { - throw new Error('Invalid JWKS URI'); + throw new Error("Invalid JWKS URI"); } // Fetch the JWKs from KV or the JWKS URI - const jwks = await kvStore.get( - jwkCacheKey && jwkCacheKey.length > 0 ? jwkCacheKey : DEFAULT_JWK_CACHE_KEY, - () => fetchJwks(jwksUri), - validateJwks, - ); + const jwks = await kvStore.get(jwkCacheKey && jwkCacheKey.length > 0 ? jwkCacheKey : DEFAULT_JWK_CACHE_KEY, () => fetchJwks(jwksUri), validateJwks); return jwks; } @@ -28,22 +20,15 @@ async function fetchJwks(jwksUri: string): Promise { try { response = await fetch(jwksUri); } catch (e) { - throw new Error( - 'Failed to request on fetching JWKs: ' + (e as Error).message, - ); + throw new Error("Failed to request on fetching JWKs: " + (e as Error).message); } - if (!response.ok || !response.status.toString().startsWith('2')) { - throw new Error('Failed to fetch JWKs: ' + response.statusText); + if (!response.ok || !response.status.toString().startsWith("2")) { + throw new Error("Failed to fetch JWKs: " + response.statusText); } const jwks: { keys: JsonWebKey[] } = await response.json(); return jwks; } function validateJwks(value: unknown): value is Jwks { - return ( - value !== null && - typeof value === 'object' && - 'keys' in value && - Array.isArray(value.keys) - ); + return value !== null && typeof value === "object" && "keys" in value && Array.isArray(value.keys); } diff --git a/apps/api/src/verify-rsa-jwt-cloudflare-worker-main/hono-middleware.ts b/apps/api/src/verify-rsa-jwt-cloudflare-worker-main/hono-middleware.ts index 569b940ea..4939b8c0c 100644 --- a/apps/api/src/verify-rsa-jwt-cloudflare-worker-main/hono-middleware.ts +++ b/apps/api/src/verify-rsa-jwt-cloudflare-worker-main/hono-middleware.ts @@ -1,4 +1,5 @@ import type { Context, MiddlewareHandler } from "hono"; + import type { GeneralKeyValueStore, VerificationResult } from "."; import { getJwks, useKVStore, verify } from "."; diff --git a/apps/api/src/verify-rsa-jwt-cloudflare-worker-main/index.ts b/apps/api/src/verify-rsa-jwt-cloudflare-worker-main/index.ts index 86dbb1345..a7a82c5cf 100644 --- a/apps/api/src/verify-rsa-jwt-cloudflare-worker-main/index.ts +++ b/apps/api/src/verify-rsa-jwt-cloudflare-worker-main/index.ts @@ -1,17 +1,13 @@ -import { GeneralKeyValueStore, KVNamespaceOrKeyValueStore, KVStore } from './use-kv-store'; +import { GeneralKeyValueStore, KVNamespaceOrKeyValueStore, KVStore } from "./use-kv-store"; -export { getJwks } from './get-jwks'; -export type { Jwks } from './get-jwks'; -export { getPayloadFromContext, verifyRsaJwt } from './hono-middleware'; -export type { VerifyRsaJwtConfig } from './hono-middleware'; -export { useKVStore } from './use-kv-store'; -export type { - GeneralKeyValueStore, - KVNamespaceOrKeyValueStore, - KVStore, -}; -export { verify } from './verify'; -export type { VerificationResult } from './verify'; +export { getJwks } from "./get-jwks"; +export type { Jwks } from "./get-jwks"; +export { getPayloadFromContext, verifyRsaJwt } from "./hono-middleware"; +export type { VerifyRsaJwtConfig } from "./hono-middleware"; +export { useKVStore } from "./use-kv-store"; +export type { GeneralKeyValueStore, KVNamespaceOrKeyValueStore, KVStore }; +export { verify } from "./verify"; +export type { VerificationResult } from "./verify"; export type VerifyRsaJwtEnv = { VERIFY_RSA_JWT: KVNamespaceOrKeyValueStore; diff --git a/apps/api/src/verify-rsa-jwt-cloudflare-worker-main/use-kv-store.ts b/apps/api/src/verify-rsa-jwt-cloudflare-worker-main/use-kv-store.ts index 77846fbfb..cdd0b6f4f 100644 --- a/apps/api/src/verify-rsa-jwt-cloudflare-worker-main/use-kv-store.ts +++ b/apps/api/src/verify-rsa-jwt-cloudflare-worker-main/use-kv-store.ts @@ -1,15 +1,10 @@ export type GeneralKeyValueStore = { - get: (key: string, format: 'json') => Promise; - put: ( - key: string, - value: string, - options: Record, - ) => Promise; + get: (key: string, format: "json") => Promise; + put: (key: string, value: string, options: Record) => Promise; }; -export type KVNamespaceOrKeyValueStore = /*KVNamespace | */GeneralKeyValueStore; +export type KVNamespaceOrKeyValueStore = /*KVNamespace | */ GeneralKeyValueStore; export type KVStore = ReturnType; -const defaultValidator = (value: unknown): value is T => - !!value && typeof value === 'object' && Object.keys(value).length > 0; +const defaultValidator = (value: unknown): value is T => !!value && typeof value === "object" && Object.keys(value).length > 0; export function useKVStore(kvStore?: KVNamespaceOrKeyValueStore) { return { @@ -17,7 +12,7 @@ export function useKVStore(kvStore?: KVNamespaceOrKeyValueStore) { key: string, fetcher: () => Promise, validator: (value: unknown) => value is T = defaultValidator, - cacheOptions?: { expirationTtl: number }, + cacheOptions?: { expirationTtl: number } ): Promise { if (!kvStore) { // No storage is available. Fetch and return the value. @@ -25,22 +20,22 @@ export function useKVStore(kvStore?: KVNamespaceOrKeyValueStore) { if (validator(freshValue)) { return freshValue; } - throw new Error('Invalid value: ' + JSON.stringify(freshValue)); + throw new Error("Invalid value: " + JSON.stringify(freshValue)); } - const cachedValue = await kvStore.get(key, 'json'); + const cachedValue = await kvStore.get(key, "json"); if (validator(cachedValue)) { return cachedValue; } else { const freshValue = await fetcher(); if (validator(freshValue)) { await kvStore.put(key, JSON.stringify(freshValue), { - ...cacheOptions, + ...cacheOptions }); return freshValue; } - throw new Error('Invalid value: ' + JSON.stringify(freshValue)); + throw new Error("Invalid value: " + JSON.stringify(freshValue)); } - }, + } }; } diff --git a/apps/api/src/verify-rsa-jwt-cloudflare-worker-main/verify.ts b/apps/api/src/verify-rsa-jwt-cloudflare-worker-main/verify.ts index be03614f9..d8f4b2fe5 100644 --- a/apps/api/src/verify-rsa-jwt-cloudflare-worker-main/verify.ts +++ b/apps/api/src/verify-rsa-jwt-cloudflare-worker-main/verify.ts @@ -1,32 +1,22 @@ -import type { Jwks } from './get-jwks'; +import type { Jwks } from "./get-jwks"; -const ALGO = { name: 'RSASSA-PKCS1-v1_5', hash: 'SHA-256' }; +const ALGO = { name: "RSASSA-PKCS1-v1_5", hash: "SHA-256" }; export type VerificationResult = { payload: unknown | null }; -export async function verify( - token: string, - jwks: Jwks, -): Promise { +export async function verify(token: string, jwks: Jwks): Promise { const { headerPayload, signature, payload } = parseToken(token); const verificationResults: VerificationResult[] = await Promise.all( jwks.keys.map(async (jwk: JsonWebKey) => { // Convert the matching JWK to a CryptoKey - const publicKey = await crypto.subtle.importKey('jwk', jwk, ALGO, false, [ - 'verify', - ]); - const isValid = await crypto.subtle.verify( - ALGO, - publicKey, - signature, - headerPayload, - ); + const publicKey = await crypto.subtle.importKey("jwk", jwk, ALGO, false, ["verify"]); + const isValid = await crypto.subtle.verify(ALGO, publicKey, signature, headerPayload); return { payload: isValid ? payload : null }; - }), + }) ); return ( - verificationResults.filter((result) => result.payload !== null)[0] || { - payload: null, + verificationResults.filter(result => result.payload !== null)[0] || { + payload: null } ); } @@ -36,9 +26,9 @@ function parseToken(token: string): { signature: Uint8Array; payload: unknown; } { - const tokenParts = token.split('.'); + const tokenParts = token.split("."); if (tokenParts.length !== 3) { - throw new Error('Invalid token format'); + throw new Error("Invalid token format"); } let payload; @@ -46,11 +36,9 @@ function parseToken(token: string): { // kid = JSON.parse(atob(tokenParts[0])).kid; - kid is optional. Cannot always expect. payload = JSON.parse(atob(tokenParts[1])); } catch (error) { - throw new Error('Invalid token format'); + throw new Error("Invalid token format"); } - const headerPayload = new TextEncoder().encode( - `${tokenParts[0]}.${tokenParts[1]}`, - ); + const headerPayload = new TextEncoder().encode(`${tokenParts[0]}.${tokenParts[1]}`); const signature = base64urlToUint8Array(tokenParts[2]); return { headerPayload, signature, payload }; @@ -58,8 +46,8 @@ function parseToken(token: string): { function base64urlToUint8Array(base64url: string): Uint8Array { const paddingLength = 4 - (base64url.length % 4); - const padding = paddingLength < 4 ? '='.repeat(paddingLength) : ''; - const base64 = base64url.replace(/-/g, '+').replace(/_/g, '/') + padding; + const padding = paddingLength < 4 ? "=".repeat(paddingLength) : ""; + const base64 = base64url.replace(/-/g, "+").replace(/_/g, "/") + padding; const binaryString = atob(base64); const bytes = new Uint8Array(binaryString.length); for (let i = 0; i < binaryString.length; i++) { diff --git a/apps/api/src/verify-rsa-jwt-cloudflare-worker-main/worker.ts b/apps/api/src/verify-rsa-jwt-cloudflare-worker-main/worker.ts index c97e11c0e..b97d040b1 100644 --- a/apps/api/src/verify-rsa-jwt-cloudflare-worker-main/worker.ts +++ b/apps/api/src/verify-rsa-jwt-cloudflare-worker-main/worker.ts @@ -1,22 +1,17 @@ -import { getJwks, useKVStore, verify, VerifyRsaJwtEnv } from './index'; +import { getJwks, useKVStore, verify, VerifyRsaJwtEnv } from "./index"; export default { async fetch(request: Request, env: VerifyRsaJwtEnv): Promise { - const token = - request.headers.get('Authorization')?.replace(/Bearer\s+/i, '') || ''; + const token = request.headers.get("Authorization")?.replace(/Bearer\s+/i, "") || ""; try { - const jwks = await getJwks( - env.JWKS_URI, - useKVStore(env.VERIFY_RSA_JWT), - env.VERIFY_RSA_JWT_JWKS_CACHE_KEY, - ); + const jwks = await getJwks(env.JWKS_URI, useKVStore(env.VERIFY_RSA_JWT), env.VERIFY_RSA_JWT_JWKS_CACHE_KEY); const { payload } = await verify(token, jwks); // Then, you could validate the payload and return a response return new Response(JSON.stringify({ payload }), { - headers: { 'content-type': 'application/json' }, + headers: { "content-type": "application/json" } }); } catch (error) { return new Response((error as Error).message, { status: 401 }); } - }, + } }; diff --git a/apps/api/test/functional/nodes-v1.spec.ts b/apps/api/test/functional/nodes-v1.spec.ts index 65efa8ae3..18580f886 100644 --- a/apps/api/test/functional/nodes-v1.spec.ts +++ b/apps/api/test/functional/nodes-v1.spec.ts @@ -1,10 +1,11 @@ +import { faker } from "@faker-js/faker"; +import { NodeSeeder } from "@test/seeders/node-seeder"; +import mcache from "memory-cache"; +import nock from "nock"; + import { app, initDb } from "@src/app"; import { closeConnections } from "@src/db/dbConnection"; -import nock from "nock"; import { env } from "@src/utils/env"; -import { NodeSeeder } from "@test/seeders/node-seeder"; -import { faker } from "@faker-js/faker"; -import mcache from "memory-cache"; describe("Nodes API", () => { const interceptor = nock(env.NODE_API_BASE_PATH); @@ -23,7 +24,7 @@ describe("Nodes API", () => { }); describe("GET /nodes/*", () => { - it.each(["mainnet", "sandbox", "testnet"])("should return %s node", async (network) => { + it.each(["mainnet", "sandbox", "testnet"])("should return %s node", async network => { const node = NodeSeeder.create(); interceptor.get(`/cloudmos/main/config/${network}-nodes.json`).times(1).reply(200, node); @@ -41,7 +42,7 @@ describe("Nodes API", () => { const PATH_REWRITE: Record = { testnet: "testnet-02" }; - it.each(["mainnet", "sandbox", "testnet"])("should return %s node version", async (network) => { + it.each(["mainnet", "sandbox", "testnet"])("should return %s node version", async network => { const version = `v${faker.number.int()}.${faker.number.int()}.${faker.number.int()}`; interceptor .get(`/net/master/${PATH_REWRITE[network] || network}/version.txt`) diff --git a/apps/api/test/seeders/node-seeder.ts b/apps/api/test/seeders/node-seeder.ts index 35f4f988d..602fe3de9 100644 --- a/apps/api/test/seeders/node-seeder.ts +++ b/apps/api/test/seeders/node-seeder.ts @@ -1,4 +1,5 @@ import { faker } from "@faker-js/faker"; + import type { Node } from "@src/routes/v1/nodes/nodeClient"; export class NodeSeeder { diff --git a/apps/deploy-web/src/chains/akash-sandbox.ts b/apps/deploy-web/src/chains/akash-sandbox.ts index c5df191bb..f351c4e38 100644 --- a/apps/deploy-web/src/chains/akash-sandbox.ts +++ b/apps/deploy-web/src/chains/akash-sandbox.ts @@ -1,3 +1,5 @@ +import { AssetList } from "@chain-registry/types"; + import { akash, akashAssetList } from "./akash"; export const akashSandbox = { @@ -12,4 +14,4 @@ export const akashSandbox = { } }; -export const akashSandboxAssetList = { ...akashAssetList, chain_name: "akash-sandbox", assets: [...akashAssetList.assets] }; +export const akashSandboxAssetList: AssetList = { ...akashAssetList, chain_name: "akash-sandbox", assets: [...akashAssetList.assets] }; diff --git a/apps/deploy-web/src/chains/akash-testnet.ts b/apps/deploy-web/src/chains/akash-testnet.ts index d9457e614..009d4fef5 100644 --- a/apps/deploy-web/src/chains/akash-testnet.ts +++ b/apps/deploy-web/src/chains/akash-testnet.ts @@ -1,3 +1,5 @@ +import { AssetList } from "@chain-registry/types"; + import { akash, akashAssetList } from "./akash"; export const akashTestnet = { @@ -12,4 +14,4 @@ export const akashTestnet = { } }; -export const akashTestnetAssetList = { ...akashAssetList, chain_name: "akash-testnet", assets: [...akashAssetList.assets] }; +export const akashTestnetAssetList: AssetList = { ...akashAssetList, chain_name: "akash-testnet", assets: [...akashAssetList.assets] }; diff --git a/apps/deploy-web/src/chains/akash.ts b/apps/deploy-web/src/chains/akash.ts index 38567d60a..b92145395 100644 --- a/apps/deploy-web/src/chains/akash.ts +++ b/apps/deploy-web/src/chains/akash.ts @@ -1,5 +1,5 @@ -import { assets } from "chain-registry"; import { AssetList } from "@chain-registry/types"; +import { assets } from "chain-registry"; // Obtained from https://raw.githubusercontent.com/cosmos/chain-registry/master/akash/chain.json export const akash = { diff --git a/apps/deploy-web/src/chains/index.ts b/apps/deploy-web/src/chains/index.ts index d0a7630e4..7e0a192ff 100644 --- a/apps/deploy-web/src/chains/index.ts +++ b/apps/deploy-web/src/chains/index.ts @@ -1,3 +1,6 @@ -export { akash, akashAssetList } from "./akash"; -export { akashSandbox, akashSandboxAssetList } from "./akash-sandbox"; -export { akashTestnet, akashTestnetAssetList } from "./akash-testnet"; +import { akash, akashAssetList } from "./akash"; +import { akashSandbox, akashSandboxAssetList } from "./akash-sandbox"; +import { akashTestnet, akashTestnetAssetList } from "./akash-testnet"; + +export { akash, akashSandbox, akashTestnet, akashAssetList, akashSandboxAssetList, akashTestnetAssetList }; +export const assetLists = [akashAssetList, akashSandboxAssetList, akashTestnetAssetList]; diff --git a/apps/deploy-web/src/components/authorizations/AllowanceGrantedRow.tsx b/apps/deploy-web/src/components/authorizations/AllowanceGrantedRow.tsx index ce116dd78..85fae1fe7 100644 --- a/apps/deploy-web/src/components/authorizations/AllowanceGrantedRow.tsx +++ b/apps/deploy-web/src/components/authorizations/AllowanceGrantedRow.tsx @@ -1,12 +1,13 @@ "use client"; import React, { ReactNode } from "react"; import { FormattedTime } from "react-intl"; -import { AllowanceType } from "@src/types/grant"; -import { coinToUDenom } from "@src/utils/priceUtils"; -import { getAllowanceTitleByType } from "@src/utils/grants"; -import { TableCell, TableRow } from "@src/components/ui/table"; + import { Address } from "@src/components/shared/Address"; import { AKTAmount } from "@src/components/shared/AKTAmount"; +import { TableCell, TableRow } from "@src/components/ui/table"; +import { AllowanceType } from "@src/types/grant"; +import { getAllowanceTitleByType } from "@src/utils/grants"; +import { coinToUDenom } from "@src/utils/priceUtils"; type Props = { allowance: AllowanceType; diff --git a/apps/deploy-web/src/components/authorizations/AllowanceIssuedRow.tsx b/apps/deploy-web/src/components/authorizations/AllowanceIssuedRow.tsx index 2e0a45aab..86ffa75fd 100644 --- a/apps/deploy-web/src/components/authorizations/AllowanceIssuedRow.tsx +++ b/apps/deploy-web/src/components/authorizations/AllowanceIssuedRow.tsx @@ -1,14 +1,15 @@ "use client"; import React, { ReactNode } from "react"; import { FormattedTime } from "react-intl"; -import { AllowanceType } from "@src/types/grant"; -import { coinToUDenom } from "@src/utils/priceUtils"; -import { getAllowanceTitleByType } from "@src/utils/grants"; -import { TableCell, TableRow } from "@src/components/ui/table"; +import { Bin, Edit } from "iconoir-react"; + import { Address } from "@src/components/shared/Address"; import { AKTAmount } from "@src/components/shared/AKTAmount"; import { Button } from "@src/components/ui/button"; -import { Bin, Edit } from "iconoir-react"; +import { TableCell, TableRow } from "@src/components/ui/table"; +import { AllowanceType } from "@src/types/grant"; +import { getAllowanceTitleByType } from "@src/utils/grants"; +import { coinToUDenom } from "@src/utils/priceUtils"; type Props = { allowance: AllowanceType; diff --git a/apps/deploy-web/src/components/authorizations/AllowanceModal.tsx b/apps/deploy-web/src/components/authorizations/AllowanceModal.tsx index 29f2172a3..95a8eb67c 100644 --- a/apps/deploy-web/src/components/authorizations/AllowanceModal.tsx +++ b/apps/deploy-web/src/components/authorizations/AllowanceModal.tsx @@ -1,23 +1,24 @@ "use client"; import { useRef, useState } from "react"; -import { useForm, Controller } from "react-hook-form"; +import { Controller, useForm } from "react-hook-form"; +import { FormattedDate } from "react-intl"; +import { EncodeObject } from "@cosmjs/proto-signing"; +import FormControl from "@mui/material/FormControl"; +import InputAdornment from "@mui/material/InputAdornment"; +import TextField from "@mui/material/TextField"; import { addYears, format } from "date-fns"; -import { useWallet } from "@src/context/WalletProvider"; -import { aktToUakt, coinToDenom } from "@src/utils/priceUtils"; -import { TransactionMessageData } from "@src/utils/TransactionMessageData"; import { event } from "nextjs-google-analytics"; -import { AnalyticsEvents } from "@src/utils/analytics"; -import { AllowanceType } from "@src/types/grant"; -import { useDenomData } from "@src/hooks/useWalletBalance"; -import { uAktDenom } from "@src/utils/constants"; -import { FormattedDate } from "react-intl"; + +import { LinkTo } from "@src/components/shared/LinkTo"; import { Popup } from "@src/components/shared/Popup"; import { Alert } from "@src/components/ui/alert"; -import { LinkTo } from "@src/components/shared/LinkTo"; -import FormControl from "@mui/material/FormControl"; -import TextField from "@mui/material/TextField"; -import InputAdornment from "@mui/material/InputAdornment"; -import { EncodeObject } from "@cosmjs/proto-signing"; +import { useWallet } from "@src/context/WalletProvider"; +import { useDenomData } from "@src/hooks/useWalletBalance"; +import { AllowanceType } from "@src/types/grant"; +import { AnalyticsEvents } from "@src/utils/analytics"; +import { uAktDenom } from "@src/utils/constants"; +import { aktToUakt, coinToDenom } from "@src/utils/priceUtils"; +import { TransactionMessageData } from "@src/utils/TransactionMessageData"; type AllowanceFormValues = { amount: number; diff --git a/apps/deploy-web/src/components/authorizations/Authorizations.tsx b/apps/deploy-web/src/components/authorizations/Authorizations.tsx index 724022d6d..4f7f5fa47 100644 --- a/apps/deploy-web/src/components/authorizations/Authorizations.tsx +++ b/apps/deploy-web/src/components/authorizations/Authorizations.tsx @@ -1,35 +1,34 @@ "use client"; -import { Fieldset } from "@src/components/shared/Fieldset"; import { useEffect, useState } from "react"; -import { useWallet } from "@src/context/WalletProvider"; +import { Bank } from "iconoir-react"; +import { NextSeo } from "next-seo"; + import { Address } from "@src/components/shared/Address"; -import { AllowanceType, GrantType } from "@src/types/grant"; -import { TransactionMessageData } from "@src/utils/TransactionMessageData"; -import { useAllowancesGranted, useAllowancesIssued, useGranteeGrants, useGranterGrants } from "@src/queries/useGrantsQuery"; +import { Fieldset } from "@src/components/shared/Fieldset"; import { Popup } from "@src/components/shared/Popup"; -import { averageBlockTime } from "@src/utils/priceUtils"; -import { Button } from "@src/components/ui/button"; -import { Bank } from "iconoir-react"; import Spinner from "@src/components/shared/Spinner"; +import { Button } from "@src/components/ui/button"; import { Table, TableBody, TableHead, TableHeader, TableRow } from "@src/components/ui/table"; +import { useWallet } from "@src/context/WalletProvider"; +import { useAllowancesGranted, useAllowancesIssued, useGranteeGrants, useGranterGrants } from "@src/queries/useGrantsQuery"; +import { AllowanceType, GrantType } from "@src/types/grant"; +import { averageBlockTime } from "@src/utils/priceUtils"; +import { TransactionMessageData } from "@src/utils/TransactionMessageData"; import Layout from "../layout/Layout"; import { SettingsLayout, SettingsTabs } from "../settings/SettingsLayout"; -import { GrantModal } from "./GrantModal"; -import { AllowanceModal } from "./AllowanceModal"; +import { Title } from "../shared/Title"; import { AllowanceGrantedRow } from "./AllowanceGrantedRow"; import { AllowanceIssuedRow } from "./AllowanceIssuedRow"; +import { AllowanceModal } from "./AllowanceModal"; import { GranteeRow } from "./GranteeRow"; import { GranterRow } from "./GranterRow"; -import { NextSeo } from "next-seo"; -import { Title } from "../shared/Title"; - -type Props = {}; +import { GrantModal } from "./GrantModal"; type RefreshingType = "granterGrants" | "granteeGrants" | "allowancesIssued" | "allowancesGranted" | null; const defaultRefetchInterval = 30 * 1000; const refreshingInterval = 1000; -export const Authorizations: React.FunctionComponent = ({}) => { +export const Authorizations: React.FunctionComponent = () => { const { address, signAndBroadcastTx } = useWallet(); const [editingGrant, setEditingGrant] = useState(null); const [editingAllowance, setEditingAllowance] = useState(null); diff --git a/apps/deploy-web/src/components/authorizations/GrantModal.tsx b/apps/deploy-web/src/components/authorizations/GrantModal.tsx index cbd6e5a92..190e8326a 100644 --- a/apps/deploy-web/src/components/authorizations/GrantModal.tsx +++ b/apps/deploy-web/src/components/authorizations/GrantModal.tsx @@ -1,27 +1,28 @@ "use client"; import { useRef, useState } from "react"; -import { useForm, Controller } from "react-hook-form"; +import { Controller, useForm } from "react-hook-form"; +import { FormattedDate } from "react-intl"; +import FormControl from "@mui/material/FormControl"; +import InputLabel from "@mui/material/InputLabel"; +import MenuItem from "@mui/material/MenuItem"; +import Select from "@mui/material/Select"; +import TextField from "@mui/material/TextField"; import { addYears, format } from "date-fns"; -import { useWallet } from "@src/context/WalletProvider"; -import { aktToUakt, coinToDenom } from "@src/utils/priceUtils"; -import { TransactionMessageData } from "@src/utils/TransactionMessageData"; import { event } from "nextjs-google-analytics"; -import { AnalyticsEvents } from "@src/utils/analytics"; -import { GrantType } from "@src/types/grant"; + +import { LinkTo } from "@src/components/shared/LinkTo"; +import { Popup } from "@src/components/shared/Popup"; +import { Alert } from "@src/components/ui/alert"; +import { useWallet } from "@src/context/WalletProvider"; import { getUsdcDenom, useUsdcDenom } from "@src/hooks/useDenom"; -import { denomToUdenom } from "@src/utils/mathHelpers"; import { useDenomData } from "@src/hooks/useWalletBalance"; +import { GrantType } from "@src/types/grant"; +import { AnalyticsEvents } from "@src/utils/analytics"; import { uAktDenom } from "@src/utils/constants"; -import { FormattedDate } from "react-intl"; +import { denomToUdenom } from "@src/utils/mathHelpers"; +import { aktToUakt, coinToDenom } from "@src/utils/priceUtils"; +import { TransactionMessageData } from "@src/utils/TransactionMessageData"; import { handleDocClick } from "@src/utils/urlUtils"; -import { Popup } from "@src/components/shared/Popup"; -import { Alert } from "@src/components/ui/alert"; -import { LinkTo } from "@src/components/shared/LinkTo"; -import FormControl from "@mui/material/FormControl"; -import InputLabel from "@mui/material/InputLabel"; -import Select from "@mui/material/Select"; -import MenuItem from "@mui/material/MenuItem"; -import TextField from "@mui/material/TextField"; type GrantFormValues = { token: string; amount: number; diff --git a/apps/deploy-web/src/components/authorizations/GranteeRow.tsx b/apps/deploy-web/src/components/authorizations/GranteeRow.tsx index d28f9f6cc..1c6addc99 100644 --- a/apps/deploy-web/src/components/authorizations/GranteeRow.tsx +++ b/apps/deploy-web/src/components/authorizations/GranteeRow.tsx @@ -1,12 +1,13 @@ "use client"; import React, { ReactNode } from "react"; import { FormattedTime } from "react-intl"; -import { coinToUDenom } from "@src/utils/priceUtils"; -import { GrantType } from "@src/types/grant"; -import { useDenomData } from "@src/hooks/useWalletBalance"; -import { TableCell, TableRow } from "@src/components/ui/table"; + import { Address } from "@src/components/shared/Address"; import { AKTAmount } from "@src/components/shared/AKTAmount"; +import { TableCell, TableRow } from "@src/components/ui/table"; +import { useDenomData } from "@src/hooks/useWalletBalance"; +import { GrantType } from "@src/types/grant"; +import { coinToUDenom } from "@src/utils/priceUtils"; type Props = { grant: GrantType; diff --git a/apps/deploy-web/src/components/authorizations/GranterRow.tsx b/apps/deploy-web/src/components/authorizations/GranterRow.tsx index 95b3b00f7..15c2b0c0c 100644 --- a/apps/deploy-web/src/components/authorizations/GranterRow.tsx +++ b/apps/deploy-web/src/components/authorizations/GranterRow.tsx @@ -1,14 +1,15 @@ "use client"; import React, { ReactNode } from "react"; import { FormattedTime } from "react-intl"; -import { coinToUDenom } from "@src/utils/priceUtils"; -import { GrantType } from "@src/types/grant"; -import { useDenomData } from "@src/hooks/useWalletBalance"; -import { TableCell, TableRow } from "@src/components/ui/table"; +import { Bin, Edit } from "iconoir-react"; + import { Address } from "@src/components/shared/Address"; import { AKTAmount } from "@src/components/shared/AKTAmount"; import { Button } from "@src/components/ui/button"; -import { Bin, Edit } from "iconoir-react"; +import { TableCell, TableRow } from "@src/components/ui/table"; +import { useDenomData } from "@src/hooks/useWalletBalance"; +import { GrantType } from "@src/types/grant"; +import { coinToUDenom } from "@src/utils/priceUtils"; type Props = { grant: GrantType; @@ -17,7 +18,7 @@ type Props = { setDeletingGrant: (grant: GrantType) => void; }; -export const GranterRow: React.FunctionComponent = ({ children, grant, onEditGrant, setDeletingGrant }) => { +export const GranterRow: React.FunctionComponent = ({ grant, onEditGrant, setDeletingGrant }) => { const denomData = useDenomData(grant.authorization.spend_limit.denom); return ( diff --git a/apps/deploy-web/src/components/deployments/DeploymentDepositModal.tsx b/apps/deploy-web/src/components/deployments/DeploymentDepositModal.tsx index 316f5def2..b5915bcb5 100644 --- a/apps/deploy-web/src/components/deployments/DeploymentDepositModal.tsx +++ b/apps/deploy-web/src/components/deployments/DeploymentDepositModal.tsx @@ -1,28 +1,29 @@ "use client"; -import { useState, useRef, useEffect, ReactNode } from "react"; -import { useForm, Controller } from "react-hook-form"; +import { ReactNode, useEffect, useRef, useState } from "react"; +import { Controller, useForm } from "react-hook-form"; import compareAsc from "date-fns/compareAsc"; -import { coinToUDenom, uaktToAKT } from "@src/utils/priceUtils"; -import { uAktDenom } from "@src/utils/constants"; -import { useWallet } from "@src/context/WalletProvider"; -import { LinkTo } from "../shared/LinkTo"; import { event } from "nextjs-google-analytics"; -import { AnalyticsEvents } from "@src/utils/analytics"; +import { useSnackbar } from "notistack"; + +import { useSettings } from "@src/context/SettingsProvider"; +import { useWallet } from "@src/context/WalletProvider"; +import { useUsdcDenom } from "@src/hooks/useDenom"; +import { useDenomData } from "@src/hooks/useWalletBalance"; import { useGranteeGrants } from "@src/queries/useGrantsQuery"; +import { AnalyticsEvents } from "@src/utils/analytics"; +import { uAktDenom } from "@src/utils/constants"; import { denomToUdenom, udenomToDenom } from "@src/utils/mathHelpers"; +import { coinToUDenom, uaktToAKT } from "@src/utils/priceUtils"; +import { LinkTo } from "../shared/LinkTo"; import { Popup } from "../shared/Popup"; -import { useDenomData } from "@src/hooks/useWalletBalance"; -import { useUsdcDenom } from "@src/hooks/useDenom"; +import { Snackbar } from "../shared/Snackbar"; import { Alert } from "../ui/alert"; +import { CheckboxWithLabel } from "../ui/checkbox"; import { FormItem } from "../ui/form"; import { InputWithIcon } from "../ui/input"; -import { CheckboxWithLabel } from "../ui/checkbox"; import { Label } from "../ui/label"; import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "../ui/select"; -import { useSettings } from "@src/context/SettingsProvider"; import { GranteeDepositMenuItem } from "./GranteeDepositMenuItem"; -import { useSnackbar } from "notistack"; -import { Snackbar } from "../shared/Snackbar"; type Props = { infoText?: string | ReactNode; @@ -42,15 +43,7 @@ export const DeploymentDepositModal: React.FunctionComponent = ({ handleC const { walletBalances, address } = useWallet(); const { data: granteeGrants } = useGranteeGrants(address); const depositData = useDenomData(denom); - const { - handleSubmit, - control, - formState: { errors }, - watch, - setValue, - clearErrors, - unregister - } = useForm({ + const { handleSubmit, control, watch, setValue, clearErrors, unregister } = useForm({ defaultValues: { amount: 0, useDepositor: false, @@ -104,7 +97,7 @@ export const DeploymentDepositModal: React.FunctionComponent = ({ handleC return false; } - let spendLimitUDenom = coinToUDenom(grant.authorization.spend_limit); + const spendLimitUDenom = coinToUDenom(grant.authorization.spend_limit); if (depositAmount > spendLimitUDenom) { setError(`Spend limit remaining: ${udenomToDenom(spendLimitUDenom)} ${depositData?.label}`); @@ -255,7 +248,7 @@ export const DeploymentDepositModal: React.FunctionComponent = ({ handleC rules={{ required: true }} - render={({ fieldState, field }) => { + render={({ field }) => { return ( ) { const router = useRouter(); const [activeTab, setActiveTab] = useState("LEASES"); - const [selectedLogsMode, setSelectedLogsMode] = useState("logs"); const { address, isWalletLoaded } = useWallet(); const { isSettingsInit } = useSettings(); const [leaseRefs, setLeaseRefs] = useState>([]); @@ -103,10 +103,6 @@ export function DeploymentDetail({ dseq }: React.PropsWithChildren<{ dseq: strin if (tabQuery) { setActiveTab(tabQuery); } - - if (logsModeQuery && (logsModeQuery === "logs" || logsModeQuery === "events")) { - setSelectedLogsMode(logsModeQuery); - } } }, [tabQuery, logsModeQuery, leases]); @@ -155,9 +151,7 @@ export function DeploymentDetail({ dseq }: React.PropsWithChildren<{ dseq: strin {isDeploymentNotFound && (
404 -

- This deployment does not exist or it was created using another wallet. -

+

This deployment does not exist or it was created using another wallet.

@@ -186,7 +180,6 @@ export function DeploymentDetail({ dseq }: React.PropsWithChildren<{ dseq: strin leases={leases} closeManifestEditor={() => { setActiveTab("EVENTS"); - setSelectedLogsMode("events"); loadDeploymentDetail(); }} /> diff --git a/apps/deploy-web/src/components/deployments/DeploymentDetailTopBar.tsx b/apps/deploy-web/src/components/deployments/DeploymentDetailTopBar.tsx index b0f1e3b79..c09a2c3c4 100644 --- a/apps/deploy-web/src/components/deployments/DeploymentDetailTopBar.tsx +++ b/apps/deploy-web/src/components/deployments/DeploymentDetailTopBar.tsx @@ -1,20 +1,21 @@ "use client"; import { Dispatch, ReactNode, SetStateAction, useState } from "react"; -import { DeploymentDepositModal } from "./DeploymentDepositModal"; -import { useLocalNotes } from "@src/context/LocalNoteProvider"; +import { DropdownMenuTrigger } from "@radix-ui/react-dropdown-menu"; +import { Edit, MoreHoriz, NavArrowLeft, Refresh, Upload, XmarkSquare } from "iconoir-react"; import { useRouter } from "next/navigation"; -import { UrlService } from "@src/utils/urlUtils"; -import { useWallet } from "@src/context/WalletProvider"; -import { TransactionMessageData } from "@src/utils/TransactionMessageData"; import { event } from "nextjs-google-analytics"; -import { AnalyticsEvents } from "@src/utils/analytics"; -import { DeploymentDto } from "@src/types/deployment"; -import { usePreviousRoute } from "@src/hooks/usePreviousRoute"; + +import { CustomDropdownLinkItem } from "@src/components/shared/CustomDropdownLinkItem"; import { Button } from "@src/components/ui/button"; -import { Edit, MoreHoriz, NavArrowLeft, Refresh, Upload, XmarkSquare } from "iconoir-react"; import { DropdownMenu, DropdownMenuContent } from "@src/components/ui/dropdown-menu"; -import { DropdownMenuTrigger } from "@radix-ui/react-dropdown-menu"; -import { CustomDropdownLinkItem } from "@src/components/shared/CustomDropdownLinkItem"; +import { useLocalNotes } from "@src/context/LocalNoteProvider"; +import { useWallet } from "@src/context/WalletProvider"; +import { usePreviousRoute } from "@src/hooks/usePreviousRoute"; +import { DeploymentDto } from "@src/types/deployment"; +import { AnalyticsEvents } from "@src/utils/analytics"; +import { TransactionMessageData } from "@src/utils/TransactionMessageData"; +import { UrlService } from "@src/utils/urlUtils"; +import { DeploymentDepositModal } from "./DeploymentDepositModal"; type Props = { address: string; @@ -43,21 +44,17 @@ export const DeploymentDetailTopBar: React.FunctionComponent = ({ address } const onCloseDeployment = async () => { - try { - const message = TransactionMessageData.getCloseDeploymentMsg(address, deployment.dseq); - const response = await signAndBroadcastTx([message]); - if (response) { - setActiveTab("LEASES"); - removeLeases(); - loadDeploymentDetail(); - - event(AnalyticsEvents.CLOSE_DEPLOYMENT, { - category: "deployments", - label: "Close deployment in deployment detail" - }); - } - } catch (error) { - throw error; + const message = TransactionMessageData.getCloseDeploymentMsg(address, deployment.dseq); + const response = await signAndBroadcastTx([message]); + if (response) { + setActiveTab("LEASES"); + removeLeases(); + loadDeploymentDetail(); + + event(AnalyticsEvents.CLOSE_DEPLOYMENT, { + category: "deployments", + label: "Close deployment in deployment detail" + }); } }; @@ -73,25 +70,15 @@ export const DeploymentDetailTopBar: React.FunctionComponent = ({ address const onDeploymentDeposit = async (deposit: number, depositorAddress: string) => { setIsDepositingDeployment(false); - try { - const message = TransactionMessageData.getDepositDeploymentMsg( - address, - deployment.dseq, - deposit, - deployment.escrowAccount.balance.denom, - depositorAddress - ); - const response = await signAndBroadcastTx([message]); - if (response) { - loadDeploymentDetail(); - - event(AnalyticsEvents.DEPLOYMENT_DEPOSIT, { - category: "deployments", - label: "Deposit deployment in deployment detail" - }); - } - } catch (error) { - throw error; + const message = TransactionMessageData.getDepositDeploymentMsg(address, deployment.dseq, deposit, deployment.escrowAccount.balance.denom, depositorAddress); + const response = await signAndBroadcastTx([message]); + if (response) { + loadDeploymentDetail(); + + event(AnalyticsEvents.DEPLOYMENT_DEPOSIT, { + category: "deployments", + label: "Deposit deployment in deployment detail" + }); } }; diff --git a/apps/deploy-web/src/components/deployments/DeploymentLeaseShell.tsx b/apps/deploy-web/src/components/deployments/DeploymentLeaseShell.tsx index 59038931d..0990404e0 100644 --- a/apps/deploy-web/src/components/deployments/DeploymentLeaseShell.tsx +++ b/apps/deploy-web/src/components/deployments/DeploymentLeaseShell.tsx @@ -1,25 +1,26 @@ "use client"; import React, { useCallback, useEffect, useRef, useState } from "react"; -import { LeaseSelect } from "./LeaseSelect"; -import { useLeaseStatus } from "@src/queries/useLeaseQuery"; -import { ServiceSelect } from "./ServiceSelect"; -import { ShellDownloadModal } from "./ShellDownloadModal"; -import { PROVIDER_PROXY_URL_WS } from "@src/utils/constants"; -import { XTermRefType } from "@src/lib/XTerm/XTerm"; -import { XTerm } from "@src/lib/XTerm"; -import { LeaseShellCode } from "@src/types/shell"; -import { useCustomWebSocket } from "@src/hooks/useCustomWebSocket"; -import { LeaseDto } from "@src/types/deployment"; -import { useProviderList } from "@src/queries/useProvidersQuery"; +import { OpenInWindow, OpenNewWindow } from "iconoir-react"; import Link from "next/link"; -import { UrlService } from "@src/utils/urlUtils"; -import { useCertificate } from "@src/context/CertificateProvider"; + +import Spinner from "@src/components/shared/Spinner"; import ViewPanel from "@src/components/shared/ViewPanel"; import { Alert } from "@src/components/ui/alert"; import { Button } from "@src/components/ui/button"; -import Spinner from "@src/components/shared/Spinner"; -import { OpenInWindow, OpenNewWindow } from "iconoir-react"; +import { useCertificate } from "@src/context/CertificateProvider"; +import { useCustomWebSocket } from "@src/hooks/useCustomWebSocket"; +import { XTerm } from "@src/lib/XTerm"; +import { XTermRefType } from "@src/lib/XTerm/XTerm"; +import { useLeaseStatus } from "@src/queries/useLeaseQuery"; +import { useProviderList } from "@src/queries/useProvidersQuery"; +import { LeaseDto } from "@src/types/deployment"; +import { LeaseShellCode } from "@src/types/shell"; +import { PROVIDER_PROXY_URL_WS } from "@src/utils/constants"; import { cn } from "@src/utils/styleUtils"; +import { UrlService } from "@src/utils/urlUtils"; +import { LeaseSelect } from "./LeaseSelect"; +import { ServiceSelect } from "./ServiceSelect"; +import { ShellDownloadModal } from "./ShellDownloadModal"; type Props = { leases: LeaseDto[] | null | undefined; @@ -109,7 +110,7 @@ export const DeploymentLeaseShell: React.FunctionComponent = ({ leases }) const closed = jsonData?.closed; if (message?.data) { - let parsedData = Buffer.from(message.data).toString("utf-8", 1); + const parsedData = Buffer.from(message.data).toString("utf-8", 1); // Check if parsedData is either ^[[A, ^[[B, ^[[C or ^[[D const arrowKeyPattern = /\^\[\[[A-D]/; @@ -117,12 +118,13 @@ export const DeploymentLeaseShell: React.FunctionComponent = ({ leases }) setShowArrowAndTabWarning(true); } - let exitCode, errorMessage; + let exitCode; try { const jsonData = JSON.parse(parsedData); exitCode = jsonData["exit_code"]; - errorMessage = jsonData["message"]; - } catch (error) {} + } catch (error) { + /* empty */ + } if (exitCode === undefined) { if (!isConnectionEstablished) { // Welcome message diff --git a/apps/deploy-web/src/components/deployments/DeploymentList.tsx b/apps/deploy-web/src/components/deployments/DeploymentList.tsx index de2f95752..fdc71e0fd 100644 --- a/apps/deploy-web/src/components/deployments/DeploymentList.tsx +++ b/apps/deploy-web/src/components/deployments/DeploymentList.tsx @@ -1,33 +1,32 @@ "use client"; -import { NextSeo } from "next-seo"; -import { useWallet } from "@src/context/WalletProvider"; -import { useDeploymentList } from "@src/queries/useDeploymentQuery"; import { useEffect, useState } from "react"; -import { useSettings } from "@src/context/SettingsProvider"; -import { useLocalNotes } from "@src/context/LocalNoteProvider"; +import { Refresh, Rocket, Xmark } from "iconoir-react"; +import { useAtom } from "jotai"; import Link from "next/link"; -import { UrlService } from "@src/utils/urlUtils"; -import { TransactionMessageData } from "@src/utils/TransactionMessageData"; +import { NextSeo } from "next-seo"; + +import { CustomPagination } from "@src/components/shared/CustomPagination"; import { LinkTo } from "@src/components/shared/LinkTo"; -import { useAtom } from "jotai"; -import sdlStore from "@src/store/sdlStore"; -import { useProviderList } from "@src/queries/useProvidersQuery"; -import { DeploymentDto, NamedDeploymentDto } from "@src/types/deployment"; +import Spinner from "@src/components/shared/Spinner"; import { Button, buttonVariants } from "@src/components/ui/button"; -import { Refresh, Rocket, Xmark } from "iconoir-react"; import { CheckboxWithLabel } from "@src/components/ui/checkbox"; -import { cn } from "@src/utils/styleUtils"; import { InputWithIcon } from "@src/components/ui/input"; -import Spinner from "@src/components/shared/Spinner"; -import { CustomPagination } from "@src/components/shared/CustomPagination"; import { Table, TableBody, TableHead, TableHeader, TableRow } from "@src/components/ui/table"; +import { useLocalNotes } from "@src/context/LocalNoteProvider"; +import { useSettings } from "@src/context/SettingsProvider"; +import { useWallet } from "@src/context/WalletProvider"; +import { useDeploymentList } from "@src/queries/useDeploymentQuery"; +import { useProviderList } from "@src/queries/useProvidersQuery"; +import sdlStore from "@src/store/sdlStore"; +import { DeploymentDto, NamedDeploymentDto } from "@src/types/deployment"; +import { cn } from "@src/utils/styleUtils"; +import { TransactionMessageData } from "@src/utils/TransactionMessageData"; +import { UrlService } from "@src/utils/urlUtils"; import Layout from "../layout/Layout"; -import { DeploymentListRow } from "./DeploymentListRow"; import { Title } from "../shared/Title"; +import { DeploymentListRow } from "./DeploymentListRow"; -type Props = {}; - -export const DeploymentList: React.FunctionComponent = ({}) => { +export const DeploymentList: React.FunctionComponent = () => { const { address, signAndBroadcastTx, isWalletLoaded } = useWallet(); const { data: providers, isFetching: isLoadingProviders } = useProviderList(); const { data: deployments, isFetching: isLoadingDeployments, refetch: getDeployments } = useDeploymentList(address, { enabled: false }); diff --git a/apps/deploy-web/src/components/deployments/DeploymentListRow.tsx b/apps/deploy-web/src/components/deployments/DeploymentListRow.tsx index cf46cba02..dfefbaa55 100644 --- a/apps/deploy-web/src/components/deployments/DeploymentListRow.tsx +++ b/apps/deploy-web/src/components/deployments/DeploymentListRow.tsx @@ -1,36 +1,37 @@ "use client"; import { ReactNode, useState } from "react"; -import { useLocalNotes } from "../../context/LocalNoteProvider"; -import { LeaseChip } from "./LeaseChip"; +import ClickAwayListener from "@mui/material/ClickAwayListener"; +import differenceInCalendarDays from "date-fns/differenceInCalendarDays"; import formatDistanceToNow from "date-fns/formatDistanceToNow"; import isValid from "date-fns/isValid"; -import differenceInCalendarDays from "date-fns/differenceInCalendarDays"; -import { SpecDetailList } from "../shared/SpecDetailList"; -import { useAllLeases } from "@src/queries/useLeaseQuery"; +import { Edit, InfoCircle, MoreHoriz, NavArrowRight, Plus, Upload, WarningCircle, WarningTriangle, XmarkSquare } from "iconoir-react"; import { useRouter } from "next/navigation"; -import { getAvgCostPerMonth, getTimeLeft, useRealTimeLeft } from "@src/utils/priceUtils"; -import { UrlService } from "@src/utils/urlUtils"; -import { DeploymentDepositModal } from "./DeploymentDepositModal"; -import { useWallet } from "@src/context/WalletProvider"; -import { TransactionMessageData } from "@src/utils/TransactionMessageData"; import { event } from "nextjs-google-analytics"; -import { AnalyticsEvents } from "@src/utils/analytics"; + +import { useWallet } from "@src/context/WalletProvider"; +import { getShortText } from "@src/hooks/useShortText"; +import { useDenomData } from "@src/hooks/useWalletBalance"; +import { useAllLeases } from "@src/queries/useLeaseQuery"; import { NamedDeploymentDto } from "@src/types/deployment"; import { ApiProviderList } from "@src/types/provider"; -import { PriceValue } from "../shared/PriceValue"; -import { CustomTooltip } from "../shared/CustomTooltip"; -import { PricePerMonth } from "../shared/PricePerMonth"; +import { AnalyticsEvents } from "@src/utils/analytics"; import { udenomToDenom } from "@src/utils/mathHelpers"; -import { useDenomData } from "@src/hooks/useWalletBalance"; -import { TableCell, TableRow } from "../ui/table"; -import { WarningCircle, MoreHoriz, InfoCircle, NavArrowRight, Plus, Edit, XmarkSquare, Upload, WarningTriangle } from "iconoir-react"; +import { getAvgCostPerMonth, getTimeLeft, useRealTimeLeft } from "@src/utils/priceUtils"; +import { TransactionMessageData } from "@src/utils/TransactionMessageData"; +import { UrlService } from "@src/utils/urlUtils"; +import { useLocalNotes } from "../../context/LocalNoteProvider"; import { CustomDropdownLinkItem } from "../shared/CustomDropdownLinkItem"; +import { CustomTooltip } from "../shared/CustomTooltip"; +import { PricePerMonth } from "../shared/PricePerMonth"; +import { PriceValue } from "../shared/PriceValue"; +import { SpecDetailList } from "../shared/SpecDetailList"; +import Spinner from "../shared/Spinner"; import { Button } from "../ui/button"; import { Checkbox } from "../ui/checkbox"; import { DropdownMenu, DropdownMenuContent, DropdownMenuTrigger } from "../ui/dropdown-menu"; -import Spinner from "../shared/Spinner"; -import ClickAwayListener from "@mui/material/ClickAwayListener"; -import { getShortText, getSplitText } from "@src/hooks/useShortText"; +import { TableCell, TableRow } from "../ui/table"; +import { DeploymentDepositModal } from "./DeploymentDepositModal"; +import { LeaseChip } from "./LeaseChip"; type Props = { deployment: NamedDeploymentDto; @@ -122,48 +123,34 @@ export const DeploymentListRow: React.FunctionComponent = ({ deployment, const onDeploymentDeposit = async (deposit, depositorAddress) => { setIsDepositingDeployment(false); - try { - const message = TransactionMessageData.getDepositDeploymentMsg( - address, - deployment.dseq, - deposit, - deployment.escrowAccount.balance.denom, - depositorAddress - ); - const response = await signAndBroadcastTx([message]); - if (response) { - refreshDeployments(); + const message = TransactionMessageData.getDepositDeploymentMsg(address, deployment.dseq, deposit, deployment.escrowAccount.balance.denom, depositorAddress); + const response = await signAndBroadcastTx([message]); + if (response) { + refreshDeployments(); - event(AnalyticsEvents.DEPLOYMENT_DEPOSIT, { - category: "deployments", - label: "Deposit to deployment from list" - }); - } - } catch (error) { - throw error; + event(AnalyticsEvents.DEPLOYMENT_DEPOSIT, { + category: "deployments", + label: "Deposit to deployment from list" + }); } }; const onCloseDeployment = async () => { handleMenuClose(); - try { - const message = TransactionMessageData.getCloseDeploymentMsg(address, deployment.dseq); - const response = await signAndBroadcastTx([message]); - if (response) { - if (onSelectDeployment) { - onSelectDeployment(false, deployment.dseq); - } + const message = TransactionMessageData.getCloseDeploymentMsg(address, deployment.dseq); + const response = await signAndBroadcastTx([message]); + if (response) { + if (onSelectDeployment) { + onSelectDeployment(false, deployment.dseq); + } - refreshDeployments(); + refreshDeployments(); - event(AnalyticsEvents.CLOSE_DEPLOYMENT, { - category: "deployments", - label: "Close deployment from list" - }); - } - } catch (error) { - throw error; + event(AnalyticsEvents.CLOSE_DEPLOYMENT, { + category: "deployments", + label: "Close deployment from list" + }); } }; diff --git a/apps/deploy-web/src/components/deployments/DeploymentLogs.tsx b/apps/deploy-web/src/components/deployments/DeploymentLogs.tsx index 79a2db202..b409f62e9 100644 --- a/apps/deploy-web/src/components/deployments/DeploymentLogs.tsx +++ b/apps/deploy-web/src/components/deployments/DeploymentLogs.tsx @@ -1,32 +1,33 @@ "use client"; -import { useCertificate } from "@src/context/CertificateProvider"; -import { useThrottledCallback } from "@src/hooks/useThrottle"; -import { useLeaseStatus } from "@src/queries/useLeaseQuery"; import { useEffect, useRef, useState } from "react"; -import { LeaseSelect } from "./LeaseSelect"; import useWebSocket from "react-use-websocket"; -import { PROVIDER_PROXY_URL_WS } from "@src/utils/constants"; -import { event } from "nextjs-google-analytics"; -import { AnalyticsEvents } from "@src/utils/analytics"; -import { useBackgroundTask } from "@src/context/BackgroundTaskProvider"; -import { LeaseDto } from "@src/types/deployment"; -import { useProviderList } from "@src/queries/useProvidersQuery"; +import { Monaco } from "@monaco-editor/react"; import { useTheme as useMuiTheme } from "@mui/material/styles"; -import { MemoMonaco } from "@src/components/shared/MemoMonaco"; +import useMediaQuery from "@mui/material/useMediaQuery"; +import { Download, MoreHoriz } from "iconoir-react"; import { editor } from "monaco-editor"; -import { Monaco } from "@monaco-editor/react"; -import { SelectCheckbox } from "@src/components/shared/SelectCheckbox"; -import { Button } from "@src/components/ui/button"; +import { event } from "nextjs-google-analytics"; + +import { CustomDropdownLinkItem } from "@src/components/shared/CustomDropdownLinkItem"; import { LinearLoadingSkeleton } from "@src/components/shared/LinearLoadingSkeleton"; +import { MemoMonaco } from "@src/components/shared/MemoMonaco"; +import { SelectCheckbox } from "@src/components/shared/SelectCheckbox"; +import Spinner from "@src/components/shared/Spinner"; import ViewPanel from "@src/components/shared/ViewPanel"; import { Alert } from "@src/components/ui/alert"; -import Spinner from "@src/components/shared/Spinner"; +import { Button } from "@src/components/ui/button"; import { Checkbox, CheckboxWithLabel } from "@src/components/ui/checkbox"; -import { cn } from "@src/utils/styleUtils"; -import { Download, MoreHoriz } from "iconoir-react"; import { DropdownMenu, DropdownMenuContent, DropdownMenuTrigger } from "@src/components/ui/dropdown-menu"; -import { CustomDropdownLinkItem } from "@src/components/shared/CustomDropdownLinkItem"; -import useMediaQuery from "@mui/material/useMediaQuery"; +import { useBackgroundTask } from "@src/context/BackgroundTaskProvider"; +import { useCertificate } from "@src/context/CertificateProvider"; +import { useThrottledCallback } from "@src/hooks/useThrottle"; +import { useLeaseStatus } from "@src/queries/useLeaseQuery"; +import { useProviderList } from "@src/queries/useProvidersQuery"; +import { LeaseDto } from "@src/types/deployment"; +import { AnalyticsEvents } from "@src/utils/analytics"; +import { PROVIDER_PROXY_URL_WS } from "@src/utils/constants"; +import { cn } from "@src/utils/styleUtils"; +import { LeaseSelect } from "./LeaseSelect"; export type LOGS_MODE = "logs" | "events"; @@ -61,13 +62,10 @@ export const DeploymentLogs: React.FunctionComponent = ({ leases, selecte enabled: false }); const { sendJsonMessage } = useWebSocket(PROVIDER_PROXY_URL_WS, { - onOpen: () => { - // console.log("opened"); - }, + onOpen: () => {}, onMessage: onLogReceived, onError: error => console.error("error", error), - shouldReconnect: closeEvent => { - // console.log(closeEvent); + shouldReconnect: () => { return true; } }); diff --git a/apps/deploy-web/src/components/deployments/DeploymentSubHeader.tsx b/apps/deploy-web/src/components/deployments/DeploymentSubHeader.tsx index 82c14940c..d89e6239b 100644 --- a/apps/deploy-web/src/components/deployments/DeploymentSubHeader.tsx +++ b/apps/deploy-web/src/components/deployments/DeploymentSubHeader.tsx @@ -1,17 +1,18 @@ "use client"; +import { ReactNode } from "react"; import formatDistanceToNow from "date-fns/formatDistanceToNow"; import isValid from "date-fns/isValid"; -import { getAvgCostPerMonth, useRealTimeLeft } from "@src/utils/priceUtils"; -import { ReactNode } from "react"; -import { DeploymentDto, LeaseDto } from "@src/types/deployment"; -import { udenomToDenom } from "@src/utils/mathHelpers"; -import { useDenomData } from "@src/hooks/useWalletBalance"; -import { LabelValue } from "@src/components/shared/LabelValue"; -import { PriceValue } from "@src/components/shared/PriceValue"; +import { InfoCircle, WarningCircle } from "iconoir-react"; + import { CustomTooltip } from "@src/components/shared/CustomTooltip"; +import { LabelValue } from "@src/components/shared/LabelValue"; import { PricePerMonth } from "@src/components/shared/PricePerMonth"; +import { PriceValue } from "@src/components/shared/PriceValue"; import { StatusPill } from "@src/components/shared/StatusPill"; -import { InfoCircle, WarningCircle } from "iconoir-react"; +import { useDenomData } from "@src/hooks/useWalletBalance"; +import { DeploymentDto, LeaseDto } from "@src/types/deployment"; +import { udenomToDenom } from "@src/utils/mathHelpers"; +import { getAvgCostPerMonth, useRealTimeLeft } from "@src/utils/priceUtils"; type Props = { deployment: DeploymentDto; diff --git a/apps/deploy-web/src/components/deployments/GranteeDepositMenuItem.tsx b/apps/deploy-web/src/components/deployments/GranteeDepositMenuItem.tsx index 04c87903b..0021280b8 100644 --- a/apps/deploy-web/src/components/deployments/GranteeDepositMenuItem.tsx +++ b/apps/deploy-web/src/components/deployments/GranteeDepositMenuItem.tsx @@ -1,11 +1,12 @@ "use client"; import React, { ReactNode } from "react"; -import { Address } from "../shared/Address"; import { FormattedDate } from "react-intl"; -import { coinToUDenom } from "@src/utils/priceUtils"; + +import { useDenomData } from "@src/hooks/useWalletBalance"; import { GrantType } from "@src/types/grant"; +import { coinToUDenom } from "@src/utils/priceUtils"; +import { Address } from "../shared/Address"; import { AKTAmount } from "../shared/AKTAmount"; -import { useDenomData } from "@src/hooks/useWalletBalance"; type Props = { grant: GrantType; diff --git a/apps/deploy-web/src/components/deployments/LeaseChip.tsx b/apps/deploy-web/src/components/deployments/LeaseChip.tsx index 36538a2a1..34e2c86bd 100644 --- a/apps/deploy-web/src/components/deployments/LeaseChip.tsx +++ b/apps/deploy-web/src/components/deployments/LeaseChip.tsx @@ -1,13 +1,14 @@ "use client"; import { useEffect, useState } from "react"; -import { StatusPill } from "../shared/StatusPill"; import Link from "next/link"; -import { UrlService } from "@src/utils/urlUtils"; + +import { getSplitText } from "@src/hooks/useShortText"; import { LeaseDto } from "@src/types/deployment"; import { ApiProviderList } from "@src/types/provider"; -import { Badge } from "../ui/badge"; +import { UrlService } from "@src/utils/urlUtils"; import { CustomTooltip } from "../shared/CustomTooltip"; -import { getSplitText } from "@src/hooks/useShortText"; +import { StatusPill } from "../shared/StatusPill"; +import { Badge } from "../ui/badge"; type Props = { lease: LeaseDto; diff --git a/apps/deploy-web/src/components/deployments/LeaseRow.tsx b/apps/deploy-web/src/components/deployments/LeaseRow.tsx index a94912dce..480a77c46 100644 --- a/apps/deploy-web/src/components/deployments/LeaseRow.tsx +++ b/apps/deploy-web/src/components/deployments/LeaseRow.tsx @@ -1,43 +1,43 @@ "use client"; import React, { SetStateAction, useCallback } from "react"; import { useEffect, useState } from "react"; -import { useLocalNotes } from "@src/context/LocalNoteProvider"; -import { useLeaseStatus } from "@src/queries/useLeaseQuery"; -import { useProviderStatus } from "@src/queries/useProvidersQuery"; -import { deploymentData } from "@src/utils/deploymentData"; -import { getGpusFromAttributes, sendManifestToProvider } from "@src/utils/deploymentUtils"; +import { Check, Copy, InfoCircle, OpenInWindow } from "iconoir-react"; +import yaml from "js-yaml"; import Link from "next/link"; -import { UrlService } from "@src/utils/urlUtils"; -import { copyTextToClipboard } from "@src/utils/copyClipboard"; -import { getSplitText } from "@src/hooks/useShortText"; -import { ApiProviderList } from "@src/types/provider"; -import { LeaseDto } from "@src/types/deployment"; -import { udenomToDenom } from "@src/utils/mathHelpers"; -import { useBidInfo } from "@src/queries/useBidQuery"; -import { useCertificate } from "@src/context/CertificateProvider"; -import { LocalCert } from "@src/context/CertificateProvider/CertificateProviderContext"; -import { Card, CardContent, CardHeader } from "@src/components/ui/card"; -import { SpecDetail } from "@src/components/shared/SpecDetail"; +import { useSnackbar } from "notistack"; + +import { AuditorButton } from "@src/components/providers/AuditorButton"; +import { CustomTooltip } from "@src/components/shared/CustomTooltip"; +import { FavoriteButton } from "@src/components/shared/FavoriteButton"; import { LabelValueOld } from "@src/components/shared/LabelValueOld"; -import { PricePerMonth } from "@src/components/shared/PricePerMonth"; +import { LinkTo } from "@src/components/shared/LinkTo"; import { PriceEstimateTooltip } from "@src/components/shared/PriceEstimateTooltip"; +import { PricePerMonth } from "@src/components/shared/PricePerMonth"; +import { SpecDetail } from "@src/components/shared/SpecDetail"; import Spinner from "@src/components/shared/Spinner"; -import { FavoriteButton } from "@src/components/shared/FavoriteButton"; -import { AuditorButton } from "@src/components/providers/AuditorButton"; +import { StatusPill } from "@src/components/shared/StatusPill"; import { Alert } from "@src/components/ui/alert"; -import { LinkTo } from "@src/components/shared/LinkTo"; +import { Badge } from "@src/components/ui/badge"; import { Button } from "@src/components/ui/button"; -import { CustomTooltip } from "@src/components/shared/CustomTooltip"; -import { StatusPill } from "@src/components/shared/StatusPill"; +import { Card, CardContent, CardHeader } from "@src/components/ui/card"; +import { useCertificate } from "@src/context/CertificateProvider"; +import { LocalCert } from "@src/context/CertificateProvider/CertificateProviderContext"; +import { useLocalNotes } from "@src/context/LocalNoteProvider"; +import { getSplitText } from "@src/hooks/useShortText"; +import { useBidInfo } from "@src/queries/useBidQuery"; +import { useLeaseStatus } from "@src/queries/useLeaseQuery"; +import { useProviderStatus } from "@src/queries/useProvidersQuery"; +import { LeaseDto } from "@src/types/deployment"; +import { ApiProviderList } from "@src/types/provider"; +import { copyTextToClipboard } from "@src/utils/copyClipboard"; +import { deploymentData } from "@src/utils/deploymentData"; +import { getGpusFromAttributes, sendManifestToProvider } from "@src/utils/deploymentUtils"; +import { udenomToDenom } from "@src/utils/mathHelpers"; import { cn } from "@src/utils/styleUtils"; -import { Check, Copy, InfoCircle, OpenInWindow } from "iconoir-react"; -import { Badge } from "@src/components/ui/badge"; -import { useSnackbar } from "notistack"; +import { UrlService } from "@src/utils/urlUtils"; import { ManifestErrorSnackbar } from "../shared/ManifestErrorSnackbar"; import { Snackbar } from "../shared/Snackbar"; -const yaml = require("js-yaml"); - type Props = { lease: LeaseDto; setActiveTab: (value: SetStateAction) => void; @@ -103,7 +103,7 @@ export const LeaseRow = React.forwardRef(({ lease, setActi servicesNames.length > 0 ? servicesNames .map(n => leaseStatus.services[n]) - .every((service, i) => { + .every(service => { return service.available > 0; }) : false; @@ -114,12 +114,6 @@ export const LeaseRow = React.forwardRef(({ lease, setActi loadLeaseStatus(); }, [lease, provider, localCert, loadLeaseStatus]); - function handleExternalUrlClick(ev, externalUrl) { - ev.preventDefault(); - - window.open("http://" + externalUrl, "_blank"); - } - function handleEditManifestClick(ev) { ev.preventDefault(); setActiveTab("EDIT"); @@ -365,7 +359,7 @@ export const LeaseRow = React.forwardRef(({ lease, setActi size="icon" variant="ghost" className="h-6 w-6 rounded-full" - onClick={ev => { + onClick={() => { copyTextToClipboard(uri); enqueueSnackbar(, { variant: "success", @@ -392,7 +386,7 @@ export const LeaseRow = React.forwardRef(({ lease, setActi {servicesNames .flatMap(service => leaseStatus.ips[service]) .filter(Boolean) - .map((ip, i) => ( + .map(ip => (
  • @@ -417,7 +411,7 @@ export const LeaseRow = React.forwardRef(({ lease, setActi size="icon" variant="ghost" className="h-6 w-6 rounded-full" - onClick={ev => { + onClick={() => { copyTextToClipboard(`${ip.IP}:${ip.ExternalPort}`); enqueueSnackbar(, { variant: "success", diff --git a/apps/deploy-web/src/components/deployments/LeaseSelect.tsx b/apps/deploy-web/src/components/deployments/LeaseSelect.tsx index a1980c0cc..528904bb3 100644 --- a/apps/deploy-web/src/components/deployments/LeaseSelect.tsx +++ b/apps/deploy-web/src/components/deployments/LeaseSelect.tsx @@ -1,9 +1,9 @@ "use client"; +import { useState } from "react"; import FormControl from "@mui/material/FormControl"; import InputLabel from "@mui/material/InputLabel"; import MenuItem from "@mui/material/MenuItem"; import Select from "@mui/material/Select"; -import { useState } from "react"; export const LeaseSelect = ({ defaultValue, leases, onSelectedChange }) => { const [selected, setSelected] = useState(defaultValue); diff --git a/apps/deploy-web/src/components/deployments/ManifestUpdate.tsx b/apps/deploy-web/src/components/deployments/ManifestUpdate.tsx index 51235b79f..bee9dabe0 100644 --- a/apps/deploy-web/src/components/deployments/ManifestUpdate.tsx +++ b/apps/deploy-web/src/components/deployments/ManifestUpdate.tsx @@ -1,32 +1,33 @@ "use client"; import { useEffect, useState } from "react"; -import { useWallet } from "@src/context/WalletProvider"; +import { InfoCircle, WarningCircle } from "iconoir-react"; +import yaml from "js-yaml"; +import { event } from "nextjs-google-analytics"; +import { useSnackbar } from "notistack"; + +import { CustomTooltip } from "@src/components/shared/CustomTooltip"; +import { DynamicMonacoEditor } from "@src/components/shared/DynamicMonacoEditor"; +import { LinearLoadingSkeleton } from "@src/components/shared/LinearLoadingSkeleton"; +import { LinkTo } from "@src/components/shared/LinkTo"; +import Spinner from "@src/components/shared/Spinner"; +import ViewPanel from "@src/components/shared/ViewPanel"; +import { Alert } from "@src/components/ui/alert"; +import { Button } from "@src/components/ui/button"; import { useCertificate } from "@src/context/CertificateProvider"; -import { getDeploymentLocalData, saveDeploymentManifest } from "@src/utils/deploymentLocalDataUtils"; +import { LocalCert } from "@src/context/CertificateProvider/CertificateProviderContext"; +import { useSettings } from "@src/context/SettingsProvider"; +import { useWallet } from "@src/context/WalletProvider"; +import { useProviderList } from "@src/queries/useProvidersQuery"; +import { DeploymentDto, LeaseDto } from "@src/types/deployment"; +import { ApiProviderList } from "@src/types/provider"; +import { AnalyticsEvents } from "@src/utils/analytics"; import { deploymentData } from "@src/utils/deploymentData"; +import { getDeploymentLocalData, saveDeploymentManifest } from "@src/utils/deploymentLocalDataUtils"; import { sendManifestToProvider } from "@src/utils/deploymentUtils"; import { TransactionMessageData } from "@src/utils/TransactionMessageData"; -import { event } from "nextjs-google-analytics"; -import { AnalyticsEvents } from "@src/utils/analytics"; -import yaml from "js-yaml"; -import { DeploymentDto, LeaseDto } from "@src/types/deployment"; -import { useProviderList } from "@src/queries/useProvidersQuery"; -import { ApiProviderList } from "@src/types/provider"; -import { useSettings } from "@src/context/SettingsProvider"; -import { LocalCert } from "@src/context/CertificateProvider/CertificateProviderContext"; -import { Alert } from "@src/components/ui/alert"; -import { Button } from "@src/components/ui/button"; -import { LinearLoadingSkeleton } from "@src/components/shared/LinearLoadingSkeleton"; -import ViewPanel from "@src/components/shared/ViewPanel"; -import { DynamicMonacoEditor } from "@src/components/shared/DynamicMonacoEditor"; -import Spinner from "@src/components/shared/Spinner"; -import { CustomTooltip } from "@src/components/shared/CustomTooltip"; -import { InfoCircle, WarningCircle } from "iconoir-react"; -import { LinkTo } from "@src/components/shared/LinkTo"; -import { Title } from "../shared/Title"; -import { useSnackbar } from "notistack"; import { ManifestErrorSnackbar } from "../shared/ManifestErrorSnackbar"; import { Snackbar } from "../shared/Snackbar"; +import { Title } from "../shared/Title"; type Props = { deployment: DeploymentDto; diff --git a/apps/deploy-web/src/components/deployments/ServiceSelect.tsx b/apps/deploy-web/src/components/deployments/ServiceSelect.tsx index 0c0305d86..b735ec781 100644 --- a/apps/deploy-web/src/components/deployments/ServiceSelect.tsx +++ b/apps/deploy-web/src/components/deployments/ServiceSelect.tsx @@ -1,9 +1,9 @@ "use client"; +import { useState } from "react"; import FormControl from "@mui/material/FormControl"; import InputLabel from "@mui/material/InputLabel"; import MenuItem from "@mui/material/MenuItem"; import Select from "@mui/material/Select"; -import { useState } from "react"; export const ServiceSelect = ({ defaultValue, services, onSelectedChange }) => { const [selected, setSelected] = useState(defaultValue); diff --git a/apps/deploy-web/src/components/deployments/ShellDownloadModal.tsx b/apps/deploy-web/src/components/deployments/ShellDownloadModal.tsx index 36ed0dfa4..091e2abb8 100644 --- a/apps/deploy-web/src/components/deployments/ShellDownloadModal.tsx +++ b/apps/deploy-web/src/components/deployments/ShellDownloadModal.tsx @@ -1,12 +1,13 @@ "use client"; import { useRef } from "react"; -import { useForm, Controller } from "react-hook-form"; +import { Controller, useForm } from "react-hook-form"; import { event } from "nextjs-google-analytics"; -import { AnalyticsEvents } from "@src/utils/analytics"; -import { useBackgroundTask } from "@src/context/BackgroundTaskProvider"; + import { Popup } from "@src/components/shared/Popup"; import { Alert } from "@src/components/ui/alert"; import { InputWithIcon } from "@src/components/ui/input"; +import { useBackgroundTask } from "@src/context/BackgroundTaskProvider"; +import { AnalyticsEvents } from "@src/utils/analytics"; export const ShellDownloadModal = ({ selectedLease, onCloseClick, selectedService, providerInfo }) => { const formRef = useRef(null); diff --git a/apps/deploy-web/src/components/get-started/CreateWalletSection.tsx b/apps/deploy-web/src/components/get-started/CreateWalletSection.tsx index 6655b5e4b..eac48a96d 100644 --- a/apps/deploy-web/src/components/get-started/CreateWalletSection.tsx +++ b/apps/deploy-web/src/components/get-started/CreateWalletSection.tsx @@ -1,11 +1,10 @@ "use client"; import React from "react"; + import { ExternalLink } from "../shared/ExternalLink"; import { Alert } from "../ui/alert"; -type Props = {}; - -export const CreateWalletSection: React.FunctionComponent = ({}) => { +export const CreateWalletSection: React.FunctionComponent = () => { return (
    • diff --git a/apps/deploy-web/src/components/get-started/GetStartedStepper.tsx b/apps/deploy-web/src/components/get-started/GetStartedStepper.tsx index 3977375d3..81d8ac2ff 100644 --- a/apps/deploy-web/src/components/get-started/GetStartedStepper.tsx +++ b/apps/deploy-web/src/components/get-started/GetStartedStepper.tsx @@ -1,26 +1,25 @@ "use client"; -import { UrlService } from "@src/utils/urlUtils"; -import Link from "next/link"; import { useEffect, useState } from "react"; -import dynamic from "next/dynamic"; -import { QontoConnector, QontoStepIcon } from "./Stepper"; -import { ExternalLink } from "../shared/ExternalLink"; -import { ConnectWalletButton } from "../wallet/ConnectWalletButton"; -import { uaktToAKT } from "@src/utils/priceUtils"; -import { CustomTooltip } from "../shared/CustomTooltip"; -import { RouteStepKeys } from "@src/utils/constants"; -import { udenomToDenom } from "@src/utils/mathHelpers"; -import { useChainParam } from "@src/context/ChainParamProvider"; -import { Button, buttonVariants } from "../ui/button"; -import Spinner from "../shared/Spinner"; -import Stepper from "@mui/material/Stepper"; +import { MdRestartAlt } from "react-icons/md"; import Step from "@mui/material/Step"; -import StepLabel from "@mui/material/StepLabel"; import StepContent from "@mui/material/StepContent"; -import { cn } from "@src/utils/styleUtils"; +import StepLabel from "@mui/material/StepLabel"; +import Stepper from "@mui/material/Stepper"; import { Check, Rocket, WarningCircle, XmarkCircleSolid } from "iconoir-react"; +import Link from "next/link"; + +import { useChainParam } from "@src/context/ChainParamProvider"; import { useWallet } from "@src/context/WalletProvider"; -import { MdRestartAlt } from "react-icons/md"; +import { RouteStepKeys } from "@src/utils/constants"; +import { udenomToDenom } from "@src/utils/mathHelpers"; +import { uaktToAKT } from "@src/utils/priceUtils"; +import { cn } from "@src/utils/styleUtils"; +import { UrlService } from "@src/utils/urlUtils"; +import { CustomTooltip } from "../shared/CustomTooltip"; +import { ExternalLink } from "../shared/ExternalLink"; +import { Button, buttonVariants } from "../ui/button"; +import { ConnectWalletButton } from "../wallet/ConnectWalletButton"; +import { QontoConnector, QontoStepIcon } from "./Stepper"; // const LiquidityModal = dynamic(() => import("../liquidity-modal"), { // ssr: false, @@ -36,11 +35,9 @@ import { MdRestartAlt } from "react-icons/md"; // } // }); -type Props = {}; - -export const GetStartedStepper: React.FunctionComponent = () => { +export const GetStartedStepper: React.FunctionComponent = () => { const [activeStep, setActiveStep] = useState(0); - const { isWalletConnected, walletBalances, address, refreshBalances } = useWallet(); + const { isWalletConnected, walletBalances } = useWallet(); const { minDeposit } = useChainParam(); const aktBalance = walletBalances ? uaktToAKT(walletBalances.uakt) : 0; const usdcBalance = walletBalances ? udenomToDenom(walletBalances.usdc) : 0; diff --git a/apps/deploy-web/src/components/get-started/NoKeplrSection.tsx b/apps/deploy-web/src/components/get-started/NoKeplrSection.tsx index 3a024d629..ef6dc0fa6 100644 --- a/apps/deploy-web/src/components/get-started/NoKeplrSection.tsx +++ b/apps/deploy-web/src/components/get-started/NoKeplrSection.tsx @@ -1,19 +1,18 @@ "use client"; import React, { useState } from "react"; +import { NavArrowLeft } from "iconoir-react"; import Link from "next/link"; + +import { cn } from "@src/utils/styleUtils"; import { UrlService } from "@src/utils/urlUtils"; import { ExternalLink } from "../shared/ExternalLink"; -import { CreateWalletSection } from "./CreateWalletSection"; import { LinkTo } from "../shared/LinkTo"; import { Alert } from "../ui/alert"; -import { NavArrowLeft } from "iconoir-react"; -import { cn } from "@src/utils/styleUtils"; import { buttonVariants } from "../ui/button"; import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "../ui/collapsible"; +import { CreateWalletSection } from "./CreateWalletSection"; -type Props = {}; - -export const NoKeplrSection: React.FunctionComponent = ({}) => { +export const NoKeplrSection: React.FunctionComponent = () => { const [isCreateWalletOpen, setIsCreateWalletOpen] = useState(false); return ( diff --git a/apps/deploy-web/src/components/get-started/NoWalletSection.tsx b/apps/deploy-web/src/components/get-started/NoWalletSection.tsx index 5b7e0439c..28bf4ac0f 100644 --- a/apps/deploy-web/src/components/get-started/NoWalletSection.tsx +++ b/apps/deploy-web/src/components/get-started/NoWalletSection.tsx @@ -1,19 +1,18 @@ "use client"; import React, { useState } from "react"; +import { NavArrowLeft } from "iconoir-react"; import Link from "next/link"; + +import { cn } from "@src/utils/styleUtils"; import { UrlService } from "@src/utils/urlUtils"; import { ExternalLink } from "../shared/ExternalLink"; -import { CreateWalletSection } from "./CreateWalletSection"; import { LinkTo } from "../shared/LinkTo"; -import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "../ui/collapsible"; import { Alert } from "../ui/alert"; import { buttonVariants } from "../ui/button"; -import { cn } from "@src/utils/styleUtils"; -import { NavArrowLeft } from "iconoir-react"; - -type Props = {}; +import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "../ui/collapsible"; +import { CreateWalletSection } from "./CreateWalletSection"; -export const NoWalletSection: React.FunctionComponent = ({}) => { +export const NoWalletSection: React.FunctionComponent = () => { const [isCreateWalletOpen, setIsCreateWalletOpen] = useState(false); return ( diff --git a/apps/deploy-web/src/components/get-started/WithKeplrSection.tsx b/apps/deploy-web/src/components/get-started/WithKeplrSection.tsx index 5855d2af5..77e06ea59 100644 --- a/apps/deploy-web/src/components/get-started/WithKeplrSection.tsx +++ b/apps/deploy-web/src/components/get-started/WithKeplrSection.tsx @@ -1,15 +1,14 @@ "use client"; import React from "react"; +import { NavArrowLeft } from "iconoir-react"; import Link from "next/link"; + +import { cn } from "@src/utils/styleUtils"; import { UrlService } from "@src/utils/urlUtils"; import { ExternalLink } from "../shared/ExternalLink"; -import { cn } from "@src/utils/styleUtils"; import { buttonVariants } from "../ui/button"; -import { NavArrowLeft } from "iconoir-react"; - -type Props = {}; -export const WithKeplrSection: React.FunctionComponent = ({}) => { +export const WithKeplrSection: React.FunctionComponent = () => { return (
      diff --git a/apps/deploy-web/src/components/graph/Graph.tsx b/apps/deploy-web/src/components/graph/Graph.tsx index 77a133a1e..5e4cd9f6c 100644 --- a/apps/deploy-web/src/components/graph/Graph.tsx +++ b/apps/deploy-web/src/components/graph/Graph.tsx @@ -1,13 +1,14 @@ "use client"; -import { ResponsiveLineCanvas } from "@nivo/line"; -import { GraphResponse, ISnapshotMetadata, ProviderSnapshots, Snapshots, SnapshotValue } from "@src/types"; import { FormattedDate, useIntl } from "react-intl"; -import { useTheme } from "next-themes"; import { useTheme as useMuiTheme } from "@mui/material/styles"; -import { nFormatter, roundDecimal } from "@src/utils/mathHelpers"; +import useMediaQuery from "@mui/material/useMediaQuery"; +import { ResponsiveLineCanvas } from "@nivo/line"; +import { useTheme } from "next-themes"; + +import { GraphResponse, ISnapshotMetadata, ProviderSnapshots, Snapshots, SnapshotValue } from "@src/types"; import { customColors } from "@src/utils/colors"; import { selectedRangeValues } from "@src/utils/constants"; -import useMediaQuery from "@mui/material/useMediaQuery"; +import { nFormatter, roundDecimal } from "@src/utils/mathHelpers"; interface IGraphProps { rangedData: SnapshotValue[]; @@ -60,13 +61,11 @@ const Graph: React.FunctionComponent = ({ rangedData, snapshotMetad max: maxValue * 1.02 }} yFormat=" >-1d" - // @ts-ignore will be fixed in 0.69.1 axisBottom={{ tickRotation: smallScreen ? 45 : 0, format: dateStr => intl.formatDate(dateStr, { day: "numeric", month: "short", timeZone: "utc" }), tickValues: getTickValues(rangedData, graphMetadata.xModulo) }} - // @ts-ignore will be fixed in 0.69.1 axisLeft={{ format: val => nFormatter(val, 2), legend: snapshotMetadata.legend, diff --git a/apps/deploy-web/src/components/home/CloudmosImportPanel.tsx b/apps/deploy-web/src/components/home/CloudmosImportPanel.tsx index c1235b769..253e6eff7 100644 --- a/apps/deploy-web/src/components/home/CloudmosImportPanel.tsx +++ b/apps/deploy-web/src/components/home/CloudmosImportPanel.tsx @@ -1,10 +1,10 @@ -import { Card, CardContent, CardHeader, CardTitle } from "@src/components/ui/card"; - -import { Import } from "iconoir-react"; -import { Button } from "../ui/button"; import { useEffect, useRef } from "react"; +import { Import } from "iconoir-react"; import { z } from "zod"; +import { Card, CardContent, CardHeader, CardTitle } from "@src/components/ui/card"; +import { Button } from "../ui/button"; + const autoImportOrigin = "https://deploy.cloudmos.io"; export default function CloudmosImportPanel() { diff --git a/apps/deploy-web/src/components/home/HomeContainer.tsx b/apps/deploy-web/src/components/home/HomeContainer.tsx index fd9d74392..9ed6a4a70 100644 --- a/apps/deploy-web/src/components/home/HomeContainer.tsx +++ b/apps/deploy-web/src/components/home/HomeContainer.tsx @@ -1,20 +1,21 @@ "use client"; import { useEffect, useState } from "react"; import React from "react"; -import { useDeploymentList } from "@src/queries/useDeploymentQuery"; + +import { Footer } from "@src/components/layout/Footer"; import { useLocalNotes } from "@src/context/LocalNoteProvider"; import { useSettings } from "@src/context/SettingsProvider"; -import { useBalances } from "@src/queries/useBalancesQuery"; import { useWallet } from "@src/context/WalletProvider"; +import { useBalances } from "@src/queries/useBalancesQuery"; +import { useDeploymentList } from "@src/queries/useDeploymentQuery"; import { useAllLeases } from "@src/queries/useLeaseQuery"; -import { Footer } from "@src/components/layout/Footer"; import { useProviderList } from "@src/queries/useProvidersQuery"; import { DeploymentDto } from "@src/types/deployment"; -import { WelcomePanel } from "./WelcomePanel"; import Layout from "../layout/Layout"; -import { YourAccount } from "./YourAccount"; import Spinner from "../shared/Spinner"; import CloudmosImportPanel from "./CloudmosImportPanel"; +import { WelcomePanel } from "./WelcomePanel"; +import { YourAccount } from "./YourAccount"; export function HomeContainer() { const { address, isWalletLoaded } = useWallet(); diff --git a/apps/deploy-web/src/components/home/WelcomePanel.tsx b/apps/deploy-web/src/components/home/WelcomePanel.tsx index 59a9266be..d6bb58254 100644 --- a/apps/deploy-web/src/components/home/WelcomePanel.tsx +++ b/apps/deploy-web/src/components/home/WelcomePanel.tsx @@ -1,19 +1,16 @@ "use client"; -import { ReactNode, useState } from "react"; +import React, { useState } from "react"; +import { Learning, NavArrowDown, Rocket, SearchEngine } from "iconoir-react"; import Link from "next/link"; -import { UrlService } from "@src/utils/urlUtils"; + +import { Avatar, AvatarFallback } from "@src/components/ui/avatar"; +import { Button } from "@src/components/ui/button"; import { Card, CardContent, CardHeader, CardTitle } from "@src/components/ui/card"; import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@src/components/ui/collapsible"; -import { Rocket, SearchEngine, Learning, NavArrowDown } from "iconoir-react"; -import { Button } from "@src/components/ui/button"; -import { Avatar, AvatarFallback } from "@src/components/ui/avatar"; import { cn } from "@src/utils/styleUtils"; +import { UrlService } from "@src/utils/urlUtils"; -type Props = { - children?: ReactNode; -}; - -export const WelcomePanel: React.FC = () => { +export const WelcomePanel: React.FC = () => { const [expanded, setExpanded] = useState(true); return ( diff --git a/apps/deploy-web/src/components/home/YourAccount.tsx b/apps/deploy-web/src/components/home/YourAccount.tsx index eb45fdb8d..34d05eee8 100644 --- a/apps/deploy-web/src/components/home/YourAccount.tsx +++ b/apps/deploy-web/src/components/home/YourAccount.tsx @@ -1,35 +1,35 @@ "use client"; import { useEffect, useState } from "react"; +import { FormattedNumber, FormattedPlural } from "react-intl"; import { ResponsivePie } from "@nivo/pie"; -import { getAvgCostPerMonth, uaktToAKT } from "@src/utils/priceUtils"; -import { PriceValue } from "../shared/PriceValue"; -import { DeploymentDto, LeaseDto } from "@src/types/deployment"; -import { StatusPill } from "../shared/StatusPill"; -import { LeaseSpecDetail } from "../shared/LeaseSpecDetail"; -import { bytesToShrink } from "@src/utils/unitUtils"; -import { roundDecimal, udenomToDenom } from "@src/utils/mathHelpers"; -import { UrlService } from "@src/utils/urlUtils"; +import { Rocket } from "iconoir-react"; +import { useAtom } from "jotai"; import Link from "next/link"; -import { FormattedNumber, FormattedPlural } from "react-intl"; +import { useTheme } from "next-themes"; + +import { usePricing } from "@src/context/PricingProvider"; import { useWallet } from "@src/context/WalletProvider"; -import { ConnectWallet } from "../shared/ConnectWallet"; +import { useUsdcDenom } from "@src/hooks/useDenom"; +import useTailwind from "@src/hooks/useTailwind"; +import sdlStore from "@src/store/sdlStore"; import { Balances } from "@src/types"; +import { DeploymentDto, LeaseDto } from "@src/types/deployment"; import { ApiProviderList } from "@src/types/provider"; -import { useAtom } from "jotai"; -import sdlStore from "@src/store/sdlStore"; -import { usePricing } from "@src/context/PricingProvider"; +import { customColors } from "@src/utils/colors"; import { uAktDenom } from "@src/utils/constants"; -import { useUsdcDenom } from "@src/hooks/useDenom"; -import { useTheme } from "next-themes"; -import { Card, CardContent, CardHeader, CardTitle } from "../ui/card"; -import Spinner from "../shared/Spinner"; +import { roundDecimal, udenomToDenom } from "@src/utils/mathHelpers"; +import { getAvgCostPerMonth, uaktToAKT } from "@src/utils/priceUtils"; import { cn } from "@src/utils/styleUtils"; -import { Button, buttonVariants } from "../ui/button"; -import { Rocket } from "iconoir-react"; +import { bytesToShrink } from "@src/utils/unitUtils"; +import { UrlService } from "@src/utils/urlUtils"; +import { ConnectWallet } from "../shared/ConnectWallet"; +import { LeaseSpecDetail } from "../shared/LeaseSpecDetail"; +import { PriceValue } from "../shared/PriceValue"; +import Spinner from "../shared/Spinner"; +import { StatusPill } from "../shared/StatusPill"; import { Badge } from "../ui/badge"; -import { HSLToHex, customColors } from "@src/utils/colors"; -import dynamic from "next/dynamic"; -import useTailwind from "@src/hooks/useTailwind"; +import { buttonVariants } from "../ui/button"; +import { Card, CardContent, CardHeader, CardTitle } from "../ui/card"; // const LiquidityModal = dynamic(() => import("../liquidity-modal"), { // ssr: false, @@ -56,7 +56,7 @@ type Props = { export const YourAccount: React.FunctionComponent = ({ balances, isLoadingBalances, activeDeployments, leases, providers }) => { const { resolvedTheme } = useTheme(); const tw = useTailwind(); - const { address, walletBalances, refreshBalances } = useWallet(); + const { address } = useWallet(); const usdcIbcDenom = useUsdcDenom(); const [selectedDataId, setSelectedDataId] = useState(null); const [costPerMonth, setCostPerMonth] = useState(null); @@ -80,7 +80,6 @@ export const YourAccount: React.FunctionComponent = ({ balances, isLoadin const _storage = bytesToShrink(totalStorage); const [, setDeploySdl] = useAtom(sdlStore.deploySdl); const { price, isLoaded } = usePricing(); - const aktBalance = walletBalances ? uaktToAKT(walletBalances.uakt) : 0; const colors = { balance_akt: customColors.akashRed, diff --git a/apps/deploy-web/src/components/layout/AccountMenu.tsx b/apps/deploy-web/src/components/layout/AccountMenu.tsx index ebe168927..d6f92da39 100644 --- a/apps/deploy-web/src/components/layout/AccountMenu.tsx +++ b/apps/deploy-web/src/components/layout/AccountMenu.tsx @@ -1,21 +1,22 @@ "use client"; import React, { useState } from "react"; +import ClickAwayListener from "@mui/material/ClickAwayListener"; +import { DropdownMenuTrigger } from "@radix-ui/react-dropdown-menu"; +import { User } from "iconoir-react"; +import { Bell, Book, LogOut, MultiplePages, Settings, Star } from "iconoir-react"; import { useRouter } from "next/navigation"; -import { UrlService } from "@src/utils/urlUtils"; + import { useCustomUser } from "@src/hooks/useCustomUser"; +import { UrlService } from "@src/utils/urlUtils"; +import { CustomDropdownLinkItem } from "../shared/CustomDropdownLinkItem"; import Spinner from "../shared/Spinner"; -import { Button } from "../ui/button"; import { Avatar, AvatarFallback } from "../ui/avatar"; -import { User } from "iconoir-react"; +import { Button } from "../ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuSeparator } from "../ui/dropdown-menu"; -import { DropdownMenuTrigger } from "@radix-ui/react-dropdown-menu"; -import { Settings, MultiplePages, Star, Bell, Book, LogOut } from "iconoir-react"; -import { CustomDropdownLinkItem } from "../shared/CustomDropdownLinkItem"; -import ClickAwayListener from "@mui/material/ClickAwayListener"; -export function AccountMenu({}: React.PropsWithChildren<{}>) { +export function AccountMenu() { const [open, setOpen] = useState(false); - const { user, error, isLoading } = useCustomUser(); + const { user, isLoading } = useCustomUser(); const username = user?.username; const router = useRouter(); diff --git a/apps/deploy-web/src/components/layout/CustomGoogleAnalytics.tsx b/apps/deploy-web/src/components/layout/CustomGoogleAnalytics.tsx index 2cbb83632..aeaccebdf 100644 --- a/apps/deploy-web/src/components/layout/CustomGoogleAnalytics.tsx +++ b/apps/deploy-web/src/components/layout/CustomGoogleAnalytics.tsx @@ -1,7 +1,8 @@ "use client"; -import { isProd } from "@src/utils/constants"; -import { event, GoogleAnalytics as GAnalytics } from "nextjs-google-analytics"; import { useReportWebVitals } from "next/web-vitals"; +import { event, GoogleAnalytics as GAnalytics } from "nextjs-google-analytics"; + +import { isProd } from "@src/utils/constants"; export default function GoogleAnalytics() { useReportWebVitals(({ id, name, label, value }) => { diff --git a/apps/deploy-web/src/components/layout/CustomIntlProvider.tsx b/apps/deploy-web/src/components/layout/CustomIntlProvider.tsx index 432bc21fa..3024439da 100644 --- a/apps/deploy-web/src/components/layout/CustomIntlProvider.tsx +++ b/apps/deploy-web/src/components/layout/CustomIntlProvider.tsx @@ -3,13 +3,10 @@ import { ReactNode, useEffect, useState } from "react"; import { IntlProvider } from "react-intl"; type Props = { - isLoading?: boolean; - isUsingSettings?: boolean; - isUsingWallet?: boolean; children?: ReactNode; }; -export const CustomIntlProvider: React.FunctionComponent = ({ children, isLoading, isUsingSettings, isUsingWallet }) => { +export const CustomIntlProvider: React.FunctionComponent = ({ children }) => { const [locale, setLocale] = useState("en-US"); useEffect(() => { diff --git a/apps/deploy-web/src/components/layout/Footer.tsx b/apps/deploy-web/src/components/layout/Footer.tsx index bcc3ca5f2..d545e7b2c 100644 --- a/apps/deploy-web/src/components/layout/Footer.tsx +++ b/apps/deploy-web/src/components/layout/Footer.tsx @@ -1,7 +1,8 @@ import React from "react"; -import { UrlService } from "@src/utils/urlUtils"; +import { Copyright, Discord, Github, X as TwitterX, Youtube } from "iconoir-react"; import Link from "next/link"; -import { Copyright, Youtube, X as TwitterX, Github, Discord } from "iconoir-react"; + +import { UrlService } from "@src/utils/urlUtils"; import { Title } from "../shared/Title"; export interface IFooterProps {} @@ -92,7 +93,7 @@ export const Footer: React.FunctionComponent = () => {
  • -

    +

     Akash Network {year}

    diff --git a/apps/deploy-web/src/components/layout/Layout.tsx b/apps/deploy-web/src/components/layout/Layout.tsx index e65537c9b..f90c1a5f0 100644 --- a/apps/deploy-web/src/components/layout/Layout.tsx +++ b/apps/deploy-web/src/components/layout/Layout.tsx @@ -1,18 +1,19 @@ "use client"; import React, { ReactNode, useEffect, useState } from "react"; -import { IntlProvider } from "react-intl"; import { ErrorBoundary } from "react-error-boundary"; -import { ErrorFallback } from "../shared/ErrorFallback"; -import { accountBarHeight } from "@src/utils/constants"; +import { IntlProvider } from "react-intl"; import { useMediaQuery, useTheme as useMuiTheme } from "@mui/material"; -import { WelcomeModal } from "./WelcomeModal"; -import { Sidebar } from "./Sidebar"; + import { useSettings } from "@src/context/SettingsProvider"; -import { LinearLoadingSkeleton } from "../shared/LinearLoadingSkeleton"; import { useWallet } from "@src/context/WalletProvider"; -import Spinner from "../shared/Spinner"; +import { accountBarHeight } from "@src/utils/constants"; import { cn } from "@src/utils/styleUtils"; +import { ErrorFallback } from "../shared/ErrorFallback"; +import { LinearLoadingSkeleton } from "../shared/LinearLoadingSkeleton"; +import Spinner from "../shared/Spinner"; import { Nav } from "./Nav"; +import { Sidebar } from "./Sidebar"; +import { WelcomeModal } from "./WelcomeModal"; type Props = { isLoading?: boolean; diff --git a/apps/deploy-web/src/components/layout/MobileSidebarUser.tsx b/apps/deploy-web/src/components/layout/MobileSidebarUser.tsx index 35fd1a816..309c4d4cd 100644 --- a/apps/deploy-web/src/components/layout/MobileSidebarUser.tsx +++ b/apps/deploy-web/src/components/layout/MobileSidebarUser.tsx @@ -1,57 +1,22 @@ "use client"; -import { ReactNode } from "react"; +import React from "react"; +import { BookStack, LogOut, MediaImageList, Settings } from "iconoir-react"; import Link from "next/link"; -import { UrlService } from "@src/utils/urlUtils"; + import { useCustomUser } from "@src/hooks/useCustomUser"; -import { SidebarRouteButton } from "./SidebarRouteButton"; -import { WalletStatus } from "./WalletStatus"; -import { Separator } from "../ui/separator"; +import { cn } from "@src/utils/styleUtils"; +import { UrlService } from "@src/utils/urlUtils"; import Spinner from "../shared/Spinner"; import { Avatar } from "../ui/avatar"; -import { BookStack, MediaImageList, Settings, LogOut } from "iconoir-react"; import { buttonVariants } from "../ui/button"; -import { cn } from "@src/utils/styleUtils"; - -// const useStyles = makeStyles()(theme => ({ -// list: { -// padding: 0, -// overflow: "hidden", -// width: "100%", -// border: "none" -// }, -// listItem: { -// padding: "4px 0" -// } -// })); - -type Props = { - children?: ReactNode; -}; +import { Separator } from "../ui/separator"; +import { SidebarRouteButton } from "./SidebarRouteButton"; +import { WalletStatus } from "./WalletStatus"; -export const MobileSidebarUser: React.FunctionComponent = ({}) => { - // const { classes } = useStyles(); - const { user, error, isLoading } = useCustomUser(); +export const MobileSidebarUser: React.FunctionComponent = () => { + const { user, isLoading } = useCustomUser(); return ( - //
      - // {!!group.title && isNavOpen && ( - //
    • - // - // {group.title} - // - //
    • - // )} - - // {group.routes.map(route => { - // return ; - // })} - //
    -
      diff --git a/apps/deploy-web/src/components/layout/ModeToggle.tsx b/apps/deploy-web/src/components/layout/ModeToggle.tsx index 511a55189..92b98fb39 100644 --- a/apps/deploy-web/src/components/layout/ModeToggle.tsx +++ b/apps/deploy-web/src/components/layout/ModeToggle.tsx @@ -1,10 +1,11 @@ "use client"; import * as React from "react"; +import { useEffect, useState } from "react"; +import { HalfMoon, SunLight } from "iconoir-react"; import { useTheme } from "next-themes"; + import { Button } from "@src/components/ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@src/components/ui/dropdown-menu"; -import { useEffect, useState } from "react"; -import { SunLight, HalfMoon } from "iconoir-react"; import { cn } from "@src/utils/styleUtils"; export function ModeToggle() { diff --git a/apps/deploy-web/src/components/layout/Nav.tsx b/apps/deploy-web/src/components/layout/Nav.tsx index 256d9ed8b..dff88c6a5 100644 --- a/apps/deploy-web/src/components/layout/Nav.tsx +++ b/apps/deploy-web/src/components/layout/Nav.tsx @@ -1,14 +1,15 @@ "use client"; -import { AkashConsoleBetaLogoDark, AkashConsoleBetaLogoLight } from "../icons/AkashConsoleLogo"; +import { Menu, Xmark } from "iconoir-react"; import Link from "next/link"; -import { UrlService } from "@src/utils/urlUtils"; -import { Button } from "../ui/button"; + import useCookieTheme from "@src/hooks/useTheme"; import { accountBarHeight } from "@src/utils/constants"; +import { UrlService } from "@src/utils/urlUtils"; +import { AkashConsoleBetaLogoDark, AkashConsoleBetaLogoLight } from "../icons/AkashConsoleLogo"; import { Badge } from "../ui/badge"; -import { WalletStatus } from "./WalletStatus"; +import { Button } from "../ui/button"; import { AccountMenu } from "./AccountMenu"; -import { Menu, Xmark } from "iconoir-react"; +import { WalletStatus } from "./WalletStatus"; export const Nav = ({ isMobileOpen, @@ -38,7 +39,7 @@ export const Nav = ({
    -
    +
    diff --git a/apps/deploy-web/src/components/providers/AuditorsModal.tsx b/apps/deploy-web/src/components/providers/AuditorsModal.tsx index 6cb70c70f..c28189772 100644 --- a/apps/deploy-web/src/components/providers/AuditorsModal.tsx +++ b/apps/deploy-web/src/components/providers/AuditorsModal.tsx @@ -1,12 +1,13 @@ "use client"; +import { MouseEventHandler } from "react"; + +import { useAuditors } from "@src/queries/useProvidersQuery"; import { Address } from "../shared/Address"; import { CustomTooltip } from "../shared/CustomTooltip"; import { LinkTo } from "../shared/LinkTo"; import { Popup } from "../shared/Popup"; -import { MouseEventHandler } from "react"; -import { useAuditors } from "@src/queries/useProvidersQuery"; -import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "../ui/table"; import { Badge } from "../ui/badge"; +import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "../ui/table"; type Props = { attributes: Array<{ key: string; value: string; auditedBy: Array }>; diff --git a/apps/deploy-web/src/components/providers/EditProviderContainer.tsx b/apps/deploy-web/src/components/providers/EditProviderContainer.tsx index ba3e9b7cf..cda7b2ac0 100644 --- a/apps/deploy-web/src/components/providers/EditProviderContainer.tsx +++ b/apps/deploy-web/src/components/providers/EditProviderContainer.tsx @@ -1,16 +1,17 @@ "use client"; import { useEffect } from "react"; -import { useProviderAttributesSchema, useProviderDetail } from "@src/queries/useProvidersQuery"; -import { getProviderNameFromUri } from "@src/utils/providerUtils"; +import { NavArrowLeft } from "iconoir-react"; import Link from "next/link"; -import { UrlService } from "@src/utils/urlUtils"; -import { EditProviderForm } from "./EditProviderForm"; +import { NextSeo } from "next-seo"; + +import Spinner from "@src/components/shared/Spinner"; import { buttonVariants } from "@src/components/ui/button"; -import { NavArrowLeft } from "iconoir-react"; +import { useProviderAttributesSchema, useProviderDetail } from "@src/queries/useProvidersQuery"; +import { getProviderNameFromUri } from "@src/utils/providerUtils"; import { cn } from "@src/utils/styleUtils"; -import Spinner from "@src/components/shared/Spinner"; -import { NextSeo } from "next-seo"; +import { UrlService } from "@src/utils/urlUtils"; import Layout from "../layout/Layout"; +import { EditProviderForm } from "./EditProviderForm"; type Props = { owner: string; diff --git a/apps/deploy-web/src/components/providers/EditProviderForm.tsx b/apps/deploy-web/src/components/providers/EditProviderForm.tsx index 7710b35fb..47409952d 100644 --- a/apps/deploy-web/src/components/providers/EditProviderForm.tsx +++ b/apps/deploy-web/src/components/providers/EditProviderForm.tsx @@ -1,25 +1,26 @@ "use client"; -import { useState, useEffect, useRef, HTMLInputTypeAttribute } from "react"; -import { useWallet } from "@src/context/WalletProvider"; -import { ApiProviderDetail } from "@src/types/provider"; +import { HTMLInputTypeAttribute, useEffect, useRef, useState } from "react"; import { Control, Controller, FieldPath, RegisterOptions, useFieldArray, useForm } from "react-hook-form"; -import { ProviderAttributeSchemaDetailValue, ProviderAttributesFormValues, ProviderAttributesSchema } from "@src/types/providerAttributes"; -import { defaultProviderAttributes } from "@src/utils/providerAttributes/data"; -import { CustomTooltip } from "@src/components/shared/CustomTooltip"; -import { TransactionMessageData } from "@src/utils/TransactionMessageData"; -import { getUnknownAttributes, mapFormValuesToAttributes } from "@src/utils/providerAttributes/helpers"; +import { Bin, InfoCircle } from "iconoir-react"; import { nanoid } from "nanoid"; + import { FormPaper } from "@src/components/sdl/FormPaper"; +import { CustomTooltip } from "@src/components/shared/CustomTooltip"; import { Alert } from "@src/components/ui/alert"; import { Button } from "@src/components/ui/button"; -import { InputWithIcon } from "@src/components/ui/input"; -import { Bin, InfoCircle } from "iconoir-react"; import { CheckboxWithLabel } from "@src/components/ui/checkbox"; -import { cn } from "@src/utils/styleUtils"; -import MultipleSelector, { Option } from "@src/components/ui/multiple-selector"; -import { Label } from "@src/components/ui/label"; import { FormItem } from "@src/components/ui/form"; +import { InputWithIcon } from "@src/components/ui/input"; +import { Label } from "@src/components/ui/label"; +import MultipleSelector, { Option } from "@src/components/ui/multiple-selector"; import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "@src/components/ui/select"; +import { useWallet } from "@src/context/WalletProvider"; +import { ApiProviderDetail } from "@src/types/provider"; +import { ProviderAttributeSchemaDetailValue, ProviderAttributesFormValues, ProviderAttributesSchema } from "@src/types/providerAttributes"; +import { defaultProviderAttributes } from "@src/utils/providerAttributes/data"; +import { getUnknownAttributes, mapFormValuesToAttributes } from "@src/utils/providerAttributes/helpers"; +import { cn } from "@src/utils/styleUtils"; +import { TransactionMessageData } from "@src/utils/TransactionMessageData"; type Props = { provider: Partial; @@ -31,7 +32,7 @@ export const EditProviderForm: React.FunctionComponent = ({ provider, pro const [error, setError] = useState(null); const formRef = useRef(null); const { signAndBroadcastTx } = useWallet(); - const { handleSubmit, reset, control, trigger, watch, setValue, formState } = useForm({ + const { handleSubmit, control, watch, setValue, formState } = useForm({ defaultValues: { ...defaultProviderAttributes } @@ -127,21 +128,15 @@ export const EditProviderForm: React.FunctionComponent = ({ provider, pro const onSubmit = async (data: ProviderAttributesFormValues) => { setError(null); - debugger; - try { const attributes = mapFormValuesToAttributes(data, providerAttributesSchema); console.log(data, attributes); - try { - const message = TransactionMessageData.getUpdateProviderMsg(provider?.owner || "", data["host-uri"], attributes, { - email: data.email, - website: data.website - }); - await signAndBroadcastTx([message]); - } catch (error) { - throw error; - } + const message = TransactionMessageData.getUpdateProviderMsg(provider?.owner || "", data["host-uri"], attributes, { + email: data.email, + website: data.website + }); + await signAndBroadcastTx([message]); } catch (error) { setError(error.message); } @@ -687,7 +682,7 @@ const ProviderSelect: React.FunctionComponent = ({ rules={{ required: required ? requiredMessage : undefined }} - render={({ field, fieldState }) => ( + render={({ field }) => (
    -
    +
    diff --git a/apps/deploy-web/src/components/providers/ProviderMap.tsx b/apps/deploy-web/src/components/providers/ProviderMap.tsx index 14c13330a..1a440fde6 100644 --- a/apps/deploy-web/src/components/providers/ProviderMap.tsx +++ b/apps/deploy-web/src/components/providers/ProviderMap.tsx @@ -1,12 +1,13 @@ "use client"; -import { ApiProviderList } from "@src/types/provider"; -import { ComposableMap, Geographies, Geography, Marker, Point, ZoomableGroup } from "react-simple-maps"; import { useEffect, useState } from "react"; -import { CustomNoDivTooltip } from "../shared/CustomTooltip"; +import { ComposableMap, Geographies, Geography, Marker, Point, ZoomableGroup } from "react-simple-maps"; +import { Minus, Plus, Restart } from "iconoir-react"; import Link from "next/link"; -import { UrlService } from "@src/utils/urlUtils"; + import { Button } from "@src/components/ui/button"; -import { Minus, Plus, Restart } from "iconoir-react"; +import { ApiProviderList } from "@src/types/provider"; +import { UrlService } from "@src/utils/urlUtils"; +import { CustomNoDivTooltip } from "../shared/CustomTooltip"; type Props = { initialZoom?: number; diff --git a/apps/deploy-web/src/components/providers/ProviderRawData.tsx b/apps/deploy-web/src/components/providers/ProviderRawData.tsx index 653e3616a..8894daead 100644 --- a/apps/deploy-web/src/components/providers/ProviderRawData.tsx +++ b/apps/deploy-web/src/components/providers/ProviderRawData.tsx @@ -1,14 +1,15 @@ "use client"; -import { useState, useEffect } from "react"; -import { useAllLeases } from "@src/queries/useLeaseQuery"; +import { useEffect, useState } from "react"; + +import { DynamicReactJson } from "@src/components/shared/DynamicJsonView"; import { useWallet } from "@src/context/WalletProvider"; -import { ClientProviderDetailWithStatus } from "@src/types/provider"; +import { useAllLeases } from "@src/queries/useLeaseQuery"; import { useProviderDetail, useProviderStatus } from "@src/queries/useProvidersQuery"; -import { DynamicReactJson } from "@src/components/shared/DynamicJsonView"; -import ProviderDetailLayout, { ProviderDetailTabs } from "./ProviderDetailLayout"; +import { ClientProviderDetailWithStatus } from "@src/types/provider"; +import { domainName, UrlService } from "@src/utils/urlUtils"; import Layout from "../layout/Layout"; import { CustomNextSeo } from "../shared/CustomNextSeo"; -import { UrlService, domainName } from "@src/utils/urlUtils"; +import ProviderDetailLayout, { ProviderDetailTabs } from "./ProviderDetailLayout"; type Props = { owner: string; @@ -32,7 +33,7 @@ export const ProviderRawData: React.FunctionComponent = ({ owner }) => { } = useProviderStatus(provider?.hostUri || "", { enabled: false, retry: false, - onSuccess: _providerStatus => { + onSuccess: () => { setProvider(provider => (provider ? { ...provider, ...providerStatus } : (providerStatus as ClientProviderDetailWithStatus))); } }); diff --git a/apps/deploy-web/src/components/providers/ProviderSpecs.tsx b/apps/deploy-web/src/components/providers/ProviderSpecs.tsx index 3fd16fc71..3d4b1f1a8 100644 --- a/apps/deploy-web/src/components/providers/ProviderSpecs.tsx +++ b/apps/deploy-web/src/components/providers/ProviderSpecs.tsx @@ -1,10 +1,11 @@ "use client"; +import { Check } from "iconoir-react"; + import { LabelValue } from "@src/components/shared/LabelValue"; import { Badge } from "@src/components/ui/badge"; import { Card, CardContent } from "@src/components/ui/card"; import { ClientProviderDetailWithStatus } from "@src/types/provider"; import { createFilterUnique } from "@src/utils/array"; -import { Check } from "iconoir-react"; type Props = { provider: ClientProviderDetailWithStatus; diff --git a/apps/deploy-web/src/components/providers/ProviderSummary.tsx b/apps/deploy-web/src/components/providers/ProviderSummary.tsx index a3ad843e0..671da9d1e 100644 --- a/apps/deploy-web/src/components/providers/ProviderSummary.tsx +++ b/apps/deploy-web/src/components/providers/ProviderSummary.tsx @@ -1,14 +1,14 @@ "use client"; +import { AuditorButton } from "@src/components/providers/AuditorButton"; +import { Uptime } from "@src/components/providers/Uptime"; +import { Address } from "@src/components/shared/Address"; +import { FavoriteButton } from "@src/components/shared/FavoriteButton"; +import { LabelValue } from "@src/components/shared/LabelValue"; +import { StatusPill } from "@src/components/shared/StatusPill"; +import { Card, CardContent } from "@src/components/ui/card"; import { useLocalNotes } from "@src/context/LocalNoteProvider"; import { ApiProviderList, ClientProviderDetailWithStatus } from "@src/types/provider"; import { ProviderMap } from "./ProviderMap"; -import { Card, CardContent } from "@src/components/ui/card"; -import { LabelValue } from "@src/components/shared/LabelValue"; -import { Address } from "@src/components/shared/Address"; -import { StatusPill } from "@src/components/shared/StatusPill"; -import { Uptime } from "@src/components/providers/Uptime"; -import { FavoriteButton } from "@src/components/shared/FavoriteButton"; -import { AuditorButton } from "@src/components/providers/AuditorButton"; type Props = { provider: ClientProviderDetailWithStatus; diff --git a/apps/deploy-web/src/components/providers/ProviderTable.tsx b/apps/deploy-web/src/components/providers/ProviderTable.tsx index 4bbff6277..98576a7ad 100644 --- a/apps/deploy-web/src/components/providers/ProviderTable.tsx +++ b/apps/deploy-web/src/components/providers/ProviderTable.tsx @@ -1,8 +1,8 @@ "use client"; -import { ClientProviderList } from "@src/types/provider"; -import { ProviderListRow } from "./ProviderTableRow"; import { Table, TableBody, TableHead, TableHeader, TableRow } from "@src/components/ui/table"; +import { ClientProviderList } from "@src/types/provider"; import { cn } from "@src/utils/styleUtils"; +import { ProviderListRow } from "./ProviderTableRow"; type Props = { providers: Array; diff --git a/apps/deploy-web/src/components/providers/ProviderTableRow.tsx b/apps/deploy-web/src/components/providers/ProviderTableRow.tsx index fd8d01ab9..3941165e2 100644 --- a/apps/deploy-web/src/components/providers/ProviderTableRow.tsx +++ b/apps/deploy-web/src/components/providers/ProviderTableRow.tsx @@ -1,23 +1,24 @@ "use client"; -import { ClientProviderList } from "@src/types/provider"; +import React from "react"; +import { WarningCircle } from "iconoir-react"; +import { useRouter } from "next/navigation"; + +import { Badge } from "@src/components/ui/badge"; +import { TableCell, TableRow } from "@src/components/ui/table"; import { useLocalNotes } from "@src/context/LocalNoteProvider"; +import { getSplitText } from "@src/hooks/useShortText"; +import { ClientProviderList } from "@src/types/provider"; +import { createFilterUnique } from "@src/utils/array"; +import { hasSomeParentTheClass } from "@src/utils/domUtils"; +import { roundDecimal } from "@src/utils/mathHelpers"; +import { cn } from "@src/utils/styleUtils"; +import { bytesToShrink } from "@src/utils/unitUtils"; +import { UrlService } from "@src/utils/urlUtils"; +import { CustomNoDivTooltip, CustomTooltip } from "../shared/CustomTooltip"; import { FavoriteButton } from "../shared/FavoriteButton"; import { AuditorButton } from "./AuditorButton"; -import { bytesToShrink } from "@src/utils/unitUtils"; -import { roundDecimal } from "@src/utils/mathHelpers"; import { CapacityIcon } from "./CapacityIcon"; -import { CustomNoDivTooltip, CustomTooltip } from "../shared/CustomTooltip"; -import { getSplitText } from "@src/hooks/useShortText"; -import { useRouter } from "next/navigation"; -import { UrlService } from "@src/utils/urlUtils"; import { Uptime } from "./Uptime"; -import React from "react"; -import { hasSomeParentTheClass } from "@src/utils/domUtils"; -import { createFilterUnique } from "@src/utils/array"; -import { TableCell, TableRow } from "@src/components/ui/table"; -import { cn } from "@src/utils/styleUtils"; -import { Badge } from "@src/components/ui/badge"; -import { WarningCircle } from "iconoir-react"; type Props = { provider: ClientProviderList; @@ -132,7 +133,7 @@ export const ProviderListRow: React.FunctionComponent = ({ provider }) =>
    - {gpuModels.slice(0, 2).map((gpu, i) => ( + {gpuModels.slice(0, 2).map(gpu => ( {gpu} @@ -142,7 +143,7 @@ export const ProviderListRow: React.FunctionComponent = ({ provider }) => - {gpuModels.map((gpu, i) => ( + {gpuModels.map(gpu => ( {gpu} diff --git a/apps/deploy-web/src/components/providers/Uptime.tsx b/apps/deploy-web/src/components/providers/Uptime.tsx index 233e639e9..ac87d549d 100644 --- a/apps/deploy-web/src/components/providers/Uptime.tsx +++ b/apps/deploy-web/src/components/providers/Uptime.tsx @@ -1,7 +1,8 @@ "use client"; -import { cn } from "@src/utils/styleUtils"; import { useIntl } from "react-intl"; +import { cn } from "@src/utils/styleUtils"; + type Props = { value: number; }; diff --git a/apps/deploy-web/src/components/sdl/AcceptFormControl.tsx b/apps/deploy-web/src/components/sdl/AcceptFormControl.tsx index f5df15310..ddb516a92 100644 --- a/apps/deploy-web/src/components/sdl/AcceptFormControl.tsx +++ b/apps/deploy-web/src/components/sdl/AcceptFormControl.tsx @@ -1,14 +1,15 @@ "use client"; -import { ReactNode, useImperativeHandle, forwardRef } from "react"; +import { forwardRef, ReactNode, useImperativeHandle } from "react"; import { Control, Controller, useFieldArray } from "react-hook-form"; -import { Accept, SdlBuilderFormValues } from "@src/types"; +import { Bin, InfoCircle } from "iconoir-react"; import { nanoid } from "nanoid"; + +import { Accept, SdlBuilderFormValues } from "@src/types"; +import { cn } from "@src/utils/styleUtils"; import { CustomTooltip } from "../shared/CustomTooltip"; -import { FormPaper } from "./FormPaper"; -import { FormInput } from "../ui/input"; import { Button } from "../ui/button"; -import { cn } from "@src/utils/styleUtils"; -import { Bin, InfoCircle } from "iconoir-react"; +import { FormInput } from "../ui/input"; +import { FormPaper } from "./FormPaper"; type Props = { serviceIndex: number; diff --git a/apps/deploy-web/src/components/sdl/AdvancedConfig.tsx b/apps/deploy-web/src/components/sdl/AdvancedConfig.tsx index 682395818..bf06b9fc0 100644 --- a/apps/deploy-web/src/components/sdl/AdvancedConfig.tsx +++ b/apps/deploy-web/src/components/sdl/AdvancedConfig.tsx @@ -1,19 +1,20 @@ "use client"; import { ReactNode, useState } from "react"; import { Control } from "react-hook-form"; + import { RentGpusFormValues, Service } from "@src/types"; +import { cn } from "@src/utils/styleUtils"; import { ExpandMore } from "../shared/ExpandMore"; -import { EnvFormModal } from "./EnvFormModal"; +import { Button } from "../ui/button"; +import { Card, CardContent } from "../ui/card"; +import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "../ui/collapsible"; import { CommandFormModal } from "./CommandFormModal"; -import { ExposeFormModal } from "./ExposeFormModal"; -import { EnvVarList } from "./EnvVarList"; import { CommandList } from "./CommandList"; +import { EnvFormModal } from "./EnvFormModal"; +import { EnvVarList } from "./EnvVarList"; +import { ExposeFormModal } from "./ExposeFormModal"; import { ExposeList } from "./ExposeList"; import { PersistentStorage } from "./PersistentStorage"; -import { Card, CardContent } from "../ui/card"; -import { Button } from "../ui/button"; -import { cn } from "@src/utils/styleUtils"; -import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "../ui/collapsible"; type Props = { currentService: Service; diff --git a/apps/deploy-web/src/components/sdl/AttributesFormControl.tsx b/apps/deploy-web/src/components/sdl/AttributesFormControl.tsx index b3e909472..bf4e5fbd6 100644 --- a/apps/deploy-web/src/components/sdl/AttributesFormControl.tsx +++ b/apps/deploy-web/src/components/sdl/AttributesFormControl.tsx @@ -1,14 +1,14 @@ "use client"; -import { ReactNode, useImperativeHandle, forwardRef } from "react"; +import { forwardRef, ReactNode, useImperativeHandle } from "react"; import { Control, Controller, useFieldArray } from "react-hook-form"; -import { PlacementAttribute, SdlBuilderFormValues } from "@src/types"; +import { Bin, InfoCircle } from "iconoir-react"; import { nanoid } from "nanoid"; + +import { PlacementAttribute, SdlBuilderFormValues } from "@src/types"; +import { cn } from "@src/utils/styleUtils"; import { CustomTooltip } from "../shared/CustomTooltip"; -import { Card, CardContent } from "../ui/card"; import { Button } from "../ui/button"; -import { Bin, InfoCircle } from "iconoir-react"; -import { cn } from "@src/utils/styleUtils"; -import { FormInput, Input } from "../ui/input"; +import { FormInput } from "../ui/input"; import { FormPaper } from "./FormPaper"; type Props = { diff --git a/apps/deploy-web/src/components/sdl/CommandFormModal.tsx b/apps/deploy-web/src/components/sdl/CommandFormModal.tsx index fdc5779b7..11f600b40 100644 --- a/apps/deploy-web/src/components/sdl/CommandFormModal.tsx +++ b/apps/deploy-web/src/components/sdl/CommandFormModal.tsx @@ -1,11 +1,12 @@ "use client"; import { ReactNode } from "react"; -import { Popup } from "../shared/Popup"; import { Control, Controller } from "react-hook-form"; + import { SdlBuilderFormValues } from "@src/types"; +import { Popup } from "../shared/Popup"; import { FormInput, Textarea } from "../ui/input"; -import { FormPaper } from "./FormPaper"; import { Label } from "../ui/label"; +import { FormPaper } from "./FormPaper"; type Props = { serviceIndex: number; diff --git a/apps/deploy-web/src/components/sdl/CommandList.tsx b/apps/deploy-web/src/components/sdl/CommandList.tsx index 1bed20b68..9f46cdb4e 100644 --- a/apps/deploy-web/src/components/sdl/CommandList.tsx +++ b/apps/deploy-web/src/components/sdl/CommandList.tsx @@ -1,9 +1,10 @@ "use client"; import { Dispatch, ReactNode, SetStateAction } from "react"; +import { InfoCircle } from "iconoir-react"; + import { Service } from "@src/types"; import { CustomTooltip } from "../shared/CustomTooltip"; import { FormPaper } from "./FormPaper"; -import { InfoCircle } from "iconoir-react"; type Props = { currentService: Service; diff --git a/apps/deploy-web/src/components/sdl/CpuFormControl.tsx b/apps/deploy-web/src/components/sdl/CpuFormControl.tsx index fceb778d8..ed8d57ffa 100644 --- a/apps/deploy-web/src/components/sdl/CpuFormControl.tsx +++ b/apps/deploy-web/src/components/sdl/CpuFormControl.tsx @@ -1,16 +1,17 @@ "use client"; import { ReactNode } from "react"; -import { RentGpusFormValues, SdlBuilderFormValues, Service } from "@src/types"; -import { CustomTooltip } from "../shared/CustomTooltip"; -import { FormPaper } from "./FormPaper"; import { Control, Controller } from "react-hook-form"; -import { validationConfig } from "../shared/akash/units"; +import { MdSpeed } from "react-icons/md"; +import { InfoCircle } from "iconoir-react"; + +import { RentGpusFormValues, SdlBuilderFormValues, Service } from "@src/types"; import { cn } from "@src/utils/styleUtils"; +import { validationConfig } from "../shared/akash/units"; +import { CustomTooltip } from "../shared/CustomTooltip"; import { FormDescription, FormItem } from "../ui/form"; -import { Slider } from "../ui/slider"; import { Input } from "../ui/input"; -import { InfoCircle } from "iconoir-react"; -import { MdSpeed } from "react-icons/md"; +import { Slider } from "../ui/slider"; +import { FormPaper } from "./FormPaper"; type Props = { serviceIndex: number; diff --git a/apps/deploy-web/src/components/sdl/EditDescriptionForm.tsx b/apps/deploy-web/src/components/sdl/EditDescriptionForm.tsx index 478581894..eb6c47caf 100644 --- a/apps/deploy-web/src/components/sdl/EditDescriptionForm.tsx +++ b/apps/deploy-web/src/components/sdl/EditDescriptionForm.tsx @@ -2,13 +2,14 @@ import { ReactNode, useRef, useState } from "react"; import { Controller, useForm } from "react-hook-form"; import axios from "axios"; -import { FormPaper } from "./FormPaper"; -import { Button } from "../ui/button"; -import Spinner from "../shared/Spinner"; -import { Label } from "../ui/label"; -import { Textarea } from "../ui/input"; import { useSnackbar } from "notistack"; + import { Snackbar } from "../shared/Snackbar"; +import Spinner from "../shared/Spinner"; +import { Button } from "../ui/button"; +import { Textarea } from "../ui/input"; +import { Label } from "../ui/label"; +import { FormPaper } from "./FormPaper"; type Props = { id: string; diff --git a/apps/deploy-web/src/components/sdl/EnvFormModal.tsx b/apps/deploy-web/src/components/sdl/EnvFormModal.tsx index 9a83e84ac..a65960f72 100644 --- a/apps/deploy-web/src/components/sdl/EnvFormModal.tsx +++ b/apps/deploy-web/src/components/sdl/EnvFormModal.tsx @@ -1,15 +1,16 @@ "use client"; import { ReactNode, useEffect } from "react"; -import { Popup } from "../shared/Popup"; import { Control, Controller, useFieldArray } from "react-hook-form"; -import { EnvironmentVariable, RentGpusFormValues, SdlBuilderFormValues } from "@src/types"; +import { Bin } from "iconoir-react"; import { nanoid } from "nanoid"; + +import { EnvironmentVariable, RentGpusFormValues, SdlBuilderFormValues } from "@src/types"; import { cn } from "@src/utils/styleUtils"; -import { FormInput } from "../ui/input"; -import { Bin } from "iconoir-react"; +import { CustomNoDivTooltip } from "../shared/CustomTooltip"; +import { Popup } from "../shared/Popup"; import { Button } from "../ui/button"; +import { FormInput } from "../ui/input"; import { Switch } from "../ui/switch"; -import { CustomNoDivTooltip, CustomTooltip } from "../shared/CustomTooltip"; import { FormPaper } from "./FormPaper"; type Props = { diff --git a/apps/deploy-web/src/components/sdl/EnvVarList.tsx b/apps/deploy-web/src/components/sdl/EnvVarList.tsx index 00e5f8a61..833da9c11 100644 --- a/apps/deploy-web/src/components/sdl/EnvVarList.tsx +++ b/apps/deploy-web/src/components/sdl/EnvVarList.tsx @@ -1,9 +1,10 @@ "use client"; import { Dispatch, ReactNode, SetStateAction } from "react"; +import { InfoCircle } from "iconoir-react"; + import { Service } from "@src/types"; import { CustomTooltip } from "../shared/CustomTooltip"; import { FormPaper } from "./FormPaper"; -import { InfoCircle } from "iconoir-react"; type Props = { currentService: Service; diff --git a/apps/deploy-web/src/components/sdl/ExposeFormModal.tsx b/apps/deploy-web/src/components/sdl/ExposeFormModal.tsx index d13749208..4771cc406 100644 --- a/apps/deploy-web/src/components/sdl/ExposeFormModal.tsx +++ b/apps/deploy-web/src/components/sdl/ExposeFormModal.tsx @@ -1,24 +1,25 @@ "use client"; import { ReactNode, useRef } from "react"; -import { Popup } from "../shared/Popup"; import { Control, Controller, useFieldArray } from "react-hook-form"; -import { Expose, SdlBuilderFormValues, Service } from "@src/types"; -import { AcceptFormControl, AcceptRefType } from "./AcceptFormControl"; +import { Bin, InfoCircle } from "iconoir-react"; import { nanoid } from "nanoid"; -import { ToFormControl, ToRefType } from "./ToFormControl"; -import { protoTypes } from "@src/utils/sdl/data"; -import { FormPaper } from "./FormPaper"; + +import { Expose, SdlBuilderFormValues, Service } from "@src/types"; import { endpointNameValidationRegex } from "@src/utils/deploymentData/v1beta3"; -import { HttpOptionsFormControl } from "./HttpOptionsFormControl"; +import { protoTypes } from "@src/utils/sdl/data"; +import { cn } from "@src/utils/styleUtils"; import { CustomTooltip } from "../shared/CustomTooltip"; +import { Popup } from "../shared/Popup"; import { Button } from "../ui/button"; -import { Bin, InfoCircle } from "iconoir-react"; -import { InputWithIcon } from "../ui/input"; -import { cn } from "@src/utils/styleUtils"; -import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "../ui/select"; import { Checkbox } from "../ui/checkbox"; import { FormItem } from "../ui/form"; +import { InputWithIcon } from "../ui/input"; import { Label } from "../ui/label"; +import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "../ui/select"; +import { AcceptFormControl, AcceptRefType } from "./AcceptFormControl"; +import { FormPaper } from "./FormPaper"; +import { HttpOptionsFormControl } from "./HttpOptionsFormControl"; +import { ToFormControl, ToRefType } from "./ToFormControl"; type Props = { serviceIndex: number; @@ -50,7 +51,7 @@ export const ExposeFormModal: React.FunctionComponent = ({ control, servi const acceptToRemove: number[] = []; const toToRemove: number[] = []; - _expose.forEach((e, i) => { + _expose.forEach(e => { e.accept?.forEach((a, ii) => { if (!a.value.trim()) { acceptToRemove.push(ii); diff --git a/apps/deploy-web/src/components/sdl/ExposeList.tsx b/apps/deploy-web/src/components/sdl/ExposeList.tsx index c529eb74e..386d1d2f1 100644 --- a/apps/deploy-web/src/components/sdl/ExposeList.tsx +++ b/apps/deploy-web/src/components/sdl/ExposeList.tsx @@ -1,10 +1,11 @@ "use client"; import { Dispatch, ReactNode, SetStateAction } from "react"; +import { InfoCircle } from "iconoir-react"; + import { Service } from "@src/types"; +import { cn } from "@src/utils/styleUtils"; import { CustomTooltip } from "../shared/CustomTooltip"; import { FormPaper } from "./FormPaper"; -import { InfoCircle } from "iconoir-react"; -import { cn } from "@src/utils/styleUtils"; type Props = { currentService: Service; diff --git a/apps/deploy-web/src/components/sdl/GpuFormControl.tsx b/apps/deploy-web/src/components/sdl/GpuFormControl.tsx index d6dfe3c89..74b82a622 100644 --- a/apps/deploy-web/src/components/sdl/GpuFormControl.tsx +++ b/apps/deploy-web/src/components/sdl/GpuFormControl.tsx @@ -1,25 +1,26 @@ "use client"; import { ReactNode } from "react"; +import { Control, Controller, useFieldArray, UseFormSetValue } from "react-hook-form"; +import { MdSpeed } from "react-icons/md"; +import FormControl from "@mui/material/FormControl"; +import IconButton from "@mui/material/IconButton"; +import InputLabel from "@mui/material/InputLabel"; +import MenuItem from "@mui/material/MenuItem"; +import { default as MuiSelect } from "@mui/material/Select"; +import { Bin, InfoCircle, Xmark } from "iconoir-react"; + import { RentGpusFormValues, SdlBuilderFormValues, Service } from "@src/types"; -import { CustomTooltip } from "../shared/CustomTooltip"; -import { FormPaper } from "./FormPaper"; -import { Control, Controller, UseFormSetValue, useFieldArray } from "react-hook-form"; +import { GpuVendor } from "@src/types/gpu"; import { gpuVendors } from "../shared/akash/gpu"; import { validationConfig } from "../shared/akash/units"; -import { FormDescription, FormItem } from "../ui/form"; -import { Slider } from "../ui/slider"; +import { CustomTooltip } from "../shared/CustomTooltip"; import Spinner from "../shared/Spinner"; -import { Input } from "../ui/input"; -import { Checkbox } from "../ui/checkbox"; -import { Bin, InfoCircle, Xmark } from "iconoir-react"; -import { MdSpeed } from "react-icons/md"; -import { GpuVendor } from "@src/types/gpu"; import { Button } from "../ui/button"; -import FormControl from "@mui/material/FormControl"; -import InputLabel from "@mui/material/InputLabel"; -import { default as MuiSelect } from "@mui/material/Select"; -import IconButton from "@mui/material/IconButton"; -import MenuItem from "@mui/material/MenuItem"; +import { Checkbox } from "../ui/checkbox"; +import { FormDescription, FormItem } from "../ui/form"; +import { Input } from "../ui/input"; +import { Slider } from "../ui/slider"; +import { FormPaper } from "./FormPaper"; type Props = { serviceIndex: number; @@ -230,7 +231,7 @@ export const GpuFormControl: React.FunctionComponent = ({ gpuModels, cont ? () => ( { + onClick={() => { field.onChange(""); setValue(`services.${serviceIndex}.profile.gpuModels.${formGpuIndex}.memory`, ""); setValue(`services.${serviceIndex}.profile.gpuModels.${formGpuIndex}.interface`, ""); @@ -276,7 +277,7 @@ export const GpuFormControl: React.FunctionComponent = ({ gpuModels, cont ? () => ( { + onClick={() => { field.onChange(""); }} > @@ -320,7 +321,7 @@ export const GpuFormControl: React.FunctionComponent = ({ gpuModels, cont ? () => ( { + onClick={() => { field.onChange(""); }} > diff --git a/apps/deploy-web/src/components/sdl/HttpOptionsFormControl.tsx b/apps/deploy-web/src/components/sdl/HttpOptionsFormControl.tsx index c399c210b..8dcbeb82a 100644 --- a/apps/deploy-web/src/components/sdl/HttpOptionsFormControl.tsx +++ b/apps/deploy-web/src/components/sdl/HttpOptionsFormControl.tsx @@ -1,20 +1,18 @@ "use client"; import { ReactNode } from "react"; import { Control, Controller } from "react-hook-form"; +import { InfoCircle } from "iconoir-react"; + import { SdlBuilderFormValues, Service } from "@src/types"; -import InfoIcon from "@mui/icons-material/Info"; import { nextCases } from "@src/utils/sdl/data"; -import { CardContent } from "@mui/material"; -import { Card } from "../ui/card"; import { cn } from "@src/utils/styleUtils"; import { CustomTooltip } from "../shared/CustomTooltip"; -import { InfoCircle } from "iconoir-react"; import { Checkbox } from "../ui/checkbox"; +import { FormItem } from "../ui/form"; import { InputWithIcon } from "../ui/input"; +import { Label } from "../ui/label"; import MultipleSelector from "../ui/multiple-selector"; import { FormPaper } from "./FormPaper"; -import { FormItem } from "../ui/form"; -import { Label } from "../ui/label"; type Props = { serviceIndex: number; diff --git a/apps/deploy-web/src/components/sdl/ImageSelect.tsx b/apps/deploy-web/src/components/sdl/ImageSelect.tsx index 1030ed047..3d38b5af4 100644 --- a/apps/deploy-web/src/components/sdl/ImageSelect.tsx +++ b/apps/deploy-web/src/components/sdl/ImageSelect.tsx @@ -1,19 +1,20 @@ "use client"; import { ReactNode, useEffect, useLayoutEffect, useRef, useState } from "react"; -import { ApiTemplate, RentGpusFormValues, SdlBuilderFormValues, Service } from "@src/types"; -import { CustomTooltip } from "../shared/CustomTooltip"; import { Control, Controller } from "react-hook-form"; +import ClickAwayListener from "@mui/material/ClickAwayListener"; +import InputAdornment from "@mui/material/InputAdornment"; +import Popper from "@mui/material/Popper"; +import { useTheme as useMuiTheme } from "@mui/material/styles"; +import TextField from "@mui/material/TextField"; +import { InfoCircle, OpenNewWindow } from "iconoir-react"; import Image from "next/image"; import Link from "next/link"; + import { useGpuTemplates } from "@src/hooks/useGpuTemplates"; -import { useTheme as useMuiTheme } from "@mui/material/styles"; -import { InfoCircle, OpenNewWindow } from "iconoir-react"; -import ClickAwayListener from "@mui/material/ClickAwayListener"; -import Popper from "@mui/material/Popper"; -import InputAdornment from "@mui/material/InputAdornment"; -import { buttonVariants } from "../ui/button"; +import { ApiTemplate, RentGpusFormValues, SdlBuilderFormValues, Service } from "@src/types"; import { cn } from "@src/utils/styleUtils"; -import TextField from "@mui/material/TextField"; +import { CustomTooltip } from "../shared/CustomTooltip"; +import { buttonVariants } from "../ui/button"; type Props = { children?: ReactNode; diff --git a/apps/deploy-web/src/components/sdl/ImportSdlModal.tsx b/apps/deploy-web/src/components/sdl/ImportSdlModal.tsx index 888983be8..d39894e22 100644 --- a/apps/deploy-web/src/components/sdl/ImportSdlModal.tsx +++ b/apps/deploy-web/src/components/sdl/ImportSdlModal.tsx @@ -1,17 +1,18 @@ "use client"; import { ReactNode, useEffect, useState } from "react"; -import Editor from "@monaco-editor/react"; -import { Timer } from "@src/utils/timer"; -import { importSimpleSdl } from "@src/utils/sdl/sdlImport"; import { UseFormSetValue } from "react-hook-form"; -import { SdlBuilderFormValues, Service } from "@src/types"; +import Editor from "@monaco-editor/react"; +import { ArrowDown } from "iconoir-react"; +import { useTheme } from "next-themes"; import { event } from "nextjs-google-analytics"; -import { AnalyticsEvents } from "@src/utils/analytics"; +import { useSnackbar } from "notistack"; + import { Popup } from "@src/components/shared/Popup"; -import { useTheme } from "next-themes"; -import { ArrowDown } from "iconoir-react"; import { Alert } from "@src/components/ui/alert"; -import { useSnackbar } from "notistack"; +import { SdlBuilderFormValues, Service } from "@src/types"; +import { AnalyticsEvents } from "@src/utils/analytics"; +import { importSimpleSdl } from "@src/utils/sdl/sdlImport"; +import { Timer } from "@src/utils/timer"; import { Snackbar } from "../shared/Snackbar"; type Props = { diff --git a/apps/deploy-web/src/components/sdl/MemoryFormControl.tsx b/apps/deploy-web/src/components/sdl/MemoryFormControl.tsx index a972f5524..1484d567c 100644 --- a/apps/deploy-web/src/components/sdl/MemoryFormControl.tsx +++ b/apps/deploy-web/src/components/sdl/MemoryFormControl.tsx @@ -1,17 +1,18 @@ "use client"; import { ReactNode } from "react"; +import { Control, Controller } from "react-hook-form"; +import { MdMemory } from "react-icons/md"; +import { InfoCircle } from "iconoir-react"; + import { RentGpusFormValues, SdlBuilderFormValues, Service } from "@src/types"; +import { cn } from "@src/utils/styleUtils"; +import { memoryUnits, validationConfig } from "../shared/akash/units"; import { CustomTooltip } from "../shared/CustomTooltip"; -import { FormPaper } from "./FormPaper"; -import { Control, Controller } from "react-hook-form"; -import { validationConfig, memoryUnits } from "../shared/akash/units"; import { FormDescription, FormItem } from "../ui/form"; -import { Slider } from "../ui/slider"; -import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "../ui/select"; import { Input } from "../ui/input"; -import { InfoCircle } from "iconoir-react"; -import { MdMemory } from "react-icons/md"; -import { cn } from "@src/utils/styleUtils"; +import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "../ui/select"; +import { Slider } from "../ui/slider"; +import { FormPaper } from "./FormPaper"; type Props = { serviceIndex: number; diff --git a/apps/deploy-web/src/components/sdl/PersistentStorage.tsx b/apps/deploy-web/src/components/sdl/PersistentStorage.tsx index fb5910478..33204f983 100644 --- a/apps/deploy-web/src/components/sdl/PersistentStorage.tsx +++ b/apps/deploy-web/src/components/sdl/PersistentStorage.tsx @@ -1,18 +1,19 @@ "use client"; import { ReactNode } from "react"; -import { RentGpusFormValues, SdlBuilderFormValues, Service } from "@src/types"; -import { CustomTooltip } from "../shared/CustomTooltip"; -import { FormPaper } from "./FormPaper"; import { Control, Controller } from "react-hook-form"; -import { persistentStorageTypes, storageUnits } from "../shared/akash/units"; -import { FormDescription, FormItem } from "../ui/form"; -import { InfoCircle } from "iconoir-react"; import { MdStorage } from "react-icons/md"; +import { InfoCircle } from "iconoir-react"; + +import { RentGpusFormValues, SdlBuilderFormValues, Service } from "@src/types"; +import { persistentStorageTypes, storageUnits } from "../shared/akash/units"; +import { CustomTooltip } from "../shared/CustomTooltip"; import { Checkbox } from "../ui/checkbox"; +import { FormDescription, FormItem } from "../ui/form"; import { Input, InputWithIcon } from "../ui/input"; +import { Label } from "../ui/label"; import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "../ui/select"; import { Slider } from "../ui/slider"; -import { Label } from "../ui/label"; +import { FormPaper } from "./FormPaper"; type Props = { currentService: Service; @@ -149,7 +150,7 @@ export const PersistentStorage: React.FunctionComponent = ({ currentServi rules={{ required: "Name is required.", validate: value => { - const hasValidChars = /^[a-z0-9\-]+$/.test(value); + const hasValidChars = /^[a-z0-9-]+$/.test(value); const hasValidStartingChar = /^[a-z]/.test(value); const hasValidEndingChar = !value.endsWith("-"); diff --git a/apps/deploy-web/src/components/sdl/PlacementFormModal.tsx b/apps/deploy-web/src/components/sdl/PlacementFormModal.tsx index 4a114e475..8a5b894f8 100644 --- a/apps/deploy-web/src/components/sdl/PlacementFormModal.tsx +++ b/apps/deploy-web/src/components/sdl/PlacementFormModal.tsx @@ -1,23 +1,23 @@ "use client"; import { ReactNode, useRef } from "react"; -import { Popup } from "../shared/Popup"; import { Control, Controller } from "react-hook-form"; +import { FormattedNumber } from "react-intl"; +import { InfoCircle } from "iconoir-react"; + +import { useSdlDenoms } from "@src/hooks/useDenom"; import { Placement, SdlBuilderFormValues, Service } from "@src/types"; -import { FormPaper } from "./FormPaper"; -import { SignedByFormControl, SignedByRefType } from "./SignedByFormControl"; -import { AttributesFormControl, AttributesRefType } from "./AttributesFormControl"; +import { uAktDenom } from "@src/utils/constants"; +import { udenomToDenom } from "@src/utils/mathHelpers"; +import { getAvgCostPerMonth, toReadableDenom, uaktToAKT } from "@src/utils/priceUtils"; import { CustomTooltip } from "../shared/CustomTooltip"; +import { Popup } from "../shared/Popup"; import { PriceValue } from "../shared/PriceValue"; -import { getAvgCostPerMonth, toReadableDenom, uaktToAKT } from "@src/utils/priceUtils"; -import { uAktDenom } from "@src/utils/constants"; -import { useSdlDenoms } from "@src/hooks/useDenom"; -import { FormattedNumber } from "react-intl"; import { USDLabel } from "../shared/UsdLabel"; -import { udenomToDenom } from "@src/utils/mathHelpers"; -import { InfoCircle } from "iconoir-react"; -import { FormControl, FormItem } from "../ui/form"; -import { FormInput, InputWithIcon } from "../ui/input"; -import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "../ui/select"; +import { FormItem } from "../ui/form"; +import { InputWithIcon } from "../ui/input"; +import { AttributesFormControl, AttributesRefType } from "./AttributesFormControl"; +import { FormPaper } from "./FormPaper"; +import { SignedByFormControl, SignedByRefType } from "./SignedByFormControl"; type Props = { serviceIndex: number; @@ -28,15 +28,6 @@ type Props = { placement: Placement; }; -// const useStyles = makeStyles()(theme => ({ -// formControl: { -// marginBottom: theme.spacing(1.5) -// }, -// textField: { -// width: "100%" -// } -// })); - export const PlacementFormModal: React.FunctionComponent = ({ control, services, serviceIndex, onClose, placement: _placement }) => { const signedByRef = useRef(null); const attritubesRef = useRef(null); @@ -103,7 +94,7 @@ export const PlacementFormModal: React.FunctionComponent = ({ control, se rules={{ required: "Placement name is required", validate: value => { - const hasValidChars = /^[a-z0-9\-]+$/.test(value); + const hasValidChars = /^[a-z0-9-]+$/.test(value); const hasValidStartingChar = /^[a-z]/.test(value); const hasValidEndingChar = !value.endsWith("-"); diff --git a/apps/deploy-web/src/components/sdl/PreviewSdl.tsx b/apps/deploy-web/src/components/sdl/PreviewSdl.tsx index 1ebb3fe71..6b021ca84 100644 --- a/apps/deploy-web/src/components/sdl/PreviewSdl.tsx +++ b/apps/deploy-web/src/components/sdl/PreviewSdl.tsx @@ -1,12 +1,13 @@ "use client"; import { ReactNode } from "react"; import Editor from "@monaco-editor/react"; -import { copyTextToClipboard } from "@src/utils/copyClipboard"; -import { Popup } from "@src/components/shared/Popup"; -import { Button } from "@src/components/ui/button"; import { Copy } from "iconoir-react"; import { useTheme } from "next-themes"; import { useSnackbar } from "notistack"; + +import { Popup } from "@src/components/shared/Popup"; +import { Button } from "@src/components/ui/button"; +import { copyTextToClipboard } from "@src/utils/copyClipboard"; import { Snackbar } from "../shared/Snackbar"; type Props = { diff --git a/apps/deploy-web/src/components/sdl/RegionSelect.tsx b/apps/deploy-web/src/components/sdl/RegionSelect.tsx index 7aa63006f..b4940c442 100644 --- a/apps/deploy-web/src/components/sdl/RegionSelect.tsx +++ b/apps/deploy-web/src/components/sdl/RegionSelect.tsx @@ -1,15 +1,16 @@ "use client"; -import { RentGpusFormValues } from "@src/types"; -import { ProviderAttributeSchemaDetailValue, ProviderRegionValue } from "@src/types/providerAttributes"; import { useState } from "react"; import { Control, Controller } from "react-hook-form"; -import { CustomTooltip } from "../shared/CustomTooltip"; -import { useProviderRegions } from "@src/queries/useProvidersQuery"; -import { cn } from "@src/utils/styleUtils"; import Autocomplete from "@mui/material/Autocomplete"; import ClickAwayListener from "@mui/material/ClickAwayListener"; -import { InfoCircle } from "iconoir-react"; import TextField from "@mui/material/TextField"; +import { InfoCircle } from "iconoir-react"; + +import { useProviderRegions } from "@src/queries/useProvidersQuery"; +import { RentGpusFormValues } from "@src/types"; +import { ProviderAttributeSchemaDetailValue, ProviderRegionValue } from "@src/types/providerAttributes"; +import { cn } from "@src/utils/styleUtils"; +import { CustomTooltip } from "../shared/CustomTooltip"; type RegionSelectProps = { control: Control; diff --git a/apps/deploy-web/src/components/sdl/RentGpusForm.tsx b/apps/deploy-web/src/components/sdl/RentGpusForm.tsx index ed233b7ed..49b835445 100644 --- a/apps/deploy-web/src/components/sdl/RentGpusForm.tsx +++ b/apps/deploy-web/src/components/sdl/RentGpusForm.tsx @@ -1,51 +1,49 @@ "use client"; -import { useForm } from "react-hook-form"; import { useEffect, useRef, useState } from "react"; -import { ApiTemplate, ProfileGpuModel, RentGpusFormValues, Service } from "@src/types"; -import { defaultAnyRegion, defaultRentGpuService } from "@src/utils/sdl/data"; -import { useRouter, useSearchParams } from "next/navigation"; -import { useAtom } from "jotai"; -import { EncodeObject } from "@cosmjs/proto-signing"; +import { useForm } from "react-hook-form"; import { certificateManager } from "@akashnetwork/akashjs/build/certificates/certificate-manager"; +import { EncodeObject } from "@cosmjs/proto-signing"; +import { Rocket } from "iconoir-react"; +import { useAtom } from "jotai"; +import { useRouter, useSearchParams } from "next/navigation"; +import { event } from "nextjs-google-analytics"; -import sdlStore from "@src/store/sdlStore"; -import { RegionSelect } from "./RegionSelect"; -import { AdvancedConfig } from "./AdvancedConfig"; -import { GpuFormControl } from "./GpuFormControl"; -import { CpuFormControl } from "./CpuFormControl"; -import { MemoryFormControl } from "./MemoryFormControl"; -import { StorageFormControl } from "./StorageFormControl"; -import { TokenFormControl } from "./TokenFormControl"; -import { generateSdl } from "@src/utils/sdl/sdlGenerator"; -import { UrlService, handleDocClick } from "@src/utils/urlUtils"; -import { RouteStepKeys, defaultInitialDeposit } from "@src/utils/constants"; -import { deploymentData } from "@src/utils/deploymentData"; import { useCertificate } from "@src/context/CertificateProvider"; +import { useChainParam } from "@src/context/ChainParamProvider"; import { useSettings } from "@src/context/SettingsProvider"; import { useWallet } from "@src/context/WalletProvider"; +import { useGpuModels } from "@src/queries/useGpuQuery"; +import sdlStore from "@src/store/sdlStore"; +import { ApiTemplate, ProfileGpuModel, RentGpusFormValues, Service } from "@src/types"; +import { ProviderAttributeSchemaDetailValue } from "@src/types/providerAttributes"; +import { AnalyticsEvents } from "@src/utils/analytics"; +import { defaultInitialDeposit, RouteStepKeys } from "@src/utils/constants"; +import { deploymentData } from "@src/utils/deploymentData"; +import { saveDeploymentManifestAndName } from "@src/utils/deploymentLocalDataUtils"; import { validateDeploymentData } from "@src/utils/deploymentUtils"; +import { defaultAnyRegion, defaultRentGpuService } from "@src/utils/sdl/data"; +import { generateSdl } from "@src/utils/sdl/sdlGenerator"; +import { importSimpleSdl } from "@src/utils/sdl/sdlImport"; import { TransactionMessageData } from "@src/utils/TransactionMessageData"; +import { handleDocClick, UrlService } from "@src/utils/urlUtils"; import { updateWallet } from "@src/utils/walletUtils"; -import { saveDeploymentManifestAndName } from "@src/utils/deploymentLocalDataUtils"; import { DeploymentDepositModal } from "../deployments/DeploymentDepositModal"; import { LinkTo } from "../shared/LinkTo"; import { PrerequisiteList } from "../shared/PrerequisiteList"; -import { ProviderAttributeSchemaDetailValue } from "@src/types/providerAttributes"; -import { importSimpleSdl } from "@src/utils/sdl/sdlImport"; -import { ImageSelect } from "./ImageSelect"; -import { event } from "nextjs-google-analytics"; -import { AnalyticsEvents } from "@src/utils/analytics"; -import { useChainParam } from "@src/context/ChainParamProvider"; -import { useGpuModels } from "@src/queries/useGpuQuery"; +import Spinner from "../shared/Spinner"; import { Alert } from "../ui/alert"; -import { FormPaper } from "./FormPaper"; import { Button } from "../ui/button"; -import { Rocket } from "iconoir-react"; -import Spinner from "../shared/Spinner"; - -type Props = {}; +import { AdvancedConfig } from "./AdvancedConfig"; +import { CpuFormControl } from "./CpuFormControl"; +import { FormPaper } from "./FormPaper"; +import { GpuFormControl } from "./GpuFormControl"; +import { ImageSelect } from "./ImageSelect"; +import { MemoryFormControl } from "./MemoryFormControl"; +import { RegionSelect } from "./RegionSelect"; +import { StorageFormControl } from "./StorageFormControl"; +import { TokenFormControl } from "./TokenFormControl"; -export const RentGpusForm: React.FunctionComponent = ({}) => { +export const RentGpusForm: React.FunctionComponent = () => { const [error, setError] = useState(null); // const [templateMetadata, setTemplateMetadata] = useState(null); const [isQueryInit, setIsQuertInit] = useState(false); diff --git a/apps/deploy-web/src/components/sdl/SaveTemplateModal.tsx b/apps/deploy-web/src/components/sdl/SaveTemplateModal.tsx index 5006a2627..c28c0943f 100644 --- a/apps/deploy-web/src/components/sdl/SaveTemplateModal.tsx +++ b/apps/deploy-web/src/components/sdl/SaveTemplateModal.tsx @@ -1,19 +1,20 @@ "use client"; import { Dispatch, ReactNode, SetStateAction, useEffect, useRef, useState } from "react"; import { Controller, useForm } from "react-hook-form"; -import { EnvironmentVariable, ITemplate, SdlSaveTemplateFormValues, Service } from "@src/types"; -import { useSaveUserTemplate } from "@src/queries/useTemplateQuery"; -import { useCustomUser } from "@src/hooks/useCustomUser"; -import { getShortText } from "@src/hooks/useShortText"; +import TextField from "@mui/material/TextField"; import { event } from "nextjs-google-analytics"; -import { AnalyticsEvents } from "@src/utils/analytics"; +import { useSnackbar } from "notistack"; + +import { MustConnect } from "@src/components/shared/MustConnect"; import { Popup } from "@src/components/shared/Popup"; import { Alert } from "@src/components/ui/alert"; -import { MustConnect } from "@src/components/shared/MustConnect"; -import TextField from "@mui/material/TextField"; -import { RadioGroup, RadioGroupItem } from "@src/components/ui/radio-group"; import { Label } from "@src/components/ui/label"; -import { useSnackbar } from "notistack"; +import { RadioGroup, RadioGroupItem } from "@src/components/ui/radio-group"; +import { useCustomUser } from "@src/hooks/useCustomUser"; +import { getShortText } from "@src/hooks/useShortText"; +import { useSaveUserTemplate } from "@src/queries/useTemplateQuery"; +import { EnvironmentVariable, ITemplate, SdlSaveTemplateFormValues, Service } from "@src/types"; +import { AnalyticsEvents } from "@src/utils/analytics"; import { Snackbar } from "../shared/Snackbar"; type Props = { diff --git a/apps/deploy-web/src/components/sdl/SignedByFormControl.tsx b/apps/deploy-web/src/components/sdl/SignedByFormControl.tsx index 14940a404..7aa373a87 100644 --- a/apps/deploy-web/src/components/sdl/SignedByFormControl.tsx +++ b/apps/deploy-web/src/components/sdl/SignedByFormControl.tsx @@ -1,12 +1,12 @@ "use client"; -import { ReactNode, useImperativeHandle, forwardRef } from "react"; +import { forwardRef, ReactNode, useImperativeHandle } from "react"; import { Control, Controller, useFieldArray } from "react-hook-form"; -import { SdlBuilderFormValues, SignedBy } from "@src/types"; -import { nanoid } from "nanoid"; -import { CustomTooltip } from "../shared/CustomTooltip"; -import { Card, CardContent } from "../ui/card"; import { Bin, InfoCircle } from "iconoir-react"; +import { nanoid } from "nanoid"; + +import { SdlBuilderFormValues, SignedBy } from "@src/types"; import { cn } from "@src/utils/styleUtils"; +import { CustomTooltip } from "../shared/CustomTooltip"; import { Button } from "../ui/button"; import { FormInput } from "../ui/input"; import { FormPaper } from "./FormPaper"; diff --git a/apps/deploy-web/src/components/sdl/SimpleSdlBuilderForm.tsx b/apps/deploy-web/src/components/sdl/SimpleSdlBuilderForm.tsx index c5739394d..02202fe9d 100644 --- a/apps/deploy-web/src/components/sdl/SimpleSdlBuilderForm.tsx +++ b/apps/deploy-web/src/components/sdl/SimpleSdlBuilderForm.tsx @@ -1,41 +1,40 @@ "use client"; -import { useForm, useFieldArray } from "react-hook-form"; import { useEffect, useRef, useState } from "react"; -import { nanoid } from "nanoid"; -import { ITemplate, SdlBuilderFormValues, Service } from "@src/types"; -import { generateSdl } from "@src/utils/sdl/sdlGenerator"; -import { defaultService } from "@src/utils/sdl/data"; -import { useRouter, useSearchParams } from "next/navigation"; +import { useFieldArray, useForm } from "react-hook-form"; import axios from "axios"; -import { importSimpleSdl } from "@src/utils/sdl/sdlImport"; +import { NavArrowRight } from "iconoir-react"; +import { useAtom } from "jotai"; +import { nanoid } from "nanoid"; import Link from "next/link"; -import { UrlService } from "@src/utils/urlUtils"; +import { useRouter, useSearchParams } from "next/navigation"; import { event } from "nextjs-google-analytics"; -import { AnalyticsEvents } from "@src/utils/analytics"; -import sdlStore from "@src/store/sdlStore"; -import { RouteStepKeys } from "@src/utils/constants"; -import { useAtom } from "jotai"; -import { useGpuModels } from "@src/queries/useGpuQuery"; -import { memoryUnits, storageUnits } from "@src/components/shared/akash/units"; +import { useSnackbar } from "notistack"; + import { SimpleServiceFormControl } from "@src/components/sdl/SimpleServiceFormControl"; -import { Button } from "@src/components/ui/button"; -import { Alert } from "@src/components/ui/alert"; +import { memoryUnits, storageUnits } from "@src/components/shared/akash/units"; import Spinner from "@src/components/shared/Spinner"; -import { NavArrowRight } from "iconoir-react"; +import { Alert } from "@src/components/ui/alert"; +import { Button } from "@src/components/ui/button"; +import useFormPersist from "@src/hooks/useFormPersist"; +import { useGpuModels } from "@src/queries/useGpuQuery"; +import sdlStore from "@src/store/sdlStore"; +import { ITemplate, SdlBuilderFormValues, Service } from "@src/types"; +import { AnalyticsEvents } from "@src/utils/analytics"; +import { RouteStepKeys } from "@src/utils/constants"; +import { defaultService } from "@src/utils/sdl/data"; +import { generateSdl } from "@src/utils/sdl/sdlGenerator"; +import { importSimpleSdl } from "@src/utils/sdl/sdlImport"; +import { UrlService } from "@src/utils/urlUtils"; +import { Snackbar } from "../shared/Snackbar"; import { ImportSdlModal } from "./ImportSdlModal"; import { PreviewSdl } from "./PreviewSdl"; import { SaveTemplateModal } from "./SaveTemplateModal"; -import { useSnackbar } from "notistack"; -import { Snackbar } from "../shared/Snackbar"; -import useFormPersist from "@src/hooks/useFormPersist"; - -type Props = {}; const DEFAULT_SERVICES = { services: [{ ...defaultService }] }; -export const SimpleSDLBuilderForm: React.FunctionComponent = ({}) => { +export const SimpleSDLBuilderForm: React.FunctionComponent = () => { const [error, setError] = useState(null); const [templateMetadata, setTemplateMetadata] = useState(null); const [serviceCollapsed, setServiceCollapsed] = useState([]); diff --git a/apps/deploy-web/src/components/sdl/SimpleServiceFormControl.tsx b/apps/deploy-web/src/components/sdl/SimpleServiceFormControl.tsx index 568d51493..9ce0a7743 100644 --- a/apps/deploy-web/src/components/sdl/SimpleServiceFormControl.tsx +++ b/apps/deploy-web/src/components/sdl/SimpleServiceFormControl.tsx @@ -1,38 +1,39 @@ "use client"; -import { Controller, Control, UseFormTrigger, UseFormSetValue } from "react-hook-form"; import { Dispatch, SetStateAction, useState } from "react"; +import { Control, Controller, UseFormSetValue, UseFormTrigger } from "react-hook-form"; +import { useTheme as useMuiTheme } from "@mui/material/styles"; +import useMediaQuery from "@mui/material/useMediaQuery"; +import { BinMinusIn, InfoCircle, NavArrowDown, OpenInWindow } from "iconoir-react"; +import Image from "next/legacy/image"; +import Link from "next/link"; + import { SdlBuilderFormValues, Service } from "@src/types"; -import { CommandFormModal } from "./CommandFormModal"; -import { EnvFormModal } from "./EnvFormModal"; -import { ExposeFormModal } from "./ExposeFormModal"; -import { FormPaper } from "./FormPaper"; -import { LeaseSpecDetail } from "../shared/LeaseSpecDetail"; -import { PlacementFormModal } from "./PlacementFormModal"; +import { GpuVendor } from "@src/types/gpu"; +import { uAktDenom } from "@src/utils/constants"; import { udenomToDenom } from "@src/utils/mathHelpers"; -import Link from "next/link"; -import { PriceValue } from "../shared/PriceValue"; import { getAvgCostPerMonth } from "@src/utils/priceUtils"; -import Image from "next/legacy/image"; -import { uAktDenom } from "@src/utils/constants"; -import { EnvVarList } from "./EnvVarList"; +import { cn } from "@src/utils/styleUtils"; +import { CustomTooltip } from "../shared/CustomTooltip"; +import { LeaseSpecDetail } from "../shared/LeaseSpecDetail"; +import { PriceValue } from "../shared/PriceValue"; +import { Button, buttonVariants } from "../ui/button"; +import { Card, CardContent } from "../ui/card"; +import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "../ui/collapsible"; +import { InputWithIcon } from "../ui/input"; +import { CommandFormModal } from "./CommandFormModal"; import { CommandList } from "./CommandList"; +import { CpuFormControl } from "./CpuFormControl"; +import { EnvFormModal } from "./EnvFormModal"; +import { EnvVarList } from "./EnvVarList"; +import { ExposeFormModal } from "./ExposeFormModal"; import { ExposeList } from "./ExposeList"; -import { PersistentStorage } from "./PersistentStorage"; +import { FormPaper } from "./FormPaper"; import { GpuFormControl } from "./GpuFormControl"; -import { CpuFormControl } from "./CpuFormControl"; import { MemoryFormControl } from "./MemoryFormControl"; +import { PersistentStorage } from "./PersistentStorage"; +import { PlacementFormModal } from "./PlacementFormModal"; import { StorageFormControl } from "./StorageFormControl"; import { TokenFormControl } from "./TokenFormControl"; -import { GpuVendor } from "@src/types/gpu"; -import { Card, CardContent } from "../ui/card"; -import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "../ui/collapsible"; -import { Button, buttonVariants } from "../ui/button"; -import { NavArrowDown, Bin, InfoCircle, OpenInWindow, BinMinusIn } from "iconoir-react"; -import { cn } from "@src/utils/styleUtils"; -import { InputWithIcon } from "../ui/input"; -import { CustomTooltip } from "../shared/CustomTooltip"; -import { useTheme as useMuiTheme } from "@mui/material/styles"; -import useMediaQuery from "@mui/material/useMediaQuery"; type Props = { _services: Service[]; @@ -81,7 +82,7 @@ export const SimpleServiceFormControl: React.FunctionComponent = ({ } }); }; - + if (!currentService) return null; return ( @@ -128,7 +129,7 @@ export const SimpleServiceFormControl: React.FunctionComponent = ({ rules={{ required: "Service name is required.", validate: value => { - const hasValidChars = /^[a-z0-9\-]+$/.test(value); + const hasValidChars = /^[a-z0-9-]+$/.test(value); const hasValidStartingChar = /^[a-z]/.test(value); const hasValidEndingChar = !value.endsWith("-"); diff --git a/apps/deploy-web/src/components/sdl/StorageFormControl.tsx b/apps/deploy-web/src/components/sdl/StorageFormControl.tsx index 89ddcd837..4b0ed3f3d 100644 --- a/apps/deploy-web/src/components/sdl/StorageFormControl.tsx +++ b/apps/deploy-web/src/components/sdl/StorageFormControl.tsx @@ -1,18 +1,19 @@ "use client"; import { ReactNode } from "react"; -import { RentGpusFormValues, SdlBuilderFormValues, Service } from "@src/types"; -import { CustomTooltip } from "../shared/CustomTooltip"; -import { FormPaper } from "./FormPaper"; import { Control, Controller } from "react-hook-form"; -import { validationConfig, storageUnits } from "../shared/akash/units"; -import { cn } from "@src/utils/styleUtils"; -import { FormControl, FormDescription, FormItem } from "../ui/form"; -import { Slider } from "../ui/slider"; -import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "../ui/select"; -import { Input } from "../ui/input"; import { MdStorage } from "react-icons/md"; import { InfoCircle } from "iconoir-react"; +import { RentGpusFormValues, SdlBuilderFormValues, Service } from "@src/types"; +import { cn } from "@src/utils/styleUtils"; +import { storageUnits, validationConfig } from "../shared/akash/units"; +import { CustomTooltip } from "../shared/CustomTooltip"; +import { FormDescription, FormItem } from "../ui/form"; +import { Input } from "../ui/input"; +import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "../ui/select"; +import { Slider } from "../ui/slider"; +import { FormPaper } from "./FormPaper"; + type Props = { serviceIndex: number; children?: ReactNode; @@ -20,15 +21,6 @@ type Props = { currentService: Service; }; -// const useStyles = makeStyles()(theme => ({ -// formControl: { -// marginBottom: theme.spacing(1.5) -// }, -// textField: { -// width: "100%" -// } -// })); - export const StorageFormControl: React.FunctionComponent = ({ control, serviceIndex, currentService }) => { return ( (({ control, serviceInd
    -
    +
    To (({ control, serviceInd } > - +
    diff --git a/apps/deploy-web/src/components/sdl/TokenFormControl.tsx b/apps/deploy-web/src/components/sdl/TokenFormControl.tsx index 7599d0adc..cb6a014bb 100644 --- a/apps/deploy-web/src/components/sdl/TokenFormControl.tsx +++ b/apps/deploy-web/src/components/sdl/TokenFormControl.tsx @@ -1,10 +1,9 @@ "use client"; import { ReactElement } from "react"; -import { makeStyles } from "tss-react/mui"; -import { Control, Controller, FieldValues, FieldPathValue, Path } from "react-hook-form"; +import { Control, Controller, FieldPathValue, FieldValues, Path } from "react-hook-form"; -import { Service } from "@src/types"; import { useSdlDenoms } from "@src/hooks/useDenom"; +import { Service } from "@src/types"; import { FormItem } from "../ui/form"; import { Label } from "../ui/label"; import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "../ui/select"; @@ -30,7 +29,7 @@ export const TokenFormControl = ({ control, name, rules={{ required: true }} - render={({ fieldState, field }) => { + render={({ field }) => { return ( = ({}) => { +export const CertificateList: React.FunctionComponent = () => { const { validCertificates, localCert, selectedCertificate, revokeCertificate, revokeAllCertificates, isLoadingCertificates } = useCertificate(); const { address } = useWallet(); diff --git a/apps/deploy-web/src/components/settings/ColorModeSelect.tsx b/apps/deploy-web/src/components/settings/ColorModeSelect.tsx index 39fc1a53d..fa7c39e20 100644 --- a/apps/deploy-web/src/components/settings/ColorModeSelect.tsx +++ b/apps/deploy-web/src/components/settings/ColorModeSelect.tsx @@ -1,12 +1,11 @@ import React, { useEffect, useState } from "react"; import { useTheme } from "next-themes"; + import { FormItem } from "@src/components/ui/form"; import { Label } from "@src/components/ui/label"; import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "@src/components/ui/select"; -type Props = {}; - -export const ColorModeSelect: React.FunctionComponent = () => { +export const ColorModeSelect: React.FunctionComponent = () => { const { setTheme, theme } = useTheme(); const [mounted, setMounted] = useState(false); diff --git a/apps/deploy-web/src/components/settings/ExportCertificate.tsx b/apps/deploy-web/src/components/settings/ExportCertificate.tsx index 1acf80658..bd2d994e3 100644 --- a/apps/deploy-web/src/components/settings/ExportCertificate.tsx +++ b/apps/deploy-web/src/components/settings/ExportCertificate.tsx @@ -1,11 +1,12 @@ "use client"; import { useEffect } from "react"; -import { useSelectedWalletFromStorage } from "@src/utils/walletUtils"; import { event } from "nextjs-google-analytics"; -import { AnalyticsEvents } from "@src/utils/analytics"; + +import { CodeSnippet } from "@src/components/shared/CodeSnippet"; import { Popup } from "@src/components/shared/Popup"; import { Alert } from "@src/components/ui/alert"; -import { CodeSnippet } from "@src/components/shared/CodeSnippet"; +import { AnalyticsEvents } from "@src/utils/analytics"; +import { useSelectedWalletFromStorage } from "@src/utils/walletUtils"; export function ExportCertificate({ isOpen, onClose }: React.PropsWithChildren<{ isOpen: boolean; onClose: () => void }>) { const selectedWallet = useSelectedWalletFromStorage(); @@ -46,7 +47,7 @@ export function ExportCertificate({ isOpen, onClose }: React.PropsWithChildren<{
    -

    Key

    +

    Key

    ) : ( diff --git a/apps/deploy-web/src/components/settings/LocalDataManager/LocalDataManager.container.tsx b/apps/deploy-web/src/components/settings/LocalDataManager/LocalDataManager.container.tsx index 773f013fc..f5856cc71 100644 --- a/apps/deploy-web/src/components/settings/LocalDataManager/LocalDataManager.container.tsx +++ b/apps/deploy-web/src/components/settings/LocalDataManager/LocalDataManager.container.tsx @@ -1,6 +1,7 @@ -import { LocalData, LocalDataManagerComponent } from "./LocalDataManager.component"; import React, { useCallback } from "react"; +import { LocalData, LocalDataManagerComponent } from "./LocalDataManager.component"; + export const LocalDataManagerContainer = () => { const importLocalData = useCallback((data: LocalData) => { Object.keys(data).forEach(key => { diff --git a/apps/deploy-web/src/components/settings/SelectNetworkModal.tsx b/apps/deploy-web/src/components/settings/SelectNetworkModal.tsx index d7f3bd8c3..a250e2fa1 100644 --- a/apps/deploy-web/src/components/settings/SelectNetworkModal.tsx +++ b/apps/deploy-web/src/components/settings/SelectNetworkModal.tsx @@ -1,14 +1,15 @@ "use client"; -import { mainnetId } from "@src/utils/constants"; import { useState } from "react"; -import { networks } from "@src/store/networkStore"; -import { cn } from "@src/utils/styleUtils"; -import { useSettings } from "@src/context/SettingsProvider"; + import { Popup } from "@src/components/shared/Popup"; -import { RadioGroup, RadioGroupItem } from "@src/components/ui/radio-group"; -import { buttonVariants } from "@src/components/ui/button"; -import { Badge } from "@src/components/ui/badge"; import { Alert, AlertDescription, AlertTitle } from "@src/components/ui/alert"; +import { Badge } from "@src/components/ui/badge"; +import { buttonVariants } from "@src/components/ui/button"; +import { RadioGroup, RadioGroupItem } from "@src/components/ui/radio-group"; +import { useSettings } from "@src/context/SettingsProvider"; +import { networks } from "@src/store/networkStore"; +import { mainnetId } from "@src/utils/constants"; +import { cn } from "@src/utils/styleUtils"; export const SelectNetworkModal = ({ onClose }) => { const { selectedNetworkId } = useSettings(); diff --git a/apps/deploy-web/src/components/settings/SettingsContainer.tsx b/apps/deploy-web/src/components/settings/SettingsContainer.tsx index 4c3b3816c..89215a158 100644 --- a/apps/deploy-web/src/components/settings/SettingsContainer.tsx +++ b/apps/deploy-web/src/components/settings/SettingsContainer.tsx @@ -1,22 +1,21 @@ "use client"; -import { Fieldset } from "@src/components/shared/Fieldset"; import { useState } from "react"; -import { useSelectedNetwork } from "@src/hooks/useSelectedNetwork"; +import { Edit } from "iconoir-react"; +import { NextSeo } from "next-seo"; + +import { LocalDataManager } from "@src/components/settings/LocalDataManager"; +import { Fieldset } from "@src/components/shared/Fieldset"; import { LabelValue } from "@src/components/shared/LabelValue"; import { Button } from "@src/components/ui/button"; -import { Edit } from "iconoir-react"; -import { CertificateList } from "./CertificateList"; +import { useSelectedNetwork } from "@src/hooks/useSelectedNetwork"; import Layout from "../layout/Layout"; -import { SettingsLayout, SettingsTabs } from "./SettingsLayout"; +import { CertificateList } from "./CertificateList"; +import { ColorModeSelect } from "./ColorModeSelect"; import { SelectNetworkModal } from "./SelectNetworkModal"; import { SettingsForm } from "./SettingsForm"; -import { ColorModeSelect } from "./ColorModeSelect"; -import { NextSeo } from "next-seo"; -import { LocalDataManager } from "@src/components/settings/LocalDataManager"; - -type Props = {}; +import { SettingsLayout, SettingsTabs } from "./SettingsLayout"; -export const SettingsContainer: React.FunctionComponent = ({}) => { +export const SettingsContainer: React.FunctionComponent = () => { const [isSelectingNetwork, setIsSelectingNetwork] = useState(false); const selectedNetwork = useSelectedNetwork(); diff --git a/apps/deploy-web/src/components/settings/SettingsForm.tsx b/apps/deploy-web/src/components/settings/SettingsForm.tsx index 51ba6dd0b..0c96d71c4 100644 --- a/apps/deploy-web/src/components/settings/SettingsForm.tsx +++ b/apps/deploy-web/src/components/settings/SettingsForm.tsx @@ -1,25 +1,24 @@ "use client"; -import { useState, useRef } from "react"; +import { useRef, useState } from "react"; import { Controller, useForm } from "react-hook-form"; -import { NodeStatus } from "@src/components/shared/NodeStatus"; -import { isUrl } from "@src/utils/stringUtils"; -import { BlockchainNode, useSettings } from "@src/context/SettingsProvider/SettingsProviderContext"; -import { SwitchWithLabel } from "@src/components/ui/switch"; -import { Label } from "@src/components/ui/label"; -import FormControl from "@mui/material/FormControl"; -import { Button } from "@src/components/ui/button"; -import ClickAwayListener from "@mui/material/ClickAwayListener"; import Autocomplete from "@mui/material/Autocomplete"; -import TextField from "@mui/material/TextField"; +import ClickAwayListener from "@mui/material/ClickAwayListener"; +import FormControl from "@mui/material/FormControl"; import FormGroup from "@mui/material/FormGroup"; -import Spinner from "@src/components/shared/Spinner"; -import { NavArrowDown, Refresh } from "iconoir-react"; -import { cn } from "@src/utils/styleUtils"; import InputAdornment from "@mui/material/InputAdornment"; +import TextField from "@mui/material/TextField"; +import { NavArrowDown, Refresh } from "iconoir-react"; -type Props = {}; +import { NodeStatus } from "@src/components/shared/NodeStatus"; +import Spinner from "@src/components/shared/Spinner"; +import { Button } from "@src/components/ui/button"; +import { Label } from "@src/components/ui/label"; +import { SwitchWithLabel } from "@src/components/ui/switch"; +import { BlockchainNode, useSettings } from "@src/context/SettingsProvider/SettingsProviderContext"; +import { isUrl } from "@src/utils/stringUtils"; +import { cn } from "@src/utils/styleUtils"; -export const SettingsForm: React.FunctionComponent = ({}) => { +export const SettingsForm: React.FunctionComponent = () => { const [isEditing, setIsEditing] = useState(false); const [isNodesOpen, setIsNodesOpen] = useState(false); const { settings, setSettings, refreshNodeStatuses, isRefreshingNodeStatus } = useSettings(); diff --git a/apps/deploy-web/src/components/settings/SettingsLayout.tsx b/apps/deploy-web/src/components/settings/SettingsLayout.tsx index b7cc21d74..73f1e463d 100644 --- a/apps/deploy-web/src/components/settings/SettingsLayout.tsx +++ b/apps/deploy-web/src/components/settings/SettingsLayout.tsx @@ -1,11 +1,12 @@ "use client"; import React, { ReactNode } from "react"; import { ErrorBoundary } from "react-error-boundary"; -import { UrlService } from "@src/utils/urlUtils"; import { useRouter } from "next/navigation"; + import { ErrorFallback } from "@src/components/shared/ErrorFallback"; import { Tabs, TabsList, TabsTrigger } from "@src/components/ui/tabs"; import { cn } from "@src/utils/styleUtils"; +import { UrlService } from "@src/utils/urlUtils"; import { Title } from "../shared/Title"; export enum SettingsTabs { diff --git a/apps/deploy-web/src/components/shared/AKTAmount.tsx b/apps/deploy-web/src/components/shared/AKTAmount.tsx index 363f28b4a..f8a26265e 100644 --- a/apps/deploy-web/src/components/shared/AKTAmount.tsx +++ b/apps/deploy-web/src/components/shared/AKTAmount.tsx @@ -1,9 +1,10 @@ "use client"; -import { FormattedNumber, FormattedNumberParts } from "react-intl"; import React from "react"; -import { AKTLabel } from "./AKTLabel"; -import { udenomToDenom } from "@src/utils/mathHelpers"; +import { FormattedNumber, FormattedNumberParts } from "react-intl"; + import { usePricing } from "@src/context/PricingProvider"; +import { udenomToDenom } from "@src/utils/mathHelpers"; +import { AKTLabel } from "./AKTLabel"; type Props = { uakt: number; diff --git a/apps/deploy-web/src/components/shared/AKTLabel.tsx b/apps/deploy-web/src/components/shared/AKTLabel.tsx index 5788689b8..4f44715d6 100644 --- a/apps/deploy-web/src/components/shared/AKTLabel.tsx +++ b/apps/deploy-web/src/components/shared/AKTLabel.tsx @@ -1,8 +1,6 @@ "use client"; import React from "react"; -type Props = {}; - -export const AKTLabel: React.FunctionComponent = ({}) => { +export const AKTLabel: React.FunctionComponent = () => { return AKT; }; diff --git a/apps/deploy-web/src/components/shared/Address.tsx b/apps/deploy-web/src/components/shared/Address.tsx index e78a310a0..27f97981b 100644 --- a/apps/deploy-web/src/components/shared/Address.tsx +++ b/apps/deploy-web/src/components/shared/Address.tsx @@ -1,10 +1,11 @@ "use client"; import React, { ReactNode, useState } from "react"; import { Copy } from "iconoir-react"; +import { useSnackbar } from "notistack"; + import { copyTextToClipboard } from "@src/utils/copyClipboard"; import { cn } from "@src/utils/styleUtils"; import { CustomTooltip } from "./CustomTooltip"; -import { useSnackbar } from "notistack"; import { Snackbar } from "./Snackbar"; type Props = { @@ -19,7 +20,7 @@ type Props = { export const Address: React.FunctionComponent = ({ address, isCopyable, disableTruncate, disableTooltip, showIcon, ...rest }) => { const [isOver, setIsOver] = useState(false); const { enqueueSnackbar } = useSnackbar(); - let formattedAddress = disableTruncate ? address : [address?.slice(0, 8), "...", address?.slice(address?.length - 5)].join(""); + const formattedAddress = disableTruncate ? address : [address?.slice(0, 8), "...", address?.slice(address?.length - 5)].join(""); const onClick = (event: React.MouseEvent) => { if (isCopyable) { diff --git a/apps/deploy-web/src/components/shared/AddressLink.tsx b/apps/deploy-web/src/components/shared/AddressLink.tsx index 20aaca928..bf23c6098 100644 --- a/apps/deploy-web/src/components/shared/AddressLink.tsx +++ b/apps/deploy-web/src/components/shared/AddressLink.tsx @@ -1,6 +1,7 @@ "use client"; import React, { ReactNode } from "react"; import Link from "next/link"; + import { Address } from "./Address"; type Props = { diff --git a/apps/deploy-web/src/components/shared/CodeSnippet.tsx b/apps/deploy-web/src/components/shared/CodeSnippet.tsx index f271efb06..b00dc51b5 100644 --- a/apps/deploy-web/src/components/shared/CodeSnippet.tsx +++ b/apps/deploy-web/src/components/shared/CodeSnippet.tsx @@ -1,10 +1,11 @@ "use client"; import { useRef } from "react"; +import { Copy } from "iconoir-react"; +import { useSnackbar } from "notistack"; + import { copyTextToClipboard } from "@src/utils/copyClipboard"; import { selectText } from "@src/utils/stringUtils"; import { Button } from "../ui/button"; -import { Copy } from "iconoir-react"; -import { useSnackbar } from "notistack"; import { Snackbar } from "./Snackbar"; export const CodeSnippet = ({ code }: React.PropsWithChildren<{ code: string }>) => { diff --git a/apps/deploy-web/src/components/shared/ConnectWallet.tsx b/apps/deploy-web/src/components/shared/ConnectWallet.tsx index b7d31b760..4ab0f05de 100644 --- a/apps/deploy-web/src/components/shared/ConnectWallet.tsx +++ b/apps/deploy-web/src/components/shared/ConnectWallet.tsx @@ -1,5 +1,6 @@ "use client"; import React, { ReactNode } from "react"; + import { WalletStatus } from "../layout/WalletStatus"; import { Title } from "./Title"; @@ -11,7 +12,9 @@ type Props = { export const ConnectWallet: React.FunctionComponent = ({ text }) => { return (
    - {text} + + {text} +
    ); diff --git a/apps/deploy-web/src/components/shared/CustomDropdownLinkItem.tsx b/apps/deploy-web/src/components/shared/CustomDropdownLinkItem.tsx index 4e556c59a..7baede801 100644 --- a/apps/deploy-web/src/components/shared/CustomDropdownLinkItem.tsx +++ b/apps/deploy-web/src/components/shared/CustomDropdownLinkItem.tsx @@ -1,7 +1,8 @@ "use client"; import React from "react"; -import { DropdownMenuIconItem } from "../ui/dropdown-menu"; + import { cn } from "@src/utils/styleUtils"; +import { DropdownMenuIconItem } from "../ui/dropdown-menu"; type Props = { icon?: string | React.ReactNode; diff --git a/apps/deploy-web/src/components/shared/CustomNextSeo.tsx b/apps/deploy-web/src/components/shared/CustomNextSeo.tsx index 3ec70297f..16f701bec 100644 --- a/apps/deploy-web/src/components/shared/CustomNextSeo.tsx +++ b/apps/deploy-web/src/components/shared/CustomNextSeo.tsx @@ -1,6 +1,6 @@ +import React from "react"; import { NextSeo } from "next-seo"; import { OpenGraphMedia } from "next-seo/lib/types"; -import React from "react"; type Props = { title: string; diff --git a/apps/deploy-web/src/components/shared/CustomTooltip.tsx b/apps/deploy-web/src/components/shared/CustomTooltip.tsx index 652576f39..95447211b 100644 --- a/apps/deploy-web/src/components/shared/CustomTooltip.tsx +++ b/apps/deploy-web/src/components/shared/CustomTooltip.tsx @@ -1,7 +1,8 @@ "use client"; +import * as TooltipPrimitive from "@radix-ui/react-tooltip"; + import { cn } from "@src/utils/styleUtils"; import { Tooltip, TooltipContent, TooltipTrigger } from "../ui/tooltip"; -import * as TooltipPrimitive from "@radix-ui/react-tooltip"; export function CustomTooltip({ children, className = "", title }: React.PropsWithChildren<{ className?: string; title: string | React.ReactNode }>) { return ( diff --git a/apps/deploy-web/src/components/shared/DiffPercentageChip.tsx b/apps/deploy-web/src/components/shared/DiffPercentageChip.tsx index 8abcd898d..31fb263e9 100644 --- a/apps/deploy-web/src/components/shared/DiffPercentageChip.tsx +++ b/apps/deploy-web/src/components/shared/DiffPercentageChip.tsx @@ -1,7 +1,8 @@ "use client"; import React from "react"; import { FormattedNumber } from "react-intl"; -import { ArrowUp, ArrowDown } from "iconoir-react"; +import { ArrowDown, ArrowUp } from "iconoir-react"; + import { cn } from "@src/utils/styleUtils"; export interface DiffPercentageChipProps { diff --git a/apps/deploy-web/src/components/shared/DynamicJsonView.tsx b/apps/deploy-web/src/components/shared/DynamicJsonView.tsx index 6c54a894d..5800153ea 100644 --- a/apps/deploy-web/src/components/shared/DynamicJsonView.tsx +++ b/apps/deploy-web/src/components/shared/DynamicJsonView.tsx @@ -1,6 +1,7 @@ "use client"; -import { useTheme } from "next-themes"; import dynamic from "next/dynamic"; +import { useTheme } from "next-themes"; + import Spinner from "./Spinner"; const _DynamicReactJson = dynamic(() => import("@textea/json-viewer").then(module => module.JsonViewer), { diff --git a/apps/deploy-web/src/components/shared/DynamicMonacoEditor.tsx b/apps/deploy-web/src/components/shared/DynamicMonacoEditor.tsx index b6f9e589c..91a06234a 100644 --- a/apps/deploy-web/src/components/shared/DynamicMonacoEditor.tsx +++ b/apps/deploy-web/src/components/shared/DynamicMonacoEditor.tsx @@ -1,9 +1,10 @@ "use client"; -import { monacoOptions } from "@src/utils/constants"; -import dynamic from "next/dynamic"; import { OnChange, OnMount } from "@monaco-editor/react"; +import dynamic from "next/dynamic"; import { useTheme } from "next-themes"; +import { monacoOptions } from "@src/utils/constants"; + const _DynamicMonacoEditor = dynamic(() => import("@monaco-editor/react"), { ssr: false, loading: () =>
    Loading...
    }); type Props = { diff --git a/apps/deploy-web/src/components/shared/ErrorFallback.tsx b/apps/deploy-web/src/components/shared/ErrorFallback.tsx index 84e358198..46cc265cb 100644 --- a/apps/deploy-web/src/components/shared/ErrorFallback.tsx +++ b/apps/deploy-web/src/components/shared/ErrorFallback.tsx @@ -1,6 +1,7 @@ "use client"; import { ReactNode } from "react"; import { FallbackProps } from "react-error-boundary"; + import { Alert, AlertTitle } from "../ui/alert"; import { Button } from "../ui/button"; @@ -10,7 +11,7 @@ interface Props extends FallbackProps { export const ErrorFallback: React.FunctionComponent = ({ error, resetErrorBoundary }) => { return ( -
    +

    Something went wrong

    diff --git a/apps/deploy-web/src/components/shared/ExpandMore.tsx b/apps/deploy-web/src/components/shared/ExpandMore.tsx index 90385c763..0ec995714 100644 --- a/apps/deploy-web/src/components/shared/ExpandMore.tsx +++ b/apps/deploy-web/src/components/shared/ExpandMore.tsx @@ -1,7 +1,8 @@ "use client"; -import { cn } from "@src/utils/styleUtils"; import { ArrowDown } from "iconoir-react"; +import { cn } from "@src/utils/styleUtils"; + interface ExpandMoreProps { expand: boolean; className?: string; diff --git a/apps/deploy-web/src/components/shared/FavoriteButton.tsx b/apps/deploy-web/src/components/shared/FavoriteButton.tsx index 9e7137d0b..3c67468e3 100644 --- a/apps/deploy-web/src/components/shared/FavoriteButton.tsx +++ b/apps/deploy-web/src/components/shared/FavoriteButton.tsx @@ -1,5 +1,6 @@ "use client"; import { Star, StarSolid } from "iconoir-react"; + import { Button } from "../ui/button"; export const FavoriteButton = ({ onClick, isFavorite }) => { diff --git a/apps/deploy-web/src/components/shared/Fieldset.tsx b/apps/deploy-web/src/components/shared/Fieldset.tsx index 846e38982..e11307992 100644 --- a/apps/deploy-web/src/components/shared/Fieldset.tsx +++ b/apps/deploy-web/src/components/shared/Fieldset.tsx @@ -1,5 +1,6 @@ "use client"; import React from "react"; + import { Card, CardContent, CardHeader } from "../ui/card"; type Props = { diff --git a/apps/deploy-web/src/components/shared/FormattedDecimal.tsx b/apps/deploy-web/src/components/shared/FormattedDecimal.tsx index a67bb47cc..1fdcf257a 100644 --- a/apps/deploy-web/src/components/shared/FormattedDecimal.tsx +++ b/apps/deploy-web/src/components/shared/FormattedDecimal.tsx @@ -1,6 +1,6 @@ "use client"; -import { FormattedNumberParts } from "react-intl"; import React from "react"; +import { FormattedNumberParts } from "react-intl"; type Props = { value: number; @@ -23,7 +23,7 @@ export const FormattedDecimal: React.FunctionComponent = ({ value, precis case "decimal": case "fraction": return ( - + {part.value} ); diff --git a/apps/deploy-web/src/components/shared/FormattedDecimalCurrency.tsx b/apps/deploy-web/src/components/shared/FormattedDecimalCurrency.tsx index 97ca8b573..e13728546 100644 --- a/apps/deploy-web/src/components/shared/FormattedDecimalCurrency.tsx +++ b/apps/deploy-web/src/components/shared/FormattedDecimalCurrency.tsx @@ -1,6 +1,6 @@ "use client"; -import { FormattedNumberParts } from "react-intl"; import React from "react"; +import { FormattedNumberParts } from "react-intl"; type Props = { value: number; diff --git a/apps/deploy-web/src/components/shared/HumanReadableBytes.tsx b/apps/deploy-web/src/components/shared/HumanReadableBytes.tsx index 28c71fd00..356937cbb 100644 --- a/apps/deploy-web/src/components/shared/HumanReadableBytes.tsx +++ b/apps/deploy-web/src/components/shared/HumanReadableBytes.tsx @@ -1,8 +1,9 @@ "use client"; -import { bytesToShrink } from "@src/utils/unitUtils"; import React from "react"; import { FormattedNumber } from "react-intl"; +import { bytesToShrink } from "@src/utils/unitUtils"; + export interface HumanReadableBytesProps { value: number; } diff --git a/apps/deploy-web/src/components/shared/LabelValueOld.tsx b/apps/deploy-web/src/components/shared/LabelValueOld.tsx index 2caf87e22..e62a43793 100644 --- a/apps/deploy-web/src/components/shared/LabelValueOld.tsx +++ b/apps/deploy-web/src/components/shared/LabelValueOld.tsx @@ -1,7 +1,8 @@ "use client"; -import { cn } from "@src/utils/styleUtils"; import { ReactNode } from "react"; +import { cn } from "@src/utils/styleUtils"; + type Props = { label: string; value?: string | ReactNode; diff --git a/apps/deploy-web/src/components/shared/LeaseSpecDetail.tsx b/apps/deploy-web/src/components/shared/LeaseSpecDetail.tsx index 0d9a7bba5..0bab714b4 100644 --- a/apps/deploy-web/src/components/shared/LeaseSpecDetail.tsx +++ b/apps/deploy-web/src/components/shared/LeaseSpecDetail.tsx @@ -1,7 +1,8 @@ "use client"; import React from "react"; +import { MdDeveloperBoard, MdMemory, MdSpeed, MdStorage } from "react-icons/md"; import { FormattedNumber } from "react-intl"; -import { MdMemory, MdStorage, MdSpeed, MdDeveloperBoard } from "react-icons/md"; + import { cn } from "@src/utils/styleUtils"; type SpecType = "cpu" | "gpu" | "ram" | "storage"; diff --git a/apps/deploy-web/src/components/shared/LinkTo.tsx b/apps/deploy-web/src/components/shared/LinkTo.tsx index da973c677..30b426f70 100644 --- a/apps/deploy-web/src/components/shared/LinkTo.tsx +++ b/apps/deploy-web/src/components/shared/LinkTo.tsx @@ -1,8 +1,9 @@ "use client"; -import { cn } from "@src/utils/styleUtils"; import React from "react"; -export function LinkTo({ children, className = "", ...rest }: React.PropsWithChildren<{ className?: string } & React.ButtonHTMLAttributes<{}>>) { +import { cn } from "@src/utils/styleUtils"; + +export function LinkTo({ children, className = "", ...rest }: React.PropsWithChildren<{ className?: string } & React.ButtonHTMLAttributes>) { return (