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