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

@counterfactual/simple-hub-server

v0.0.15

Published

An example backend server for the Playground app that acts as a hub.

Downloads

18

Readme

Simple Hub Server

The Simple Hub Server provides several services for the Playground, including:

  • Account login and registration
  • Matchmaking, used to provide a multiplayer experience for the demo dApps.
  • Multisig creation, to enable deposits on the onboarding flow

It also operates as an intermediary Node between peers.

Usage

Successfully running the server requires 2 steps:

  • Funding the server's ETH account: The server must have access to funds which it uses to deploy multisignature wallet contracts and collateralize channels. To fund the server, follow the funding instructions.
  • Having a relational database to store users connecting to the Simple Hub Server. If you have a database already running, you can set its connection string via DB_CONNECTION_STRING as an environment variable for the Simple Hub Server to connect to. For example, the default connection string used is
postgresql://postgres@localhost:5432/postgres

If no database is locally running, you can either install Postgres or if you're already running Docker, in packages/simple-hub-server simply execute

docker-compose up

which will start a Postgres instance for you and expose it on port 5432.

The database gets auto-configured with the right schema if the appopriate table doesn't exist.

  • (Optional) By default the local in-memory Firebase instance is volatile which means that all open channels will have to be re-created after simple-hub-server restarts. In order to enable persistency across restarts, export the environment variable export PLAYGROUND_PERSISTENCE_ENABLED=true

Once the database is up and running, the Simple Hub Server can be started by executing:

yarn start

If running the entire Playground (and not just the server), from the root of the monorepo, execute:

yarn run:playground

You'll need a database (local or remote) to store account data there. By default, we recommend using PostgreSQL, but since we connect to it via Knex, you can configure any database you want.

Testing

You can run tests at any time using:

yarn test

Instead of using the regular PostgreSQL database, the test scope uses a volatile SQLite DB. Keep in mind that any schema changes you do on the real DB, you'll need to apply them to the SQLite schema creation as well.

Environment settings

Unlike other packages, the Server relies on a .env-cmdrc which allows to configure multiple environments in the same file. See env-cmd's reference for more information on how it works.

Funding the Hub Account for Playground Testing

Where do I send Kovan ETH for testing?

First of all, you need to generate a mnemonic:

$ node
> const ethers = require("ethers")
> ethers.utils.HDNode.fromMnemonic(ethers.Wallet.createRandom().mnemonic).extendedKey
'xprv9s21ZrQH143K3n6GUhRTVqwyqEVVy4KBPy5dXSdNCg1L1PDSJHqzQJKrXV7rYdYJLjnkHLvcGtkUtVdUD5rCbfpEpxa8sdfe8PmQtETuBcY'

And save it in .env in the format specified in .env.schema.

Option 1 Compute the address:

$ node
> const ethers = require("ethers")
> const xprv = ethers.utils.HDNode.fromMnemonic(ethers.Wallet.createRandom().mnemonic).extendedKey
> ethers.utils.HDNode.fromExtendedKey(xprv).derivePath("m/44'/60'/0'/25446").address
'0x84D1C440f73DD5c20fA9a3a7CB8A24D5F70a753c'

Option 2 Read the logs of simple-hub-server when running it:

@counterfactual/simple-hub-server: Node signer address: 0x84D1C440f73DD5c20fA9a3a7CB8A24D5F70a753c