Skip to content

Commit 5ebb0fd

Browse files
committed
chore(minajs): remove scalar and add tests for klesia
1 parent ed51624 commit 5ebb0fd

File tree

9 files changed

+166
-29
lines changed

9 files changed

+166
-29
lines changed

apps/docs/docs/pages/getting-started.mdx

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,63 @@ MinaJS is a set of packages and apps built by our team. The aim is to provide a
1212

1313
The libraries are available on npm. You can install them using npm, yarn, pnpm, and bun (yep, we support Bun).
1414

15-
```bash
16-
# Install MinaJS Connect
17-
$ npm install @mina-js/connect
15+
<div role="tablist" className="tabs tabs-boxed">
16+
<input type="radio" name="my_tabs_2" role="tab" className="tab ml-2" aria-label="NPM" checked="checked" readOnly />
17+
<div role="tabpanel" className="tab-content">
18+
```bash
19+
# Install MinaJS Connect
20+
$ npm install @mina-js/connect
1821

19-
# Install MinaJS Accounts
20-
$ npm install @mina-js/accounts
22+
# Install MinaJS Accounts
23+
$ npm install @mina-js/accounts
2124

22-
# Install Klesia SDK
23-
$ npm install @mina-js/klesia-sdk
24-
```
25+
# Install Klesia SDK
26+
$ npm install @mina-js/klesia-sdk
27+
```
28+
</div>
29+
30+
<input type="radio" name="my_tabs_2" role="tab" className="tab" aria-label="Yarn" />
31+
<div role="tabpanel" className="tab-content">
32+
```bash
33+
# Install MinaJS Connect
34+
$ yarn add @mina-js/connect
35+
36+
# Install MinaJS Accounts
37+
$ yarn add @mina-js/accounts
38+
39+
# Install Klesia SDK
40+
$ yarn add @mina-js/klesia-sdk
41+
```
42+
</div>
43+
44+
<input type="radio" name="my_tabs_2" role="tab" className="tab" aria-label="PNPM" />
45+
<div role="tabpanel" className="tab-content">
46+
```bash
47+
# Install MinaJS Connect
48+
$ pnpm add @mina-js/connect
49+
50+
# Install MinaJS Accounts
51+
$ pnpm add @mina-js/accounts
52+
53+
# Install Klesia SDK
54+
$ pnpm add @mina-js/klesia-sdk
55+
```
56+
</div>
57+
58+
<input type="radio" name="my_tabs_2" role="tab" className="tab" aria-label="Bun" />
59+
<div role="tabpanel" className="tab-content">
60+
```bash
61+
# Install MinaJS Connect
62+
$ bun add @mina-js/connect
63+
64+
# Install MinaJS Accounts
65+
$ bun add @mina-js/accounts
66+
67+
# Install Klesia SDK
68+
$ bun add @mina-js/klesia-sdk
69+
```
70+
</div>
71+
</div>
2572

2673
## SDK specific usage
2774

apps/docs/docs/pages/roadmap.mdx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Roadmap
2+
3+
```mermaid
4+
timeline
5+
section Q4 2024
6+
MinaJS
7+
: @mina-js/connect Beta
8+
: @mina-js/provider Beta
9+
: @mina-js/accounts Beta
10+
Klesia
11+
: Klesia RPC Beta
12+
: @mina-js/klesia-sdk Beta
13+
section Q1 2025
14+
MinaJS
15+
: Auro Wallet integration
16+
Klesia
17+
: Zeko integration
18+
: Protokit integration
19+
```

apps/docs/vocs.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ export default defineConfig({
7474
text: "FAQ",
7575
link: "/faq",
7676
},
77+
{
78+
text: "Roadmap",
79+
link: "/roadmap",
80+
},
7781
{
7882
text: "MinaJS Connect",
7983
link: "/connect",

apps/klesia/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
"scripts": {
1414
"build": "tsup-node",
1515
"dev": "tsup-node --watch --onSuccess \"node dist/index.js\"",
16-
"start": "node dist/index.js"
16+
"start": "node dist/index.js",
17+
"test": "bun test"
1718
},
1819
"dependencies": {
1920
"@hono/node-server": "^1.12.2",
2021
"@hono/zod-openapi": "^0.16.0",
2122
"@mina-js/shared": "workspace:*",
22-
"@scalar/hono-api-reference": "^0.5.143",
2323
"@urql/core": "^5.0.6",
2424
"dayjs": "^1.11.13",
2525
"dotenv": "^16.4.5",

apps/klesia/src/index.spec.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { expect, it } from "bun:test";
2+
import { testClient } from "hono/testing";
3+
import { klesiaRpcRoute } from "./";
4+
5+
const client = testClient(klesiaRpcRoute);
6+
7+
it("returns result for mina_getTransactionCount", async () => {
8+
const response = await client.api.$post({
9+
json: {
10+
method: "mina_getTransactionCount",
11+
params: ["B62qkYa1o6Mj6uTTjDQCob7FYZspuhkm4RRQhgJg9j4koEBWiSrTQrS"],
12+
},
13+
});
14+
const { result } = await response.json();
15+
expect(result).toBeGreaterThan(0);
16+
});
17+
18+
it("returns result for mina_getBalance", async () => {
19+
const response = await client.api.$post({
20+
json: {
21+
method: "mina_getBalance",
22+
params: ["B62qkYa1o6Mj6uTTjDQCob7FYZspuhkm4RRQhgJg9j4koEBWiSrTQrS"],
23+
},
24+
});
25+
const { result } = await response.json();
26+
expect(BigInt(String(result))).toBeGreaterThan(0);
27+
});
28+
29+
it("returns result for mina_blockHash", async () => {
30+
const response = await client.api.$post({
31+
json: { method: "mina_blockHash" },
32+
});
33+
const { result } = await response.json();
34+
expect((result as unknown as string).length).toBeGreaterThan(0);
35+
});
36+
37+
it("returns result for mina_chainId", async () => {
38+
const response = await client.api.$post({
39+
json: { method: "mina_chainId" },
40+
});
41+
const { result } = await response.json();
42+
expect((result as unknown as string).length).toBeGreaterThan(0);
43+
});

apps/klesia/src/index.ts

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { serve } from "@hono/node-server";
33
import { getConnInfo } from "@hono/node-server/conninfo";
44
import { OpenAPIHono, createRoute } from "@hono/zod-openapi";
55
import { PublicKeySchema } from "@mina-js/shared";
6-
import { apiReference } from "@scalar/hono-api-reference";
76
import { rateLimiter } from "hono-rate-limiter";
87
import { cors } from "hono/cors";
98
import { logger } from "hono/logger";
@@ -15,12 +14,15 @@ import { mina } from "./methods/mina";
1514
import { RpcMethodSchema, RpcResponseSchema } from "./schema";
1615
import { buildResponse } from "./utils/build-response";
1716

18-
const api = new OpenAPIHono();
17+
export const api = new OpenAPIHono();
1918

2019
api.use(logger());
2120
api.use(
2221
rateLimiter({
23-
skip: (c) => c.req.path !== "/api" || c.req.method !== "POST",
22+
skip: (c) =>
23+
process.env.NODE_ENV === "test" ||
24+
c.req.path !== "/api" ||
25+
c.req.method !== "POST",
2426
keyGenerator: (c) =>
2527
c.req.header("x-forwarded-for") ??
2628
getConnInfo(c).remote.address ??
@@ -58,9 +60,7 @@ const rpcRoute = createRoute({
5860
},
5961
});
6062

61-
api.get("/", ({ redirect }) => redirect("/api", 301));
62-
63-
const klesiaRpcRoute = api.openapi(rpcRoute, async ({ req, json }) => {
63+
export const klesiaRpcRoute = api.openapi(rpcRoute, async ({ req, json }) => {
6464
const body = req.valid("json");
6565
return match(body)
6666
.with({ method: "mina_getTransactionCount" }, async ({ params }) => {
@@ -93,16 +93,6 @@ const klesiaRpcRoute = api.openapi(rpcRoute, async ({ req, json }) => {
9393
.exhaustive();
9494
});
9595

96-
api.get(
97-
"/api",
98-
apiReference({
99-
spec: {
100-
url: "/api/openapi",
101-
},
102-
theme: "deepSpace",
103-
}),
104-
);
105-
10696
serve(api);
10797

10898
export type KlesiaRpc = typeof klesiaRpcRoute;

apps/klesia/src/methods/mina.spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { expect, it } from "bun:test";
2+
import { mina } from "./mina";
3+
4+
const TEST_PKEY = "B62qkYa1o6Mj6uTTjDQCob7FYZspuhkm4RRQhgJg9j4koEBWiSrTQrS";
5+
6+
it("should return transactions count", async () => {
7+
const result = await mina.getTransactionCount({ publicKey: TEST_PKEY });
8+
expect(result).toBeGreaterThan(0);
9+
});
10+
11+
it("should return balance", async () => {
12+
const result = await mina.getBalance({ publicKey: TEST_PKEY });
13+
expect(BigInt(result)).toBeGreaterThan(0);
14+
});
15+
16+
it("should return block hash", async () => {
17+
const result = await mina.blockHash();
18+
expect(result.length).toBeGreaterThan(0);
19+
});
20+
21+
it("should return chain id", async () => {
22+
const result = await mina.chainId();
23+
expect(result.length).toBeGreaterThan(0);
24+
});

apps/klesia/src/utils/node.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,19 @@ import { z } from "zod";
44

55
const NetworkMatcher = z.enum(["devnet", "mainnet"]);
66

7-
const MINA_NETWORK = NetworkMatcher.parse(process.env.MINA_NETWORK);
8-
const NODE_API_DEVNET = z.string().parse(process.env.NODE_API_DEVNET);
9-
const NODE_API_MAINNET = z.string().parse(process.env.NODE_API_MAINNET);
7+
const MINA_NETWORK = NetworkMatcher.parse(process.env.MINA_NETWORK ?? "devnet");
8+
const NODE_API_DEVNET = z
9+
.string()
10+
.parse(
11+
process.env.NODE_API_DEVNET ??
12+
"https://api.minascan.io/node/devnet/v1/graphql",
13+
);
14+
const NODE_API_MAINNET = z
15+
.string()
16+
.parse(
17+
process.env.NODE_API_MAINNET ??
18+
"https://api.minascan.io/node/mainnet/v1/graphql",
19+
);
1020

1121
export const getNodeApiUrl = () => {
1222
return match(MINA_NETWORK)

bun.lockb

-2.51 KB
Binary file not shown.

0 commit comments

Comments
 (0)