Skip to content

Commit ce73910

Browse files
committed
feat(connect): add basic docs
1 parent 392a3f8 commit ce73910

File tree

23 files changed

+308
-166
lines changed

23 files changed

+308
-166
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ jobs:
1212
- run: bun i --no-save
1313
- run: bun run build
1414
- run: bun run test
15-
- run: bunx pkg-pr-new publish './packages/klesia-sdk' './packages/accounts'
15+
- run: bunx pkg-pr-new publish './packages/klesia-sdk' './packages/accounts' './packages/connect'

apps/docs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
},
1919
"devDependencies": {
2020
"@mina-js/klesia-sdk": "workspace:*",
21+
"@mina-js/connect": "workspace:*",
2122
"daisyui": "^4.12.10"
2223
}
2324
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ MinaJS Accounts shares an API similar to [Viem](https://viem.sh/).
1212
$ npm install @mina-js/accounts
1313
```
1414

15+
### Nightly builds
16+
17+
```sh
18+
$ npm install https://pkg.pr.new/palladians/mina-js/@mina-js/accounts@main
19+
```
20+
21+
:::warning
22+
For now there are only [nightly builds](/getting-started#nightly-builds) available. The stable version will be released soon™️.
23+
:::
24+
1525
## Utilities
1626

1727
### generateMnemonic
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,31 @@
11
# Getting Started [Start with MinaJS Connect.]
2+
3+
## Installation
4+
5+
```sh
6+
$ npm install @mina-js/connect
7+
```
8+
9+
### Nightly builds
10+
11+
```sh
12+
$ npm install https://pkg.pr.new/palladians/mina-js/@mina-js/connect@main
13+
```
14+
15+
:::warning
16+
For now there are only [nightly builds](/getting-started#nightly-builds) available. The stable version will be released soon™️.
17+
:::
18+
19+
## Find Mina wallets
20+
21+
To discover injected wallet providers, we've developed a Provider Discovery reactive store utility. [Check out the usage](/connect/provider-discovery).
22+
23+
## Window Polyfill
24+
25+
For your convenient TypeScript development, we've created a window polyfill. This will make sure you have an autocompletion for MinaJS compliant providers.
26+
27+
```ts
28+
import '@mina-js/connect/window'
29+
30+
const account = await window.mina.request({ method: 'mina_accounts' })
31+
```
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Provider Discovery [Discover injected wallet providers with ease.]
2+
3+
For your convenience, MinaJS Connect provides a simple way to discover all Mina's injected wallet providers. This is done by an API similar to [Wevm's MIPD](https://github.com/wevm/mipd).
4+
5+
## Vanilla TypeScript
6+
7+
```ts twoslash
8+
import { createStore, type MinaProviderDetail } from '@mina-js/connect'
9+
10+
const store = createStore()
11+
12+
// Reactively, you can use MinaProviderDetail to type the array, but it fails in docs ffs.
13+
const providersReactively = []
14+
const unsubscribe = store.subscribe((provider) => providersReactively.push(provider))
15+
16+
// Imperatively
17+
const providersImperatively = store.getProviders()
18+
```
19+
20+
## React
21+
22+
```tsx twoslash
23+
import { useSyncExternalStore } from 'react'
24+
import { createStore } from '@mina-js/connect'
25+
26+
const store = createStore()
27+
28+
function Example() {
29+
const providers = useSyncExternalStore(store.subscribe, store.getProviders)
30+
}
31+
```
32+
33+
## Svelte
34+
35+
```svelte twoslash
36+
<script lang="ts">
37+
import { readable } from 'svelte/store'
38+
import { createStore } from '@mina-js/connect'
39+
40+
const store = createStore()
41+
const providers = readable(store.getProviders(), store.subscribe)
42+
</script>
43+
```
44+
45+
## Vue
46+
47+
```vue twoslash
48+
<script setup lang="ts">
49+
import { reactive } from 'vue'
50+
import { createStore } from '@mina-js/connect'
51+
52+
const store = createStore()
53+
const state = reactive({ providers: store.getProviders() })
54+
store.subscribe(providers => (state.providers = providers))
55+
</script>
56+
```

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,9 @@ The libraries are available on npm. You can install them using npm, yarn, pnpm,
7575
- [MinaJS Connect](/connect)
7676
- [MinaJS Accounts](/accounts)
7777
- [Klesia SDK](/klesia/sdk)
78+
79+
## Nightly builds
80+
81+
We have nightly builds available for the SDK. You can find the latest nightly versions of our packages on:
82+
83+
https://nightly.akryum.dev/palladians/mina-js

apps/docs/src/pages/klesia/sdk.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@ Klesia has a TypeScript SDK to interact with the JSON-RPC API. The SDK provides
88
$ npm install @mina-js/klesia-sdk
99
```
1010

11+
### Nightly builds
12+
13+
```sh
14+
$ npm install https://pkg.pr.new/palladians/mina-js/@mina-js/klesia-sdk@main
15+
```
16+
1117
:::warning
12-
For now there are only [nightly builds](/klesia/sdk#nightly-builds) available. The stable version will be released soon™️.
18+
For now there are only [nightly builds](/getting-started#nightly-builds) available. The stable version will be released soon™️.
1319
:::
1420

1521
## Client Options
@@ -34,9 +40,3 @@ const { result } = await client.request<'mina_getTransactionCount'>({
3440
## Methods
3541

3642
Refer to the [RPC Methods](/klesia/rpc#rpc-methods) page for a complete list of methods available on Klesia.
37-
38-
## Nightly Builds
39-
40-
We have nightly builds available for the SDK. You can find the latest nightly versions of our packages on:
41-
42-
https://nightly.akryum.dev/palladians/mina-js

apps/docs/vocs.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export default defineConfig({
8585
items: [
8686
{ text: "Introduction", link: "/connect" },
8787
{ text: "Getting Started", link: "/connect/getting-started" },
88+
{ text: "Provider Discovery", link: "/connect/provider-discovery" },
8889
],
8990
},
9091
{

bun.lockb

456 Bytes
Binary file not shown.

packages/connect/package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@
44
"module": "dist/index.js",
55
"types": "dist/index.d.ts",
66
"exports": {
7+
"./window": {
8+
"types": "./dist/window.d.ts",
9+
"default": "./dist/window.js",
10+
"import": "./dist/window.mjs"
11+
},
712
".": {
813
"types": "./dist/index.d.ts",
9-
"default": "./dist/index.cjs",
10-
"import": "./dist/index.js"
14+
"default": "./dist/index.js",
15+
"import": "./dist/index.mjs"
1116
}
1217
},
1318
"scripts": {
@@ -17,6 +22,7 @@
1722
},
1823
"dependencies": {
1924
"@mina-js/providers": "workspace:*",
25+
"ts-pattern": "^5.3.1",
2026
"zod": "3.23.8"
2127
},
2228
"peerDependencies": {

0 commit comments

Comments
 (0)