mirror of
https://github.com/logos-messaging/OpChan.git
synced 2026-01-03 21:33:09 +00:00
chore: move lib
This commit is contained in:
parent
611db99cb1
commit
b897dca588
@ -15,6 +15,7 @@
|
|||||||
"test:ui": "vitest --ui"
|
"test:ui": "vitest --ui"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@opchan/core": "workspace:*",
|
||||||
"@hookform/resolvers": "^3.9.0",
|
"@hookform/resolvers": "^3.9.0",
|
||||||
"@noble/ed25519": "^2.2.3",
|
"@noble/ed25519": "^2.2.3",
|
||||||
"@noble/hashes": "^1.8.0",
|
"@noble/hashes": "^1.8.0",
|
||||||
|
|||||||
@ -26,9 +26,8 @@ import Dashboard from './pages/Dashboard';
|
|||||||
import Index from './pages/Index';
|
import Index from './pages/Index';
|
||||||
import ProfilePage from './pages/ProfilePage';
|
import ProfilePage from './pages/ProfilePage';
|
||||||
import BookmarksPage from './pages/BookmarksPage';
|
import BookmarksPage from './pages/BookmarksPage';
|
||||||
import { appkitConfig } from './lib/wallet/config';
|
import { appkitConfig, config } from '@opchan/core';
|
||||||
import { WagmiProvider } from 'wagmi';
|
import { WagmiProvider } from 'wagmi';
|
||||||
import { config } from './lib/wallet/config';
|
|
||||||
import { AppKitProvider } from '@reown/appkit/react';
|
import { AppKitProvider } from '@reown/appkit/react';
|
||||||
|
|
||||||
// Create a client
|
// Create a client
|
||||||
|
|||||||
@ -24,8 +24,8 @@ import {
|
|||||||
import { CypherImage } from './ui/CypherImage';
|
import { CypherImage } from './ui/CypherImage';
|
||||||
import { RelevanceIndicator } from './ui/relevance-indicator';
|
import { RelevanceIndicator } from './ui/relevance-indicator';
|
||||||
import { ModerationToggle } from './ui/moderation-toggle';
|
import { ModerationToggle } from './ui/moderation-toggle';
|
||||||
import { sortCells, SortOption } from '@/lib/utils/sorting';
|
import { sortCells, SortOption } from '@opchan/core';
|
||||||
import { Cell } from '@/types/forum';
|
import { Cell } from '@opchan/core';
|
||||||
import { usePending } from '@/hooks/usePending';
|
import { usePending } from '@/hooks/usePending';
|
||||||
import { ShareButton } from './ui/ShareButton';
|
import { ShareButton } from './ui/ShareButton';
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { ArrowUp, ArrowDown, Clock, Shield, UserX } from 'lucide-react';
|
import { ArrowUp, ArrowDown, Clock, Shield, UserX } from 'lucide-react';
|
||||||
import { formatDistanceToNow } from 'date-fns';
|
import { formatDistanceToNow } from 'date-fns';
|
||||||
import { Comment } from '@/types/forum';
|
import { Comment } from '@opchan/core';
|
||||||
import {
|
import {
|
||||||
useForumActions,
|
useForumActions,
|
||||||
usePermissions,
|
usePermissions,
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import {
|
|||||||
DialogTrigger,
|
DialogTrigger,
|
||||||
} from '@/components/ui/dialog';
|
} from '@/components/ui/dialog';
|
||||||
import { useToast } from '@/hooks/use-toast';
|
import { useToast } from '@/hooks/use-toast';
|
||||||
import { urlLoads } from '@/lib/utils/urlLoads';
|
import { urlLoads } from '@opchan/core';
|
||||||
|
|
||||||
const formSchema = z.object({
|
const formSchema = z.object({
|
||||||
title: z
|
title: z
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { TrendingUp, Users, Eye, CheckCircle } from 'lucide-react';
|
|||||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||||
import { Badge } from '@/components/ui/badge';
|
import { Badge } from '@/components/ui/badge';
|
||||||
import { useForumData, useAuth } from '@/hooks';
|
import { useForumData, useAuth } from '@/hooks';
|
||||||
import { EVerificationStatus } from '@/types/identity';
|
import { EVerificationStatus } from '@opchan/core';
|
||||||
import { CypherImage } from '@/components/ui/CypherImage';
|
import { CypherImage } from '@/components/ui/CypherImage';
|
||||||
import { useUserDisplay } from '@/hooks';
|
import { useUserDisplay } from '@/hooks';
|
||||||
|
|
||||||
|
|||||||
@ -2,10 +2,10 @@ import React, { useState } from 'react';
|
|||||||
import { Link, useLocation } from 'react-router-dom';
|
import { Link, useLocation } from 'react-router-dom';
|
||||||
import { useAuth, useWakuHealthStatus } from '@/hooks';
|
import { useAuth, useWakuHealthStatus } from '@/hooks';
|
||||||
import { useAuth as useAuthContext } from '@/contexts/useAuth';
|
import { useAuth as useAuthContext } from '@/contexts/useAuth';
|
||||||
import { EVerificationStatus } from '@/types/identity';
|
import { EVerificationStatus } from '@opchan/core';
|
||||||
import { useForum } from '@/contexts/useForum';
|
import { useForum } from '@/contexts/useForum';
|
||||||
import { localDatabase } from '@/lib/database/LocalDatabase';
|
import { localDatabase } from '@opchan/core';
|
||||||
import { DelegationFullStatus } from '@/lib/delegation';
|
import { DelegationFullStatus } from '@opchan/core';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Badge } from '@/components/ui/badge';
|
import { Badge } from '@/components/ui/badge';
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import React from 'react';
|
|||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { ArrowUp, ArrowDown, MessageSquare } from 'lucide-react';
|
import { ArrowUp, ArrowDown, MessageSquare } from 'lucide-react';
|
||||||
import { formatDistanceToNow } from 'date-fns';
|
import { formatDistanceToNow } from 'date-fns';
|
||||||
import { Post } from '@/types/forum';
|
import { Post } from '@opchan/core';
|
||||||
import {
|
import {
|
||||||
useForumActions,
|
useForumActions,
|
||||||
usePermissions,
|
usePermissions,
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
type CypherImageProps = {
|
type CypherImageProps = {
|
||||||
src?: string;
|
src?: string;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Share2 } from 'lucide-react';
|
import { Share2 } from 'lucide-react';
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
import { useToast } from '../ui/use-toast';
|
import { useToast } from '../ui/use-toast';
|
||||||
|
|
||||||
interface ShareButtonProps {
|
interface ShareButtonProps {
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import * as React from 'react';
|
|||||||
import * as AccordionPrimitive from '@radix-ui/react-accordion';
|
import * as AccordionPrimitive from '@radix-ui/react-accordion';
|
||||||
import { ChevronDown } from 'lucide-react';
|
import { ChevronDown } from 'lucide-react';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
const Accordion = AccordionPrimitive.Root;
|
const Accordion = AccordionPrimitive.Root;
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
|
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
import { buttonVariants } from '@/components/ui/button-variants';
|
import { buttonVariants } from '@/components/ui/button-variants';
|
||||||
|
|
||||||
const AlertDialog = AlertDialogPrimitive.Root;
|
const AlertDialog = AlertDialogPrimitive.Root;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { cva, type VariantProps } from 'class-variance-authority';
|
import { cva, type VariantProps } from 'class-variance-authority';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
const alertVariants = cva(
|
const alertVariants = cva(
|
||||||
'relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground',
|
'relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground',
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import * as AvatarPrimitive from '@radix-ui/react-avatar';
|
import * as AvatarPrimitive from '@radix-ui/react-avatar';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
const Avatar = React.forwardRef<
|
const Avatar = React.forwardRef<
|
||||||
React.ElementRef<typeof AvatarPrimitive.Root>,
|
React.ElementRef<typeof AvatarPrimitive.Root>,
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { cva, type VariantProps } from 'class-variance-authority';
|
import { cva, type VariantProps } from 'class-variance-authority';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
const badgeVariants = cva(
|
const badgeVariants = cva(
|
||||||
'inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2',
|
'inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2',
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Bookmark, BookmarkCheck } from 'lucide-react';
|
import { Bookmark, BookmarkCheck } from 'lucide-react';
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
interface BookmarkButtonProps {
|
interface BookmarkButtonProps {
|
||||||
isBookmarked: boolean;
|
isBookmarked: boolean;
|
||||||
|
|||||||
@ -8,9 +8,9 @@ import {
|
|||||||
Trash2,
|
Trash2,
|
||||||
ExternalLink,
|
ExternalLink,
|
||||||
} from 'lucide-react';
|
} from 'lucide-react';
|
||||||
import { Bookmark, BookmarkType } from '@/types/forum';
|
import { Bookmark, BookmarkType } from '@opchan/core';
|
||||||
import { useUserDisplay } from '@/hooks';
|
import { useUserDisplay } from '@/hooks';
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
import { formatDistanceToNow } from 'date-fns';
|
import { formatDistanceToNow } from 'date-fns';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import * as React from 'react';
|
|||||||
import { Slot } from '@radix-ui/react-slot';
|
import { Slot } from '@radix-ui/react-slot';
|
||||||
import { ChevronRight, MoreHorizontal } from 'lucide-react';
|
import { ChevronRight, MoreHorizontal } from 'lucide-react';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
const Breadcrumb = React.forwardRef<
|
const Breadcrumb = React.forwardRef<
|
||||||
HTMLElement,
|
HTMLElement,
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import * as React from 'react';
|
|||||||
import { Slot } from '@radix-ui/react-slot';
|
import { Slot } from '@radix-ui/react-slot';
|
||||||
import { type VariantProps } from 'class-variance-authority';
|
import { type VariantProps } from 'class-variance-authority';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
import { buttonVariants } from './button-variants';
|
import { buttonVariants } from './button-variants';
|
||||||
|
|
||||||
export interface ButtonProps
|
export interface ButtonProps
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import * as React from 'react';
|
|||||||
import { ChevronLeft, ChevronRight } from 'lucide-react';
|
import { ChevronLeft, ChevronRight } from 'lucide-react';
|
||||||
import { DayPicker } from 'react-day-picker';
|
import { DayPicker } from 'react-day-picker';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
import { buttonVariants } from '@/components/ui/button-variants';
|
import { buttonVariants } from '@/components/ui/button-variants';
|
||||||
|
|
||||||
export type CalendarProps = React.ComponentProps<typeof DayPicker>;
|
export type CalendarProps = React.ComponentProps<typeof DayPicker>;
|
||||||
|
|||||||
@ -30,7 +30,7 @@ import {
|
|||||||
SelectValue,
|
SelectValue,
|
||||||
} from '@/components/ui/select';
|
} from '@/components/ui/select';
|
||||||
import { useToast } from '@/hooks/use-toast';
|
import { useToast } from '@/hooks/use-toast';
|
||||||
import { EDisplayPreference } from '@/types/identity';
|
import { EDisplayPreference } from '@opchan/core';
|
||||||
|
|
||||||
const formSchema = z.object({
|
const formSchema = z.object({
|
||||||
callSign: z
|
callSign: z
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
const Card = React.forwardRef<
|
const Card = React.forwardRef<
|
||||||
HTMLDivElement,
|
HTMLDivElement,
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import useEmblaCarousel, {
|
|||||||
} from 'embla-carousel-react';
|
} from 'embla-carousel-react';
|
||||||
import { ArrowLeft, ArrowRight } from 'lucide-react';
|
import { ArrowLeft, ArrowRight } from 'lucide-react';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
|
|
||||||
type CarouselApi = UseEmblaCarouselType[1];
|
type CarouselApi = UseEmblaCarouselType[1];
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import * as RechartsPrimitive from 'recharts';
|
import * as RechartsPrimitive from 'recharts';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
// Format: { THEME_NAME: CSS_SELECTOR }
|
// Format: { THEME_NAME: CSS_SELECTOR }
|
||||||
const THEMES = { light: '', dark: '.dark' } as const;
|
const THEMES = { light: '', dark: '.dark' } as const;
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import * as React from 'react';
|
|||||||
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
||||||
import { Check } from 'lucide-react';
|
import { Check } from 'lucide-react';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
const Checkbox = React.forwardRef<
|
const Checkbox = React.forwardRef<
|
||||||
React.ElementRef<typeof CheckboxPrimitive.Root>,
|
React.ElementRef<typeof CheckboxPrimitive.Root>,
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { type DialogProps } from '@radix-ui/react-dialog';
|
|||||||
import { Command as CommandPrimitive } from 'cmdk';
|
import { Command as CommandPrimitive } from 'cmdk';
|
||||||
import { Search } from 'lucide-react';
|
import { Search } from 'lucide-react';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
import { Dialog, DialogContent } from '@/components/ui/dialog';
|
import { Dialog, DialogContent } from '@/components/ui/dialog';
|
||||||
|
|
||||||
const Command = React.forwardRef<
|
const Command = React.forwardRef<
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import * as React from 'react';
|
|||||||
import * as ContextMenuPrimitive from '@radix-ui/react-context-menu';
|
import * as ContextMenuPrimitive from '@radix-ui/react-context-menu';
|
||||||
import { Check, ChevronRight, Circle } from 'lucide-react';
|
import { Check, ChevronRight, Circle } from 'lucide-react';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
const ContextMenu = ContextMenuPrimitive.Root;
|
const ContextMenu = ContextMenuPrimitive.Root;
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { Button } from './button';
|
|||||||
import { useAuth, useAuthActions } from '@/hooks';
|
import { useAuth, useAuthActions } from '@/hooks';
|
||||||
import { useAuth as useAuthContext } from '@/contexts/useAuth';
|
import { useAuth as useAuthContext } from '@/contexts/useAuth';
|
||||||
import { CheckCircle, AlertCircle, Trash2 } from 'lucide-react';
|
import { CheckCircle, AlertCircle, Trash2 } from 'lucide-react';
|
||||||
import { DelegationDuration, DelegationFullStatus } from '@/lib/delegation';
|
import { DelegationDuration, DelegationFullStatus } from '@opchan/core';
|
||||||
|
|
||||||
interface DelegationStepProps {
|
interface DelegationStepProps {
|
||||||
onComplete: () => void;
|
onComplete: () => void;
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import * as React from 'react';
|
|||||||
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
||||||
import { X } from 'lucide-react';
|
import { X } from 'lucide-react';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
const Dialog = DialogPrimitive.Root;
|
const Dialog = DialogPrimitive.Root;
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { Drawer as DrawerPrimitive } from 'vaul';
|
import { Drawer as DrawerPrimitive } from 'vaul';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
const Drawer = ({
|
const Drawer = ({
|
||||||
shouldScaleBackground = true,
|
shouldScaleBackground = true,
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import * as React from 'react';
|
|||||||
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
||||||
import { Check, ChevronRight, Circle } from 'lucide-react';
|
import { Check, ChevronRight, Circle } from 'lucide-react';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
const DropdownMenu = DropdownMenuPrimitive.Root;
|
const DropdownMenu = DropdownMenuPrimitive.Root;
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import {
|
|||||||
useFormContext,
|
useFormContext,
|
||||||
} from 'react-hook-form';
|
} from 'react-hook-form';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
import { Label } from '@/components/ui/label';
|
import { Label } from '@/components/ui/label';
|
||||||
|
|
||||||
const Form = FormProvider;
|
const Form = FormProvider;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import * as HoverCardPrimitive from '@radix-ui/react-hover-card';
|
import * as HoverCardPrimitive from '@radix-ui/react-hover-card';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
const HoverCard = HoverCardPrimitive.Root;
|
const HoverCard = HoverCardPrimitive.Root;
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import * as React from 'react';
|
|||||||
import { OTPInput, OTPInputContext } from 'input-otp';
|
import { OTPInput, OTPInputContext } from 'input-otp';
|
||||||
import { Dot } from 'lucide-react';
|
import { Dot } from 'lucide-react';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
const InputOTP = React.forwardRef<
|
const InputOTP = React.forwardRef<
|
||||||
React.ElementRef<typeof OTPInput>,
|
React.ElementRef<typeof OTPInput>,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<'input'>>(
|
const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<'input'>>(
|
||||||
({ className, type, ...props }, ref) => {
|
({ className, type, ...props }, ref) => {
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import * as React from 'react';
|
|||||||
import * as LabelPrimitive from '@radix-ui/react-label';
|
import * as LabelPrimitive from '@radix-ui/react-label';
|
||||||
import { cva, type VariantProps } from 'class-variance-authority';
|
import { cva, type VariantProps } from 'class-variance-authority';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
const labelVariants = cva(
|
const labelVariants = cva(
|
||||||
'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70'
|
'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70'
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import * as React from 'react';
|
|||||||
import * as MenubarPrimitive from '@radix-ui/react-menubar';
|
import * as MenubarPrimitive from '@radix-ui/react-menubar';
|
||||||
import { Check, ChevronRight, Circle } from 'lucide-react';
|
import { Check, ChevronRight, Circle } from 'lucide-react';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
const MenubarMenu = MenubarPrimitive.Menu;
|
const MenubarMenu = MenubarPrimitive.Menu;
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import * as NavigationMenuPrimitive from '@radix-ui/react-navigation-menu';
|
|||||||
import { cva } from 'class-variance-authority';
|
import { cva } from 'class-variance-authority';
|
||||||
import { ChevronDown } from 'lucide-react';
|
import { ChevronDown } from 'lucide-react';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
const NavigationMenu = React.forwardRef<
|
const NavigationMenu = React.forwardRef<
|
||||||
React.ElementRef<typeof NavigationMenuPrimitive.Root>,
|
React.ElementRef<typeof NavigationMenuPrimitive.Root>,
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { ChevronLeft, ChevronRight, MoreHorizontal } from 'lucide-react';
|
import { ChevronLeft, ChevronRight, MoreHorizontal } from 'lucide-react';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
import { ButtonProps } from '@/components/ui/button';
|
import { ButtonProps } from '@/components/ui/button';
|
||||||
import { buttonVariants } from '@/components/ui/button-variants';
|
import { buttonVariants } from '@/components/ui/button-variants';
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
const Popover = PopoverPrimitive.Root;
|
const Popover = PopoverPrimitive.Root;
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import * as ProgressPrimitive from '@radix-ui/react-progress';
|
import * as ProgressPrimitive from '@radix-ui/react-progress';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
const Progress = React.forwardRef<
|
const Progress = React.forwardRef<
|
||||||
React.ElementRef<typeof ProgressPrimitive.Root>,
|
React.ElementRef<typeof ProgressPrimitive.Root>,
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import * as React from 'react';
|
|||||||
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
|
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
|
||||||
import { Circle } from 'lucide-react';
|
import { Circle } from 'lucide-react';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
const RadioGroup = React.forwardRef<
|
const RadioGroup = React.forwardRef<
|
||||||
React.ElementRef<typeof RadioGroupPrimitive.Root>,
|
React.ElementRef<typeof RadioGroupPrimitive.Root>,
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import {
|
|||||||
MessageSquare,
|
MessageSquare,
|
||||||
ThumbsUp,
|
ThumbsUp,
|
||||||
} from 'lucide-react';
|
} from 'lucide-react';
|
||||||
import { RelevanceScoreDetails } from '@/types/forum';
|
import { RelevanceScoreDetails } from '@opchan/core';
|
||||||
|
|
||||||
interface RelevanceIndicatorProps {
|
interface RelevanceIndicatorProps {
|
||||||
score: number;
|
score: number;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { Resizable } from 're-resizable';
|
import { Resizable } from 're-resizable';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
import { Textarea } from '@/components/ui/textarea';
|
import { Textarea } from '@/components/ui/textarea';
|
||||||
|
|
||||||
type ResizableTextareaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement> & {
|
type ResizableTextareaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement> & {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { GripVertical } from 'lucide-react';
|
import { GripVertical } from 'lucide-react';
|
||||||
import * as ResizablePrimitive from 'react-resizable-panels';
|
import * as ResizablePrimitive from 'react-resizable-panels';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
const ResizablePanelGroup = ({
|
const ResizablePanelGroup = ({
|
||||||
className,
|
className,
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
|
import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
const ScrollArea = React.forwardRef<
|
const ScrollArea = React.forwardRef<
|
||||||
React.ElementRef<typeof ScrollAreaPrimitive.Root>,
|
React.ElementRef<typeof ScrollAreaPrimitive.Root>,
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import * as React from 'react';
|
|||||||
import * as SelectPrimitive from '@radix-ui/react-select';
|
import * as SelectPrimitive from '@radix-ui/react-select';
|
||||||
import { Check, ChevronDown, ChevronUp } from 'lucide-react';
|
import { Check, ChevronDown, ChevronUp } from 'lucide-react';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
const Select = SelectPrimitive.Root;
|
const Select = SelectPrimitive.Root;
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import * as SeparatorPrimitive from '@radix-ui/react-separator';
|
import * as SeparatorPrimitive from '@radix-ui/react-separator';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
const Separator = React.forwardRef<
|
const Separator = React.forwardRef<
|
||||||
React.ElementRef<typeof SeparatorPrimitive.Root>,
|
React.ElementRef<typeof SeparatorPrimitive.Root>,
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { cva, type VariantProps } from 'class-variance-authority';
|
|||||||
import { X } from 'lucide-react';
|
import { X } from 'lucide-react';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
const Sheet = SheetPrimitive.Root;
|
const Sheet = SheetPrimitive.Root;
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import { VariantProps, cva } from 'class-variance-authority';
|
|||||||
import { PanelLeft } from 'lucide-react';
|
import { PanelLeft } from 'lucide-react';
|
||||||
|
|
||||||
import { useIsMobile } from '@/hooks/use-mobile';
|
import { useIsMobile } from '@/hooks/use-mobile';
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
import { Separator } from '@/components/ui/separator';
|
import { Separator } from '@/components/ui/separator';
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
function Skeleton({
|
function Skeleton({
|
||||||
className,
|
className,
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import * as SliderPrimitive from '@radix-ui/react-slider';
|
import * as SliderPrimitive from '@radix-ui/react-slider';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
const Slider = React.forwardRef<
|
const Slider = React.forwardRef<
|
||||||
React.ElementRef<typeof SliderPrimitive.Root>,
|
React.ElementRef<typeof SliderPrimitive.Root>,
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import * as SwitchPrimitives from '@radix-ui/react-switch';
|
import * as SwitchPrimitives from '@radix-ui/react-switch';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
const Switch = React.forwardRef<
|
const Switch = React.forwardRef<
|
||||||
React.ElementRef<typeof SwitchPrimitives.Root>,
|
React.ElementRef<typeof SwitchPrimitives.Root>,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
const Table = React.forwardRef<
|
const Table = React.forwardRef<
|
||||||
HTMLTableElement,
|
HTMLTableElement,
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
const Tabs = TabsPrimitive.Root;
|
const Tabs = TabsPrimitive.Root;
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
const Textarea = React.forwardRef<
|
const Textarea = React.forwardRef<
|
||||||
HTMLTextAreaElement,
|
HTMLTextAreaElement,
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import * as ToastPrimitives from '@radix-ui/react-toast';
|
|||||||
import { cva, type VariantProps } from 'class-variance-authority';
|
import { cva, type VariantProps } from 'class-variance-authority';
|
||||||
import { X } from 'lucide-react';
|
import { X } from 'lucide-react';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
const ToastProvider = ToastPrimitives.Provider;
|
const ToastProvider = ToastPrimitives.Provider;
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import * as React from 'react';
|
|||||||
import * as ToggleGroupPrimitive from '@radix-ui/react-toggle-group';
|
import * as ToggleGroupPrimitive from '@radix-ui/react-toggle-group';
|
||||||
import { type VariantProps } from 'class-variance-authority';
|
import { type VariantProps } from 'class-variance-authority';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
import { toggleVariants } from '@/components/ui/toggle-variants';
|
import { toggleVariants } from '@/components/ui/toggle-variants';
|
||||||
|
|
||||||
const ToggleGroupContext = React.createContext<
|
const ToggleGroupContext = React.createContext<
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import * as React from 'react';
|
|||||||
import * as TogglePrimitive from '@radix-ui/react-toggle';
|
import * as TogglePrimitive from '@radix-ui/react-toggle';
|
||||||
import { type VariantProps } from 'class-variance-authority';
|
import { type VariantProps } from 'class-variance-authority';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
import { toggleVariants } from './toggle-variants';
|
import { toggleVariants } from './toggle-variants';
|
||||||
|
|
||||||
const Toggle = React.forwardRef<
|
const Toggle = React.forwardRef<
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
const TooltipProvider = TooltipPrimitive.Provider;
|
const TooltipProvider = TooltipPrimitive.Provider;
|
||||||
|
|
||||||
|
|||||||
@ -9,9 +9,9 @@ import {
|
|||||||
AlertCircle,
|
AlertCircle,
|
||||||
} from 'lucide-react';
|
} from 'lucide-react';
|
||||||
import { useAuth, useAuthActions } from '@/hooks';
|
import { useAuth, useAuthActions } from '@/hooks';
|
||||||
import { EVerificationStatus } from '@/types/identity';
|
import { EVerificationStatus } from '@opchan/core';
|
||||||
import { useAppKitAccount } from '@reown/appkit/react';
|
import { useAppKitAccount } from '@reown/appkit/react';
|
||||||
import { OrdinalDetails, EnsDetails } from '@/types/identity';
|
import { OrdinalDetails, EnsDetails } from '@opchan/core';
|
||||||
|
|
||||||
interface VerificationStepProps {
|
interface VerificationStepProps {
|
||||||
onComplete: () => void;
|
onComplete: () => void;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { Wifi, WifiOff, AlertTriangle, CheckCircle } from 'lucide-react';
|
import { Wifi, WifiOff, AlertTriangle, CheckCircle } from 'lucide-react';
|
||||||
import { useWakuHealthStatus } from '@/hooks/useWakuHealth';
|
import { useWakuHealthStatus } from '@/hooks/useWakuHealth';
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@opchan/core';
|
||||||
|
|
||||||
interface WakuHealthIndicatorProps {
|
interface WakuHealthIndicatorProps {
|
||||||
className?: string;
|
className?: string;
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import { Button } from '@/components/ui/button';
|
|||||||
import { CheckCircle, Circle, Loader2 } from 'lucide-react';
|
import { CheckCircle, Circle, Loader2 } from 'lucide-react';
|
||||||
import { useAuth } from '@/hooks';
|
import { useAuth } from '@/hooks';
|
||||||
import { useDelegation } from '@/hooks/useDelegation';
|
import { useDelegation } from '@/hooks/useDelegation';
|
||||||
import { EVerificationStatus } from '@/types/identity';
|
import { EVerificationStatus } from '@opchan/core';
|
||||||
import { WalletConnectionStep } from './wallet-connection-step';
|
import { WalletConnectionStep } from './wallet-connection-step';
|
||||||
import { VerificationStep } from './verification-step';
|
import { VerificationStep } from './verification-step';
|
||||||
import { DelegationStep } from './delegation-step';
|
import { DelegationStep } from './delegation-step';
|
||||||
|
|||||||
@ -1,23 +1,23 @@
|
|||||||
import React, { createContext, useState, useEffect, useMemo } from 'react';
|
import React, { createContext, useState, useEffect, useMemo } from 'react';
|
||||||
import { useToast } from '@/components/ui/use-toast';
|
import { useToast } from '@/components/ui/use-toast';
|
||||||
import { OpchanMessage } from '@/types/forum';
|
import { OpchanMessage } from '@opchan/core';
|
||||||
import {
|
import {
|
||||||
User,
|
User,
|
||||||
EVerificationStatus,
|
EVerificationStatus,
|
||||||
EDisplayPreference,
|
EDisplayPreference,
|
||||||
} from '@/types/identity';
|
} from '@opchan/core';
|
||||||
import { WalletManager } from '@/lib/wallet';
|
import { WalletManager } from '@opchan/core';
|
||||||
import {
|
import {
|
||||||
DelegationManager,
|
DelegationManager,
|
||||||
DelegationDuration,
|
DelegationDuration,
|
||||||
DelegationFullStatus,
|
DelegationFullStatus,
|
||||||
} from '@/lib/delegation';
|
} from '@opchan/core';
|
||||||
import { localDatabase } from '@/lib/database/LocalDatabase';
|
import { localDatabase } from '@opchan/core';
|
||||||
import { useAppKitAccount, useDisconnect, modal } from '@reown/appkit/react';
|
import { useAppKitAccount, useDisconnect, modal } from '@reown/appkit/react';
|
||||||
import { MessageService } from '@/lib/services/MessageService';
|
import { MessageService } from '@opchan/core';
|
||||||
import { UserIdentityService } from '@/lib/services/UserIdentityService';
|
import { UserIdentityService } from '@opchan/core';
|
||||||
import { reconnect } from '@wagmi/core';
|
import { reconnect } from '@wagmi/core';
|
||||||
import { config as wagmiConfig } from '@/lib/wallet/config';
|
import { config as wagmiConfig } from '@opchan/core';
|
||||||
|
|
||||||
interface AuthContextType {
|
interface AuthContextType {
|
||||||
currentUser: User | null;
|
currentUser: User | null;
|
||||||
|
|||||||
@ -6,25 +6,25 @@ import React, {
|
|||||||
useMemo,
|
useMemo,
|
||||||
useRef,
|
useRef,
|
||||||
} from 'react';
|
} from 'react';
|
||||||
import { Cell, Post, Comment } from '@/types/forum';
|
import { Cell, Post, Comment } from '@opchan/core';
|
||||||
import {
|
import {
|
||||||
User,
|
User,
|
||||||
EVerificationStatus,
|
EVerificationStatus,
|
||||||
EDisplayPreference,
|
EDisplayPreference,
|
||||||
} from '@/types/identity';
|
} from '@opchan/core';
|
||||||
import { useToast } from '@/components/ui/use-toast';
|
import { useToast } from '@/components/ui/use-toast';
|
||||||
|
|
||||||
import { ForumActions } from '@/lib/forum/ForumActions';
|
import { ForumActions } from '@opchan/core';
|
||||||
import { monitorNetworkHealth, initializeNetwork } from '@/lib/waku/network';
|
import { monitorNetworkHealth, initializeNetwork } from '@opchan/core';
|
||||||
import messageManager from '@/lib/waku';
|
import { messageManager } from '@opchan/core';
|
||||||
import { getDataFromCache } from '@/lib/forum/transformers';
|
import { getDataFromCache } from '@opchan/core';
|
||||||
import { RelevanceCalculator } from '@/lib/forum/RelevanceCalculator';
|
import { RelevanceCalculator } from '@opchan/core';
|
||||||
import { UserVerificationStatus } from '@/types/forum';
|
import { UserVerificationStatus } from '@opchan/core';
|
||||||
import { DelegationManager } from '@/lib/delegation';
|
import { DelegationManager } from '@opchan/core';
|
||||||
import { UserIdentityService } from '@/lib/services/UserIdentityService';
|
import { UserIdentityService } from '@opchan/core';
|
||||||
import { MessageService } from '@/lib/services/MessageService';
|
import { MessageService } from '@opchan/core';
|
||||||
import { useAuth } from '@/contexts/useAuth';
|
import { useAuth } from '@/contexts/useAuth';
|
||||||
import { localDatabase } from '@/lib/database/LocalDatabase';
|
import { localDatabase } from '@opchan/core';
|
||||||
|
|
||||||
interface ForumContextType {
|
interface ForumContextType {
|
||||||
cells: Cell[];
|
cells: Cell[];
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import React, { createContext, useContext, useState, useEffect } from 'react';
|
import React, { createContext, useContext, useState, useEffect } from 'react';
|
||||||
import { localDatabase } from '@/lib/database/LocalDatabase';
|
import { localDatabase } from '@opchan/core';
|
||||||
|
|
||||||
interface ModerationContextType {
|
interface ModerationContextType {
|
||||||
showModerated: boolean;
|
showModerated: boolean;
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
import { useCallback, useState } from 'react';
|
import { useCallback, useState } from 'react';
|
||||||
import { useAuth } from '@/hooks/core/useAuth';
|
import { useAuth } from '@/hooks/core/useAuth';
|
||||||
import { DelegationDuration } from '@/lib/delegation';
|
import { DelegationDuration } from '@opchan/core';
|
||||||
import { useToast } from '@/components/ui/use-toast';
|
import { useToast } from '@/components/ui/use-toast';
|
||||||
import { useAuth as useAuthContext } from '@/contexts/useAuth';
|
import { useAuth as useAuthContext } from '@/contexts/useAuth';
|
||||||
import { EVerificationStatus } from '@/types/identity';
|
import { EVerificationStatus } from '@opchan/core';
|
||||||
|
|
||||||
export interface AuthActionStates {
|
export interface AuthActionStates {
|
||||||
isConnecting: boolean;
|
isConnecting: boolean;
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { useCallback } from 'react';
|
|||||||
import { useForum } from '@/contexts/useForum';
|
import { useForum } from '@/contexts/useForum';
|
||||||
import { useAuth } from '@/hooks/core/useAuth';
|
import { useAuth } from '@/hooks/core/useAuth';
|
||||||
import { usePermissions } from '@/hooks/core/usePermissions';
|
import { usePermissions } from '@/hooks/core/usePermissions';
|
||||||
import { Cell, Post, Comment } from '@/types/forum';
|
import { Cell, Post, Comment } from '@opchan/core';
|
||||||
import { useToast } from '@/components/ui/use-toast';
|
import { useToast } from '@/components/ui/use-toast';
|
||||||
|
|
||||||
export interface ForumActionStates {
|
export interface ForumActionStates {
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { useCallback, useState } from 'react';
|
|||||||
import { useForum } from '@/contexts/useForum';
|
import { useForum } from '@/contexts/useForum';
|
||||||
import { useAuth } from '@/hooks/core/useAuth';
|
import { useAuth } from '@/hooks/core/useAuth';
|
||||||
import { usePermissions } from '@/hooks/core/usePermissions';
|
import { usePermissions } from '@/hooks/core/usePermissions';
|
||||||
import { EDisplayPreference } from '@/types/identity';
|
import { EDisplayPreference } from '@opchan/core';
|
||||||
import { useToast } from '@/components/ui/use-toast';
|
import { useToast } from '@/components/ui/use-toast';
|
||||||
|
|
||||||
export interface UserActionStates {
|
export interface UserActionStates {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { useAuth as useBaseAuth } from '@/contexts/useAuth';
|
import { useAuth as useBaseAuth } from '@/contexts/useAuth';
|
||||||
import { useForum } from '@/contexts/useForum';
|
import { useForum } from '@/contexts/useForum';
|
||||||
import { User, EVerificationStatus } from '@/types/identity';
|
import { User, EVerificationStatus } from '@opchan/core';
|
||||||
|
|
||||||
export interface AuthState {
|
export interface AuthState {
|
||||||
currentUser: User | null;
|
currentUser: User | null;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { useState, useEffect, useCallback } from 'react';
|
import { useState, useEffect, useCallback } from 'react';
|
||||||
import { Bookmark, BookmarkType, Post, Comment } from '@/types/forum';
|
import { Bookmark, BookmarkType, Post, Comment } from '@opchan/core';
|
||||||
import { BookmarkService } from '@/lib/services/BookmarkService';
|
import { BookmarkService } from '@opchan/core';
|
||||||
import { useAuth } from '@/contexts/useAuth';
|
import { useAuth } from '@/contexts/useAuth';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { useState, useEffect, useMemo } from 'react';
|
import { useState, useEffect, useMemo } from 'react';
|
||||||
import { useForum } from '@/contexts/useForum';
|
import { useForum } from '@/contexts/useForum';
|
||||||
import { EDisplayPreference, EVerificationStatus } from '@/types/identity';
|
import { EDisplayPreference, EVerificationStatus } from '@opchan/core';
|
||||||
|
|
||||||
export interface UserDisplayInfo {
|
export interface UserDisplayInfo {
|
||||||
displayName: string;
|
displayName: string;
|
||||||
|
|||||||
@ -2,8 +2,8 @@ import { useMemo } from 'react';
|
|||||||
import { useForum } from '@/contexts/useForum';
|
import { useForum } from '@/contexts/useForum';
|
||||||
import { useAuth } from '@/contexts/useAuth';
|
import { useAuth } from '@/contexts/useAuth';
|
||||||
import { useModeration } from '@/contexts/ModerationContext';
|
import { useModeration } from '@/contexts/ModerationContext';
|
||||||
import { Cell, Post, Comment, UserVerificationStatus } from '@/types/forum';
|
import { Cell, Post, Comment, UserVerificationStatus } from '@opchan/core';
|
||||||
import { EVerificationStatus } from '@/types/identity';
|
import { EVerificationStatus } from '@opchan/core';
|
||||||
|
|
||||||
export interface CellWithStats extends Cell {
|
export interface CellWithStats extends Cell {
|
||||||
postCount: number;
|
postCount: number;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { useAuth } from './useAuth';
|
import { useAuth } from './useAuth';
|
||||||
import { useForumData } from './useForumData';
|
import { useForumData } from './useForumData';
|
||||||
import { EVerificationStatus } from '@/types/identity';
|
import { EVerificationStatus } from '@opchan/core';
|
||||||
|
|
||||||
export interface Permission {
|
export interface Permission {
|
||||||
canPost: boolean;
|
canPost: boolean;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { useForumData, CellWithStats } from '@/hooks/core/useForumData';
|
import { useForumData, CellWithStats } from '@/hooks/core/useForumData';
|
||||||
import { useAuth } from '@/hooks/core/useAuth';
|
import { useAuth } from '@/hooks/core/useAuth';
|
||||||
import { EVerificationStatus } from '@/types/identity';
|
import { EVerificationStatus } from '@opchan/core';
|
||||||
|
|
||||||
export interface CellData extends CellWithStats {
|
export interface CellData extends CellWithStats {
|
||||||
posts: Array<{
|
posts: Array<{
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { useCallback, useContext, useState, useEffect } from 'react';
|
import { useCallback, useContext, useState, useEffect } from 'react';
|
||||||
import { AuthContext } from '@/contexts/AuthContext';
|
import { AuthContext } from '@/contexts/AuthContext';
|
||||||
import { DelegationDuration } from '@/lib/delegation';
|
import { DelegationDuration } from '@opchan/core';
|
||||||
|
|
||||||
export const useDelegation = () => {
|
export const useDelegation = () => {
|
||||||
const context = useContext(AuthContext);
|
const context = useContext(AuthContext);
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { useCallback, useContext } from 'react';
|
import { useCallback, useContext } from 'react';
|
||||||
import { AuthContext } from '@/contexts/AuthContext';
|
import { AuthContext } from '@/contexts/AuthContext';
|
||||||
import { OpchanMessage } from '@/types/forum';
|
import { OpchanMessage } from '@opchan/core';
|
||||||
|
|
||||||
export const useMessageSigning = () => {
|
export const useMessageSigning = () => {
|
||||||
const context = useContext(AuthContext);
|
const context = useContext(AuthContext);
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { localDatabase } from '@/lib/database/LocalDatabase';
|
import { localDatabase } from '@opchan/core';
|
||||||
import { useAuth } from '@/contexts/useAuth';
|
import { useAuth } from '@/contexts/useAuth';
|
||||||
|
|
||||||
export function usePending(id: string | undefined) {
|
export function usePending(id: string | undefined) {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { useState, useEffect, useCallback } from 'react';
|
import { useState, useEffect, useCallback } from 'react';
|
||||||
import { HealthStatus } from '@waku/sdk';
|
import { HealthStatus } from '@waku/sdk';
|
||||||
import messageManager from '@/lib/waku';
|
import { messageManager } from '@opchan/core';
|
||||||
|
|
||||||
export interface WakuHealthState {
|
export interface WakuHealthState {
|
||||||
isReady: boolean;
|
isReady: boolean;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { ForumData } from '@/hooks/core/useForumData';
|
import { ForumData } from '@/hooks/core/useForumData';
|
||||||
import { Cell, Post, Comment } from '@/types/forum';
|
import { Cell, Post, Comment } from '@opchan/core';
|
||||||
import { EVerificationStatus } from '@/types/identity';
|
import { EVerificationStatus } from '@opchan/core';
|
||||||
|
|
||||||
// Selector types for different data slices
|
// Selector types for different data slices
|
||||||
export type CellSelector<T> = (cells: Cell[]) => T;
|
export type CellSelector<T> = (cells: Cell[]) => T;
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { useMemo, useState, useEffect } from 'react';
|
|||||||
import { useForum } from '@/contexts/useForum';
|
import { useForum } from '@/contexts/useForum';
|
||||||
import { useAuth } from '@/hooks/core/useAuth';
|
import { useAuth } from '@/hooks/core/useAuth';
|
||||||
import { useAuth as useAuthContext } from '@/contexts/useAuth';
|
import { useAuth as useAuthContext } from '@/contexts/useAuth';
|
||||||
import { DelegationFullStatus } from '@/lib/delegation';
|
import { DelegationFullStatus } from '@opchan/core';
|
||||||
|
|
||||||
export interface NetworkHealth {
|
export interface NetworkHealth {
|
||||||
isConnected: boolean;
|
isConnected: boolean;
|
||||||
|
|||||||
@ -2,6 +2,16 @@ import { createRoot } from 'react-dom/client';
|
|||||||
import App from './App.tsx';
|
import App from './App.tsx';
|
||||||
import './index.css';
|
import './index.css';
|
||||||
import { Buffer } from 'buffer';
|
import { Buffer } from 'buffer';
|
||||||
|
import { environment } from '@opchan/core';
|
||||||
|
|
||||||
|
// Configure the core library environment
|
||||||
|
environment.configure({
|
||||||
|
isDevelopment: import.meta.env.DEV,
|
||||||
|
isProduction: import.meta.env.PROD,
|
||||||
|
apiKeys: {
|
||||||
|
ordiscan: import.meta.env.VITE_ORDISCAN_API,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
// Ensure Buffer is available in the browser (needed by some wallet libs)
|
// Ensure Buffer is available in the browser (needed by some wallet libs)
|
||||||
if (!(window as Window & typeof globalThis).Buffer) {
|
if (!(window as Window & typeof globalThis).Buffer) {
|
||||||
|
|||||||
@ -17,7 +17,7 @@ import {
|
|||||||
AlertDialogTrigger,
|
AlertDialogTrigger,
|
||||||
} from '@/components/ui/alert-dialog';
|
} from '@/components/ui/alert-dialog';
|
||||||
import { useBookmarks } from '@/hooks';
|
import { useBookmarks } from '@/hooks';
|
||||||
import { Bookmark, BookmarkType } from '@/types/forum';
|
import { Bookmark, BookmarkType } from '@opchan/core';
|
||||||
import {
|
import {
|
||||||
Trash2,
|
Trash2,
|
||||||
Bookmark as BookmarkIcon,
|
Bookmark as BookmarkIcon,
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { Fragment, useEffect, useMemo, useRef, useState } from 'react';
|
import { Fragment, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import messageManager from '@/lib/waku';
|
import messageManager from '@opchan/core';
|
||||||
import { MessageType } from '@/types/waku';
|
import { MessageType } from '@opchan/core';
|
||||||
import type { OpchanMessage } from '@/types/forum';
|
import type { OpchanMessage } from '@opchan/core';
|
||||||
|
|
||||||
interface ReceivedMessage {
|
interface ReceivedMessage {
|
||||||
receivedAt: number;
|
receivedAt: number;
|
||||||
|
|||||||
@ -13,8 +13,8 @@ import PostCard from '@/components/PostCard';
|
|||||||
import FeedSidebar from '@/components/FeedSidebar';
|
import FeedSidebar from '@/components/FeedSidebar';
|
||||||
import { ModerationToggle } from '@/components/ui/moderation-toggle';
|
import { ModerationToggle } from '@/components/ui/moderation-toggle';
|
||||||
import { useForumData, useAuth, useForumActions } from '@/hooks';
|
import { useForumData, useAuth, useForumActions } from '@/hooks';
|
||||||
import { EVerificationStatus } from '@/types/identity';
|
import { EVerificationStatus } from '@opchan/core';
|
||||||
import { sortPosts, SortOption } from '@/lib/utils/sorting';
|
import { sortPosts, SortOption } from '@opchan/core';
|
||||||
|
|
||||||
const FeedPage: React.FC = () => {
|
const FeedPage: React.FC = () => {
|
||||||
const forumData = useForumData();
|
const forumData = useForumData();
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { useAuth, useUserActions, useForumActions } from '@/hooks';
|
|||||||
import { useAuth as useAuthContext } from '@/contexts/useAuth';
|
import { useAuth as useAuthContext } from '@/contexts/useAuth';
|
||||||
import { useUserDisplay } from '@/hooks';
|
import { useUserDisplay } from '@/hooks';
|
||||||
import { useDelegation } from '@/hooks/useDelegation';
|
import { useDelegation } from '@/hooks/useDelegation';
|
||||||
import { DelegationFullStatus } from '@/lib/delegation';
|
import { DelegationFullStatus } from '@opchan/core';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
import { Label } from '@/components/ui/label';
|
import { Label } from '@/components/ui/label';
|
||||||
@ -32,7 +32,7 @@ import {
|
|||||||
Save,
|
Save,
|
||||||
X,
|
X,
|
||||||
} from 'lucide-react';
|
} from 'lucide-react';
|
||||||
import { EDisplayPreference, EVerificationStatus } from '@/types/identity';
|
import { EDisplayPreference, EVerificationStatus } from '@opchan/core';
|
||||||
import { useToast } from '@/hooks/use-toast';
|
import { useToast } from '@/hooks/use-toast';
|
||||||
|
|
||||||
export default function ProfilePage() {
|
export default function ProfilePage() {
|
||||||
|
|||||||
8300
package-lock.json
generated
8300
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -11,10 +11,10 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "npm run build:cjs && npm run build:esm && npm run build:types",
|
"build": "npm run build:cjs && npm run build:esm && npm run build:types",
|
||||||
"build:cjs": "tsc --module commonjs --outDir dist/cjs",
|
"build:cjs": "tsc --module commonjs --outDir dist/cjs",
|
||||||
"build:esm": "tsc --module esnext --outDir dist/esm && mv dist/esm/index.js dist/index.esm.js",
|
"build:esm": "tsc --module esnext --outDir dist/esm && cp -r dist/esm/* dist/ && mv dist/index.js dist/index.esm.js",
|
||||||
"build:types": "tsc --declaration --emitDeclarationOnly --outDir dist",
|
"build:types": "tsc --declaration --emitDeclarationOnly --outDir dist",
|
||||||
"dev": "tsc --watch",
|
"dev": "tsc --watch",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "vitest",
|
||||||
"lint": "eslint src --ext .ts",
|
"lint": "eslint src --ext .ts",
|
||||||
"clean": "rm -rf dist"
|
"clean": "rm -rf dist"
|
||||||
},
|
},
|
||||||
@ -25,9 +25,26 @@
|
|||||||
],
|
],
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@noble/ed25519": "^2.2.3",
|
||||||
|
"@noble/hashes": "^1.8.0",
|
||||||
|
"@reown/appkit": "^1.7.17",
|
||||||
|
"@reown/appkit-adapter-bitcoin": "^1.7.17",
|
||||||
|
"@reown/appkit-adapter-wagmi": "^1.7.17",
|
||||||
|
"@reown/appkit-common": "^1.7.17",
|
||||||
|
"@reown/appkit-controllers": "^1.7.17",
|
||||||
|
"@waku/sdk": "^0.0.35-67a7287.0",
|
||||||
|
"clsx": "^2.1.1",
|
||||||
|
"ordiscan": "^1.3.0",
|
||||||
|
"tailwind-merge": "^2.5.2",
|
||||||
|
"uuid": "^11.1.0",
|
||||||
|
"wagmi": "^2.16.1"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^5.0.0",
|
"@types/node": "^22.5.5",
|
||||||
"@types/node": "^20.0.0"
|
"@types/uuid": "^10.0.0",
|
||||||
|
"typescript": "^5.5.3",
|
||||||
|
"vitest": "^3.2.4"
|
||||||
},
|
},
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
"> 1%",
|
"> 1%",
|
||||||
|
|||||||
@ -2,39 +2,47 @@
|
|||||||
* @opchan/core - Browser library for opchan
|
* @opchan/core - Browser library for opchan
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export interface OpchanOptions {
|
// Export all types
|
||||||
debug?: boolean;
|
export * from './types/forum';
|
||||||
version?: string;
|
export * from './types/identity';
|
||||||
}
|
export * from './types/waku';
|
||||||
|
|
||||||
export class Opchan {
|
// Export database functionality
|
||||||
private options: OpchanOptions;
|
export { LocalDatabase, localDatabase } from './lib/database/LocalDatabase';
|
||||||
|
export * from './lib/database/schema';
|
||||||
|
|
||||||
constructor(options: OpchanOptions = {}) {
|
// Export delegation system
|
||||||
this.options = {
|
export {
|
||||||
debug: false,
|
DelegationManager,
|
||||||
version: '1.0.0',
|
delegationManager,
|
||||||
...options,
|
DelegationStorage,
|
||||||
};
|
DelegationCrypto
|
||||||
}
|
} from './lib/delegation';
|
||||||
|
export * from './lib/delegation/types';
|
||||||
|
|
||||||
public getVersion(): string {
|
// Export forum functionality
|
||||||
return this.options.version || '1.0.0';
|
export { ForumActions } from './lib/forum/ForumActions';
|
||||||
}
|
export { RelevanceCalculator } from './lib/forum/RelevanceCalculator';
|
||||||
|
export * from './lib/forum/transformers';
|
||||||
|
|
||||||
public isDebug(): boolean {
|
// Export services
|
||||||
return this.options.debug || false;
|
export { BookmarkService } from './lib/services/BookmarkService';
|
||||||
}
|
export { MessageService } from './lib/services/MessageService';
|
||||||
|
export { UserIdentityService } from './lib/services/UserIdentityService';
|
||||||
|
export { ordinals } from './lib/services/Ordinals';
|
||||||
|
|
||||||
public log(message: string): void {
|
// Export utilities
|
||||||
if (this.options.debug) {
|
export * from './lib/utils';
|
||||||
console.log(`[Opchan] ${message}`);
|
export { MessageValidator } from './lib/utils/MessageValidator';
|
||||||
}
|
export * from './lib/utils/sorting';
|
||||||
}
|
export { urlLoads } from './lib/utils/urlLoads';
|
||||||
}
|
export { environment, type EnvironmentConfig } from './lib/utils/environment';
|
||||||
|
|
||||||
// Default export
|
// Export Waku networking
|
||||||
export default Opchan;
|
export { default as messageManager } from './lib/waku';
|
||||||
|
export * from './lib/waku/network';
|
||||||
|
|
||||||
// Named exports for convenience
|
// Export wallet functionality
|
||||||
export { Opchan as OpchanCore };
|
export { WalletManager, walletManager } from './lib/wallet';
|
||||||
|
export * from './lib/wallet/config';
|
||||||
|
export * from './lib/wallet/types';
|
||||||
@ -11,13 +11,13 @@ import {
|
|||||||
PostMessage,
|
PostMessage,
|
||||||
CommentMessage,
|
CommentMessage,
|
||||||
VoteMessage,
|
VoteMessage,
|
||||||
} from '@/types/waku';
|
} from '../../types/waku';
|
||||||
import { OpchanMessage } from '@/types/forum';
|
import { OpchanMessage } from '../../types/forum';
|
||||||
import { MessageValidator } from '@/lib/utils/MessageValidator';
|
import { MessageValidator } from '../utils/MessageValidator';
|
||||||
import { EVerificationStatus, User } from '@/types/identity';
|
import { EVerificationStatus, User } from '../../types/identity';
|
||||||
import { DelegationInfo } from '@/lib/delegation/types';
|
import { DelegationInfo } from '../delegation/types';
|
||||||
import { openLocalDB, STORE, StoreName } from '@/lib/database/schema';
|
import { openLocalDB, STORE, StoreName } from '../database/schema';
|
||||||
import { Bookmark, BookmarkCache } from '@/types/forum';
|
import { Bookmark, BookmarkCache } from '../../types/forum';
|
||||||
|
|
||||||
export interface LocalDatabaseCache {
|
export interface LocalDatabaseCache {
|
||||||
cells: CellCache;
|
cells: CellCache;
|
||||||
@ -1,7 +1,7 @@
|
|||||||
import * as ed from '@noble/ed25519';
|
import * as ed from '@noble/ed25519';
|
||||||
import { sha512 } from '@noble/hashes/sha512';
|
import { sha512 } from '@noble/hashes/sha512';
|
||||||
import { bytesToHex, hexToBytes } from '@/lib/utils';
|
import { bytesToHex, hexToBytes } from '../utils';
|
||||||
import { WalletManager } from '@/lib/wallet';
|
import { WalletManager } from '../wallet';
|
||||||
|
|
||||||
// Set up ed25519 with sha512
|
// Set up ed25519 with sha512
|
||||||
ed.etc.sha512Sync = (...m) => sha512(ed.etc.concatBytes(...m));
|
ed.etc.sha512Sync = (...m) => sha512(ed.etc.concatBytes(...m));
|
||||||
@ -1,5 +1,5 @@
|
|||||||
import { OpchanMessage } from '@/types/forum';
|
import { OpchanMessage } from '../../types/forum';
|
||||||
import { UnsignedMessage } from '@/types/waku';
|
import { UnsignedMessage } from '../../types/waku';
|
||||||
import {
|
import {
|
||||||
DelegationDuration,
|
DelegationDuration,
|
||||||
DelegationInfo,
|
DelegationInfo,
|
||||||
@ -361,4 +361,4 @@ export class DelegationManager {
|
|||||||
// Export singleton instance
|
// Export singleton instance
|
||||||
export const delegationManager = new DelegationManager();
|
export const delegationManager = new DelegationManager();
|
||||||
export * from './types';
|
export * from './types';
|
||||||
export { DelegationStorage };
|
export { DelegationStorage, DelegationCrypto };
|
||||||
@ -1,5 +1,6 @@
|
|||||||
import { localDatabase } from '@/lib/database/LocalDatabase';
|
import { localDatabase } from '../database/LocalDatabase';
|
||||||
import { DelegationInfo } from './types';
|
import { DelegationInfo } from './types';
|
||||||
|
import { environment } from '../utils/environment';
|
||||||
|
|
||||||
export class DelegationStorage {
|
export class DelegationStorage {
|
||||||
/**
|
/**
|
||||||
@ -7,7 +8,7 @@ export class DelegationStorage {
|
|||||||
*/
|
*/
|
||||||
static async store(delegation: DelegationInfo): Promise<void> {
|
static async store(delegation: DelegationInfo): Promise<void> {
|
||||||
// Reduce verbose logging in production; keep minimal signal
|
// Reduce verbose logging in production; keep minimal signal
|
||||||
if (import.meta.env?.MODE !== 'production') {
|
if (!environment.isProduction) {
|
||||||
console.log('DelegationStorage.store');
|
console.log('DelegationStorage.store');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,7 +25,7 @@ export class DelegationStorage {
|
|||||||
static async retrieve(): Promise<DelegationInfo | null> {
|
static async retrieve(): Promise<DelegationInfo | null> {
|
||||||
try {
|
try {
|
||||||
const delegation = await localDatabase.loadDelegation();
|
const delegation = await localDatabase.loadDelegation();
|
||||||
if (import.meta.env?.MODE !== 'production') {
|
if (!environment.isProduction) {
|
||||||
console.log('DelegationStorage.retrieve');
|
console.log('DelegationStorage.retrieve');
|
||||||
}
|
}
|
||||||
return delegation;
|
return delegation;
|
||||||
@ -10,13 +10,13 @@ import {
|
|||||||
CommentMessage,
|
CommentMessage,
|
||||||
PostMessage,
|
PostMessage,
|
||||||
EModerationAction,
|
EModerationAction,
|
||||||
} from '@/types/waku';
|
} from '../../types/waku';
|
||||||
import { Cell, Comment, Post } from '@/types/forum';
|
import { Cell, Comment, Post } from '../../types/forum';
|
||||||
import { EVerificationStatus, User } from '@/types/identity';
|
import { EVerificationStatus, User } from '../../types/identity';
|
||||||
import { transformCell, transformComment, transformPost } from './transformers';
|
import { transformCell, transformComment, transformPost } from './transformers';
|
||||||
import { DelegationManager } from '@/lib/delegation';
|
import { DelegationManager } from '../delegation';
|
||||||
import { localDatabase } from '@/lib/database/LocalDatabase';
|
import { localDatabase } from '../database/LocalDatabase';
|
||||||
import messageManager from '@/lib/waku';
|
import messageManager from '../waku';
|
||||||
|
|
||||||
type ActionResult<T> = {
|
type ActionResult<T> = {
|
||||||
success: boolean;
|
success: boolean;
|
||||||
@ -4,9 +4,9 @@ import {
|
|||||||
Cell,
|
Cell,
|
||||||
RelevanceScoreDetails,
|
RelevanceScoreDetails,
|
||||||
UserVerificationStatus,
|
UserVerificationStatus,
|
||||||
} from '@/types/forum';
|
} from '../../types/forum';
|
||||||
import { EVerificationStatus, User } from '@/types/identity';
|
import { EVerificationStatus, User } from '../../types/identity';
|
||||||
import { VoteMessage } from '@/types/waku';
|
import { VoteMessage } from '../../types/waku';
|
||||||
|
|
||||||
export class RelevanceCalculator {
|
export class RelevanceCalculator {
|
||||||
private static readonly BASE_SCORES = {
|
private static readonly BASE_SCORES = {
|
||||||
@ -1,12 +1,12 @@
|
|||||||
import { RelevanceCalculator } from '../RelevanceCalculator';
|
import { RelevanceCalculator } from '../RelevanceCalculator';
|
||||||
import { Post, Comment, UserVerificationStatus } from '@/types/forum';
|
import { Post, Comment, UserVerificationStatus } from '../../types/forum';
|
||||||
import {
|
import {
|
||||||
User,
|
User,
|
||||||
EVerificationStatus,
|
EVerificationStatus,
|
||||||
EDisplayPreference,
|
EDisplayPreference,
|
||||||
} from '@/types/identity';
|
} from '../../types/identity';
|
||||||
import { VoteMessage, MessageType } from '@/types/waku';
|
import { VoteMessage, MessageType } from '../../types/waku';
|
||||||
import { DelegationProof } from '@/lib/delegation/types';
|
import { DelegationProof } from '../delegation/types';
|
||||||
import { expect, describe, beforeEach, it } from 'vitest';
|
import { expect, describe, beforeEach, it } from 'vitest';
|
||||||
|
|
||||||
// Mock delegation proof for tests
|
// Mock delegation proof for tests
|
||||||
@ -1,14 +1,15 @@
|
|||||||
import { Cell, Post, Comment } from '@/types/forum';
|
import { Cell, Post, Comment } from '../../types/forum';
|
||||||
import {
|
import {
|
||||||
CellMessage,
|
CellMessage,
|
||||||
CommentMessage,
|
CommentMessage,
|
||||||
PostMessage,
|
PostMessage,
|
||||||
VoteMessage,
|
VoteMessage,
|
||||||
|
ModerateMessage,
|
||||||
EModerationAction,
|
EModerationAction,
|
||||||
} from '@/types/waku';
|
} from '../../types/waku';
|
||||||
import messageManager from '@/lib/waku';
|
import messageManager from '../waku';
|
||||||
import { RelevanceCalculator } from './RelevanceCalculator';
|
import { RelevanceCalculator } from './RelevanceCalculator';
|
||||||
import { UserVerificationStatus } from '@/types/forum';
|
import { UserVerificationStatus } from '../../types/forum';
|
||||||
// Validation is enforced at ingestion time by LocalDatabase. Transformers assume
|
// Validation is enforced at ingestion time by LocalDatabase. Transformers assume
|
||||||
// cache contains only valid, verified messages.
|
// cache contains only valid, verified messages.
|
||||||
|
|
||||||
@ -68,7 +69,7 @@ export const transformPost = async (
|
|||||||
// Message validity already enforced upstream
|
// Message validity already enforced upstream
|
||||||
|
|
||||||
const votes = Object.values(messageManager.messageCache.votes).filter(
|
const votes = Object.values(messageManager.messageCache.votes).filter(
|
||||||
vote => vote.targetId === postMessage.id
|
(vote): vote is VoteMessage => vote && vote.targetId === postMessage.id
|
||||||
);
|
);
|
||||||
// Votes in cache are already validated; just map
|
// Votes in cache are already validated; just map
|
||||||
const filteredVotes = votes;
|
const filteredVotes = votes;
|
||||||
@ -87,7 +88,8 @@ export const transformPost = async (
|
|||||||
const userModMsg = Object.values(
|
const userModMsg = Object.values(
|
||||||
messageManager.messageCache.moderations
|
messageManager.messageCache.moderations
|
||||||
).find(
|
).find(
|
||||||
m =>
|
(m): m is ModerateMessage =>
|
||||||
|
m &&
|
||||||
m.targetType === 'user' &&
|
m.targetType === 'user' &&
|
||||||
m.cellId === postMessage.cellId &&
|
m.cellId === postMessage.cellId &&
|
||||||
m.targetId === postMessage.author
|
m.targetId === postMessage.author
|
||||||
@ -135,9 +137,11 @@ export const transformPost = async (
|
|||||||
|
|
||||||
// Get comments for this post
|
// Get comments for this post
|
||||||
const comments = await Promise.all(
|
const comments = await Promise.all(
|
||||||
Object.values(messageManager.messageCache.comments).map(comment =>
|
Object.values(messageManager.messageCache.comments)
|
||||||
transformComment(comment, undefined, userVerificationStatus)
|
.filter((comment): comment is CommentMessage => comment !== null)
|
||||||
)
|
.map(comment =>
|
||||||
|
transformComment(comment, undefined, userVerificationStatus)
|
||||||
|
)
|
||||||
).then(comments =>
|
).then(comments =>
|
||||||
comments.filter((comment): comment is Comment => comment !== null)
|
comments.filter((comment): comment is Comment => comment !== null)
|
||||||
);
|
);
|
||||||
@ -187,7 +191,7 @@ export const transformComment = async (
|
|||||||
): Promise<Comment | null> => {
|
): Promise<Comment | null> => {
|
||||||
// Message validity already enforced upstream
|
// Message validity already enforced upstream
|
||||||
const votes = Object.values(messageManager.messageCache.votes).filter(
|
const votes = Object.values(messageManager.messageCache.votes).filter(
|
||||||
vote => vote.targetId === commentMessage.id
|
(vote): vote is VoteMessage => vote && vote.targetId === commentMessage.id
|
||||||
);
|
);
|
||||||
// Votes in cache are already validated
|
// Votes in cache are already validated
|
||||||
const filteredVotes = votes;
|
const filteredVotes = votes;
|
||||||
@ -205,12 +209,13 @@ export const transformComment = async (
|
|||||||
modMsg.action === EModerationAction.MODERATE;
|
modMsg.action === EModerationAction.MODERATE;
|
||||||
// Find the post to get the correct cell ID
|
// Find the post to get the correct cell ID
|
||||||
const parentPost = Object.values(messageManager.messageCache.posts).find(
|
const parentPost = Object.values(messageManager.messageCache.posts).find(
|
||||||
post => post.id === commentMessage.postId
|
(post): post is PostMessage => post && post.id === commentMessage.postId
|
||||||
);
|
);
|
||||||
const userModMsg = Object.values(
|
const userModMsg = Object.values(
|
||||||
messageManager.messageCache.moderations
|
messageManager.messageCache.moderations
|
||||||
).find(
|
).find(
|
||||||
m =>
|
(m): m is ModerateMessage =>
|
||||||
|
m &&
|
||||||
m.targetType === 'user' &&
|
m.targetType === 'user' &&
|
||||||
m.cellId === parentPost?.cellId &&
|
m.cellId === parentPost?.cellId &&
|
||||||
m.targetId === commentMessage.author
|
m.targetId === commentMessage.author
|
||||||
@ -286,24 +291,30 @@ export const getDataFromCache = async (
|
|||||||
// First transform posts and comments to get relevance scores
|
// First transform posts and comments to get relevance scores
|
||||||
// All validation is now handled internally by the transform functions
|
// All validation is now handled internally by the transform functions
|
||||||
const posts = await Promise.all(
|
const posts = await Promise.all(
|
||||||
Object.values(messageManager.messageCache.posts).map(post =>
|
Object.values(messageManager.messageCache.posts)
|
||||||
transformPost(post, undefined, userVerificationStatus)
|
.filter((post): post is PostMessage => post !== null)
|
||||||
)
|
.map(post =>
|
||||||
|
transformPost(post, undefined, userVerificationStatus)
|
||||||
|
)
|
||||||
).then(posts => posts.filter((post): post is Post => post !== null));
|
).then(posts => posts.filter((post): post is Post => post !== null));
|
||||||
|
|
||||||
const comments = await Promise.all(
|
const comments = await Promise.all(
|
||||||
Object.values(messageManager.messageCache.comments).map(c =>
|
Object.values(messageManager.messageCache.comments)
|
||||||
transformComment(c, undefined, userVerificationStatus)
|
.filter((c): c is CommentMessage => c !== null)
|
||||||
)
|
.map(c =>
|
||||||
|
transformComment(c, undefined, userVerificationStatus)
|
||||||
|
)
|
||||||
).then(comments =>
|
).then(comments =>
|
||||||
comments.filter((comment): comment is Comment => comment !== null)
|
comments.filter((comment): comment is Comment => comment !== null)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Then transform cells with posts for relevance calculation
|
// Then transform cells with posts for relevance calculation
|
||||||
const cells = await Promise.all(
|
const cells = await Promise.all(
|
||||||
Object.values(messageManager.messageCache.cells).map(cell =>
|
Object.values(messageManager.messageCache.cells)
|
||||||
transformCell(cell, undefined, userVerificationStatus, posts)
|
.filter((cell): cell is CellMessage => cell !== null)
|
||||||
)
|
.map(cell =>
|
||||||
|
transformCell(cell, undefined, userVerificationStatus, posts)
|
||||||
|
)
|
||||||
).then(cells => cells.filter((cell): cell is Cell => cell !== null));
|
).then(cells => cells.filter((cell): cell is Cell => cell !== null));
|
||||||
|
|
||||||
return { cells, posts, comments };
|
return { cells, posts, comments };
|
||||||
@ -1,5 +1,5 @@
|
|||||||
import { Bookmark, BookmarkType, Post, Comment } from '@/types/forum';
|
import { Bookmark, BookmarkType, Post, Comment } from '../../types/forum';
|
||||||
import { localDatabase } from '@/lib/database/LocalDatabase';
|
import { localDatabase } from '../database/LocalDatabase';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service for managing bookmarks
|
* Service for managing bookmarks
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user