Giter Site home page Giter Site logo

elsirion / webimint-rs Goto Github PK

View Code? Open in Web Editor NEW
19.0 3.0 11.0 59.34 MB

Experimental integration of `fedimint-client` with the Leptos web frontend framework

Home Page: https://webimint.sirion.io/

License: MIT License

Nix 2.82% HTML 0.48% Rust 80.84% CSS 0.51% JavaScript 2.91% Shell 10.04% Just 2.41%
bitcoin e-cash fedimint

webimint-rs's Introduction

CAUTION: highly experimental, the Database implementation is likely horribly broken

Fedimint Client built with Leptos

This repo contains a proof-of-concept of how to integrate fedimint-client with the Leptos web framework to build a PWA. There are still some bugs being worked out, but there is a demo available at https://webimint.sirion.io/.

Join federation screen Redeem e-cash screen Lightning pay invoice screen
Lightning generate invoice screen Lightning generated invoice was paid screen List all transactions screen

Prerequisites

Check out Fedimint branch releases/v0.2:

git clone https://github.com/fedimint/fedimint
cd fedimint
git checkout releases/v0.2

Make sure you have set up local dev environment needed to run fedimint locally

Open terminal and run to open development shell:

nix develop

just build
just mprocs

To get an invite code (you'll need it for next steps) select user process and enter fedimint-cli dev invite-code.

Example

bash-5.1$ fedimint-cli dev invite-code
{
  "invite_code": "fed1132h0j84q5t6qzg8vkxk2lj3dmmzw54flqh3m6z4yrf6ryyerrn6sg36nuratsuf0mjvm84svt40cuqq4waen5te0xyerwt3s9cczuvf6xyurzde59ld2c273s3xm3z3ms552g7x2yu0"
}

The invite code is needed in next step Development.

Development

  1. Open terminal and enter:
nix develop

# only once
npm i

trunk serve

Your output will look like this:

$ nix develop
๐Ÿ’ก Run 'just' for a list of available 'just ...' helper recipes
$ trunk serve
2023-08-06T12:00:41.373844Z  INFO ๐Ÿ“ฆ starting build
2023-08-06T12:00:41.374062Z  INFO spawning asset pipelines
2023-08-06T12:00:41.522959Z  INFO building webimint
    Finished dev [unoptimized + debuginfo] target(s) in 0.14s
2023-08-06T12:00:41.673972Z  INFO fetching cargo artifacts
2023-08-06T12:00:41.834730Z  INFO processing WASM for webimint
2023-08-06T12:00:41.933395Z  INFO calling wasm-bindgen for webimint
2023-08-06T12:00:42.907392Z  INFO copying generated wasm-bindgen artifacts
2023-08-06T12:00:42.919447Z  INFO applying new distribution
2023-08-06T12:00:42.919736Z  INFO โœ… success
2023-08-06T12:00:42.919871Z  INFO ๐Ÿ“ก serving static assets at -> /
2023-08-06T12:00:42.919899Z  INFO ๐Ÿ“ก server listening at http://127.0.0.1:8080
  1. Open http://127.0.0.1:8080 in your browser

  2. Enter invite code into to input and submit. Check Prerequisites above to see how to get it.

To see what's going on underneath open the browser console:

Screenshot of logs shown in browser console

webimint-rs's People

Contributors

elsirion avatar kodylow avatar sectore avatar toyota-corolla0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

webimint-rs's Issues

Copyable text component

Both raw e-cash and lightning invoices need to be copied by the user, we should have a component that displays the data in monospace, has proper line breaking and a copy button, but also allows easy selection of the text.

Automating screenshots in README

This is probably a total nerd-snipe and not a good idea, but I remembered we are installing Firefox as part of our CI build env anyway since Fedimint uses it for WASM testing, so maybe the screenshot in the README could be automatically generated ๐Ÿ˜†

Routing

Routes:

  • / Show simple ui while checking joined / not joined state
  • /join Join Federation
  • /{id} - joined federation
  • /{id}/ln/send - send lightning invoice
  • /{id}/ln/receive - receive lightning invoice
  • /{id}/ecash/receive - send ecash invoice
  • /{id}/ecash/send - send ecash invoice

Docs: https://leptos-rs.github.io/leptos/router/index.html

Note: Make sure an user needs to joined a federation before navigating to other routes. Special case: Deep-links!

IndexedDB-based database implementation

Unfortunately IndexedDB's transaction abstraction is absolutely unusable for our purposes, so we'll have to build our own.

One possible design I wrote about elsewhere:

I think a possible way of implementing our level of isolation (I think it was snapshot isolation that we expect?) by:

  • Saving each value together with its "generation". The global DB generation is defined as the max of all value generations.
  • Having an index of all ongoing transactions and their start DB generation
  • On commit of transactions with writes written KV pairs are updated and their generation set to DB generation + 1. If there are other transactions active the old KV pairs are written to a generation cache (together with their original generation).
  • Whenever a transaction finishes (commit/abort) the generation cache is cleaned of all entries older than the minimum generation of all ongoing transactions
  • When reading from a key in a transaction:
    1. Check the local transaction log for writes to the key
    2. Check the generation cache
    3. Read directly from the IndexedDB
  • Commits are conflict-free if:
    • All reads before the last write read values with a generation at commit time <= the transaction generation
    • All writes write to values with a generation at commit time <= the transaction generation (deleted item generations have to be kept I guess to notice conflicts)
  • Commits can use IndexedDB transactions for atomicity since the reads/writes all happen without other tasks in between.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.