/** * ROB Domains — Windsurf (Codeium) Integration Example * * This file provides helper functions for integrating ROB Domains * into a Windsurf-assisted project. Call these functions from Cascade * or use them directly in your code. * * No SDK required — uses native fetch. * Paste this file into your project and import as needed. * * Base URL: https://robdn.com */ const BASE_URL = 'https://robdn.com'; type AgentResponse = | { success: true; data: T; meta: { chain: string; chainId: number; timestamp: string } } | { success: false; code: number; message: string; details?: string }; // ─── Read Endpoints ─────────────────────────────────────────────────────────── export async function searchDomain(domain: string): Promise> { const res = await fetch(`${BASE_URL}/agent/search/${encodeURIComponent(domain)}`); return res.json(); } export async function getProfile(domain: string): Promise> { const res = await fetch(`${BASE_URL}/agent/profile/${encodeURIComponent(domain)}`); return res.json(); } export async function reverseResolve(wallet: string): Promise> { const res = await fetch(`${BASE_URL}/agent/reverse/${encodeURIComponent(wallet)}`); return res.json(); } export async function getPrimaryDomain(wallet: string): Promise> { const res = await fetch(`${BASE_URL}/agent/primary/${encodeURIComponent(wallet)}`); return res.json(); } // ─── Transaction Builders ───────────────────────────────────────────────────── interface TransactionPayload { to: string; data: string; value: string; chainId: number; contractName: string; method: string; description: string; } export async function buildMintTx(domain: string): Promise> { const res = await fetch(`${BASE_URL}/agent/tx/mint`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ domain }), }); return res.json(); } export async function buildSetPrimaryTx( tokenId: string, wallet: string ): Promise> { const res = await fetch(`${BASE_URL}/agent/tx/set-primary`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ tokenId, wallet }), }); return res.json(); } export async function buildUpdateProfileTx(params: { tokenId: string; bio?: string; profilePicture?: string; coverImage?: string; background?: string; socialLinks?: { platform: string; url: string }[]; customLinks?: { title: string; url: string }[]; }): Promise> { const res = await fetch(`${BASE_URL}/agent/tx/update-profile`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(params), }); return res.json(); } // ─── Workflow ───────────────────────────────────────────────────────────────── export async function registerDomainPlan(params: { domain: string; wallet: string; setPrimary?: boolean; profile?: { bio?: string; profilePicture?: string; coverImage?: string; background?: string; socialLinks?: { platform: string; url: string }[]; customLinks?: { title: string; url: string }[]; }; }) { const res = await fetch(`${BASE_URL}/agent/workflow/register-domain`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(params), }); return res.json(); } // ─── Demo ───────────────────────────────────────────────────────────────────── async function main() { // Search for a domain const search = await searchDomain('alice'); if (search.success) { console.log(`"alice.rob" is ${search.data.available ? 'available' : 'taken'}`); } // Build a mint transaction const mintResult = await buildMintTx('alice'); if (mintResult.success) { console.log('\nMint TX payload:'); console.log(` to: ${mintResult.data.to}`); console.log(` value: ${mintResult.data.value} wei`); console.log(` chainId: ${mintResult.data.chainId}`); console.log(' Pass this payload to your wallet for signing.'); } // Full registration plan const plan = await registerDomainPlan({ domain: 'alice', wallet: '0xAbCd1234567890AbCd1234567890AbCd12345678', setPrimary: true, profile: { bio: 'Web3 builder' }, }); if (plan.success) { console.log(`\nExecution plan: ${plan.data.totalSteps} step(s)`); for (const step of plan.data.steps) { console.log(` Step ${step.step}: ${step.action}`); } } } main().catch(console.error);