Skip to content

Commit e944086

Browse files
committed
fix(conflicts): resolve
2 parents 400e97b + b5e48fd commit e944086

File tree

22 files changed

+553
-461
lines changed

22 files changed

+553
-461
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ jobs:
1414
- run: bun i --no-save
1515
- run: bun run build
1616
- run: bun run test
17-
- run: bunx pkg-pr-new publish './packages/klesia-sdk' './packages/accounts' './packages/connect' './packages/providers' './packages/utils'
17+
- run: bunx pkg-pr-new publish './packages/klesia-sdk' './packages/klesia-utils' './packages/accounts' './packages/connect' './packages/providers' './packages/utils'

apps/klesia/package.json

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,34 @@
11
{
2-
"name": "@mina-js/klesia",
3-
"type": "module",
4-
"version": "0.0.1",
5-
"module": "dist/index.js",
6-
"types": "dist/index.d.ts",
7-
"exports": {
8-
".": {
9-
"types": "./dist/index.d.ts",
10-
"default": "./dist/index.js"
11-
}
12-
},
13-
"scripts": {
14-
"build": "tsup-node",
15-
"dev": "tsup-node --watch --onSuccess \"node dist/server.js\"",
16-
"start": "node dist/server.js",
17-
"test": "bun test --rerun-each 3",
18-
"cleanup": "rimraf dist .turbo node_modules"
19-
},
20-
"devDependencies": {
21-
"@mina-js/utils": "0.1.1"
22-
},
23-
"dependencies": {
24-
"@hono/node-server": "1.13.8",
25-
"@hono/zod-openapi": "0.19.2",
26-
"@urql/core": "5.1.1",
27-
"bigint-quantile": "0.0.2",
28-
"dayjs": "1.11.13",
29-
"dotenv": "16.4.7",
30-
"hono": "4.7.4",
31-
"hono-rate-limiter": "0.4.2",
32-
"nanoid": "5.1.3",
33-
"ofetch": "1.4.1",
34-
"ts-pattern": "5.6.2",
35-
"zod": "3.24.2"
36-
}
2+
"name": "@mina-js/klesia",
3+
"type": "module",
4+
"version": "0.0.1",
5+
"module": "dist/index.js",
6+
"types": "dist/index.d.ts",
7+
"exports": {
8+
".": {
9+
"types": "./dist/index.d.ts",
10+
"default": "./dist/index.js"
11+
}
12+
},
13+
"scripts": {
14+
"build": "tsup-node",
15+
"dev": "tsup-node --watch --onSuccess \"node dist/server.js\"",
16+
"start": "node dist/server.js",
17+
"test": "bun test --rerun-each 3",
18+
"cleanup": "rimraf dist .turbo node_modules"
19+
},
20+
"devDependencies": {
21+
"@mina-js/klesia-utils": "0.1.1",
22+
"@mina-js/utils": "0.1.1"
23+
},
24+
"dependencies": {
25+
"@hono/node-server": "1.13.8",
26+
"@hono/zod-openapi": "0.19.2",
27+
"dotenv": "16.4.7",
28+
"hono": "4.7.4",
29+
"hono-rate-limiter": "0.4.2",
30+
"nanoid": "5.1.3",
31+
"ts-pattern": "5.6.2",
32+
"zod": "3.24.2"
33+
}
3734
}

apps/klesia/src/index.ts

Lines changed: 7 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
import { getConnInfo } from "@hono/node-server/conninfo";
22
import { OpenAPIHono, createRoute } from "@hono/zod-openapi";
33
import {
4-
KlesiaRpcMethod,
54
KlesiaRpcMethodSchema,
65
KlesiaRpcResponseSchema,
7-
PublicKeySchema,
8-
} from "@mina-js/utils";
6+
} from "@mina-js/klesia-utils";
7+
import { handleJsonRpcRequest } from "@mina-js/klesia-utils";
98
import { rateLimiter } from "hono-rate-limiter";
109
import { cors } from "hono/cors";
1110
import { logger } from "hono/logger";
1211
import { nanoid } from "nanoid";
13-
import { match } from "ts-pattern";
14-
import { mina } from "./methods/mina";
15-
import { buildResponse } from "./utils/build-response";
12+
import { getNodeApiUrl } from "./utils/node";
1613

1714
export const api = new OpenAPIHono();
1815

@@ -61,76 +58,10 @@ const rpcRoute = createRoute({
6158
});
6259

6360
export const klesiaRpcRoute = api.openapi(rpcRoute, async ({ req, json }) => {
64-
const body = KlesiaRpcMethodSchema.parse(await req.json());
65-
return match(body)
66-
.with(
67-
{ method: KlesiaRpcMethod.enum.mina_getTransactionCount },
68-
async ({ params }) => {
69-
const [publicKey] = params;
70-
const result = await mina.getTransactionCount({
71-
publicKey: PublicKeySchema.parse(publicKey),
72-
});
73-
return json(
74-
buildResponse({
75-
result,
76-
}),
77-
200,
78-
);
79-
},
80-
)
81-
.with(
82-
{ method: KlesiaRpcMethod.enum.mina_getBalance },
83-
async ({ params }) => {
84-
const [publicKey] = params;
85-
const result = await mina.getBalance({
86-
publicKey: PublicKeySchema.parse(publicKey),
87-
});
88-
return json(buildResponse({ result }), 200);
89-
},
90-
)
91-
.with({ method: KlesiaRpcMethod.enum.mina_blockHash }, async () => {
92-
if (process.env.MINA_NETWORK === "zeko_devnet") {
93-
return json(
94-
buildResponse({
95-
error: {
96-
code: -32600,
97-
message: "Network not supported.",
98-
},
99-
}),
100-
200,
101-
);
102-
}
103-
const result = await mina.blockHash();
104-
return json(buildResponse({ result }), 200);
105-
})
106-
.with({ method: KlesiaRpcMethod.enum.mina_networkId }, async () => {
107-
const result = await mina.networkId();
108-
return json(buildResponse({ result }), 200);
109-
})
110-
.with(
111-
{ method: KlesiaRpcMethod.enum.mina_sendTransaction },
112-
async ({ params }) => {
113-
const [signedTransaction, type] = params;
114-
const result = await mina.sendTransaction({ signedTransaction, type });
115-
return json(
116-
buildResponse({
117-
result,
118-
}),
119-
200,
120-
);
121-
},
122-
)
123-
.with(
124-
{ method: KlesiaRpcMethod.enum.mina_getAccount },
125-
async ({ params }) => {
126-
const [publicKey] = params;
127-
const result = await mina.getAccount({
128-
publicKey: PublicKeySchema.parse(publicKey),
129-
});
130-
return json(buildResponse({ result }), 200);
131-
},
132-
)
133-
.exhaustive();
61+
return json(
62+
await handleJsonRpcRequest(getNodeApiUrl(), await req.json()),
63+
200,
64+
);
13465
});
13566

13667
export type KlesiaRpc = typeof klesiaRpcRoute;

apps/klesia/src/methods/mina.ts

Lines changed: 0 additions & 219 deletions
This file was deleted.

0 commit comments

Comments
 (0)