Skip to content

Commit 0d0ad14

Browse files
committed
Migrate to Lens v3
1 parent af8fb77 commit 0d0ad14

File tree

6 files changed

+25
-22
lines changed

6 files changed

+25
-22
lines changed

apps/web/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"@hey/ui": "workspace:*",
2525
"@lens-network/sdk": "canary",
2626
"@lens-protocol/metadata": "next",
27+
"@lens-protocol/storage-node-client": "^0.0.2",
2728
"@livepeer/react": "^4.2.9",
2829
"@next/bundle-analyzer": "^15.0.4",
2930
"@radix-ui/react-hover-card": "^1.1.2",

apps/web/src/components/Composer/NewPublication.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { AudioPostSchema } from "@components/Shared/Audio";
44
import Wrapper from "@components/Shared/Embed/Wrapper";
55
import errorToast from "@helpers/errorToast";
66
import uploadMetadata from "@helpers/uploadMetadata";
7-
import { KNOWN_ATTRIBUTES, METADATA_ENDPOINT } from "@hey/data/constants";
7+
import { KNOWN_ATTRIBUTES } from "@hey/data/constants";
88
import { Errors } from "@hey/data/errors";
99
import collectModuleParams from "@hey/helpers/collectModuleParams";
1010
import getAccount from "@hey/helpers/getAccount";
@@ -261,12 +261,12 @@ const NewPublication: FC<NewPublicationProps> = ({ className, post }) => {
261261
};
262262

263263
const metadata = getMetadata({ baseMetadata });
264-
const metadataId = await uploadMetadata(metadata);
264+
const contentUri = await uploadMetadata(metadata);
265265

266266
return await createPost({
267267
variables: {
268268
request: {
269-
contentUri: `${METADATA_ENDPOINT}/${metadataId}`,
269+
contentUri,
270270
...(isComment && { commentOn: { post: post?.id } }),
271271
...(isQuote && { quoteOf: { post: quotedPost?.id } }),
272272
...(collectModule.type && {

apps/web/src/components/Settings/Profile/Account.tsx

+3-10
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@ import uploadCroppedImage, { readFile } from "@helpers/accountPictureUtils";
44
import errorToast from "@helpers/errorToast";
55
import uploadMetadata from "@helpers/uploadMetadata";
66
import { InformationCircleIcon } from "@heroicons/react/24/outline";
7-
import {
8-
AVATAR,
9-
COVER,
10-
METADATA_ENDPOINT,
11-
STATIC_IMAGES_URL
12-
} from "@hey/data/constants";
7+
import { AVATAR, COVER, STATIC_IMAGES_URL } from "@hey/data/constants";
138
import { Errors } from "@hey/data/errors";
149
import { Regex } from "@hey/data/regex";
1510
import getAccountAttribute from "@hey/helpers/getAccountAttribute";
@@ -233,12 +228,10 @@ const AccountSettingsForm: FC = () => {
233228
return m.key !== "" && Boolean(trimify(m.value));
234229
});
235230
const metadata = accountMetadata(preparedAccountMetadata);
236-
const metadataId = await uploadMetadata(metadata);
231+
const metadataUri = await uploadMetadata(metadata);
237232

238233
return await setAccountMetadata({
239-
variables: {
240-
request: { metadataUri: `${METADATA_ENDPOINT}/${metadataId}` }
241-
}
234+
variables: { request: { metadataUri } }
242235
});
243236
} catch (error) {
244237
onError(error);

apps/web/src/components/Shared/Auth/Signup/ChooseUsername.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
FaceFrownIcon,
77
FaceSmileIcon
88
} from "@heroicons/react/24/outline";
9-
import { APP_NAME, METADATA_ENDPOINT } from "@hey/data/constants";
9+
import { APP_NAME } from "@hey/data/constants";
1010
import { Errors } from "@hey/data/errors";
1111
import { Regex } from "@hey/data/regex";
1212
import {
@@ -101,14 +101,14 @@ const ChooseUsername: FC = () => {
101101
if (auth.data?.authenticate.__typename === "AuthenticationTokens") {
102102
const accessToken = auth.data?.authenticate.accessToken;
103103
const metadata = accountMetadata({ name: username });
104-
const metadataId = await uploadMetadata(metadata);
104+
const metadataUri = await uploadMetadata(metadata);
105105

106106
return await createAccountWithUsername({
107107
context: { headers: { "X-Access-Token": accessToken } },
108108
variables: {
109109
request: {
110110
username: { localName: username.toLowerCase() },
111-
metadataUri: `${METADATA_ENDPOINT}/${metadataId}`
111+
metadataUri
112112
}
113113
},
114114
onCompleted: ({ createAccountWithUsername }) => {

apps/web/src/helpers/uploadMetadata.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { HEY_API_URL } from "@hey/data/constants";
21
import { Errors } from "@hey/data/errors";
32
import axios from "axios";
43
import toast from "react-hot-toast";
@@ -12,12 +11,14 @@ import toast from "react-hot-toast";
1211
*/
1312
const uploadMetadata = async (data: any): Promise<string> => {
1413
try {
15-
const response = await axios.post(`${HEY_API_URL}/metadata`, {
16-
...data
17-
});
18-
const { id }: { id: string } = response.data;
14+
const response = await axios.post(
15+
"https://storage-api.testnet.lens.dev",
16+
data
17+
);
1918

20-
return id;
19+
const { uri } = response.data[0];
20+
21+
return uri;
2122
} catch {
2223
toast.error(Errors.SomethingWentWrong);
2324
throw new Error(Errors.SomethingWentWrong);

pnpm-lock.yaml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)