Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
187 changes: 97 additions & 90 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,36 @@ import {
groupIconMdPlugin,
groupIconVitePlugin,
} from 'vitepress-plugin-group-icons'
import { defineConfig } from 'vitepress'
import defineVersionedConfig from 'vitepress-versioning-plugin'
import { Plugin as VitePressPlugin } from 'vitepress'

// https://vitepress.dev/reference/site-config
export default defineConfig({
title: 'Fedimint Sdk',
description: 'Building Fedimint Ecash into Apps',
ignoreDeadLinks: false,
lang: 'en-US',
lastUpdated: true,
markdown: {
// TODO: Fix version conflicts
// @ts-ignore
codeTransformers: [transformerTwoslash()],
config: (md) => {
export default defineVersionedConfig(
{
title: 'Fedimint Sdk',
description: 'Building Fedimint Ecash into Apps',
ignoreDeadLinks: false,
lang: 'en-US',
lastUpdated: true,
markdown: {
// TODO: Fix version conflicts
// @ts-ignore
md.use(groupIconMdPlugin)
codeTransformers: [transformerTwoslash()],
config: (md) => {
// @ts-ignore
md.use(groupIconMdPlugin)
},
},
},
vite: {
plugins: [
{
...groupIconVitePlugin(),
name: 'vitepress-group-icons-compat',
} as VitePressPlugin,
],
},
/* prettier-ignore */
head: [
vite: {
plugins: [
{
...groupIconVitePlugin(),
name: 'vitepress-group-icons-compat',
} as VitePressPlugin,
],
},
/* prettier-ignore */
head: [
['meta', { name: 'keywords', content: 'bitcoin, lightning, ecash, fedimint, typescript, wasm, react' } ],
['link', { rel: 'icon', href: '/favicon.ico' }],
['meta', { name: 'theme-color', content: '#346cff' }],
Expand All @@ -49,77 +50,83 @@ export default defineConfig({
['meta', { name: 'twitter:creator', content: '@fedimint' }],
['meta', { name: 'twitter:site', content: '@fedimint' }],
],
themeConfig: {
editLink: {
pattern: 'https://github.com/fedimint/fedimint-sdk/edit/main/docs/:path',
text: 'Suggest changes to this page',
},
footer: {
message:
'Released under the <a href="https://github.com/fedimint/fedimint-sdk/blob/main/LICENSE">MIT License</a>.',
},
nav: [
{ text: 'Documentation', link: '/core/getting-started' },
{ text: 'Examples', link: '/examples/vite-react' },
{
text: 'More',
items: [
{
text: 'Contributing',
link: '/core/dev/contributing',
},
{
text: 'Awesome Fedimint Sdk',
link: '/core/dev/awesome',
},
{
text: 'Discussions ',
link: 'https://chat.fedimint.org',
},
{
text: 'Release Notes ',
link: 'https://github.com/fedimint/fedimint-sdk/releases',
},
],
},
],
logo: {
light: '/icon.png',
dark: '/icon.png',
alt: 'Fedimint Logo',
},
sidebar: getSidebar(),

socialLinks: [
{
icon: 'github',
link: 'https://github.com/fedimint/fedimint-sdk',
},
{
icon: 'npm',
link: 'https://www.npmjs.com/package/@fedimint/core',
themeConfig: {
editLink: {
pattern:
'https://github.com/fedimint/fedimint-sdk/edit/main/docs/:path',
text: 'Suggest changes to this page',
},
{
icon: 'discord',
link: 'https://chat.fedimint.org',
footer: {
message:
'Released under the <a href="https://github.com/fedimint/fedimint-sdk/blob/main/LICENSE">MIT License</a>.',
},
{
icon: 'twitter',
link: 'https://twitter.com/fedimint',
nav: [
{ text: 'Documentation', link: '/core/getting-started' },
{ text: 'Examples', link: '/examples/vite-react' },
{
text: 'More',
items: [
{
text: 'Contributing',
link: '/core/dev/contributing',
},
{
text: 'Awesome Fedimint Sdk',
link: '/core/dev/awesome',
},
{
text: 'Discussions ',
link: 'https://chat.fedimint.org',
},
{
text: 'Release Notes ',
link: 'https://github.com/fedimint/fedimint-sdk/releases',
},
],
},
],
logo: {
light: '/icon.png',
dark: '/icon.png',
alt: 'Fedimint Logo',
},
],
sidebar: getSidebar(),

outline: [2, 3],
search: {
provider: 'local',
options: {
_render(src, env, md) {
const html = md.render(src, env)
if (env.frontmatter?.search === false) return ''
if (env.relativePath.startsWith('shared')) return ''
return html
socialLinks: [
{
icon: 'github',
link: 'https://github.com/fedimint/fedimint-sdk',
},
{
icon: 'npm',
link: 'https://www.npmjs.com/package/@fedimint/core',
},
{
icon: 'discord',
link: 'https://chat.fedimint.org',
},
{
icon: 'twitter',
link: 'https://twitter.com/fedimint',
},
],

outline: [2, 3],
search: {
provider: 'local',
options: {
_render(src, env, md) {
const html = md.render(src, env)
if (env.frontmatter?.search === false) return ''
if (env.relativePath.startsWith('shared')) return ''
return html
},
},
},
},
versioning: {
latestVersion: '0.1.x',
},
},
})
__dirname,
)
72 changes: 37 additions & 35 deletions docs/.vitepress/sidebar.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
import type { DefaultTheme } from 'vitepress'

export function getSidebar() {
return [
{
base: '/core/',
collapsed: false,
text: 'Introduction',
items: [
{ text: 'Overview', link: 'overview' },
{ text: 'Getting Started', link: 'getting-started' },
{ text: 'Architecture', link: 'architecture' },
],
},
...FedimintWalletSidebar,
{
base: '/examples/',
collapsed: false,
text: 'Examples',
items: [
{ text: 'Vite + React', link: 'vite-react' },
{ text: 'Vanilla JS', link: 'bare-js' },
{ text: 'Next.JS', link: 'next-js' },
{ text: 'Webpack', link: 'webpack' },
],
},
{
text: 'Dev',
collapsed: true,
base: '/core/dev/',
items: [
{ text: 'Contributing', link: 'contributing' },
{ text: 'Nix Setup', link: 'nix_setup' },
{ text: 'Awesome Projects', link: 'awesome' },
{ text: 'Testing', link: 'testing' },
],
},
] satisfies DefaultTheme.Sidebar
return {
'/': [
{
base: '/core/',
collapsed: false,
text: 'Introduction',
items: [
{ text: 'Overview', link: 'overview' },
{ text: 'Getting Started', link: 'getting-started' },
{ text: 'Architecture', link: 'architecture' },
],
},
...FedimintWalletSidebar,
{
base: '/examples/',
collapsed: false,
text: 'Examples',
items: [
{ text: 'Vite + React', link: 'vite-react' },
{ text: 'Vanilla JS', link: 'bare-js' },
{ text: 'Next.JS', link: 'next-js' },
{ text: 'Webpack', link: 'webpack' },
],
},
{
text: 'Dev',
collapsed: true,
base: '/core/dev/',
items: [
{ text: 'Contributing', link: 'contributing' },
{ text: 'Nix Setup', link: 'nix_setup' },
{ text: 'Awesome Projects', link: 'awesome' },
{ text: 'Testing', link: 'testing' },
],
},
],
} satisfies DefaultTheme.SidebarMulti
}

const FedimintWalletSidebar = [
Expand Down
3 changes: 2 additions & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@fedimint/types": "workspace:*",
"@shikijs/vitepress-twoslash": "1.4.0",
"vitepress": "1.1.4",
"vitepress-plugin-group-icons": "^1.7.1"
"vitepress-plugin-group-icons": "^1.7.1",
"vitepress-versioning-plugin": "^1.3.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Get Balance

### `balance.getBalance()`

Get the current balance of the wallet in milli-satoshis (MSats).

```ts twoslash
// @esModuleInterop
import { WalletDirector } from '@fedimint/core'
import { WasmWorkerTransport } from '@fedimint/transport-web'

const director = new WalletDirector(new WasmWorkerTransport())
const wallet = await director.createWallet()

await wallet.open()

const mSats = await wallet.balance.getBalance() // [!code focus]

// 1000 mSats = 1 satoshi
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Subscribe Balance

### `balance.subscribeBalance()` <Badge type="info" text="Streaming" />

Subscribe to balance updates as they occur.

```ts twoslash
// @esModuleInterop
import { WalletDirector } from '@fedimint/core'
import { WasmWorkerTransport } from '@fedimint/transport-web'

const director = new WalletDirector(new WasmWorkerTransport())
const wallet = await director.createWallet()

await wallet.open()

const unsubscribe = wallet.balance.subscribeBalance((mSats) => {
// [!code focus]
console.log('Balance updated:', mSats) // [!code focus]
// 1000 mSats = 1 satoshi // [!code focus]
}) // [!code focus]

// ...Cleanup Later
unsubscribe()
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Redeem Ecash

### `federation.getConfig()`

Access configuration details about a connected federation.

```ts twoslash
// @esModuleInterop
import { WalletDirector } from '@fedimint/core'
import { WasmWorkerTransport } from '@fedimint/transport-web'

const director = new WalletDirector(new WasmWorkerTransport())
const wallet = await director.createWallet()

await wallet.open()

const config = await wallet.federation.getConfig() // [!code focus]
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Redeem Ecash

### `federation.getFederationId()`

Access the `federationId` of the connected Federation.

```ts twoslash
// @esModuleInterop
import { WalletDirector } from '@fedimint/core'
import { WasmWorkerTransport } from '@fedimint/transport-web'

const director = new WalletDirector(new WasmWorkerTransport())
const wallet = await director.createWallet()

await wallet.open()

const config = await wallet.federation.getFederationId() // [!code focus]
```
Loading