mirror of
https://github.com/luxfi/mpc.git
synced 2026-09-24 00:26:24 +00:00
Complete MPC wallet management platform rivaling Fireblocks/Utila/Fordefi: Backend (Go): - REST API with 60+ endpoints on chi router (pkg/api/) - PostgreSQL schema with 13 tables (pkg/db/) - JWT + MFA auth, bcrypt passwords, API key management - Policy engine (deny/approve/require_approval) - Transaction signing flow with approval workflow - Subscription scheduler for recurring payments - Payment requests with public pay pages - Safe + ERC-4337 smart wallet integration (pkg/smart/) - Rate limiting, webhook delivery (HMAC-SHA256), audit logging - 27 passing tests (auth, policy engine, middleware) Frontend (Next.js 14): - 27 routes with monochrome dark theme (Tailwind + Geist fonts) - Full API client with JWT auto-refresh - React Query hooks for all resources - Pages: dashboard, vaults, wallets, transactions, policies, whitelist, team, settings, API keys, webhooks, audit, subscriptions, payments, smart wallets Infrastructure: - Dockerfiles for API (Go) and dashboard (Next.js standalone) - compose.yml for local development (PostgreSQL + API + dashboard) - K8s manifests for mpc.lux.network + cloud.lux.network - GitHub Actions deploy workflow (build → push GHCR → kubectl apply) - TLS via cert-manager, Traefik IngressRoute for both domains
93 lines
2.4 KiB
TypeScript
93 lines
2.4 KiB
TypeScript
'use client'
|
|
|
|
import { useState } from 'react'
|
|
|
|
export interface ApprovalPanelProps {
|
|
transactionId: string
|
|
status: 'awaiting_approval' | 'pending' | 'confirmed' | 'failed'
|
|
requiredApprovals: number
|
|
currentApprovals: number
|
|
canApprove: boolean
|
|
onApprove: (transactionId: string) => Promise<void>
|
|
onReject: (transactionId: string) => Promise<void>
|
|
}
|
|
|
|
export function ApprovalPanel({
|
|
transactionId,
|
|
status,
|
|
requiredApprovals,
|
|
currentApprovals,
|
|
canApprove,
|
|
onApprove,
|
|
onReject,
|
|
}: ApprovalPanelProps) {
|
|
const [acting, setActing] = useState(false)
|
|
|
|
async function handleApprove() {
|
|
setActing(true)
|
|
try {
|
|
await onApprove(transactionId)
|
|
} finally {
|
|
setActing(false)
|
|
}
|
|
}
|
|
|
|
async function handleReject() {
|
|
setActing(true)
|
|
try {
|
|
await onReject(transactionId)
|
|
} finally {
|
|
setActing(false)
|
|
}
|
|
}
|
|
|
|
if (status !== 'awaiting_approval') {
|
|
return null
|
|
}
|
|
|
|
return (
|
|
<div className="rounded-lg border border-border bg-card p-4 space-y-4">
|
|
<div className="flex items-center justify-between text-sm">
|
|
<span className="text-muted-foreground">Approvals</span>
|
|
<span className="font-mono">
|
|
{currentApprovals} / {requiredApprovals}
|
|
</span>
|
|
</div>
|
|
|
|
<div className="h-1.5 w-full rounded-full bg-muted">
|
|
<div
|
|
className="h-1.5 rounded-full bg-primary transition-all"
|
|
style={{
|
|
width: `${Math.min(100, (currentApprovals / requiredApprovals) * 100)}%`,
|
|
}}
|
|
/>
|
|
</div>
|
|
|
|
{canApprove && (
|
|
<div className="flex gap-3">
|
|
<button
|
|
onClick={handleReject}
|
|
disabled={acting}
|
|
className="flex-1 rounded-md border border-destructive/30 px-4 py-2 text-sm font-medium text-destructive hover:bg-destructive/10 disabled:opacity-50"
|
|
>
|
|
Reject
|
|
</button>
|
|
<button
|
|
onClick={handleApprove}
|
|
disabled={acting}
|
|
className="flex-1 rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50"
|
|
>
|
|
{acting ? 'Submitting...' : 'Approve'}
|
|
</button>
|
|
</div>
|
|
)}
|
|
|
|
{!canApprove && (
|
|
<p className="text-center text-xs text-muted-foreground">
|
|
You have already submitted your approval for this transaction.
|
|
</p>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|