Hey is a decentralized and permissionless social media app built with Lens Protocol 馃尶
at main 29 lines 844 B view raw
1import type { Context } from "hono"; 2import type { Hex } from "viem"; 3import { getRecord } from "./query"; 4import { decodeEnsOffchainRequest, encodeEnsOffchainResponse } from "./utils"; 5 6const CCIP = async (ctx: Context) => { 7 const sender = ctx.req.param("sender"); 8 const dataParam = ctx.req.param("data"); 9 if (!sender || !dataParam) return ctx.json({ error: "Bad Request" }, 400); 10 11 let result: string; 12 13 try { 14 const param = { data: dataParam as Hex, sender: sender as Hex }; 15 const { name, query } = decodeEnsOffchainRequest(param); 16 result = await getRecord(name, query); 17 const data = await encodeEnsOffchainResponse( 18 param, 19 result, 20 process.env.PRIVATE_KEY as Hex 21 ); 22 23 return ctx.json({ data }, 200); 24 } catch { 25 return ctx.json({ error: "Bad Request" }, 400); 26 } 27}; 28 29export default CCIP;