chore: initial commit for v0.0.1
DChain single-node blockchain + React Native messenger client. Core: - PBFT consensus with multi-sig validator admission + equivocation slashing - BadgerDB + schema migration scaffold (CurrentSchemaVersion=0) - libp2p gossipsub (tx/v1, blocks/v1, relay/v1, version/v1) - Native Go contracts (username_registry) alongside WASM (wazero) - WebSocket gateway with topic-based fanout + Ed25519-nonce auth - Relay mailbox with NaCl envelope encryption (X25519 + Ed25519) - Prometheus /metrics, per-IP rate limit, body-size cap Deployment: - Single-node compose (deploy/single/) with Caddy TLS + optional Prometheus - 3-node dev compose (docker-compose.yml) with mocked internet topology - 3-validator prod compose (deploy/prod/) for federation - Auto-update from Gitea via /api/update-check + systemd timer - Build-time version injection (ldflags → node --version) - UI / Swagger toggle flags (DCHAIN_DISABLE_UI, DCHAIN_DISABLE_SWAGGER) Client (client-app/): - Expo / React Native / NativeWind - E2E NaCl encryption, typing indicator, contact requests - Auto-discovery of canonical contracts, chain_id aware, WS reconnect on node switch Documentation: - README.md, CHANGELOG.md, CONTEXT.md - deploy/single/README.md with 6 operator scenarios - deploy/UPDATE_STRATEGY.md with 4-layer forward-compat design - docs/contracts/*.md per contract
This commit is contained in:
37
client-app/components/ui/Avatar.tsx
Normal file
37
client-app/components/ui/Avatar.tsx
Normal file
@@ -0,0 +1,37 @@
|
||||
import React from 'react';
|
||||
import { View, Text } from 'react-native';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
/** Deterministic color from a string */
|
||||
function colorFor(str: string): string {
|
||||
const colors = [
|
||||
'bg-blue-600', 'bg-purple-600', 'bg-green-600',
|
||||
'bg-pink-600', 'bg-orange-600', 'bg-teal-600',
|
||||
'bg-red-600', 'bg-indigo-600', 'bg-cyan-600',
|
||||
];
|
||||
let h = 0;
|
||||
for (let i = 0; i < str.length; i++) h = (h * 31 + str.charCodeAt(i)) >>> 0;
|
||||
return colors[h % colors.length];
|
||||
}
|
||||
|
||||
interface AvatarProps {
|
||||
name?: string;
|
||||
size?: 'sm' | 'md' | 'lg';
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const sizeMap = {
|
||||
sm: { outer: 'w-8 h-8', text: 'text-sm' },
|
||||
md: { outer: 'w-10 h-10', text: 'text-base' },
|
||||
lg: { outer: 'w-14 h-14', text: 'text-xl' },
|
||||
};
|
||||
|
||||
export function Avatar({ name = '?', size = 'md', className }: AvatarProps) {
|
||||
const initials = name.slice(0, 2).toUpperCase();
|
||||
const { outer, text } = sizeMap[size];
|
||||
return (
|
||||
<View className={cn(outer, colorFor(name), 'rounded-full items-center justify-center', className)}>
|
||||
<Text className={cn(text, 'text-white font-bold')}>{initials}</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
24
client-app/components/ui/Badge.tsx
Normal file
24
client-app/components/ui/Badge.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
import React from 'react';
|
||||
import { View, Text } from 'react-native';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
interface BadgeProps {
|
||||
label: string | number;
|
||||
variant?: 'default' | 'success' | 'destructive' | 'muted';
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const variantMap = {
|
||||
default: 'bg-primary',
|
||||
success: 'bg-success',
|
||||
destructive: 'bg-destructive',
|
||||
muted: 'bg-surfaceHigh border border-border',
|
||||
};
|
||||
|
||||
export function Badge({ label, variant = 'default', className }: BadgeProps) {
|
||||
return (
|
||||
<View className={cn('rounded-full px-2 py-0.5 items-center justify-center', variantMap[variant], className)}>
|
||||
<Text className="text-white text-xs font-semibold">{label}</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
76
client-app/components/ui/Button.tsx
Normal file
76
client-app/components/ui/Button.tsx
Normal file
@@ -0,0 +1,76 @@
|
||||
import React from 'react';
|
||||
import { Pressable, Text, ActivityIndicator } from 'react-native';
|
||||
import { cva, type VariantProps } from 'class-variance-authority';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const buttonVariants = cva(
|
||||
'flex-row items-center justify-center rounded-xl px-5 py-3 active:opacity-80',
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: 'bg-primary',
|
||||
secondary: 'bg-surfaceHigh border border-border',
|
||||
destructive: 'bg-destructive',
|
||||
ghost: 'bg-transparent',
|
||||
outline: 'bg-transparent border border-primary',
|
||||
},
|
||||
size: {
|
||||
sm: 'px-3 py-2',
|
||||
md: 'px-5 py-3',
|
||||
lg: 'px-6 py-4',
|
||||
icon: 'p-2',
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: 'default',
|
||||
size: 'md',
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
const textVariants = cva('font-semibold text-center', {
|
||||
variants: {
|
||||
variant: {
|
||||
default: 'text-white',
|
||||
secondary: 'text-white',
|
||||
destructive: 'text-white',
|
||||
ghost: 'text-primary',
|
||||
outline: 'text-primary',
|
||||
},
|
||||
size: {
|
||||
sm: 'text-sm',
|
||||
md: 'text-base',
|
||||
lg: 'text-lg',
|
||||
icon: 'text-base',
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: 'default',
|
||||
size: 'md',
|
||||
},
|
||||
});
|
||||
|
||||
interface ButtonProps extends VariantProps<typeof buttonVariants> {
|
||||
onPress?: () => void;
|
||||
disabled?: boolean;
|
||||
loading?: boolean;
|
||||
children: React.ReactNode;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function Button({
|
||||
variant, size, onPress, disabled, loading, children, className,
|
||||
}: ButtonProps) {
|
||||
return (
|
||||
<Pressable
|
||||
onPress={onPress}
|
||||
disabled={disabled || loading}
|
||||
className={cn(buttonVariants({ variant, size }), disabled && 'opacity-50', className)}
|
||||
>
|
||||
{loading
|
||||
? <ActivityIndicator color="#fff" size="small" />
|
||||
: <Text className={textVariants({ variant, size })}>{children}</Text>
|
||||
}
|
||||
</Pressable>
|
||||
);
|
||||
}
|
||||
16
client-app/components/ui/Card.tsx
Normal file
16
client-app/components/ui/Card.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
import React from 'react';
|
||||
import { View } from 'react-native';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
interface CardProps {
|
||||
children: React.ReactNode;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function Card({ children, className }: CardProps) {
|
||||
return (
|
||||
<View className={cn('bg-surface border border-border rounded-2xl p-4', className)}>
|
||||
{children}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
34
client-app/components/ui/Input.tsx
Normal file
34
client-app/components/ui/Input.tsx
Normal file
@@ -0,0 +1,34 @@
|
||||
import React, { forwardRef } from 'react';
|
||||
import { TextInput, View, Text, type TextInputProps } from 'react-native';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
interface InputProps extends TextInputProps {
|
||||
label?: string;
|
||||
error?: string;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export const Input = forwardRef<TextInput, InputProps>(
|
||||
({ label, error, className, ...props }, ref) => (
|
||||
<View className="w-full gap-1">
|
||||
{label && (
|
||||
<Text className="text-muted text-sm font-medium mb-1">{label}</Text>
|
||||
)}
|
||||
<TextInput
|
||||
ref={ref}
|
||||
placeholderTextColor="#8b949e"
|
||||
className={cn(
|
||||
'bg-surfaceHigh border border-border rounded-xl px-4 py-3 text-white text-base',
|
||||
error && 'border-destructive',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
{error && (
|
||||
<Text className="text-destructive text-xs mt-1">{error}</Text>
|
||||
)}
|
||||
</View>
|
||||
),
|
||||
);
|
||||
|
||||
Input.displayName = 'Input';
|
||||
7
client-app/components/ui/Separator.tsx
Normal file
7
client-app/components/ui/Separator.tsx
Normal file
@@ -0,0 +1,7 @@
|
||||
import React from 'react';
|
||||
import { View } from 'react-native';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
export function Separator({ className }: { className?: string }) {
|
||||
return <View className={cn('h-px bg-border my-2', className)} />;
|
||||
}
|
||||
6
client-app/components/ui/index.ts
Normal file
6
client-app/components/ui/index.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export { Button } from './Button';
|
||||
export { Card } from './Card';
|
||||
export { Input } from './Input';
|
||||
export { Avatar } from './Avatar';
|
||||
export { Badge } from './Badge';
|
||||
export { Separator } from './Separator';
|
||||
Reference in New Issue
Block a user