caelum0x 2d43618725 feat: real integrations (Casper Testnet, x402/EIP-712, MCP, RealFi, cross-chain), wallet sign-in, branding
Replace the design-note docs (p1–p7) with the implemented "make it real" phase
docs (p8–p10) and wire production-grade, env-gated real integrations:

- p8 Casper Testnet: byte-exact deploys + WASM install via casper-js-sdk; live
  node reads (node.testnet.casper.network); CRED402_CHAIN=sim|testnet transport.
- p9 x402 + data + MCP: real EIP-712 typed-data digests (@casper-ecosystem/
  casper-eip-712); casper-x402 facilitator client (x402 V2); live Open-Meteo GHI;
  official @modelcontextprotocol/sdk server; casper-sidecar SSE event feed.
- p10 RealFi + cross-chain: real Stripe test-mode webhooks (HMAC-verified) and
  Plaid sandbox → privacy-preserving on-chain envelopes; Base Sepolia EVM deploy
  (Foundry); reachable via /api/realfi/* and /api/x402/facilitator routes.
- Sign-in with Casper Wallet: real extension provider + challenge/ed25519/session
  flow (/v1/auth/wallet/*), console connect + sign-in button.
- Branding: Cred402 logo mark, favicon, OG image; Vercel config for the console.

All env-gated with sim/free-API fallbacks; full suite green, all toolchains
(TS/Rust/Go/Solidity) build.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 00:37:36 +03:00

73 lines
1.8 KiB
Go

// Command indexer replays the Cred402 durable event journal (NDJSON) into
// queryable projections (p2 §7.4). It consumes exactly what
// lib/gateway/persistence.ts writes, maintains a seq checkpoint, and can either
// run once or watch the journal for new events.
//
// go run ./cmd/indexer --journal /path/to/events.ndjson
// go run ./cmd/indexer --journal events.ndjson --out projections.json --watch 2s
package main
import (
"flag"
"fmt"
"log"
"os"
"time"
"github.com/cred402/event-indexer/internal/event"
"github.com/cred402/event-indexer/internal/projections"
"github.com/cred402/event-indexer/internal/sink"
)
func main() {
journalPath := flag.String("journal", "", "path to the NDJSON event journal (required)")
outPath := flag.String("out", "", "write projections JSON to this file (default: stdout)")
watch := flag.Duration("watch", 0, "poll the journal at this interval (e.g. 2s); 0 = run once")
flag.Parse()
if *journalPath == "" {
fmt.Fprintln(os.Stderr, "error: --journal is required")
flag.Usage()
os.Exit(2)
}
var out sink.Sink = sink.StdoutSink{}
if *outPath != "" {
out = sink.FileSink{Path: *outPath}
}
store := projections.NewStore()
run := func() error {
f, err := os.Open(*journalPath)
if err != nil {
return err
}
defer f.Close()
events, err := event.DecodeJournal(f)
if err != nil {
return err
}
// Replay only events beyond the current checkpoint (incremental + idempotent).
store.ApplyAll(events, store.LastSeq)
return out.Write(store)
}
if *watch == 0 {
if err := run(); err != nil {
log.Fatalf("indexer: %v", err)
}
return
}
log.Printf("indexer watching %s every %s", *journalPath, *watch)
ticker := time.NewTicker(*watch)
defer ticker.Stop()
for {
if err := run(); err != nil {
log.Printf("indexer: %v", err)
}
<-ticker.C
}
}