Skip to content

Commit

Permalink
chore: tweak docs site layout (#68)
Browse files Browse the repository at this point in the history
* chore: clean up docs

* chore: update sidebar and exmaple instructions
  • Loading branch information
alexlwn123 authored Oct 4, 2024
1 parent 6e3ffae commit 8cd9114
Show file tree
Hide file tree
Showing 22 changed files with 114 additions and 240 deletions.
89 changes: 43 additions & 46 deletions docs/.vitepress/sidebar.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,35 @@
import type { DefaultTheme } from 'vitepress'

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

const FedimintWalletSidebar = [
Expand Down Expand Up @@ -113,18 +110,18 @@ const FedimintWalletSidebar = [
},
],
},
{
text: 'Type Aliases',
collapsed: true,
base: '/core/type-aliases/',
items: [
{ text: 'CreateResponse', link: 'CreateResponse' },
{ text: 'FeeToAmount', link: 'FeeToAmount' },
{ text: 'LightningGateway', link: 'LightningGateway' },
{ text: 'LnPayState', link: 'LnPayState' },
{ text: 'OutgoingLightningPayment', link: 'OutgoingLightningPayment' },
{ text: 'PayType', link: 'PayType' },
{ text: 'RouteHint', link: 'RouteHint' },
],
},
// {
// text: 'Type Aliases',
// collapsed: true,
// base: '/core/type-aliases/',
// items: [
// { text: 'CreateResponse', link: 'CreateResponse' },
// { text: 'FeeToAmount', link: 'FeeToAmount' },
// { text: 'LightningGateway', link: 'LightningGateway' },
// { text: 'LnPayState', link: 'LnPayState' },
// { text: 'OutgoingLightningPayment', link: 'OutgoingLightningPayment' },
// { text: 'PayType', link: 'PayType' },
// { text: 'RouteHint', link: 'RouteHint' },
// ],
// },
]
2 changes: 1 addition & 1 deletion docs/core/FedimintWallet/cleanup.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ This guide hasn't been written yet.

If you'd like to contribute, please open a PR!

You can use the `Edit This Page` link below.
You can use the `Suggest changes to this page` link below.
2 changes: 0 additions & 2 deletions docs/core/FedimintWallet/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ After this call, the FedimintWallet instance should be discarded.

> **initialize**(): `Promise`\<`void`\>
https://wagmi.sh/react/api/hooks/useAccount

#### Returns

`Promise`\<`void`\>
Expand Down
2 changes: 1 addition & 1 deletion docs/core/FedimintWallet/initialize.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ This guide hasn't been written yet.

If you'd like to contribute, please open a PR!

You can use the `Edit This Page` link below.
You can use the `Suggest changes to this page` link below.
2 changes: 1 addition & 1 deletion docs/core/FedimintWallet/isOpen.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ This guide hasn't been written yet.

If you'd like to contribute, please open a PR!

You can use the `Edit This Page` link below.
You can use the `Suggest changes to this page` link below.
2 changes: 1 addition & 1 deletion docs/core/FedimintWallet/joinFederation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ This guide hasn't been written yet.

If you'd like to contribute, please open a PR!

You can use the `Edit This Page` link below.
You can use the `Suggest changes to this page` link below.
2 changes: 1 addition & 1 deletion docs/core/FedimintWallet/open.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ This guide hasn't been written yet.

If you'd like to contribute, please open a PR!

You can use the `Edit This Page` link below.
You can use the `Suggest changes to this page` link below.
2 changes: 1 addition & 1 deletion docs/core/FedimintWallet/setLogLevel.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ This guide hasn't been written yet.

If you'd like to contribute, please open a PR!

You can use the `Edit This Page` link below.
You can use the `Suggest changes to this page` link below.
4 changes: 2 additions & 2 deletions docs/core/architecture.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Architecture

The Fedimint Web SDK **Core Web** library is a modular and extensible JavaScript library designed to interact with the Fedimint client in a web browser. It provides a high-level API for developers to manage federated e-cash wallets, perform operations like minting and spending e-cash, and interact with the Lightning Network. The library is structured to promote maintainability, scalability, and ease of use, leveraging modern software development practices.
The Fedimint Web SDK **Core Web** library is a modular and extensible JavaScript library designed to interact with the Fedimint client in a web browser. It provides a high-level API for developers to manage federated ecash wallets, perform operations like minting and spending ecash, and interact with the Lightning Network. The library is structured to promote maintainability, scalability, and ease of use, leveraging modern software development practices.

The **Core Web** library is built around a set of composable services and a communication layer that interacts with a Web Worker running WebAssembly (WASM) code.

Expand Down Expand Up @@ -36,7 +36,7 @@ Handles federation-related operations such as joining federations, retrieving co

### **MintService**

Manages operations related to minting and handling e-cash notes, including redeeming, reissuing, spending, and validating notes.
Manages operations related to minting and handling ecash notes, including redeeming, reissuing, spending, and validating notes.

### **LightningService**

Expand Down
26 changes: 15 additions & 11 deletions docs/core/getting-started.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Getting Started

::: danger READ THIS FIRST (Disclaimer)
::: danger Disclaimer
This is very new. Use with caution. [Report bugs](https://github.com/fedimint/fedimint-web-sdk/issues).

This is very new. It is still a work in progress and should not be used for any serious applications. The api's are not settled and may change often.
APIs may change.
:::

[[toc]]

## Installation

To add @fedimint/core-web to your project, install the package using your preferred package manager:
Expand Down Expand Up @@ -242,10 +241,15 @@ For a list of public federations with invite codes, visit [Bitcoin Mints](https:

## What's Next?

- To see the sdk in action, check out the [examples](../examples/vite-react.md)
- Vite + React: [`examples/vite-react`](../examples/vite-react.md)
- VanillaJS + HTML example: [`examples/bare-js`](../examples/bare-js.md)
- To learn more about @fedimint/core-web and how to use it effectively in your projects, explore the following topics:
- [Overview](overview)
- [API Reference](FedimintWallet/index)
- [Architecture](architecture)
#### Check out the Example Projects

- [Vite + React](../examples/vite-react.md)
- [VanillaJS + HTML example](../examples/bare-js.md)

<br>

#### To learn more about Web SDK, explore the docs

- [SDK Overview](overview)
- [Library Architecture](architecture)
- [API Reference](FedimintWallet/index)
2 changes: 1 addition & 1 deletion docs/core/guides/balance.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ This guide hasn't been written yet.

If you'd like to contribute, please open a PR!

You can use the `Edit This Page` link below.
You can use the `Suggest changes to this page` link below.
2 changes: 1 addition & 1 deletion docs/core/guides/cleanup.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ This guide hasn't been written yet.

If you'd like to contribute, please open a PR!

You can use the `Edit This Page` link below.
You can use the `Suggest changes to this page` link below.
2 changes: 1 addition & 1 deletion docs/core/guides/first-payment.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ This guide hasn't been written yet.

If you'd like to contribute, please open a PR!

You can use the `Edit This Page` link below.
You can use the `Suggest changes to this page` link below.
2 changes: 1 addition & 1 deletion docs/core/guides/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ This guide hasn't been written yet.

If you'd like to contribute, please open a PR!

You can use the `Edit This Page` link below.
You can use the `Suggest changes to this page` link below.
2 changes: 1 addition & 1 deletion docs/core/guides/initialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ This guide hasn't been written yet.

If you'd like to contribute, please open a PR!

You can use the `Edit This Page` link below.
You can use the `Suggest changes to this page` link below.
2 changes: 1 addition & 1 deletion docs/core/guides/multiple-federations.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ This guide hasn't been written yet.

If you'd like to contribute, please open a PR!

You can use the `Edit This Page` link below.
You can use the `Suggest changes to this page` link below.
2 changes: 1 addition & 1 deletion docs/core/guides/sending-ecash.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ This guide hasn't been written yet.

If you'd like to contribute, please open a PR!

You can use the `Edit This Page` link below.
You can use the `Suggest changes to this page` link below.
24 changes: 19 additions & 5 deletions docs/examples/bare-js.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,35 @@ There's no ui, so open your browser's console to see the library in action.
## Live Preview

::: tip
You might need to disable your adblocker or Brave Shields to see the preview.
The Live Previews don't always work. If you're having trouble, try running the example locally OR using the [StackBlitz link](https://stackblitz.com/github/fedimint/fedimint-web-sdk/tree/main/examples/bare-js).

Also, you might need to disable your adblocker or Brave Shields to see the preview.
:::

<br>

<iframe src="https://stackblitz.com/github/fedimint/fedimint-web-sdk/tree/main/examples/bare-js?embed=1&file=index.html" style=" width: 100%; height: 600px; border: 0;"></iframe>

[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/fedimint/fedimint-web-sdk/tree/main/examples/bare-js)

## Running the Example Locally

```bash
# from the root of the repo
Clone the repo

```sh
git clone https://github.com/fedimint/fedimint-web-sdk.git
cd fedimint-web-sdk
```

# install dependencies
Install the package manager with [Corepack](https://nodejs.org/api/corepack.html) & install dependencies.

```sh
corepack enable
pnpm i
```

Run the Example

# run the dev server
```sh
pnpm run dev:bare
```
18 changes: 14 additions & 4 deletions docs/examples/vite-react.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,22 @@ You might need to disable your adblocker or Brave Shields to see the preview.

## Running the Example Locally

```bash
# from the root of the repo
Clone the repo

# install dependencies
```sh
git clone https://github.com/fedimint/fedimint-web-sdk.git
cd fedimint-web-sdk
```

Install the package manager with [Corepack](https://nodejs.org/api/corepack.html) & install dependencies.

```sh
corepack enable
pnpm i
```

Run the Example

# run the dev server
```sh
pnpm run dev:vite
```
77 changes: 6 additions & 71 deletions packages/core-web/README.md
Original file line number Diff line number Diff line change
@@ -1,80 +1,15 @@
# @fedimint/core-web

### THIS IS A WORK IN PROGRESS AND NOT READY FOR SERIOUS USE
### This is early software. Use with caution. Report Bugs.

This package provides a typescript interface for a fedimint client in the browser.
Check out the [Getting Started Guide](https://web.fedimint.org/core/getting-started.html) for more information.

It contains the wasm-pack output of the rust-based [fedimint client](https://github.com/fedimint/fedimint/tree/master/fedimint-client-wasm).
---

## Key Features:
Also check out the examples for working code

- **WebAssembly-powered Client**: Exposes the robust, fault-tolerant fedimint-client (built in Rust) via WebAssembly. Lazy-Loads within a web worker for performance.
- **eCash Payments**: Includes support for joining federations, sending/receiving eCash, and managing balances.
- **Lightning Payments**: Ships with zero-setup Lightning Network payments.
- 🛠️ **State Management**: Handles the complex state management and storage challenges for browser wallets.
- 🤫 **Privacy Included**: Offers a privacy-centric wallet by default.
- ⚙️ **Framework Agnostic**: Designed as a "core" library compatible with vanilla JavaScript, laying the groundwork for future framework-specific packages.

## Installation

```bash
// npm or yarn or pnpm
pnpm add @fedimint/core-web
```

## Setup

This package relies on the wasm binary to be bundled with your application. You will likely need to update your bundler's or framework's configuration to load the wasm file. Setup guides for popular frameworks are coming soon.

See the `vite.config.ts` file in the [vite-core example](../../examples/vite-core/vite.config.ts) for an example of configuring wasm within a web-worker using Vite.

## Usage

```ts
import { FedimintWallet } from '@fedimint/core-web'

// Create the Wallet client
const wallet = new FedimintWallet()

// This should be called only once in the application
// lifecycle. It will automatically load your saved
// wallet state from previous sessions.
await wallet.open()

// Joining a Federation

// You can't join a federation
// if your wallet is already open
if (!wallet.isOpen()) {
// Check out [bitcoin mints](https://bitcoinmints.com/?tab=mints&showFedimint=true) for
// a list of federations with public invite codes.
const inviteCode = 'fed11qgqpw9thwvaz7t...'

await wallet.joinFederation(inviteCode)
// After you've joined a federation, your federation state
// will be stored in the browser. Future calls to `open()`
// will automatically load your saved federation.
}

// Get Wallet Balance (sync)
const balance = await wallet.balance.getBalance()

// Subscribe to Balance Updates
const unsubscribe = wallet.balance.subscribeBalance((balance: number) => {
console.log('updated balance', balance)
})
// Make sure to call `unsubscribe()` when you're done

// Receive Ecash Payments
await wallet.mint.reissueNotes('A11qgqpw9thwvaz7t...')

// Pay Lightning Invoice
await wallet.lightning.payInvoice('lnbc...')
```

### Check out the example

- Vite + React: [`examples/vite-core`](../../examples/vite-core/README.md) [(demo)](https://fedimint.github.io/fedimint-web-sdk/)
- [Vite + React](https://web.fedimint.org/examples/vite-react)
- [Bare JS](https://web.fedimint.org/examples/bare-js)

### Resources

Expand Down
Loading

0 comments on commit 8cd9114

Please sign in to comment.