diff --git a/apps/web/package.json b/apps/web/package.json index 9a4f10a91080..b475cc878c37 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -24,6 +24,7 @@ "@hey/ui": "workspace:*", "@lens-network/sdk": "canary", "@lens-protocol/metadata": "next", + "@lens-protocol/storage-node-client": "^0.0.2", "@livepeer/react": "^4.2.9", "@next/bundle-analyzer": "^15.0.4", "@radix-ui/react-hover-card": "^1.1.2", diff --git a/apps/web/src/components/Composer/NewPublication.tsx b/apps/web/src/components/Composer/NewPublication.tsx index dad3b8dc8162..90219341b4f7 100644 --- a/apps/web/src/components/Composer/NewPublication.tsx +++ b/apps/web/src/components/Composer/NewPublication.tsx @@ -4,7 +4,7 @@ import { AudioPostSchema } from "@components/Shared/Audio"; import Wrapper from "@components/Shared/Embed/Wrapper"; import errorToast from "@helpers/errorToast"; import uploadMetadata from "@helpers/uploadMetadata"; -import { KNOWN_ATTRIBUTES, METADATA_ENDPOINT } from "@hey/data/constants"; +import { KNOWN_ATTRIBUTES } from "@hey/data/constants"; import { Errors } from "@hey/data/errors"; import collectModuleParams from "@hey/helpers/collectModuleParams"; import getAccount from "@hey/helpers/getAccount"; @@ -261,12 +261,12 @@ const NewPublication: FC = ({ className, post }) => { }; const metadata = getMetadata({ baseMetadata }); - const metadataId = await uploadMetadata(metadata); + const contentUri = await uploadMetadata(metadata); return await createPost({ variables: { request: { - contentUri: `${METADATA_ENDPOINT}/${metadataId}`, + contentUri, ...(isComment && { commentOn: { post: post?.id } }), ...(isQuote && { quoteOf: { post: quotedPost?.id } }), ...(collectModule.type && { diff --git a/apps/web/src/components/Settings/Profile/Account.tsx b/apps/web/src/components/Settings/Profile/Account.tsx index 5d30a7208d51..082b11901025 100644 --- a/apps/web/src/components/Settings/Profile/Account.tsx +++ b/apps/web/src/components/Settings/Profile/Account.tsx @@ -4,12 +4,7 @@ import uploadCroppedImage, { readFile } from "@helpers/accountPictureUtils"; import errorToast from "@helpers/errorToast"; import uploadMetadata from "@helpers/uploadMetadata"; import { InformationCircleIcon } from "@heroicons/react/24/outline"; -import { - AVATAR, - COVER, - METADATA_ENDPOINT, - STATIC_IMAGES_URL -} from "@hey/data/constants"; +import { AVATAR, COVER, STATIC_IMAGES_URL } from "@hey/data/constants"; import { Errors } from "@hey/data/errors"; import { Regex } from "@hey/data/regex"; import getAccountAttribute from "@hey/helpers/getAccountAttribute"; @@ -233,12 +228,10 @@ const AccountSettingsForm: FC = () => { return m.key !== "" && Boolean(trimify(m.value)); }); const metadata = accountMetadata(preparedAccountMetadata); - const metadataId = await uploadMetadata(metadata); + const metadataUri = await uploadMetadata(metadata); return await setAccountMetadata({ - variables: { - request: { metadataUri: `${METADATA_ENDPOINT}/${metadataId}` } - } + variables: { request: { metadataUri } } }); } catch (error) { onError(error); diff --git a/apps/web/src/components/Shared/Auth/Signup/ChooseUsername.tsx b/apps/web/src/components/Shared/Auth/Signup/ChooseUsername.tsx index b562483f75ed..d2ee6275c53c 100644 --- a/apps/web/src/components/Shared/Auth/Signup/ChooseUsername.tsx +++ b/apps/web/src/components/Shared/Auth/Signup/ChooseUsername.tsx @@ -6,7 +6,7 @@ import { FaceFrownIcon, FaceSmileIcon } from "@heroicons/react/24/outline"; -import { APP_NAME, METADATA_ENDPOINT } from "@hey/data/constants"; +import { APP_NAME } from "@hey/data/constants"; import { Errors } from "@hey/data/errors"; import { Regex } from "@hey/data/regex"; import { @@ -101,14 +101,14 @@ const ChooseUsername: FC = () => { if (auth.data?.authenticate.__typename === "AuthenticationTokens") { const accessToken = auth.data?.authenticate.accessToken; const metadata = accountMetadata({ name: username }); - const metadataId = await uploadMetadata(metadata); + const metadataUri = await uploadMetadata(metadata); return await createAccountWithUsername({ context: { headers: { "X-Access-Token": accessToken } }, variables: { request: { username: { localName: username.toLowerCase() }, - metadataUri: `${METADATA_ENDPOINT}/${metadataId}` + metadataUri } }, onCompleted: ({ createAccountWithUsername }) => { diff --git a/apps/web/src/helpers/uploadMetadata.ts b/apps/web/src/helpers/uploadMetadata.ts index 25cb1a4bb5c7..ccaff41cf4f3 100644 --- a/apps/web/src/helpers/uploadMetadata.ts +++ b/apps/web/src/helpers/uploadMetadata.ts @@ -1,4 +1,3 @@ -import { HEY_API_URL } from "@hey/data/constants"; import { Errors } from "@hey/data/errors"; import axios from "axios"; import toast from "react-hot-toast"; @@ -12,12 +11,14 @@ import toast from "react-hot-toast"; */ const uploadMetadata = async (data: any): Promise => { try { - const response = await axios.post(`${HEY_API_URL}/metadata`, { - ...data - }); - const { id }: { id: string } = response.data; + const response = await axios.post( + "https://storage-api.testnet.lens.dev", + data + ); - return id; + const { uri } = response.data[0]; + + return uri; } catch { toast.error(Errors.SomethingWentWrong); throw new Error(Errors.SomethingWentWrong); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f1433394e784..441fade17948 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -288,6 +288,9 @@ importers: '@lens-protocol/metadata': specifier: next version: 2.0.0-next.1(zod@3.23.8) + '@lens-protocol/storage-node-client': + specifier: ^0.0.2 + version: 0.0.2 '@livepeer/react': specifier: ^4.2.9 version: 4.2.9(@types/react-dom@19.0.1)(@types/react@19.0.1)(immer@10.1.1)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) @@ -2148,6 +2151,9 @@ packages: zod: optional: true + '@lens-protocol/storage-node-client@0.0.2': + resolution: {integrity: sha512-Miza+o4MMAiQZQ5wowthMjCv21fV94+3825r/E9Mh0lVEcj7RL0cgHWXAxEUQTko+lI6633EKPw4jjnpWzxvlw==} + '@lit-labs/ssr-dom-shim@1.2.1': resolution: {integrity: sha512-wx4aBmgeGvFmOKucFKY+8VFJSYZxs9poN3SDNQFF6lT6NrQUnHiPB2PWz2sc4ieEcAaYYzN+1uWahEeTq2aRIQ==} @@ -10052,6 +10058,8 @@ snapshots: optionalDependencies: zod: 3.23.8 + '@lens-protocol/storage-node-client@0.0.2': {} + '@lit-labs/ssr-dom-shim@1.2.1': {} '@lit/reactive-element@1.6.3':