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

55 lines
1.9 KiB
TypeScript

/**
* `demo` command group: run the honest loop, the RealFi flow, or reset state.
*/
import { type CommandContext, emit, UsageError } from "../lib/context.js";
import { color, heading, sym } from "../lib/render.js";
interface StepLog {
scene: string;
lines: string[];
}
const USAGE = `demo — run the protocol demo scenarios
Usage:
cred402 demo run full honest loop (resets, earns, underwrites, draws, repays)
cred402 demo realfi RealFi bridge flow (operator + fiat billing uplift)
cred402 demo reset reset the ledger to a clean bootstrapped state`;
export async function demoCommand(ctx: CommandContext): Promise<void> {
const sub = ctx.args[0];
switch (sub) {
case "run":
return runScenes(ctx, "/api/demo/run", "Honest Loop Demo");
case "realfi":
return runScenes(ctx, "/api/demo/realfi", "RealFi Bridge Demo");
case "reset":
return reset(ctx);
case undefined:
case "--help":
case "-h":
process.stdout.write(USAGE + "\n");
return;
default:
throw new UsageError(`unknown subcommand: demo ${sub}\n\n${USAGE}`);
}
}
async function runScenes(ctx: CommandContext, path: string, title: string): Promise<void> {
const result = await ctx.client.post<{ scenes: StepLog[] }>(path);
emit(ctx, result, () => {
const scenes = result.scenes ?? [];
const blocks = scenes.map((s, i) => {
const head = `${color.bold(color.cyan(`${i + 1}. ${s.scene}`))}`;
const lines = s.lines.map((l) => ` ${color.gray("│")} ${l}`).join("\n");
return `${head}\n${lines}`;
});
return heading(title) + `\n${color.dim(`${scenes.length} scenes`)}\n\n` + blocks.join("\n\n");
});
}
async function reset(ctx: CommandContext): Promise<void> {
const result = await ctx.client.post<{ ok: boolean }>("/api/demo/reset");
emit(ctx, result, () => `${sym.ok()} ledger reset to a clean bootstrapped state`);
}