Skip to content

Commit

Permalink
Migrate to Lens v3
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoginth committed Dec 5, 2024
1 parent e416ff3 commit c09f3ca
Show file tree
Hide file tree
Showing 15 changed files with 33 additions and 264 deletions.
4 changes: 2 additions & 2 deletions apps/og/src/helpers/getCollectModuleMetadata.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import getPostOGImages from "@helpers/getPostOGImages";
import { APP_NAME } from "@hey/data/constants";
import allowedOpenActionModules from "@hey/helpers/allowedOpenActionModules";
import allowedPostActionModules from "@hey/helpers/allowedPostActionModules";
import getAccount from "@hey/helpers/getAccount";
import { beforeEach, describe, expect, test, vi } from "vitest";
import getCollectModuleMetadata from "./getCollectModuleMetadata";
Expand Down Expand Up @@ -36,7 +36,7 @@ describe("getCollectModuleMetadata", () => {
},
openActionModules: [
{
type: allowedOpenActionModules[0],
type: allowedPostActionModules[0],
contract: { address: "0xabcdefabcdef" }
}
],
Expand Down
4 changes: 2 additions & 2 deletions apps/og/src/helpers/getCollectModuleMetadata.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import getPostOGImages from "@helpers/getPostOGImages";
import { APP_NAME } from "@hey/data/constants";
import allowedOpenActionModules from "@hey/helpers/allowedOpenActionModules";
import allowedPostActionModules from "@hey/helpers/allowedPostActionModules";
import getAccount from "@hey/helpers/getAccount";
import type { AnyPost } from "@hey/indexer";

Expand All @@ -12,7 +12,7 @@ const getCollectModuleMetadata = (post: AnyPost) => {
}

const openAction = openActionModules.filter((module) =>
allowedOpenActionModules.includes(module.type)
allowedPostActionModules.includes(module.type)
);

// 0 th index is the collect module
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Account/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const ViewProfile: NextPage = () => {
cover={
isSuspended
? `${STATIC_IMAGES_URL}/patterns/2.svg`
: account?.metadata?.coverPicture?.optimized?.uri ||
: account?.metadata?.coverPicture ||
`${STATIC_IMAGES_URL}/patterns/2.svg`
}
/>
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Post/OpenAction/Collect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Leafwatch } from "@helpers/leafwatch";
import hasOptimisticallyCollected from "@helpers/optimistic/hasOptimisticallyCollected";
import { FeatureFlag } from "@hey/data/feature-flags";
import { POST } from "@hey/data/tracking";
import allowedOpenActionModules from "@hey/helpers/allowedOpenActionModules";
import allowedPostActionModules from "@hey/helpers/allowedPostActionModules";
import type { Post } from "@hey/indexer";
import { Button, Modal } from "@hey/ui";
import { useFlag } from "@unleash/proxy-client-react";
Expand All @@ -18,7 +18,7 @@ const Collect: FC<CollectProps> = ({ post }) => {
const enabled = useFlag(FeatureFlag.Collect);
const [showCollectModal, setShowCollectModal] = useState(false);
const openActions = post.openActionModules.filter((module) =>
allowedOpenActionModules.includes(module.type)
allowedPostActionModules.includes(module.type)
);

const hasActed =
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Post/OpenAction/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Leafwatch } from "@helpers/leafwatch";
import { ShoppingBagIcon } from "@heroicons/react/24/outline";
import { POST } from "@hey/data/tracking";
import allowedOpenActionModules from "@hey/helpers/allowedOpenActionModules";
import allowedPostActionModules from "@hey/helpers/allowedPostActionModules";
import humanize from "@hey/helpers/humanize";
import nFormatter from "@hey/helpers/nFormatter";
import type { Post } from "@hey/indexer";
Expand All @@ -18,7 +18,7 @@ const OpenAction: FC<OpenActionProps> = ({ post }) => {
const [showCollectModal, setShowCollectModal] = useState(false);
const { countOpenActions } = post.stats;
const openActions = post.openActionModules.filter((module) =>
allowedOpenActionModules.includes(module.type)
allowedPostActionModules.includes(module.type)
);

return (
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Settings/Allowance/CollectModules.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Loader from "@components/Shared/Loader";
import { DEFAULT_COLLECT_TOKEN, STATIC_IMAGES_URL } from "@hey/data/constants";
import allowedOpenActionModules from "@hey/helpers/allowedOpenActionModules";
import allowedPostActionModules from "@hey/helpers/allowedPostActionModules";
import { CardHeader, ErrorMessage, Select } from "@hey/ui";
import type { FC } from "react";
import { useState } from "react";
Expand All @@ -12,7 +12,7 @@ const getAllowancePayload = (currency: string) => {
return {
currencies: [currency],
followModules: [FollowModuleType.FeeFollowModule],
openActionModules: allowedOpenActionModules
openActionModules: allowedPostActionModules
};
};

Expand Down
Empty file added packages/abis/Graph.ts
Empty file.
6 changes: 0 additions & 6 deletions packages/helpers/allowedOpenActionModules.ts

This file was deleted.

8 changes: 8 additions & 0 deletions packages/helpers/allowedPostActionModules.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { PostActionType } from "@hey/indexer";

const allowedPostActionModules = [
PostActionType.SimpleCollectAction,
PostActionType.MultirecipientFeeCollectOpenActionModule
];

export default allowedPostActionModules;
142 changes: 0 additions & 142 deletions packages/helpers/getAttachmentsData.spec.ts

This file was deleted.

22 changes: 10 additions & 12 deletions packages/helpers/getAttachmentsData.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
import type { Maybe, PublicationMetadataMedia } from "@hey/indexer";
import type { AnyMedia, Maybe } from "@hey/indexer";

const getAttachmentsData = (
attachments?: Maybe<PublicationMetadataMedia[]>
): any => {
const getAttachmentsData = (attachments?: Maybe<AnyMedia[]>): any => {
if (!attachments) {
return [];
}

return attachments.map((attachment) => {
switch (attachment.__typename) {
case "PublicationMetadataMediaImage":
case "MediaImage":
return {
type: "Image",
uri: attachment.image.optimized?.uri
uri: attachment.item
};
case "PublicationMetadataMediaVideo":
case "MediaVideo":
return {
coverUri: attachment.cover?.optimized?.uri,
coverUri: attachment.cover,
type: "Video",
uri: attachment.video.optimized?.uri
uri: attachment.item
};
case "PublicationMetadataMediaAudio":
case "MediaAudio":
return {
artist: attachment.artist,
coverUri: attachment.cover?.optimized?.uri,
coverUri: attachment.cover,
type: "Audio",
uri: attachment.audio.optimized?.uri
uri: attachment.item
};
default:
return [];
Expand Down
12 changes: 2 additions & 10 deletions packages/helpers/getAvatar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,8 @@ import sanitizeDStorageUrl from "./sanitizeDStorageUrl";
* @param namedTransform The named transform to use.
* @returns The avatar image URL.
*/
const getAvatar = (profile: any, namedTransform = AVATAR): string => {
const avatarUrl =
// Lens NFT Avatar fallbacks
profile?.metadata?.picture?.image?.optimized?.uri ||
profile?.metadata?.picture?.image?.raw?.uri ||
// Lens Account Avatar fallbacks
profile?.metadata?.picture?.optimized?.uri ||
profile?.metadata?.picture?.raw?.uri ||
// Stamp.fyi Avatar fallbacks
getLennyURL(profile.id);
const getAvatar = (account: any, namedTransform = AVATAR): string => {
const avatarUrl = account?.metadata?.picture || getLennyURL(account.address);

return imageKit(sanitizeDStorageUrl(avatarUrl), namedTransform);
};
Expand Down
56 changes: 0 additions & 56 deletions packages/helpers/getThumbnailUrl.spec.ts

This file was deleted.

25 changes: 0 additions & 25 deletions packages/helpers/getThumbnailUrl.ts

This file was deleted.

Loading

0 comments on commit c09f3ca

Please sign in to comment.