Skip to content

Commit

Permalink
chore: polish state of fedimint-ts
Browse files Browse the repository at this point in the history
- improve type exports to avoid missaps on lib
- refactor dir structure for src/ and test/ clarity
- new lib asset compilation using tsc to dist/
  • Loading branch information
okjodom committed Apr 17, 2024
1 parent 734947d commit 449708b
Show file tree
Hide file tree
Showing 13 changed files with 1,920 additions and 425 deletions.
2 changes: 1 addition & 1 deletion justfile.local.just
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mprocs:
./scripts/mprocs-nix.sh dev-fed mprocs-new.yaml

test-ts:
bun run wrappers/fedimint-ts/test.ts
bun run wrappers/fedimint-ts/tests/test.ts

test-py:
python3.11 wrappers/fedimint-py/test.py
Expand Down
36 changes: 8 additions & 28 deletions wrappers/fedimint-ts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
This is a TypeScript client that consumes the [Fedimint Http Client](https://github.com/kodylow/fedimint-http), communicating with it via HTTP and a password. It's a hacky prototype, but it works until we can get a proper TS client for Fedimint. All of the federation handling code happens in the fedimint-http-client, this just exposes a simple API for interacting with the client from TypeScript (will be mirrored in Python and Go).

## Usage

```typescript
import {FedimintClientBuilder} from "./FedimintClient";
import dotenv from "dotenv";
import { FedimintClientBuilder } from "fedimint-ts";

dotenv.config();

Expand Down Expand Up @@ -51,41 +52,20 @@ fedimintClient.ln.awaitInvoice({ operation_id }).then((response) => {
});
```

# Setup

Set the following in the fedimint-http .env environment variables:

```bash
FEDERATION_INVITE_CODE = 'fed1-some-invite-code'
SECRET_KEY = 'some-secret-key' # generate this with `openssl rand -base64 32`
FM_DB_PATH = '/absolute/path/to/fm.db' # just make this a new dir called `fm_db` in the root of the fedimint-http-client and use the absolute path to thatm it'll create the db file for you on startup
PASSWORD = 'password'
DOMAIN = 'localhost'
PORT = 5000
BASE_URL = 'http://localhost:5000'
```

Then start the fedimint-http-client server:
## Development

```bash
cargo run
```
Install dependencies with `bun install` or `npm install`.

Then you're ready to run the typescript client, which will use the same base url and password as the fedimint-http-client:
Follow these [steps to setup a `fedimint-clientd` server](https://github.com/fedimint/fedimint-clientd?tab=readme-ov-file#getting-started) and then you're ready to run the typescript client.
`fedimint-ts` will use the same base url and password as the `fedimint-clientd`:

```bash
BASE_URL = 'http://localhost:5000'
PASSWORD = 'password'
```

To install dependencies:

```bash
bun install
```

To run (this just runs an example that creates FedimintClient in typescript and creates an invoice):
Then run your code that follows the pattern of `tests/info-example.ts`.

```bash
bun run example.ts
bun run tests/info-example.ts
```
Binary file removed wrappers/fedimint-ts/bun.lockb
Binary file not shown.
4 changes: 0 additions & 4 deletions wrappers/fedimint-ts/index.ts

This file was deleted.

Loading

0 comments on commit 449708b

Please sign in to comment.