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

52 lines
1.8 KiB
TypeScript

/**
* Typed Casper runtime arguments (the inputs to a contract entry point).
*
* A dependency-free, serializable representation of CLValues. casper-js-sdk turns
* these into the exact CL byte encoding at submit time; keeping the typed spec
* here means the contract-call shape is defined and testable without the SDK.
*/
export type CLType = "String" | "Bool" | "U64" | "U512" | "Key" | "PublicKey" | "ByteArray";
export interface RuntimeArg {
name: string;
clType: CLType;
value: string; // canonical string form (bigints as decimal, keys as hex)
}
export const arg = {
string(name: string, value: string): RuntimeArg {
return { name, clType: "String", value };
},
bool(name: string, value: boolean): RuntimeArg {
return { name, clType: "Bool", value: value ? "true" : "false" };
},
u64(name: string, value: number | bigint): RuntimeArg {
return { name, clType: "U64", value: BigInt(value).toString() };
},
u512(name: string, motes: bigint): RuntimeArg {
if (motes < 0n) throw new Error("U512 cannot be negative");
return { name, clType: "U512", value: motes.toString() };
},
key(name: string, hashHex: string): RuntimeArg {
return { name, clType: "Key", value: normalizeHex(hashHex) };
},
publicKey(name: string, pubKeyHex: string): RuntimeArg {
return { name, clType: "PublicKey", value: normalizeHex(pubKeyHex) };
},
};
function normalizeHex(h: string): string {
const x = h.startsWith("0x") ? h.slice(2) : h;
if (!/^[0-9a-fA-F]*$/.test(x)) throw new Error(`invalid hex: ${h}`);
return x.toLowerCase();
}
/** Render args as `casper-client`'s `--session-arg "name:type='value'"` flags. */
export function toCasperClientArgs(args: RuntimeArg[]): string[] {
return args.map((a) => {
const t = a.clType.toLowerCase();
return `--session-arg "${a.name}:${t}='${a.value}'"`;
});
}