From 41f860529ffe61c43fb6e72dfbb83315c1be5092 Mon Sep 17 00:00:00 2001 From: Tomek Marciniak Date: Mon, 2 Sep 2024 22:50:40 +0200 Subject: [PATCH] feat(packages): add klesia-sdk --- apps/klesia/docs/index.txt | 5 ++++ apps/klesia/{src/docs.md => docs/rpc.txt} | 4 --- apps/klesia/package.json | 19 +++++++++++--- apps/klesia/src/custom.d.ts | 2 +- apps/klesia/src/index.ts | 16 ++++++++---- apps/klesia/tsup.config.ts | 3 +++ bun.lockb | Bin 85968 -> 87208 bytes packages/klesia-sdk/README.md | 15 +++++++++++ packages/klesia-sdk/package.json | 29 ++++++++++++++++++++++ packages/klesia-sdk/src/client.ts | 17 +++++++++++++ packages/klesia-sdk/src/index.ts | 1 + packages/klesia-sdk/tsup.config.ts | 3 +++ 12 files changed, 100 insertions(+), 14 deletions(-) create mode 100644 apps/klesia/docs/index.txt rename apps/klesia/{src/docs.md => docs/rpc.txt} (80%) create mode 100644 apps/klesia/tsup.config.ts create mode 100644 packages/klesia-sdk/README.md create mode 100644 packages/klesia-sdk/package.json create mode 100644 packages/klesia-sdk/src/client.ts create mode 100644 packages/klesia-sdk/src/index.ts create mode 100644 packages/klesia-sdk/tsup.config.ts diff --git a/apps/klesia/docs/index.txt b/apps/klesia/docs/index.txt new file mode 100644 index 0000000..d26e16d --- /dev/null +++ b/apps/klesia/docs/index.txt @@ -0,0 +1,5 @@ +Klesia RPC is a JSON-RPC 2.0 wrapper over common Mina Protocol tools and services. The intention is to provide an outstanding Developer Experience for Mina Protocol's zkApp Developers. + +## TypeScript SDK + +There is a TypeScript SDK available for Klesia RPC. It is available on npm as `@mina-js/klesia-sdk`. diff --git a/apps/klesia/src/docs.md b/apps/klesia/docs/rpc.txt similarity index 80% rename from apps/klesia/src/docs.md rename to apps/klesia/docs/rpc.txt index 34a92ce..d332161 100644 --- a/apps/klesia/src/docs.md +++ b/apps/klesia/docs/rpc.txt @@ -1,7 +1,3 @@ -# Klesia RPC - -Klesia RPC is a JSON-RPC 2.0 wrapper over common Mina Protocol tools and services. The intention is to provide an outstanding Developer Experience for Mina Protocol's zkApp Developers. - ## Methods ### mina_getTransactionCount diff --git a/apps/klesia/package.json b/apps/klesia/package.json index 49d24a2..6d2c50c 100644 --- a/apps/klesia/package.json +++ b/apps/klesia/package.json @@ -1,17 +1,28 @@ { "name": "@mina-js/klesia", "type": "module", + "module": "dist/index.js", + "types": "dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "default": "./dist/index.cjs", + "import": "./dist/index.js" + } + }, "scripts": { - "build": "tsc --noEmit && bun build src/index.ts --outdir dist", - "dev": "bun run --hot src/index.ts", - "start": "bun dist/index.js" + "build": "tsup-node", + "dev": "tsup-node --watch --onSuccess \"node dist/index.js\"", + "start": "node dist/index.js" }, "dependencies": { - "@mina-js/shared": "workspace:*", + "@hono/node-server": "^1.12.2", "@hono/zod-openapi": "^0.16.0", + "@mina-js/shared": "workspace:*", "@scalar/hono-api-reference": "^0.5.143", "@urql/core": "^5.0.6", "dayjs": "^1.11.13", + "dotenv": "^16.4.5", "hono": "^4.5.10", "hono-rate-limiter": "^0.4.0", "nanoid": "^5.0.7", diff --git a/apps/klesia/src/custom.d.ts b/apps/klesia/src/custom.d.ts index 18f423b..2ca0a44 100644 --- a/apps/klesia/src/custom.d.ts +++ b/apps/klesia/src/custom.d.ts @@ -1 +1 @@ -declare module "*.md"; +declare module "*.txt"; diff --git a/apps/klesia/src/index.ts b/apps/klesia/src/index.ts index 7793208..334e5c3 100644 --- a/apps/klesia/src/index.ts +++ b/apps/klesia/src/index.ts @@ -1,12 +1,15 @@ +import "dotenv/config"; +import { serve } from "@hono/node-server"; +import { getConnInfo } from "@hono/node-server/conninfo"; import { OpenAPIHono, createRoute } from "@hono/zod-openapi"; import { PublicKeySchema } from "@mina-js/shared"; import { apiReference } from "@scalar/hono-api-reference"; import { rateLimiter } from "hono-rate-limiter"; -import { getConnInfo } from "hono/bun"; import { logger } from "hono/logger"; import { nanoid } from "nanoid"; import { match } from "ts-pattern"; -import rpcDocs from "./docs.md" with { type: "text" }; +import mainDocs from "../docs/index.txt"; +import rpcDocs from "../docs/rpc.txt"; import { mina } from "./methods/mina"; import { RpcMethodSchema, RpcResponseSchema } from "./schema"; import { buildResponse } from "./utils/build-response"; @@ -25,7 +28,8 @@ api.doc("/api/openapi", { openapi: "3.0.0", info: { version: "1.0.0", - title: "Klesia API", + title: "Klesia RPC", + description: mainDocs, }, }); @@ -50,7 +54,7 @@ const rpcRoute = createRoute({ api.get("/", ({ redirect }) => redirect("/api", 301)); -api.openapi(rpcRoute, async ({ req, json }) => { +const klesiaRpcRoute = api.openapi(rpcRoute, async ({ req, json }) => { const body = req.valid("json"); return match(body) .with({ method: "mina_getTransactionCount" }, async ({ params }) => { @@ -93,4 +97,6 @@ api.get( }), ); -export default api; +serve(api); + +export type KlesiaRpc = typeof klesiaRpcRoute; diff --git a/apps/klesia/tsup.config.ts b/apps/klesia/tsup.config.ts new file mode 100644 index 0000000..33013ce --- /dev/null +++ b/apps/klesia/tsup.config.ts @@ -0,0 +1,3 @@ +import sharedConfig from "../../packages/shared/tsup.config"; + +export default sharedConfig; diff --git a/bun.lockb b/bun.lockb index b975fc1fc8ab9ab488a8034038a4d6b0356e6191..423e4fbef046c42978d649e5b24c515390599301 100755 GIT binary patch delta 12952 zcmeHOcUY8H)_?E7zzm9tf-nq9QBYKnB29!rMKl6-gC&VlMjb>@K@-y$Q+DGT6O*Hk z8bz!T6F0hQvWaUft1;2o(qkc_W);PP#*X;?&Rc}draYVM{_{P1AAj#D_uO{wx$nL2 za6PZ&{g-dou5|SoCL~VZ zzn0}c@yIEe$77PMFgq;2SaLzGnwLsnl8lgxr{zw~F1AVoU#s$dDBMMony}FXYoTr245_s$2ZFjopR89Z zA74Xd+t3bK2KO2+BZYt4Mhbg zH+UQwOqZf|u=W~IF7PWA+1taR+>syG69ac}2ik&iJF74OX3*K7CaF}ikHySz#&jsW zK!?ET++crCg)Rl~;QZ1T~Lgq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i=WI(@}Iv8b)EnJz>w$`-xEghhW7 zvfa3-HsUYuJdyiV*|pjjFs`&sa?4zr^p|z{kifO<+zE@Sg)Fu^{e?)=cRlA6Ap-4x zu!HJhW87m4F`XaM_u4gH*0H~FZErY_2-NoQ7Ap2TttMd;>egrd7aN?I=Uk3$*KS;V zTXT5v#1(m;=3>-wI5=QM)$hnT7PK2Qr}^7S@sLDeN=8M*g*t!W9sBPUT1nbtbB4GG zo7K21x3<;U+2bD#=e0p!hbK74x}XN*^4rBbw$T@wxgcC4BjR}NkTyG4K|$8OpEH~Odd^h!`WUy~a=d1~@=@f#h^D-SMe>2{AD1+4*zI4q zU`JH(r2@4KOdV~rIS-hH%~{_~1d1eQYd6G4Z|6jS>0qMspquDrdNtYE$X#^tj8?Ss z?FPj;!d*n!jazwpo;tPk=#CfLaDYU_N8lreac^(lri-VO>VFb!!cu@8Ee^Z6^RT-} z3ofBOCgmhSfvp%mwrw2T@Hhpswc^!DJ_IdvS^&a>|pWOn!KKKvf zhxS*V?(k&*|GtB#UYgUhu9&@TS6#6t!TD_u(akxehsfI2{Za9(aPH|L8adbZ6hYf= z^%Rp`x9#X7B21o-rDyIhZvY)8$8KD1*KuRCyrv74(nRhnzHiz?n0cLxOng9R* diff --git a/packages/klesia-sdk/README.md b/packages/klesia-sdk/README.md new file mode 100644 index 0000000..ac29d3f --- /dev/null +++ b/packages/klesia-sdk/README.md @@ -0,0 +1,15 @@ +# klesia-sdk + +To install dependencies: + +```bash +bun install +``` + +To run: + +```bash +bun run index.ts +``` + +This project was created using `bun init` in bun v1.1.27. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime. diff --git a/packages/klesia-sdk/package.json b/packages/klesia-sdk/package.json new file mode 100644 index 0000000..571c4c7 --- /dev/null +++ b/packages/klesia-sdk/package.json @@ -0,0 +1,29 @@ +{ + "name": "@mina-js/klesia-sdk", + "type": "module", + "module": "dist/index.js", + "types": "dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "default": "./dist/index.cjs", + "import": "./dist/index.js" + } + }, + "scripts": { + "build": "tsup", + "test": "bun test", + "cleanup": "rimraf dist .turbo" + }, + "devDependencies": { + "@mina-js/klesia": "workspace:*" + }, + "peerDependencies": { + "typescript": "^5.0.0" + }, + "dependencies": { + "hono": "^4.5.10", + "ts-pattern": "^5.3.1", + "zod": "^3.23.8" + } +} diff --git a/packages/klesia-sdk/src/client.ts b/packages/klesia-sdk/src/client.ts new file mode 100644 index 0000000..2208505 --- /dev/null +++ b/packages/klesia-sdk/src/client.ts @@ -0,0 +1,17 @@ +import type { KlesiaRpc } from "@mina-js/klesia"; +import { hc } from "hono/client"; +import { match } from "ts-pattern"; +import { z } from "zod"; + +const NetworkMatcher = z.enum(["mainnet", "devnet"]); + +export const createClient = ({ network }: { network: 'mainnet' | 'devnet' }) => { + return match(NetworkMatcher.parse(network)) + .with("devnet", () => + hc("https://devnet.klesia.palladians.xyz/api"), + ) + .with("mainnet", () => + hc("https://mainnet.klesia.palladians.xyz/api"), + ) + .exhaustive(); +}; diff --git a/packages/klesia-sdk/src/index.ts b/packages/klesia-sdk/src/index.ts new file mode 100644 index 0000000..da6c2d5 --- /dev/null +++ b/packages/klesia-sdk/src/index.ts @@ -0,0 +1 @@ +export { createClient } from "./client"; diff --git a/packages/klesia-sdk/tsup.config.ts b/packages/klesia-sdk/tsup.config.ts new file mode 100644 index 0000000..6e9381b --- /dev/null +++ b/packages/klesia-sdk/tsup.config.ts @@ -0,0 +1,3 @@ +import sharedConfig from "../shared/tsup.config"; + +export default sharedConfig;