diff --git a/apps/klesia/package.json b/apps/klesia/package.json index 8a2005f..5f0bbf4 100644 --- a/apps/klesia/package.json +++ b/apps/klesia/package.json @@ -7,6 +7,7 @@ "start": "bun dist/index.js" }, "dependencies": { + "@mina-js/shared": "workspace:*", "@hono/zod-openapi": "^0.16.0", "@scalar/hono-api-reference": "^0.5.143", "@urql/core": "^5.0.6", diff --git a/apps/klesia/src/index.ts b/apps/klesia/src/index.ts index 42ad052..230a2a2 100644 --- a/apps/klesia/src/index.ts +++ b/apps/klesia/src/index.ts @@ -5,6 +5,7 @@ import { match } from "ts-pattern"; import { mina } from "./methods/mina"; import { RpcMethodSchema, RpcResponseSchema } from "./schema"; import { buildResponse } from "./utils/build-response"; +import { PublicKeySchema } from "@mina-js/shared"; const api = new OpenAPIHono(); @@ -41,12 +42,12 @@ api.openapi(rpcRoute, async ({ req, json }) => { return match(body) .with({ method: "mina_getTransactionCount" }, async ({ params }) => { const [publicKey] = params; - const result = await mina.getTransactionCount({ publicKey }); + const result = await mina.getTransactionCount({ publicKey: PublicKeySchema.parse(publicKey) }); return json(buildResponse(result), 200); }) .with({ method: "mina_getBalance" }, async ({ params }) => { const [publicKey] = params; - const result = await mina.getBalance({ publicKey }); + const result = await mina.getBalance({ publicKey: PublicKeySchema.parse(publicKey) }); return json(buildResponse(result), 200); }) .with({ method: "mina_blockHash" }, async () => { diff --git a/apps/klesia/src/methods/mina.ts b/apps/klesia/src/methods/mina.ts index 8dda210..cef574a 100644 --- a/apps/klesia/src/methods/mina.ts +++ b/apps/klesia/src/methods/mina.ts @@ -1,6 +1,7 @@ import { gql } from "@urql/core"; import { match } from "ts-pattern"; import { getNodeClient } from "../utils/node"; +import { SignedTransactionSchema } from "@mina-js/shared"; const getTransactionCount = async ({ publicKey }: { publicKey: string }) => { const client = getNodeClient(); @@ -75,7 +76,7 @@ const sendTransaction = async ({ const client = getNodeClient(); return match(type) .with("payment", async () => { - const { signature, data: input } = signedTransaction; + const { signature, data: input } = SignedTransactionSchema.parse(signedTransaction) const { data } = await client.mutation( gql` mutation { @@ -91,7 +92,7 @@ const sendTransaction = async ({ return data.sendPayment.payment.hash; }) .with("delegation", async () => { - const { signature, data: input } = signedTransaction; + const { signature, data: input } = SignedTransactionSchema.parse(signedTransaction) const { data } = await client.mutation( gql` mutation { diff --git a/apps/klesia/src/schema.ts b/apps/klesia/src/schema.ts index ddedebf..a3ac52e 100644 --- a/apps/klesia/src/schema.ts +++ b/apps/klesia/src/schema.ts @@ -1,6 +1,6 @@ +import { PublicKeySchema } from "@mina-js/shared"; import { z } from "zod"; -export const PublicKeySchema = z.string().length(55); export const PublicKeyParamsSchema = z.array(PublicKeySchema).length(1); export const EmptyParamsSchema = z.array(z.string()).length(0).optional(); export const SendTransactionSchema = z.array(z.any(), z.string()).length(2); diff --git a/bun.lockb b/bun.lockb index 460b1ad..df0c653 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/packages/accounts/.turbo/turbo-build.log b/packages/accounts/.turbo/turbo-build.log deleted file mode 100644 index 529d2b4..0000000 --- a/packages/accounts/.turbo/turbo-build.log +++ /dev/null @@ -1,20 +0,0 @@ - -$ tsup -CLI Building entry: src/index.ts -CLI Using tsconfig: ../../tsconfig.json -CLI tsup v8.2.3 -CLI Using tsup config: /Users/tomek/repos/mina-js/packages/accounts/tsup.config.ts -CLI Target: esnext -CLI Cleaning output folder -ESM Build start -CJS Build start -CJS dist/index.js 2.25 KB -CJS dist/index.js.map 1.44 KB -CJS ⚡️ Build success in 6ms -ESM dist/index.mjs 575.00 B -ESM dist/index.mjs.map 1.35 KB -ESM ⚡️ Build success in 7ms -DTS Build start -DTS ⚡️ Build success in 516ms -DTS dist/index.d.mts 631.00 B -DTS dist/index.d.ts 631.00 B diff --git a/packages/connect/.turbo/turbo-build.log b/packages/connect/.turbo/turbo-build.log deleted file mode 100644 index 41157dd..0000000 --- a/packages/connect/.turbo/turbo-build.log +++ /dev/null @@ -1,20 +0,0 @@ - -$ tsup -CLI Building entry: src/index.ts -CLI Using tsconfig: ../../tsconfig.json -CLI tsup v8.2.3 -CLI Using tsup config: /Users/tomek/repos/mina-js/packages/connect/tsup.config.ts -CLI Target: esnext -CLI Cleaning output folder -ESM Build start -CJS Build start -CJS dist/index.js 3.07 KB -CJS dist/index.js.map 6.11 KB -CJS ⚡️ Build success in 5ms -ESM dist/index.mjs 1.99 KB -ESM dist/index.mjs.map 5.61 KB -ESM ⚡️ Build success in 6ms -DTS Build start -DTS ⚡️ Build success in 594ms -DTS dist/index.d.mts 2.51 KB -DTS dist/index.d.ts 2.51 KB diff --git a/packages/providers/.turbo/turbo-build.log b/packages/providers/.turbo/turbo-build.log deleted file mode 100644 index b3ffb67..0000000 --- a/packages/providers/.turbo/turbo-build.log +++ /dev/null @@ -1,20 +0,0 @@ - -$ tsup -CLI Building entry: src/index.ts -CLI Using tsconfig: ../../tsconfig.json -CLI tsup v8.2.3 -CLI Using tsup config: /Users/tomek/repos/mina-js/packages/providers/tsup.config.ts -CLI Target: esnext -CLI Cleaning output folder -ESM Build start -CJS Build start -ESM dist/index.js 1.52 KB -ESM dist/index.js.map 3.07 KB -ESM ⚡️ Build success in 6ms -CJS dist/index.cjs 3.40 KB -CJS dist/index.cjs.map 3.24 KB -CJS ⚡️ Build success in 6ms -DTS Build start -DTS ⚡️ Build success in 643ms -DTS dist/index.d.ts 12.33 KB -DTS dist/index.d.cts 12.33 KB diff --git a/packages/shared/.turbo/turbo-build.log b/packages/shared/.turbo/turbo-build.log deleted file mode 100644 index 7a5a1d2..0000000 --- a/packages/shared/.turbo/turbo-build.log +++ /dev/null @@ -1,20 +0,0 @@ - -$ tsup -CLI Building entry: src/index.ts -CLI Using tsconfig: ../../tsconfig.json -CLI tsup v8.2.3 -CLI Using tsup config: /Users/tomek/repos/mina-js/packages/shared/tsup.config.ts -CLI Target: esnext -CLI Cleaning output folder -ESM Build start -CJS Build start -CJS dist/index.cjs 4.62 KB -CJS dist/index.cjs.map 4.36 KB -CJS ⚡️ Build success in 6ms -ESM dist/index.js 2.33 KB -ESM dist/index.js.map 4.16 KB -ESM ⚡️ Build success in 6ms -DTS Build start -DTS ⚡️ Build success in 719ms -DTS dist/index.d.ts 11.44 KB -DTS dist/index.d.cts 11.44 KB diff --git a/turbo.json b/turbo.json index da62c81..1c4931b 100644 --- a/turbo.json +++ b/turbo.json @@ -1,14 +1,14 @@ { - "$schema": "https://turbo.build/schema.json", - "tasks": { - "build": { - "dependsOn": ["^build"], - "outputs": ["dist/**"] - }, - "cleanup": {}, - "dev": { - "persistent": true, - "cache": false - } - } + "$schema": "https://turbo.build/schema.json", + "tasks": { + "build": { + "dependsOn": ["^build"], + "outputs": ["dist/**"] + }, + "cleanup": {}, + "dev": { + "persistent": true, + "cache": false + } + } }