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
62 lines
1.6 KiB
TypeScript
62 lines
1.6 KiB
TypeScript
'use client'
|
|
|
|
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
|
import { api } from '@/lib/api'
|
|
import type { CreateWalletRequest, ReshareWalletRequest } from '@/lib/types'
|
|
|
|
const WALLETS_KEY = ['wallets'] as const
|
|
|
|
export function useWallets(vaultId: string) {
|
|
return useQuery({
|
|
queryKey: [...WALLETS_KEY, 'by-vault', vaultId],
|
|
queryFn: () => api.listWallets(vaultId),
|
|
enabled: !!vaultId,
|
|
})
|
|
}
|
|
|
|
export function useWallet(id: string) {
|
|
return useQuery({
|
|
queryKey: [...WALLETS_KEY, id],
|
|
queryFn: () => api.getWallet(id),
|
|
enabled: !!id,
|
|
})
|
|
}
|
|
|
|
export function useWalletAddresses(id: string) {
|
|
return useQuery({
|
|
queryKey: [...WALLETS_KEY, id, 'addresses'],
|
|
queryFn: () => api.getWalletAddresses(id),
|
|
enabled: !!id,
|
|
})
|
|
}
|
|
|
|
export function useWalletHistory(id: string) {
|
|
return useQuery({
|
|
queryKey: [...WALLETS_KEY, id, 'history'],
|
|
queryFn: () => api.getWalletHistory(id),
|
|
enabled: !!id,
|
|
})
|
|
}
|
|
|
|
export function useCreateWallet() {
|
|
const qc = useQueryClient()
|
|
return useMutation({
|
|
mutationFn: ({ vaultId, ...req }: CreateWalletRequest & { vaultId: string }) =>
|
|
api.createWallet(vaultId, req),
|
|
onSuccess: (_data, variables) => {
|
|
qc.invalidateQueries({ queryKey: [...WALLETS_KEY, 'by-vault', variables.vaultId] })
|
|
},
|
|
})
|
|
}
|
|
|
|
export function useReshareWallet() {
|
|
const qc = useQueryClient()
|
|
return useMutation({
|
|
mutationFn: ({ id, ...req }: ReshareWalletRequest & { id: string }) =>
|
|
api.reshareWallet(id, req),
|
|
onSuccess: (_data, variables) => {
|
|
qc.invalidateQueries({ queryKey: [...WALLETS_KEY, variables.id] })
|
|
},
|
|
})
|
|
}
|