npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

okj-fmts

v0.2.25

Published

A TypeScript Wrapper for the Fedimint HTTP Client

Downloads

73

Readme

Fedimint SDK in Typescript

This is a TypeScript client that consumes the Fedimint Http Client, 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

import dotenv from "dotenv";
import { FedimintClientBuilder } from "fedimint-ts";

dotenv.config();

const baseUrl = process.env.BASE_URL || "http://localhost:3000";
const password = process.env.PASSWORD || "password";
const builder = new FedimintClientBuilder();
builder.setBaseUrl(baseUrl).setPassword(password);

// If you pass in an invite code, it will be set as the default federation
if (process.env.INVITE_CODE) {
  builder.setInviteCode(process.env.INVITE_CODE);
}

// The FedimintClient has a default federationId set that it'll call any module methods on
const fedimintClient = await builder.build();

// You can update the federationId to call methods on a different federation
const { federation_ids } = await fedimintClient.federationIds();
await fedimintClient.setDefaultFederationId(federation_ids[0]);

// Any methods that call on a specific federation can optionally take a federationId as the last argument
// If no federationId is passed, the default federationId is used
const _ = await fedimintClient.listOperations({ limit: 10 }, federation_ids[1]);

// Admin methods give summaries by federation
fedimintClient.info().then((response) => {
  console.log("Current Total Msats Ecash: ", response.total_amount_msat);
});

// All module methods are called on the default federationId if you don't pass in a federationId
const { operation_id, invoice } = await fedimintClient.ln.createInvoice({
  amount_msat: 10000,
  description: "test",
});

console.log("Created 10 sat Invoice: ", invoice);

console.log("Waiting for payment...");

fedimintClient.ln.awaitInvoice({ operation_id }).then((response) => {
  console.log("Payment Received!");
  console.log("New Total Msats Ecash: ", response.total_amount_msat);
});

Development

Install dependencies with bun install or npm install.

Follow these steps to setup a fedimint-clientd server and then you're ready to run the typescript client. fedimint-ts will use the same base url and password as the fedimint-clientd:

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

Then run your code that follows the pattern of tests/info-example.ts.

bun run tests/info-example.ts